summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2011-06-28 06:26:03 +0000
committergrehan <grehan@FreeBSD.org>2011-06-28 06:26:03 +0000
commit2c6741be0f59191f2283eb268e4f7690399d578a (patch)
treeb139c8c6dcca4fa284815daade405b75886ee360 /lib
parent3c35264f695e0a1f8a04dbcca1c93bb5159b2274 (diff)
parent19ae02bba572390c7299166228d31e54003e094a (diff)
downloadFreeBSD-src-2c6741be0f59191f2283eb268e4f7690399d578a.zip
FreeBSD-src-2c6741be0f59191f2283eb268e4f7690399d578a.tar.gz
IFC @ r222830
Diffstat (limited to 'lib')
-rw-r--r--lib/clang/include/clang/Basic/Version.inc4
-rw-r--r--lib/clang/libclangfrontend/Makefile1
-rw-r--r--lib/clang/libllvmasmprinter/Makefile4
-rw-r--r--lib/clang/libllvmcodegen/Makefile1
-rw-r--r--lib/clang/libllvmmc/Makefile1
-rw-r--r--lib/clang/libllvmmipscodegen/Makefile1
-rw-r--r--lib/libc/db/btree/bt_split.c7
-rw-r--r--lib/libc/db/man/mpool.311
-rw-r--r--lib/libc/gen/basename.351
-rw-r--r--lib/libc/gen/basename.c71
-rw-r--r--lib/libc/gen/feature_present.32
-rw-r--r--lib/libc/gen/ftw.c8
-rw-r--r--lib/libc/gen/posix_spawn.323
-rw-r--r--lib/libc/gen/posix_spawn.c7
-rw-r--r--lib/libc/gen/sysconf.c6
-rw-r--r--lib/libc/iconv/Symbol.map21
-rw-r--r--lib/libc/iconv/citrus_mapper.c2
-rw-r--r--lib/libc/iconv/iconv.c2
-rw-r--r--lib/libc/iconv/iconvctl.36
-rw-r--r--lib/libc/net/sctp_opt_info.335
-rw-r--r--lib/libc/net/sctp_sys_calls.c326
-rw-r--r--lib/libc/sys/wait.213
-rw-r--r--lib/libcompiler_rt/Makefile5
-rw-r--r--lib/libiconv/Makefile1
-rw-r--r--lib/libkvm/kvm_pcpu.c31
-rw-r--r--lib/libmemstat/memstat_uma.c15
-rw-r--r--lib/libprocstat/libprocstat.c30
-rw-r--r--lib/libstand/bswap.c36
-rw-r--r--lib/libstand/net.c2
-rw-r--r--lib/libstand/tftp.c293
-rw-r--r--lib/libstand/zalloc.c6
-rw-r--r--lib/libstand/zalloc_malloc.c2
-rw-r--r--lib/libthr/arch/sparc64/Makefile.inc2
-rw-r--r--lib/libthr/arch/sparc64/include/pthread_md.h23
-rw-r--r--lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S38
-rw-r--r--lib/libthr/arch/sparc64/sparc64/pthread_md.c12
-rw-r--r--lib/libthr/thread/thr_init.c1
-rw-r--r--lib/msun/ld128/e_rem_pio2l.h5
-rw-r--r--lib/msun/ld80/e_rem_pio2l.h7
-rw-r--r--lib/msun/src/e_rem_pio2.c3
-rw-r--r--lib/msun/src/s_cosl.c1
-rw-r--r--lib/msun/src/s_sinl.c1
-rw-r--r--lib/msun/src/s_tanl.c1
43 files changed, 881 insertions, 237 deletions
diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc
index 1febce2..144a920 100644
--- a/lib/clang/include/clang/Basic/Version.inc
+++ b/lib/clang/include/clang/Basic/Version.inc
@@ -5,6 +5,6 @@
#define CLANG_VERSION_MINOR 0
#define CLANG_VENDOR "FreeBSD "
-#define CLANG_VENDOR_SUFFIX " 20110502"
+#define CLANG_VENDOR_SUFFIX " 20110612"
-#define SVN_REVISION "130700"
+#define SVN_REVISION "132879"
diff --git a/lib/clang/libclangfrontend/Makefile b/lib/clang/libclangfrontend/Makefile
index 71f76b7..ff32c08 100644
--- a/lib/clang/libclangfrontend/Makefile
+++ b/lib/clang/libclangfrontend/Makefile
@@ -12,7 +12,6 @@ SRCS= ASTConsumers.cpp \
CompilerInvocation.cpp \
CreateInvocationFromCommandLine.cpp \
DependencyFile.cpp \
- DiagChecker.cpp \
FrontendAction.cpp \
FrontendActions.cpp \
FrontendOptions.cpp \
diff --git a/lib/clang/libllvmasmprinter/Makefile b/lib/clang/libllvmasmprinter/Makefile
index 7e5182c..26f113f 100644
--- a/lib/clang/libllvmasmprinter/Makefile
+++ b/lib/clang/libllvmasmprinter/Makefile
@@ -12,7 +12,7 @@ SRCS= ARMException.cpp \
DwarfCompileUnit.cpp \
DwarfDebug.cpp \
DwarfException.cpp \
- DwarfTableException.cpp \
- OcamlGCPrinter.cpp
+ OcamlGCPrinter.cpp \
+ Win64Exception.cpp
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmcodegen/Makefile b/lib/clang/libllvmcodegen/Makefile
index c7c55a2..c657316 100644
--- a/lib/clang/libllvmcodegen/Makefile
+++ b/lib/clang/libllvmcodegen/Makefile
@@ -71,6 +71,7 @@ SRCS= AggressiveAntiDepBreaker.cpp \
RegAllocGreedy.cpp \
RegAllocLinearScan.cpp \
RegAllocPBQP.cpp \
+ RegisterClassInfo.cpp \
RegisterCoalescer.cpp \
RegisterScavenging.cpp \
RenderMachineFunction.cpp \
diff --git a/lib/clang/libllvmmc/Makefile b/lib/clang/libllvmmc/Makefile
index a7ed25b..07b91ad 100644
--- a/lib/clang/libllvmmc/Makefile
+++ b/lib/clang/libllvmmc/Makefile
@@ -31,6 +31,7 @@ SRCS= ELFObjectWriter.cpp \
MCSectionMachO.cpp \
MCStreamer.cpp \
MCSymbol.cpp \
+ MCWin64EH.cpp \
MachObjectWriter.cpp \
TargetAsmBackend.cpp \
WinCOFFObjectWriter.cpp \
diff --git a/lib/clang/libllvmmipscodegen/Makefile b/lib/clang/libllvmmipscodegen/Makefile
index 47744ed..63e9e0e 100644
--- a/lib/clang/libllvmmipscodegen/Makefile
+++ b/lib/clang/libllvmmipscodegen/Makefile
@@ -5,6 +5,7 @@ LIB= llvmmipscodegen
SRCDIR= lib/Target/Mips
SRCS= MipsAsmPrinter.cpp \
MipsDelaySlotFiller.cpp \
+ MipsEmitGPRestore.cpp \
MipsExpandPseudo.cpp \
MipsFrameLowering.cpp \
MipsISelDAGToDAG.cpp \
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index ca8b16a..f0db406 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -37,6 +37,7 @@ static char sccsid[] = "@(#)bt_split.c 8.10 (Berkeley) 1/9/95";
__FBSDID("$FreeBSD$");
#include <sys/types.h>
+#include <sys/param.h>
#include <limits.h>
#include <stdio.h>
@@ -482,7 +483,7 @@ bt_rroot(BTREE *t, PAGE *h, PAGE *l, PAGE *r)
WR_RINTERNAL(dest,
l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno);
- h->linp[1] = h->upper -= NRINTERNAL;
+ __PAST_END(h->linp, 1) = h->upper -= NRINTERNAL;
dest = (char *)h + h->upper;
WR_RINTERNAL(dest,
r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno);
@@ -534,7 +535,7 @@ bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r)
case P_BLEAF:
bl = GETBLEAF(r, 0);
nbytes = NBINTERNAL(bl->ksize);
- h->linp[1] = h->upper -= nbytes;
+ __PAST_END(h->linp, 1) = h->upper -= nbytes;
dest = (char *)h + h->upper;
WR_BINTERNAL(dest, bl->ksize, r->pgno, 0);
memmove(dest, bl->bytes, bl->ksize);
@@ -550,7 +551,7 @@ bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r)
case P_BINTERNAL:
bi = GETBINTERNAL(r, 0);
nbytes = NBINTERNAL(bi->ksize);
- h->linp[1] = h->upper -= nbytes;
+ __PAST_END(h->linp, 1) = h->upper -= nbytes;
dest = (char *)h + h->upper;
memmove(dest, bi, nbytes);
((BINTERNAL *)dest)->pgno = r->pgno;
diff --git a/lib/libc/db/man/mpool.3 b/lib/libc/db/man/mpool.3
index 3de51c3..5af7d27 100644
--- a/lib/libc/db/man/mpool.3
+++ b/lib/libc/db/man/mpool.3
@@ -28,7 +28,7 @@
.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd February 25, 1999
+.Dd June 17, 2011
.Dt MPOOL 3
.Os
.Sh NAME
@@ -147,7 +147,14 @@ is returned and
is set.
The
.Fa flags
-argument is not currently used.
+argument is specified by
+.Em or Ns 'ing
+any of the following values:
+.Bl -tag -width indent
+.It Dv MPOOL_IGNOREPIN
+The page returned is not pinned;
+page will otherwise be pinned on return.
+.El
.Pp
The
.Fn mpool_put
diff --git a/lib/libc/gen/basename.3 b/lib/libc/gen/basename.3
index 4a3743a..bcdd99e 100644
--- a/lib/libc/gen/basename.3
+++ b/lib/libc/gen/basename.3
@@ -1,33 +1,22 @@
+.\" $OpenBSD: basename.3,v 1.20 2007/05/31 19:19:28 jmc Exp $
.\"
.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
-.\" All rights reserved.
.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
.\"
-.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $OpenBSD: basename.3,v 1.12 2000/04/18 03:01:25 aaron Exp $
.\" $FreeBSD$
.\"
-.Dd October 6, 2009
+.Dd March 31, 2010
.Dt BASENAME 3
.Os
.Sh NAME
@@ -42,8 +31,7 @@
.Sh DESCRIPTION
The
.Fn basename
-function
-returns the last component from the pathname pointed to by
+function returns the last component from the pathname pointed to by
.Fa path ,
deleting any trailing
.Sq \&/
@@ -111,4 +99,15 @@ function first appeared in
and
.Fx 4.2 .
.Sh AUTHORS
-.An "Todd C. Miller" Aq Todd.Miller@courtesan.com
+.An Todd C. Miller
+.Sh CAVEATS
+.Fn basename
+returns a pointer to internal static storage space that will be overwritten
+by subsequent calls.
+.Pp
+Other vendor implementations of
+.Fn basename
+may modify the contents of the string passed to
+.Fn basename ;
+this should be taken into account when writing code which calls this function
+if portability is desired.
diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c
index 9588c28..f2bfe5f 100644
--- a/lib/libc/gen/basename.c
+++ b/lib/libc/gen/basename.c
@@ -1,35 +1,21 @@
+/* $OpenBSD: basename.c,v 1.14 2005/08/08 08:05:33 espie Exp $ */
+
/*
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
+ * Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if 0
-#ifndef lint
-static char rcsid[] = "$OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $";
-#endif /* not lint */
-#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -40,27 +26,28 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
char *
-basename_r(path, bname)
- const char *path;
- char *bname;
+basename_r(const char *path, char *bname)
{
const char *endp, *startp;
+ size_t len;
/* Empty or NULL string gets treated as "." */
if (path == NULL || *path == '\0') {
- (void)strcpy(bname, ".");
- return(bname);
+ bname[0] = '.';
+ bname[1] = '\0';
+ return (bname);
}
- /* Strip trailing slashes */
+ /* Strip any trailing slashes */
endp = path + strlen(path) - 1;
while (endp > path && *endp == '/')
endp--;
/* All slashes becomes "/" */
if (endp == path && *endp == '/') {
- (void)strcpy(bname, "/");
- return(bname);
+ bname[0] = '/';
+ bname[1] = '\0';
+ return (bname);
}
/* Find the start of the base */
@@ -68,18 +55,18 @@ basename_r(path, bname)
while (startp > path && *(startp - 1) != '/')
startp--;
- if (endp - startp + 2 > MAXPATHLEN) {
+ len = endp - startp + 1;
+ if (len >= MAXPATHLEN) {
errno = ENAMETOOLONG;
- return(NULL);
+ return (NULL);
}
- (void)strncpy(bname, startp, endp - startp + 1);
- bname[endp - startp + 1] = '\0';
- return(bname);
+ memcpy(bname, startp, len);
+ bname[len] = '\0';
+ return (bname);
}
char *
-basename(path)
- const char *path;
+basename(const char *path)
{
static char *bname = NULL;
diff --git a/lib/libc/gen/feature_present.3 b/lib/libc/gen/feature_present.3
index 9a4269e..3a702d4 100644
--- a/lib/libc/gen/feature_present.3
+++ b/lib/libc/gen/feature_present.3
@@ -29,7 +29,7 @@
.\" $FreeBSD$
.\"
.Dd January 8, 2008
-.Dt feature_present 3
+.Dt FEATURE_PRESENT 3
.Os
.Sh NAME
.Nm feature_present
diff --git a/lib/libc/gen/ftw.c b/lib/libc/gen/ftw.c
index 0177712..bfaf121 100644
--- a/lib/libc/gen/ftw.c
+++ b/lib/libc/gen/ftw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */
+/* $OpenBSD: ftw.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */
/*
* Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -20,12 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-#endif
-
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3
index 7569239..3d902bf 100644
--- a/lib/libc/gen/posix_spawn.3
+++ b/lib/libc/gen/posix_spawn.3
@@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 24, 2008
+.Dd June 17, 2011
.Dt POSIX_SPAWN 3
.Os
.Sh NAME
@@ -384,29 +384,28 @@ the child process exits with exit status 127).
.It
If the
.Fa file_actions
-argument is not NULL, and specifies any close, dup2, or open actions to be
+argument is not NULL, and specifies any dup2 or open actions to be
performed, and if
.Fn posix_spawn
or
.Fn posix_spawnp
fails for any of the reasons that would cause
-.Fn close ,
-.Fn dup2 ,
+.Fn dup2
or
.Fn open
to fail, an error value is returned as described by
-.Fn close ,
-.Fn dup2 ,
+.Fn dup2
and
.Fn open ,
respectively (or, if the error occurs after the calling process successfully
returns, the child process exits with exit status 127). An open file action
may, by itself, result in any of the errors described by
-.Fn close
-or
.Fn dup2 ,
in addition to those described by
.Fn open .
+This implementation ignores any errors from
+.Fn close ,
+including trying to close a descriptor that is not open.
.El
.Sh SEE ALSO
.Xr close 2 ,
@@ -443,7 +442,13 @@ The
and
.Fn posix_spawnp
functions conform to
-.St -p1003.1-2001 .
+.St -p1003.1-2001 ,
+except that they ignore all errors from
+.Fn close .
+A future update of the Standard is expected to require that these functions
+not fail because a file descriptor to be closed (via
+.Fn posix_spawn_file_actions_addclose )
+is not open.
.Sh HISTORY
The
.Fn posix_spawn
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
index 20f2c16..58044b3 100644
--- a/lib/libc/gen/posix_spawn.c
+++ b/lib/libc/gen/posix_spawn.c
@@ -163,11 +163,8 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae)
return (errno);
break;
case FAE_CLOSE:
- /* Perform a close() */
- if (_close(fae->fae_fildes) != 0) {
- if (errno == EBADF)
- return (EBADF);
- }
+ /* Perform a close(), do not fail if already closed */
+ (void)_close(fae->fae_fildes);
break;
}
return (0);
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c
index 7539d61..80ae626 100644
--- a/lib/libc/gen/sysconf.c
+++ b/lib/libc/gen/sysconf.c
@@ -599,11 +599,11 @@ yesno:
#ifdef _SC_CPUSET_SIZE
case _SC_CPUSET_SIZE:
- len = sizeof(lvalue);
- if (sysctlbyname("kern.sched.cpusetsize", &lvalue, &len, NULL,
+ len = sizeof(value);
+ if (sysctlbyname("kern.sched.cpusetsize", &value, &len, NULL,
0) == -1)
return (-1);
- return (lvalue);
+ return ((long)value);
#endif
default:
diff --git a/lib/libc/iconv/Symbol.map b/lib/libc/iconv/Symbol.map
index 515cddc..73e0e22 100644
--- a/lib/libc/iconv/Symbol.map
+++ b/lib/libc/iconv/Symbol.map
@@ -6,6 +6,18 @@ FBSD_1.2 {
__iconv;
__iconv_free_list;
__iconv_get_list;
+ _libiconv_version;
+ iconv_canonicalize;
+ libiconv;
+ libiconv_close;
+ libiconv_open;
+ libiconv_open_into;
+ libiconv_set_relocation_prefix;
+ libiconvctl;
+ libiconvlist;
+};
+
+FBSDprivate_1.0 {
_citrus_bcs_convert_to_lower;
_citrus_bcs_convert_to_upper;
_citrus_bcs_isalnum;
@@ -89,13 +101,4 @@ FBSD_1.2 {
_citrus_stdenc_close;
_citrus_stdenc_open;
_citrus_unmap_file;
- _libiconv_version;
- iconv_canonicalize;
- libiconv;
- libiconv_close;
- libiconv_open;
- libiconv_open_into;
- libiconv_set_relocation_prefix;
- libiconvctl;
- libiconvlist;
};
diff --git a/lib/libc/iconv/citrus_mapper.c b/lib/libc/iconv/citrus_mapper.c
index a788a9d9..b5ae96d 100644
--- a/lib/libc/iconv/citrus_mapper.c
+++ b/lib/libc/iconv/citrus_mapper.c
@@ -337,7 +337,9 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma,
goto quit;
/* open mapper */
+ UNLOCK;
ret = mapper_open(ma, &cm, module, variable);
+ WLOCK;
if (ret)
goto quit;
cm->cm_key = strdup(mapname);
diff --git a/lib/libc/iconv/iconv.c b/lib/libc/iconv/iconv.c
index 2cd38df..d1e01e8 100644
--- a/lib/libc/iconv/iconv.c
+++ b/lib/libc/iconv/iconv.c
@@ -85,7 +85,7 @@ _iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc)
errno = ENOMEM;
return ((iconv_t)-1);
}
-
+
p = out_truncated;
while (*p != 0) {
if (p[0] == '/' && p[1] == '/') {
diff --git a/lib/libc/iconv/iconvctl.3 b/lib/libc/iconv/iconvctl.3
index 29007c1..30fc0aa 100644
--- a/lib/libc/iconv/iconvctl.3
+++ b/lib/libc/iconv/iconvctl.3
@@ -150,6 +150,9 @@ facility is a non-standard extension, which appeared in
the GNU implementation and was adopted in
.Fx 9
for compatibility's sake.
+.Sh AUTHORS
+This manual page was written by
+.An Gabor Kovesdan Aq gabor@FreeBSD.org .
.Sh BUGS
Transliteration is enabled in this implementation by default, so it
is impossible by design to turn it off.
@@ -157,6 +160,3 @@ Accordingly, trying to turn it off will always fail and \-1 will be
returned.
Getting the transliteration state will always succeed and indicate
that it is turned on, though.
-.Sh AUTHORS
-This manual page was written by
-.An Gabor Kovesdan Aq gabor@FreeBSD.org .
diff --git a/lib/libc/net/sctp_opt_info.3 b/lib/libc/net/sctp_opt_info.3
index f010613..df8faa6 100644
--- a/lib/libc/net/sctp_opt_info.3
+++ b/lib/libc/net/sctp_opt_info.3
@@ -32,7 +32,7 @@
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
.\" $FreeBSD$
.\"
-.Dd December 15, 2006
+.Dd June 18, 2011
.Dt SCTP_OPT_INFO 3
.Os
.Sh NAME
@@ -76,14 +76,30 @@ socket options.
.Pp
.Dv SCTP_PRIMARY_ADDR
.Pp
-.Dv SCTP_SET_PEER_PRIMARY_ADDR
+.Dv SCTP_PEER_ADDR_PARAMS
.Pp
-.Dv SCTP_STATUS
+.Dv SCTP_DEFAULT_SEND_PARAM
.Pp
-.Dv SCTP_GET_PEER_ADDR_INFO
+.Dv SCTP_MAX_SEG
.Pp
.Dv SCTP_AUTH_ACTIVE_KEY
.Pp
+.Dv SCTP_DELAYED_SACK
+.Pp
+.Dv SCTP_MAX_BURST
+.Pp
+.Dv SCTP_CONTEXT
+.Pp
+.Dv SCTP_EVENT
+.Pp
+.Dv SCTP_DEFAULT_SNDINFO
+.Pp
+.Dv SCTP_DEFAULT_PRINFO
+.Pp
+.Dv SCTP_STATUS
+.Pp
+.Dv SCTP_GET_PEER_ADDR_INFO
+.Pp
.Dv SCTP_PEER_AUTH_CHUNKS
.Pp
.Dv SCTP_LOCAL_AUTH_CHUNKS
@@ -115,3 +131,14 @@ is not a socket.
.Sh SEE ALSO
.Xr getsockopt 2 ,
.Xr sctp 4
+.Sh BUGS
+Because the structure used for
+.Fa arg
+of the
+.Dv SCTP_MAX_BURST
+socket option has changed in FreeBSD 9.0 and higher,
+using
+.Dv SCTP_MAX_BURST
+as
+.Fa opt
+is only supported in FreeBSD 9.0 and higher.
diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c
index 0921669..27664bc 100644
--- a/lib/libc/net/sctp_sys_calls.c
+++ b/lib/libc/net/sctp_sys_calls.c
@@ -141,7 +141,7 @@ in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
int
sctp_getaddrlen(sa_family_t family)
{
- int error, sd;
+ int ret, sd;
socklen_t siz;
struct sctp_assoc_value av;
@@ -151,13 +151,15 @@ sctp_getaddrlen(sa_family_t family)
sd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
#elif defined(AF_INET6)
sd = socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP);
+#else
+ sd = -1;
#endif
if (sd == -1) {
return (-1);
}
- error = getsockopt(sd, IPPROTO_SCTP, SCTP_GET_ADDR_LEN, &av, &siz);
+ ret = getsockopt(sd, IPPROTO_SCTP, SCTP_GET_ADDR_LEN, &av, &siz);
close(sd);
- if (error == 0) {
+ if (ret == 0) {
return ((int)av.assoc_value);
} else {
return (-1);
@@ -363,9 +365,6 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
case SCTP_DEFAULT_SEND_PARAM:
((struct sctp_assocparams *)arg)->sasoc_assoc_id = id;
break;
- case SCTP_SET_PEER_PRIMARY_ADDR:
- ((struct sctp_setpeerprim *)arg)->sspp_assoc_id = id;
- break;
case SCTP_PRIMARY_ADDR:
((struct sctp_setprim *)arg)->ssp_assoc_id = id;
break;
@@ -402,6 +401,18 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
case SCTP_TIMEOUTS:
((struct sctp_timeouts *)arg)->stimo_assoc_id = id;
break;
+ case SCTP_EVENT:
+ ((struct sctp_event *)arg)->se_assoc_id = id;
+ break;
+ case SCTP_DEFAULT_SNDINFO:
+ ((struct sctp_sndinfo *)arg)->snd_assoc_id = id;
+ break;
+ case SCTP_DEFAULT_PRINFO:
+ ((struct sctp_default_prinfo *)arg)->pr_assoc_id = id;
+ break;
+ case SCTP_MAX_BURST:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
default:
break;
}
@@ -919,32 +930,297 @@ sctp_recvmsg(int s,
#endif
}
+ssize_t
+sctp_recvv(int sd,
+ const struct iovec *iov,
+ int iovlen,
+ struct sockaddr *from,
+ socklen_t * fromlen,
+ void *info,
+ socklen_t * infolen,
+ unsigned int *infotype,
+ int *flags)
+{
+ char ctlbuf[SCTP_CONTROL_VEC_SIZE_RCV];
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
+ ssize_t n;
+ struct sctp_rcvinfo *rcvinfo;
+ struct sctp_nxtinfo *nxtinfo;
-#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
-#include <netinet/sctp_peeloff.h>
+ if (((info != NULL) && (infolen == NULL)) |
+ ((info == NULL) && (infolen != NULL) && (*infolen != 0)) ||
+ ((info != NULL) && (infotype == NULL))) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if (infotype) {
+ *infotype = SCTP_RECVV_NOINFO;
+ }
+ msg.msg_name = from;
+ if (fromlen == NULL) {
+ msg.msg_namelen = 0;
+ } else {
+ msg.msg_namelen = *fromlen;
+ }
+ msg.msg_iov = (struct iovec *)iov;
+ msg.msg_iovlen = iovlen;
+ msg.msg_control = ctlbuf;
+ msg.msg_controllen = sizeof(ctlbuf);
+ errno = 0;
+ n = recvmsg(sd, &msg, *flags);
+ *flags = msg.msg_flags;
+ if ((n > 0) &&
+ (msg.msg_controllen > 0) &&
+ (infotype != NULL) &&
+ (infolen != NULL) &&
+ (*infolen > 0)) {
+ rcvinfo = NULL;
+ nxtinfo = NULL;
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level != IPPROTO_SCTP) {
+ continue;
+ }
+ if (cmsg->cmsg_type == SCTP_RCVINFO) {
+ rcvinfo = (struct sctp_rcvinfo *)CMSG_DATA(cmsg);
+ }
+ if (cmsg->cmsg_type == SCTP_NXTINFO) {
+ nxtinfo = (struct sctp_nxtinfo *)CMSG_DATA(cmsg);
+ }
+ if (rcvinfo && nxtinfo) {
+ break;
+ }
+ }
+ if (rcvinfo) {
+ if (nxtinfo) {
+ if (*infolen >= sizeof(struct sctp_recvv_rn)) {
+ struct sctp_recvv_rn *rn_info;
+
+ rn_info = (struct sctp_recvv_rn *)info;
+ rn_info->recvv_rcvinfo = *rcvinfo;
+ rn_info->recvv_nxtinfo = *nxtinfo;
+ *infolen = (socklen_t) sizeof(struct sctp_recvv_rn);
+ *infotype = SCTP_RECVV_RN;
+ }
+ } else {
+ if (*infolen >= sizeof(struct sctp_rcvinfo)) {
+ memcpy(info, rcvinfo, sizeof(struct sctp_rcvinfo));
+ *infolen = (socklen_t) sizeof(struct sctp_rcvinfo);
+ *infotype = SCTP_RECVV_RCVINFO;
+ }
+ }
+ } else if (nxtinfo) {
+ if (*infolen >= sizeof(struct sctp_rcvinfo)) {
+ memcpy(info, nxtinfo, sizeof(struct sctp_nxtinfo));
+ *infolen = (socklen_t) sizeof(struct sctp_nxtinfo);
+ *infotype = SCTP_RECVV_NXTINFO;
+ }
+ }
+ }
+ return (n);
+}
-int
-sctp_peeloff(int sd, sctp_assoc_t assoc_id)
+ssize_t
+sctp_sendv(int sd,
+ const struct iovec *iov, int iovcnt,
+ struct sockaddr *addrs, int addrcnt,
+ void *info, socklen_t infolen, unsigned int infotype,
+ int flags)
{
- struct sctp_peeloff_opt peeloff;
- int result;
- socklen_t optlen;
-
- /* set in the socket option params */
- memset(&peeloff, 0, sizeof(peeloff));
- peeloff.s = sd;
- peeloff.assoc_id = assoc_id;
- optlen = sizeof(peeloff);
- result = getsockopt(sd, IPPROTO_SCTP, SCTP_PEELOFF, (void *)&peeloff, &optlen);
-
- if (result < 0) {
+ ssize_t ret;
+ int i;
+ socklen_t addr_len;
+ struct msghdr msg;
+ in_port_t port;
+ struct sctp_sendv_spa *spa_info;
+ struct cmsghdr *cmsg;
+ char *cmsgbuf;
+ struct sockaddr *addr;
+ struct sockaddr_in *addr_in;
+ struct sockaddr_in6 *addr_in6;
+
+ if ((addrcnt < 0) ||
+ (iovcnt < 0) ||
+ ((addrs == NULL) && (addrcnt > 0)) ||
+ ((addrs != NULL) && (addrcnt == 0)) ||
+ ((iov == NULL) && (iovcnt > 0)) ||
+ ((iov != NULL) && (iovcnt == 0))) {
+ errno = EINVAL;
return (-1);
- } else {
- return (peeloff.new_sd);
}
+ cmsgbuf = malloc(CMSG_SPACE(sizeof(struct sctp_sndinfo)) +
+ CMSG_SPACE(sizeof(struct sctp_prinfo)) +
+ CMSG_SPACE(sizeof(struct sctp_authinfo)) +
+ addrcnt * CMSG_SPACE(sizeof(struct in6_addr)));
+ if (cmsgbuf == NULL) {
+ errno = ENOBUFS;
+ return (-1);
+ }
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = 0;
+ cmsg = (struct cmsghdr *)cmsgbuf;
+ switch (infotype) {
+ case SCTP_SENDV_NOINFO:
+ if ((infolen != 0) || (info != NULL)) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ break;
+ case SCTP_SENDV_SNDINFO:
+ if ((info == NULL) || (infolen < sizeof(struct sctp_sndinfo))) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_SNDINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndinfo));
+ memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_sndinfo));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
+ break;
+ case SCTP_SENDV_PRINFO:
+ if ((info == NULL) || (infolen < sizeof(struct sctp_prinfo))) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_PRINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_prinfo));
+ memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_prinfo));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_prinfo));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_prinfo)));
+ break;
+ case SCTP_SENDV_AUTHINFO:
+ if ((info == NULL) || (infolen < sizeof(struct sctp_authinfo))) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_AUTHINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_authinfo));
+ memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_authinfo));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_authinfo));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_authinfo)));
+ break;
+ case SCTP_SENDV_SPA:
+ if ((info == NULL) || (infolen < sizeof(struct sctp_sendv_spa))) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ spa_info = (struct sctp_sendv_spa *)info;
+ if (spa_info->sendv_flags & SCTP_SEND_SNDINFO_VALID) {
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_SNDINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndinfo));
+ memcpy(CMSG_DATA(cmsg), &spa_info->sendv_sndinfo, sizeof(struct sctp_sndinfo));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
+ }
+ if (spa_info->sendv_flags & SCTP_SEND_PRINFO_VALID) {
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_PRINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_prinfo));
+ memcpy(CMSG_DATA(cmsg), &spa_info->sendv_prinfo, sizeof(struct sctp_prinfo));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_prinfo));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_prinfo)));
+ }
+ if (spa_info->sendv_flags & SCTP_SEND_AUTHINFO_VALID) {
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_AUTHINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_authinfo));
+ memcpy(CMSG_DATA(cmsg), &spa_info->sendv_authinfo, sizeof(struct sctp_authinfo));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_authinfo));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_authinfo)));
+ }
+ break;
+ default:
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ addr = addrs;
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+
+ for (i = 0; i < addrcnt; i++) {
+ switch (addr->sa_family) {
+ case AF_INET:
+ addr_len = (socklen_t) sizeof(struct sockaddr_in);
+ addr_in = (struct sockaddr_in *)addr;
+ if (addr_in->sin_len != addr_len) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ if (i == 0) {
+ port = addr_in->sin_port;
+ } else {
+ if (port == addr_in->sin_port) {
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_DSTADDRV4;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
+ memcpy(CMSG_DATA(cmsg), &addr_in->sin_addr, sizeof(struct in_addr));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct in_addr));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct in_addr)));
+ } else {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ }
+ break;
+ case AF_INET6:
+ addr_len = (socklen_t) sizeof(struct sockaddr_in6);
+ addr_in6 = (struct sockaddr_in6 *)addr;
+ if (addr_in6->sin6_len != addr_len) {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ if (i == 0) {
+ port = addr_in6->sin6_port;
+ } else {
+ if (port == addr_in6->sin6_port) {
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_DSTADDRV6;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_addr));
+ memcpy(CMSG_DATA(cmsg), &addr_in6->sin6_addr, sizeof(struct in6_addr));
+ msg.msg_controllen += CMSG_SPACE(sizeof(struct in6_addr));
+ cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct in6_addr)));
+ } else {
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ }
+ break;
+ default:
+ free(cmsgbuf);
+ errno = EINVAL;
+ return (-1);
+ }
+ if (i == 0) {
+ msg.msg_name = addr;
+ msg.msg_namelen = addr_len;
+ }
+ addr = (struct sockaddr *)((caddr_t)addr + addr_len);
+ }
+ if (msg.msg_controllen == 0) {
+ msg.msg_control = NULL;
+ }
+ msg.msg_iov = (struct iovec *)iov;
+ msg.msg_iovlen = iovcnt;
+ msg.msg_flags = 0;
+ ret = sendmsg(sd, &msg, flags);
+ free(cmsgbuf);
+ return (ret);
}
-#endif
#if !defined(SYS_sctp_peeloff) && !defined(HAVE_SCTP_PEELOFF_SOCKOPT)
diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2
index 2e084d2..e4812fc 100644
--- a/lib/libc/sys/wait.2
+++ b/lib/libc/sys/wait.2
@@ -66,6 +66,19 @@ the
.Fa status
area contains termination information about the process that exited
as defined below.
+The
+.Fn wait
+call is the same as
+.Fn wait4
+with a
+.Fa wpid
+value of -1,
+with an
+.Fa options
+value of zero,
+and a
+.Fa rusage
+value of zero.
.Pp
The
.Fn wait4
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
index dcfcf74..3a501f5 100644
--- a/lib/libcompiler_rt/Makefile
+++ b/lib/libcompiler_rt/Makefile
@@ -41,6 +41,8 @@ SRCF= absvdi2 \
ctzti2 \
divdc3 \
divdi3 \
+ divmoddi4 \
+ divmodsi4 \
divsc3 \
divti3 \
divxc3 \
@@ -114,6 +116,7 @@ SRCF= absvdi2 \
ucmpti2 \
udivdi3 \
udivmoddi4 \
+ udivmodsi4 \
udivmodti4 \
udivti3 \
umoddi3 \
@@ -134,6 +137,8 @@ SRCF+= adddf3 \
modsi3 \
muldf3 \
mulsf3 \
+ subdf3 \
+ subsf3 \
truncdfsf2 \
udivsi3 \
umodsi3
diff --git a/lib/libiconv/Makefile b/lib/libiconv/Makefile
index 078771e..71c2885 100644
--- a/lib/libiconv/Makefile
+++ b/lib/libiconv/Makefile
@@ -19,7 +19,6 @@ SRCS= citrus_bcs.c citrus_bcs_strtol.c citrus_bcs_strtoul.c \
citrus_module.c citrus_none.c citrus_pivot_factory.c \
citrus_prop.c citrus_stdenc.c iconv.c
-WARNS?= 6
CFLAGS+= --param max-inline-insns-single=128 -I ${.CURDIR}/../../include -I${.CURDIR}/../libc/include
.include <bsd.lib.mk>
diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c
index fd09fc8..bc73baf 100644
--- a/lib/libkvm/kvm_pcpu.c
+++ b/lib/libkvm/kvm_pcpu.c
@@ -39,11 +39,13 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/cpuset.h>
#include <sys/pcpu.h>
#include <sys/sysctl.h>
#include <kvm.h>
#include <limits.h>
#include <stdlib.h>
+#include <unistd.h>
#include "kvm_private.h"
@@ -118,6 +120,9 @@ _kvm_pcpu_clear(void)
void *
kvm_getpcpu(kvm_t *kd, int cpu)
{
+ long kcpusetsize;
+ ssize_t nbytes;
+ uintptr_t readptr;
char *buf;
if (kd == NULL) {
@@ -125,6 +130,10 @@ kvm_getpcpu(kvm_t *kd, int cpu)
return (NULL);
}
+ kcpusetsize = sysconf(_SC_CPUSET_SIZE);
+ if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t))
+ return ((void *)-1);
+
if (maxcpu == 0)
if (_kvm_pcpu_init(kd) < 0)
return ((void *)-1);
@@ -137,8 +146,26 @@ kvm_getpcpu(kvm_t *kd, int cpu)
_kvm_err(kd, kd->program, "out of memory");
return ((void *)-1);
}
- if (kvm_read(kd, (uintptr_t)pcpu_data[cpu], buf, sizeof(struct pcpu)) !=
- sizeof(struct pcpu)) {
+ nbytes = sizeof(struct pcpu) - 2 * kcpusetsize;
+ readptr = (uintptr_t)pcpu_data[cpu];
+ if (kvm_read(kd, readptr, buf, nbytes) != nbytes) {
+ _kvm_err(kd, kd->program, "unable to read per-CPU data");
+ free(buf);
+ return ((void *)-1);
+ }
+
+ /* Fetch the valid cpuset_t objects. */
+ CPU_ZERO((cpuset_t *)(buf + nbytes));
+ CPU_ZERO((cpuset_t *)(buf + nbytes + sizeof(cpuset_t)));
+ readptr += nbytes;
+ if (kvm_read(kd, readptr, buf + nbytes, kcpusetsize) != kcpusetsize) {
+ _kvm_err(kd, kd->program, "unable to read per-CPU data");
+ free(buf);
+ return ((void *)-1);
+ }
+ readptr += kcpusetsize;
+ if (kvm_read(kd, readptr, buf + nbytes + sizeof(cpuset_t),
+ kcpusetsize) != kcpusetsize) {
_kvm_err(kd, kd->program, "unable to read per-CPU data");
free(buf);
return ((void *)-1);
diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c
index 4aae61a..485a4f2 100644
--- a/lib/libmemstat/memstat_uma.c
+++ b/lib/libmemstat/memstat_uma.c
@@ -27,6 +27,7 @@
*/
#include <sys/param.h>
+#include <sys/cpuset.h>
#include <sys/sysctl.h>
#define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */
@@ -44,6 +45,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "memstat.h"
#include "memstat_internal.h"
@@ -313,7 +315,8 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle)
struct uma_keg *kzp, kz;
int hint_dontsearch, i, mp_maxid, ret;
char name[MEMTYPE_MAXNAME];
- __cpumask_t all_cpus;
+ cpuset_t all_cpus;
+ long cpusetsize;
kvm_t *kvm;
kvm = (kvm_t *)kvm_handle;
@@ -337,7 +340,13 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle)
list->mtl_error = ret;
return (-1);
}
- ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, sizeof(all_cpus), 0);
+ cpusetsize = sysconf(_SC_CPUSET_SIZE);
+ if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) {
+ list->mtl_error = MEMSTAT_ERROR_KVM_NOSYMBOL;
+ return (-1);
+ }
+ CPU_ZERO(&all_cpus);
+ ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, cpusetsize, 0);
if (ret != 0) {
list->mtl_error = ret;
return (-1);
@@ -407,7 +416,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle)
if (kz.uk_flags & UMA_ZFLAG_INTERNAL)
goto skip_percpu;
for (i = 0; i < mp_maxid + 1; i++) {
- if ((all_cpus & (1 << i)) == 0)
+ if (!CPU_ISSET(i, &all_cpus))
continue;
ucp = &ucp_array[i];
mtp->mt_numallocs += ucp->uc_allocs;
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index 384fe73..22ca668 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -191,7 +191,7 @@ procstat_getprocs(struct procstat *procstat, int what, int arg,
len = *count * sizeof(*p);
p = malloc(len);
if (p == NULL) {
- warnx("malloc(%zd)", len);
+ warnx("malloc(%zu)", len);
goto fail;
}
bcopy(p0, p, len);
@@ -213,7 +213,7 @@ procstat_getprocs(struct procstat *procstat, int what, int arg,
}
p = malloc(len);
if (p == NULL) {
- warnx("malloc(%zd)", len);
+ warnx("malloc(%zu)", len);
goto fail;
}
error = sysctl(name, 4, p, &len, NULL, 0);
@@ -229,7 +229,7 @@ procstat_getprocs(struct procstat *procstat, int what, int arg,
*count = len / sizeof(*p);
return (p);
} else {
- warnx("unknown access method");
+ warnx("unknown access method: %d", procstat->type);
return (NULL);
}
fail:
@@ -271,11 +271,11 @@ procstat_freefiles(struct procstat *procstat, struct filestat_list *head)
}
free(head);
if (procstat->vmentries != NULL) {
- free (procstat->vmentries);
+ free(procstat->vmentries);
procstat->vmentries = NULL;
}
if (procstat->files != NULL) {
- free (procstat->files);
+ free(procstat->files);
procstat->files = NULL;
}
}
@@ -426,7 +426,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
nfiles = filed.fd_lastfile + 1;
ofiles = malloc(nfiles * sizeof(struct file *));
if (ofiles == NULL) {
- warn("malloc(%zd)", nfiles * sizeof(struct file *));
+ warn("malloc(%zu)", nfiles * sizeof(struct file *));
goto do_mmapped;
}
if (!kvm_read_all(kd, (unsigned long)filed.fd_ofiles, ofiles,
@@ -522,7 +522,8 @@ do_mmapped:
fflags = 0;
if (prot & VM_PROT_READ)
fflags = PS_FST_FFLAG_READ;
- if (prot & VM_PROT_WRITE)
+ if ((vmentry.eflags & MAP_ENTRY_COW) == 0 &&
+ prot & VM_PROT_WRITE)
fflags |= PS_FST_FFLAG_WRITE;
/*
@@ -696,7 +697,8 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, int m
fflags = 0;
if (kve->kve_protection & KVME_PROT_READ)
fflags = PS_FST_FFLAG_READ;
- if (kve->kve_protection & KVME_PROT_WRITE)
+ if ((kve->kve_flags & KVME_FLAG_COW) == 0 &&
+ kve->kve_protection & KVME_PROT_WRITE)
fflags |= PS_FST_FFLAG_WRITE;
offset = kve->kve_offset;
refcount = kve->kve_ref_count;
@@ -726,7 +728,7 @@ procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
} else if (procstat->type == PROCSTAT_SYSCTL) {
return (procstat_get_pipe_info_sysctl(fst, ps, errbuf));
} else {
- warnx("unknow access method: %d", procstat->type);
+ warnx("unknown access method: %d", procstat->type);
snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -790,7 +792,7 @@ procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
} else if (procstat->type == PROCSTAT_SYSCTL) {
return (procstat_get_pts_info_sysctl(fst, pts, errbuf));
} else {
- warnx("unknow access method: %d", procstat->type);
+ warnx("unknown access method: %d", procstat->type);
snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -852,7 +854,7 @@ procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
} else if (procstat->type == PROCSTAT_SYSCTL) {
return (procstat_get_vnode_info_sysctl(fst, vn, errbuf));
} else {
- warnx("unknow access method: %d", procstat->type);
+ warnx("unknown access method: %d", procstat->type);
snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -1059,7 +1061,7 @@ procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
} else if (procstat->type == PROCSTAT_SYSCTL) {
return (procstat_get_socket_info_sysctl(fst, sock, errbuf));
} else {
- warnx("unknow access method: %d", procstat->type);
+ warnx("unknown access method: %d", procstat->type);
snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -1283,7 +1285,7 @@ vntype2psfsttype(int type)
static char *
getmnton(kvm_t *kd, struct mount *m)
{
- static struct mount mnt;
+ struct mount mnt;
static struct mtab {
struct mtab *next;
struct mount *m;
@@ -1302,7 +1304,7 @@ getmnton(kvm_t *kd, struct mount *m)
err(1, NULL);
mt->m = m;
bcopy(&mnt.mnt_stat.f_mntonname[0], &mt->mntonname[0], MNAMELEN);
- mnt.mnt_stat.f_mntonname[MNAMELEN] = '\0';
+ mt->mntonname[MNAMELEN] = '\0';
mt->next = mhead;
mhead = mt;
return (mt->mntonname);
diff --git a/lib/libstand/bswap.c b/lib/libstand/bswap.c
index 212e2af..b8e6ffb 100644
--- a/lib/libstand/bswap.c
+++ b/lib/libstand/bswap.c
@@ -8,7 +8,7 @@ __FBSDID("$FreeBSD$");
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$NetBSD: bswap32.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $";
-static char *rcsid = "$NetBSD: bswap64.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $";
+static char *rcsid = "$NetBSD: bswap64.c,v 1.3 2009/03/16 05:59:21 cegger Exp $";
#endif
#include <sys/types.h>
@@ -30,12 +30,28 @@ bswap32(u_int32_t x)
u_int64_t
bswap64(u_int64_t x)
-{
- u_int32_t *p = (u_int32_t*)&x;
- u_int32_t t;
- t = bswap32(p[0]);
- p[0] = bswap32(p[1]);
- p[1] = t;
- return x;
-}
-
+{
+#ifdef _LP64
+ /*
+ * Assume we have wide enough registers to do it without touching
+ * memory.
+ */
+ return ( (x << 56) & 0xff00000000000000UL ) |
+ ( (x << 40) & 0x00ff000000000000UL ) |
+ ( (x << 24) & 0x0000ff0000000000UL ) |
+ ( (x << 8) & 0x000000ff00000000UL ) |
+ ( (x >> 8) & 0x00000000ff000000UL ) |
+ ( (x >> 24) & 0x0000000000ff0000UL ) |
+ ( (x >> 40) & 0x000000000000ff00UL ) |
+ ( (x >> 56) & 0x00000000000000ffUL );
+#else
+ /*
+ * Split the operation in two 32bit steps.
+ */
+ u_int32_t tl, th;
+
+ th = bswap32((u_int32_t)(x & 0x00000000ffffffffULL));
+ tl = bswap32((u_int32_t)((x >> 32) & 0x00000000ffffffffULL));
+ return ((u_int64_t)th << 32) | tl;
+#endif
+}
diff --git a/lib/libstand/net.c b/lib/libstand/net.c
index 81b4521..24593e6 100644
--- a/lib/libstand/net.c
+++ b/lib/libstand/net.c
@@ -100,7 +100,7 @@ sendrecv(struct iodesc *d,
cc, ssize);
tleft = tmo;
- tmo <<= 1;
+ tmo += MINTMO;
if (tmo > MAXTMO)
tmo = MAXTMO;
diff --git a/lib/libstand/tftp.c b/lib/libstand/tftp.c
index 29590fc..54e184c 100644
--- a/lib/libstand/tftp.c
+++ b/lib/libstand/tftp.c
@@ -60,12 +60,21 @@ __FBSDID("$FreeBSD$");
#include "tftp.h"
+struct tftp_handle;
+
static int tftp_open(const char *path, struct open_file *f);
static int tftp_close(struct open_file *f);
+static void tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t tftp_seek(struct open_file *f, off_t offset, int where);
+static int tftp_set_blksize(struct tftp_handle *h, const char *str);
static int tftp_stat(struct open_file *f, struct stat *sb);
+static ssize_t sendrecv_tftp(struct tftp_handle *h,
+ ssize_t (*sproc)(struct iodesc *, void *, size_t),
+ void *sbuf, size_t ssize,
+ ssize_t (*rproc)(struct tftp_handle *h, void *, ssize_t, time_t, unsigned short *),
+ void *rbuf, size_t rsize, unsigned short *rtype);
struct fs_ops tftp_fsops = {
"tftp",
@@ -81,8 +90,20 @@ struct fs_ops tftp_fsops = {
extern struct in_addr servip;
static int tftpport = 2000;
+static int is_open = 0;
+
+/*
+ * The legacy TFTP_BLKSIZE value was 512.
+ * TFTP_REQUESTED_BLKSIZE of 1428 is (Ethernet MTU, less the TFTP, UDP and
+ * IP header lengths).
+ */
+#define TFTP_REQUESTED_BLKSIZE 1428
-#define RSPACE 520 /* max data packet, rounded up */
+/*
+ * Choose a blksize big enough so we can test with Ethernet
+ * Jumbo frames in the future.
+ */
+#define TFTP_MAX_BLKSIZE 9008
struct tftp_handle {
struct iodesc *iodesc;
@@ -91,10 +112,12 @@ struct tftp_handle {
int validsize;
int off;
char *path; /* saved for re-requests */
+ unsigned int tftp_blksize;
+ unsigned long tftp_tsize;
struct {
u_char header[HEADER_SIZE];
struct tftphdr t;
- u_char space[RSPACE];
+ u_char space[TFTP_MAX_BLKSIZE];
} __packed __aligned(4) lastdata;
};
@@ -110,8 +133,10 @@ static const int tftperrors[8] = {
};
static ssize_t
-recvtftp(struct iodesc *d, void *pkt, ssize_t len, time_t tleft)
+recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
+ unsigned short *rtype)
{
+ struct iodesc *d = h->iodesc;
struct tftphdr *t;
errno = 0;
@@ -122,6 +147,7 @@ recvtftp(struct iodesc *d, void *pkt, ssize_t len, time_t tleft)
return (-1);
t = (struct tftphdr *) pkt;
+ *rtype = ntohs(t->th_opcode);
switch (ntohs(t->th_opcode)) {
case DATA: {
int got;
@@ -154,6 +180,18 @@ recvtftp(struct iodesc *d, void *pkt, ssize_t len, time_t tleft)
errno = tftperrors[ntohs(t->th_code)];
}
return (-1);
+ case OACK: {
+ struct udphdr *uh;
+ int tftp_oack_len = len - sizeof(t->th_opcode);
+ tftp_parse_oack(h, t->th_u.tu_stuff, tftp_oack_len);
+ /*
+ * Remember which port this OACK came from,
+ * because we need to send the ACK back to it.
+ */
+ uh = (struct udphdr *) pkt - 1;
+ d->destport = uh->uh_sport;
+ return (0);
+ }
default:
#ifdef TFTP_DEBUG
printf("tftp type %d not handled\n", ntohs(t->th_opcode));
@@ -175,14 +213,35 @@ tftp_makereq(struct tftp_handle *h)
int l;
ssize_t res;
struct tftphdr *t;
+ char *tftp_blksize = NULL;
+ int blksize_l;
+ unsigned short rtype = 0;
+
+ /*
+ * Allow overriding default TFTP block size by setting
+ * a tftp.blksize environment variable.
+ */
+ if ((tftp_blksize = getenv("tftp.blksize")) != NULL) {
+ tftp_set_blksize(h, tftp_blksize);
+ }
wbuf.t.th_opcode = htons((u_short) RRQ);
wtail = wbuf.t.th_stuff;
l = strlen(h->path);
+ if (l > FNAME_SIZE)
+ return (ENAMETOOLONG);
bcopy(h->path, wtail, l + 1);
wtail += l + 1;
bcopy("octet", wtail, 6);
wtail += 6;
+ bcopy("blksize", wtail, 8);
+ wtail += 8;
+ blksize_l = sprintf(wtail, "%d", h->tftp_blksize);
+ wtail += blksize_l + 1;
+ bcopy("tsize", wtail, 6);
+ wtail += 6;
+ bcopy("0", wtail, 2);
+ wtail += 2;
t = &h->lastdata.t;
@@ -191,18 +250,33 @@ tftp_makereq(struct tftp_handle *h)
h->iodesc->destport = htons(IPPORT_TFTP);
h->iodesc->xid = 1; /* expected block */
- res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
- recvtftp, t, sizeof(*t) + RSPACE);
+ res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
+ &recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
+
+ if (rtype == OACK) {
+ wbuf.t.th_opcode = htons((u_short)ACK);
+ wtail = (char *) &wbuf.t.th_block;
+ wbuf.t.th_block = htons(0);
+ wtail += 2;
+ rtype = 0;
+ res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
+ &recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
+ }
- if (res == -1)
- return (errno);
+ switch (rtype) {
+ case DATA: {
+ h->currblock = 1;
+ h->validsize = res;
+ h->islastblock = 0;
+ if (res < h->tftp_blksize)
+ h->islastblock = 1; /* very short file */
+ return (0);
+ }
+ case ERROR:
+ default:
+ return (errno);
+ }
- h->currblock = 1;
- h->validsize = res;
- h->islastblock = 0;
- if (res < SEGSIZE)
- h->islastblock = 1; /* very short file */
- return (0);
}
/* ack block, expect next */
@@ -216,7 +290,7 @@ tftp_getnextblock(struct tftp_handle *h)
char *wtail;
int res;
struct tftphdr *t;
-
+ unsigned short rtype = 0;
wbuf.t.th_opcode = htons((u_short) ACK);
wtail = (char *) &wbuf.t.th_block;
wbuf.t.th_block = htons((u_short) h->currblock);
@@ -226,16 +300,23 @@ tftp_getnextblock(struct tftp_handle *h)
h->iodesc->xid = h->currblock + 1; /* expected block */
- res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
- recvtftp, t, sizeof(*t) + RSPACE);
+ res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
+ &recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
if (res == -1) /* 0 is OK! */
return (errno);
h->currblock++;
h->validsize = res;
- if (res < SEGSIZE)
+ if (res < h->tftp_blksize)
h->islastblock = 1; /* EOF */
+
+ if (h->islastblock == 1) {
+ /* Send an ACK for the last block */
+ wbuf.t.th_block = htons((u_short) h->currblock);
+ sendudp(h->iodesc, &wbuf.t, wtail - (char *)&wbuf.t);
+ }
+
return (0);
}
@@ -251,10 +332,15 @@ tftp_open(const char *path, struct open_file *f)
return (EINVAL);
#endif
+ if (is_open)
+ return (EBUSY);
+
tftpfile = (struct tftp_handle *) malloc(sizeof(*tftpfile));
if (!tftpfile)
return (ENOMEM);
+ memset(tftpfile, 0, sizeof(*tftpfile));
+ tftpfile->tftp_blksize = TFTP_REQUESTED_BLKSIZE;
tftpfile->iodesc = io = socktodesc(*(int *) (f->f_devdata));
if (io == NULL)
return (EINVAL);
@@ -275,6 +361,7 @@ tftp_open(const char *path, struct open_file *f)
return (res);
}
f->f_fsdata = (void *) tftpfile;
+ is_open = 1;
return (0);
}
@@ -292,7 +379,7 @@ tftp_read(struct open_file *f, void *addr, size_t size,
if (!(tc++ % 16))
twiddle();
- needblock = tftpfile->off / SEGSIZE + 1;
+ needblock = tftpfile->off / tftpfile->tftp_blksize + 1;
if (tftpfile->currblock > needblock) /* seek backwards */
tftp_makereq(tftpfile); /* no error check, it worked
@@ -315,7 +402,7 @@ tftp_read(struct open_file *f, void *addr, size_t size,
if (tftpfile->currblock == needblock) {
int offinblock, inbuffer;
- offinblock = tftpfile->off % SEGSIZE;
+ offinblock = tftpfile->off % tftpfile->tftp_blksize;
inbuffer = tftpfile->validsize - offinblock;
if (inbuffer < 0) {
@@ -361,18 +448,19 @@ tftp_close(struct open_file *f)
free(tftpfile->path);
free(tftpfile);
}
+ is_open = 0;
return (0);
}
static int
tftp_write(struct open_file *f __unused, void *start __unused, size_t size __unused,
- size_t *resid /* out */ __unused)
+ size_t *resid __unused /* out */)
{
return (EROFS);
}
static int
-tftp_stat(struct open_file *f, struct stat *sb)
+tftp_stat(struct open_file *f, struct stat *sb)
{
struct tftp_handle *tftpfile;
tftpfile = (struct tftp_handle *) f->f_fsdata;
@@ -404,3 +492,166 @@ tftp_seek(struct open_file *f, off_t offset, int where)
}
return (tftpfile->off);
}
+
+static ssize_t
+sendrecv_tftp(struct tftp_handle *h,
+ ssize_t (*sproc)(struct iodesc *, void *, size_t),
+ void *sbuf, size_t ssize,
+ ssize_t (*rproc)(struct tftp_handle *, void *, ssize_t, time_t, unsigned short *),
+ void *rbuf, size_t rsize, unsigned short *rtype)
+{
+ struct iodesc *d = h->iodesc;
+ ssize_t cc;
+ time_t t, t1, tleft;
+
+#ifdef TFTP_DEBUG
+ if (debug)
+ printf("sendrecv: called\n");
+#endif
+
+ tleft = MINTMO;
+ t = t1 = getsecs();
+ for (;;) {
+ if ((getsecs() - t) > MAXTMO) {
+ errno = ETIMEDOUT;
+ return -1;
+ }
+
+ cc = (*sproc)(d, sbuf, ssize);
+ if (cc != -1 && cc < ssize)
+ panic("sendrecv: short write! (%zd < %zu)",
+ cc, ssize);
+
+ if (cc == -1) {
+ /* Error on transmit; wait before retrying */
+ while ((getsecs() - t1) < tleft);
+ continue;
+ }
+
+recvnext:
+ /* Try to get a packet and process it. */
+ cc = (*rproc)(h, rbuf, rsize, tleft, rtype);
+ /* Return on data, EOF or real error. */
+ if (cc != -1 || errno != 0)
+ return (cc);
+ if ((getsecs() - t1) < tleft) {
+ goto recvnext;
+ }
+
+ /* Timed out or didn't get the packet we're waiting for */
+ tleft += MINTMO;
+ if (tleft > (2 * MINTMO)) {
+ tleft = (2 * MINTMO);
+ }
+ t1 = getsecs();
+ }
+}
+
+static int
+tftp_set_blksize(struct tftp_handle *h, const char *str)
+{
+ char *endptr;
+ int new_blksize;
+ int ret = 0;
+
+ if (h == NULL || str == NULL)
+ return (ret);
+
+ new_blksize =
+ (unsigned int)strtol(str, &endptr, 0);
+
+ /*
+ * Only accept blksize value if it is numeric.
+ * RFC2348 specifies that acceptable valuesare 8-65464
+ * 8-65464 . Let's choose a limit less than MAXRSPACE
+ */
+ if (*endptr == '\0' && new_blksize >= 8
+ && new_blksize <= TFTP_MAX_BLKSIZE) {
+ h->tftp_blksize = new_blksize;
+ ret = 1;
+ }
+
+ return (ret);
+}
+
+/*
+ * In RFC2347, the TFTP Option Acknowledgement package (OACK)
+ * is used to acknowledge a client's option negotiation request.
+ * The format of an OACK packet is:
+ * +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+
+ * | opc | opt1 | 0 | value1 | 0 | optN | 0 | valueN | 0 |
+ * +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+
+ *
+ * opc
+ * The opcode field contains a 6, for Option Acknowledgment.
+ *
+ * opt1
+ * The first option acknowledgment, copied from the original
+ * request.
+ *
+ * value1
+ * The acknowledged value associated with the first option. If
+ * and how this value may differ from the original request is
+ * detailed in the specification for the option.
+ *
+ * optN, valueN
+ * The final option/value acknowledgment pair.
+ */
+static void
+tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len)
+{
+ /*
+ * We parse the OACK strings into an array
+ * of name-value pairs.
+ *
+ */
+ char *tftp_options[128] = { 0 };
+ char *val = buf;
+ int i = 0;
+ int option_idx = 0;
+ int blksize_is_set = 0;
+ int tsize = 0;
+
+
+ while ( option_idx < 128 && i < len ) {
+ if (buf[i] == '\0') {
+ if (&buf[i] > val) {
+ tftp_options[option_idx] = val;
+ val = &buf[i] + 1;
+ ++option_idx;
+ }
+ }
+ ++i;
+ }
+
+ /*
+ * Parse individual TFTP options.
+ * * "blksize" is specified in RFC2348.
+ * * "tsize" is specified in RFC2349.
+ */
+ for (i = 0; i < option_idx; i += 2) {
+ if (strcasecmp(tftp_options[i], "blksize") == 0) {
+ if (i + 1 < option_idx) {
+ blksize_is_set =
+ tftp_set_blksize(h, tftp_options[i + 1]);
+ }
+ } else if (strcasecmp(tftp_options[i], "tsize") == 0) {
+ if (i + 1 < option_idx) {
+ tsize = strtol(tftp_options[i + 1], (char **)NULL, 10);
+ }
+ }
+ }
+
+ if (!blksize_is_set) {
+ /*
+ * If TFTP blksize was not set, try defaulting
+ * to the legacy TFTP blksize of 512
+ */
+ h->tftp_blksize = 512;
+ }
+
+#ifdef TFTP_DEBUG
+ printf("tftp_blksize: %u\n", h->tftp_blksize);
+ printf("tftp_tsize: %lu\n", h->tftp_tsize);
+#endif
+}
diff --git a/lib/libstand/zalloc.c b/lib/libstand/zalloc.c
index aa8ccd0..2cd71c4 100644
--- a/lib/libstand/zalloc.c
+++ b/lib/libstand/zalloc.c
@@ -154,7 +154,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes)
if ((char *)ptr < (char *)mp->mp_Base ||
(char *)ptr + bytes > (char *)mp->mp_End ||
((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0)
- panic("zfree(%p,%d): wild pointer", ptr, bytes);
+ panic("zfree(%p,%ju): wild pointer", ptr, bytes);
/*
* free the segment
@@ -178,7 +178,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes)
* range check
*/
if ((char *)ptr + bytes > (char *)mn)
- panic("zfree(%p,%d): corrupt memlist1",ptr, bytes);
+ panic("zfree(%p,%ju): corrupt memlist1",ptr, bytes);
/*
* merge against next area or create independant area
@@ -209,7 +209,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes)
/* NOT REACHED */
}
if ((char *)ptr < (char *)mn + mn->mr_Bytes)
- panic("zfree(%p,%d): corrupt memlist2", ptr, bytes);
+ panic("zfree(%p,%ju): corrupt memlist2", ptr, bytes);
}
/*
* We are beyond the last MemNode, append new MemNode. Merge against
diff --git a/lib/libstand/zalloc_malloc.c b/lib/libstand/zalloc_malloc.c
index cdacf13..5cd7bcb 100644
--- a/lib/libstand/zalloc_malloc.c
+++ b/lib/libstand/zalloc_malloc.c
@@ -110,7 +110,7 @@ Free(void *ptr, const char *file, int line)
return;
}
if (*((signed char *)res + res->ga_Bytes - 1) != -2)
- panic("free: guard2 fail @ %p + %d from %s:%d", ptr, res->ga_Bytes - MALLOCALIGN, file, line);
+ panic("free: guard2 fail @ %p + %zu from %s:%d", ptr, res->ga_Bytes - MALLOCALIGN, file, line);
*((signed char *)res + res->ga_Bytes - 1) = -1;
#endif
diff --git a/lib/libthr/arch/sparc64/Makefile.inc b/lib/libthr/arch/sparc64/Makefile.inc
index 2ee2247..88586b4 100644
--- a/lib/libthr/arch/sparc64/Makefile.inc
+++ b/lib/libthr/arch/sparc64/Makefile.inc
@@ -1,3 +1,3 @@
# $FreeBSD$
-SRCS+= pthread_md.c
+SRCS+= _umtx_op_err.S pthread_md.c
diff --git a/lib/libthr/arch/sparc64/include/pthread_md.h b/lib/libthr/arch/sparc64/include/pthread_md.h
index 7909291..7ee9654 100644
--- a/lib/libthr/arch/sparc64/include/pthread_md.h
+++ b/lib/libthr/arch/sparc64/include/pthread_md.h
@@ -50,10 +50,6 @@ struct tcb {
void *tcb_spare[1];
};
-register struct tcb *_tp __asm("%g7");
-
-#define _tcb (_tp)
-
/*
* The tcb constructors.
*/
@@ -64,26 +60,25 @@ void _tcb_dtor(struct tcb *);
static __inline void
_tcb_set(struct tcb *tcb)
{
- _tp = tcb;
+
+ __asm __volatile("mov %0, %%g7" : : "r" (tcb));
}
-/*
- * Get the current tcb.
- */
static __inline struct tcb *
_tcb_get(void)
{
- return (_tcb);
-}
+ register struct tcb *tp __asm("%g7");
-extern struct pthread *_thr_initial;
+ return (tp);
+}
static __inline struct pthread *
_get_curthread(void)
{
- if (_thr_initial)
- return (_tcb->tcb_thread);
- return (NULL);
+
+ return (_tcb_get()->tcb_thread);
}
+#define HAS__UMTX_OP_ERR 1
+
#endif /* _PTHREAD_MD_H_ */
diff --git a/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S b/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S
new file mode 100644
index 0000000..220d279
--- /dev/null
+++ b/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2011 Marius Strobl <marius@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/syscall.h>
+
+#include <machine/utrap.h>
+
+ENTRY(_umtx_op_err)
+ mov SYS__umtx_op, %g1
+ retl
+ ta %xcc, ST_SYSCALL
+END(_umtx_op_err)
diff --git a/lib/libthr/arch/sparc64/sparc64/pthread_md.c b/lib/libthr/arch/sparc64/sparc64/pthread_md.c
index 3f8e105..e1d439a 100644
--- a/lib/libthr/arch/sparc64/sparc64/pthread_md.c
+++ b/lib/libthr/arch/sparc64/sparc64/pthread_md.c
@@ -24,10 +24,11 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/types.h>
#include <rtld_tls.h>
@@ -37,13 +38,11 @@ struct tcb *
_tcb_ctor(struct pthread *thread, int initial)
{
struct tcb *tcb;
- void *oldtls;
if (initial)
- oldtls = _tp;
+ tcb = _tcb_get();
else
- oldtls = NULL;
- tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16);
+ tcb = _rtld_allocate_tls(NULL, sizeof(struct tcb), 16);
if (tcb)
tcb->tcb_thread = thread;
return (tcb);
@@ -52,5 +51,6 @@ _tcb_ctor(struct pthread *thread, int initial)
void
_tcb_dtor(struct tcb *tcb)
{
+
_rtld_free_tls(tcb, sizeof(struct tcb), 16);
}
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index 7e07215..86abad8 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -409,7 +409,6 @@ init_main_thread(struct pthread *thread)
thread->cancel_enable = 1;
thread->cancel_async = 0;
- thr_set_name(thread->tid, "initial thread");
/* Initialize the mutex queue: */
TAILQ_INIT(&thread->mutexq);
diff --git a/lib/msun/ld128/e_rem_pio2l.h b/lib/msun/ld128/e_rem_pio2l.h
index d223627..5d78c4d 100644
--- a/lib/msun/ld128/e_rem_pio2l.h
+++ b/lib/msun/ld128/e_rem_pio2l.h
@@ -58,10 +58,7 @@ pio2_2t = 2.0670321098263988236496903051604844e-43L, /* 0x127044533e63a0105df5
pio2_3 = 2.0670321098263988236499468110329591e-43L, /* 0x127044533e63a0105e00000000000.0p-254 */
pio2_3t = -2.5650587247459238361625433492959285e-65L; /* -0x159c4ec64ddaeb5f78671cbfb2210.0p-327 */
-#ifdef INLINE_REM_PIO2L
-static inline __always_inline
-#endif
-int
+static inline __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;
diff --git a/lib/msun/ld80/e_rem_pio2l.h b/lib/msun/ld80/e_rem_pio2l.h
index cfe3fb9..75e4e4b 100644
--- a/lib/msun/ld80/e_rem_pio2l.h
+++ b/lib/msun/ld80/e_rem_pio2l.h
@@ -70,10 +70,7 @@ pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */
pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
#endif
-#ifdef INLINE_REM_PIO2L
-static inline __always_inline
-#endif
-int
+static inline __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;
@@ -85,7 +82,7 @@ __ieee754_rem_pio2l(long double x, long double *y)
u.e = x;
expsign = u.xbits.expsign;
ex = expsign & 0x7fff;
- if (ex < BIAS + 25 || ex == BIAS + 25 && u.bits.manh < 0xc90fdaa2) {
+ if (ex < BIAS + 25 || (ex == BIAS + 25 && u.bits.manh < 0xc90fdaa2)) {
/* |x| ~< 2^25*(pi/2), medium size */
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
fn = x*invpio2+0x1.8p63;
diff --git a/lib/msun/src/e_rem_pio2.c b/lib/msun/src/e_rem_pio2.c
index a58a81b..fde9660 100644
--- a/lib/msun/src/e_rem_pio2.c
+++ b/lib/msun/src/e_rem_pio2.c
@@ -171,9 +171,8 @@ medium:
}
/* set z = scalbn(|x|,ilogb(x)-23) */
GET_LOW_WORD(low,x);
- SET_LOW_WORD(z,low);
e0 = (ix>>20)-1046; /* e0 = ilogb(z)-23; */
- SET_HIGH_WORD(z, ix - ((int32_t)(e0<<20)));
+ INSERT_WORDS(z, ix - ((int32_t)(e0<<20)), low);
for(i=0;i<2;i++) {
tx[i] = (double)((int32_t)(z));
z = (z-tx[i])*two24;
diff --git a/lib/msun/src/s_cosl.c b/lib/msun/src/s_cosl.c
index 77611c1..8d43626 100644
--- a/lib/msun/src/s_cosl.c
+++ b/lib/msun/src/s_cosl.c
@@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
#include <float.h>
#include "math.h"
-#define INLINE_REM_PIO2L
#include "math_private.h"
#if LDBL_MANT_DIG == 64
#include "../ld80/e_rem_pio2l.h"
diff --git a/lib/msun/src/s_sinl.c b/lib/msun/src/s_sinl.c
index 19d9572..919deb9 100644
--- a/lib/msun/src/s_sinl.c
+++ b/lib/msun/src/s_sinl.c
@@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$");
#include <float.h>
#include "math.h"
-#define INLINE_REM_PIO2L
#include "math_private.h"
#if LDBL_MANT_DIG == 64
#include "../ld80/e_rem_pio2l.h"
diff --git a/lib/msun/src/s_tanl.c b/lib/msun/src/s_tanl.c
index 3cf4a69..9562cf8 100644
--- a/lib/msun/src/s_tanl.c
+++ b/lib/msun/src/s_tanl.c
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <float.h>
#include "math.h"
-#define INLINE_REM_PIO2L
#include "math_private.h"
#if LDBL_MANT_DIG == 64
#include "../ld80/e_rem_pio2l.h"
OpenPOWER on IntegriCloud