summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2013-02-08 16:10:16 +0000
committerobrien <obrien@FreeBSD.org>2013-02-08 16:10:16 +0000
commit3028e3f8aba938dfd0bf9fda987b8a72140b8027 (patch)
treeb2f038222ff8a70f687652441df00d2b564c8abe /lib/libc
parent952a6d5a7cd3d3f9007acfa06805262fc04a105f (diff)
parent1d08d5f677c1dfa810e381073590adbae19cc69f (diff)
downloadFreeBSD-src-3028e3f8aba938dfd0bf9fda987b8a72140b8027.zip
FreeBSD-src-3028e3f8aba938dfd0bf9fda987b8a72140b8027.tar.gz
Sync with HEAD.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/amd64/sys/__vdso_gettc.c11
-rw-r--r--lib/libc/arm/Makefile.inc8
-rw-r--r--lib/libc/arm/SYS.h8
-rw-r--r--lib/libc/arm/Symbol.map4
-rw-r--r--lib/libc/arm/Symbol_oabi.map16
-rw-r--r--lib/libc/arm/aeabi/Makefile.inc11
-rw-r--r--lib/libc/arm/aeabi/Symbol.map47
-rw-r--r--lib/libc/arm/aeabi/aeabi_atexit.c38
-rw-r--r--lib/libc/arm/aeabi/aeabi_double.c101
-rw-r--r--lib/libc/arm/aeabi/aeabi_float.c101
-rw-r--r--lib/libc/arm/aeabi/aeabi_unwind_cpp.c61
-rw-r--r--lib/libc/arm/gen/Makefile.inc6
-rw-r--r--lib/libc/arm/softfloat/arm-gcc.h2
-rw-r--r--lib/libc/arm/sys/Makefile.inc2
-rw-r--r--lib/libc/arm/sys/__vdso_gettc.c48
-rw-r--r--lib/libc/gen/Makefile.inc10
-rw-r--r--lib/libc/gen/Symbol.map14
-rw-r--r--lib/libc/gen/check_utility_compat.c12
-rw-r--r--lib/libc/gen/fmtmsg.c2
-rw-r--r--lib/libc/gen/fstab.c12
-rw-r--r--lib/libc/gen/getbsize.338
-rw-r--r--lib/libc/gen/getcap.c4
-rw-r--r--lib/libc/gen/getgrent.c8
-rw-r--r--lib/libc/gen/getnetgrent.c4
-rw-r--r--lib/libc/gen/getttyent.c2
-rw-r--r--lib/libc/gen/getusershell.c2
-rw-r--r--lib/libc/gen/getutxent.c2
-rw-r--r--lib/libc/gen/glob.c113
-rw-r--r--lib/libc/gen/isnan.c7
-rw-r--r--lib/libc/gen/sysctlbyname.c9
-rw-r--r--lib/libc/gen/unvis-compat.c46
-rw-r--r--lib/libc/gen/unvis.3200
-rw-r--r--lib/libc/gen/unvis.c293
-rw-r--r--lib/libc/gen/vis.3308
-rw-r--r--lib/libc/gen/vis.c201
-rw-r--r--lib/libc/gen/waitid.c65
-rw-r--r--lib/libc/i386/sys/__vdso_gettc.c10
-rw-r--r--lib/libc/ia64/sys/Makefile.inc2
-rw-r--r--lib/libc/ia64/sys/__vdso_gettc.c48
-rw-r--r--lib/libc/iconv/citrus_mmap.c6
-rw-r--r--lib/libc/include/namespace.h1
-rw-r--r--lib/libc/include/un-namespace.h1
-rw-r--r--lib/libc/locale/collate.c2
-rw-r--r--lib/libc/locale/setrunelocale.c18
-rw-r--r--lib/libc/mips/sys/Makefile.inc2
-rw-r--r--lib/libc/mips/sys/__vdso_gettc.c48
-rw-r--r--lib/libc/net/getnetent.35
-rw-r--r--lib/libc/net/getprotoent.35
-rw-r--r--lib/libc/net/getservent.35
-rw-r--r--lib/libc/net/name6.c10
-rw-r--r--lib/libc/net/sctp_sys_calls.c86
-rw-r--r--lib/libc/nls/Makefile.inc3
-rw-r--r--lib/libc/nls/msgcat.c1
-rw-r--r--lib/libc/nls/zh_CN.GB18030.msg297
-rw-r--r--lib/libc/nls/zh_CN.GB2312.msg297
-rw-r--r--lib/libc/nls/zh_CN.UTF-8.msg295
-rw-r--r--lib/libc/powerpc/Makefile.inc2
-rw-r--r--lib/libc/powerpc/sys/__vdso_gettc.c48
-rw-r--r--lib/libc/powerpc64/Makefile.inc2
-rw-r--r--lib/libc/powerpc64/sys/__vdso_gettc.c48
-rw-r--r--lib/libc/quad/Makefile.inc4
-rw-r--r--lib/libc/sparc64/Makefile.inc2
-rw-r--r--lib/libc/sparc64/sys/__vdso_gettc.c48
-rw-r--r--lib/libc/stdio/Makefile.inc5
-rw-r--r--lib/libc/stdio/Symbol.map1
-rw-r--r--lib/libc/stdio/fdopen.c6
-rw-r--r--lib/libc/stdio/flags.c5
-rw-r--r--lib/libc/stdio/fmemopen.c258
-rw-r--r--lib/libc/stdio/fopen.371
-rw-r--r--lib/libc/stdio/freopen.c5
-rw-r--r--lib/libc/stdio/getline.34
-rw-r--r--lib/libc/stdio/printf.32
-rw-r--r--lib/libc/sys/Makefile.inc3
-rw-r--r--lib/libc/sys/Symbol.map3
-rw-r--r--lib/libc/sys/__vdso_gettimeofday.c4
-rw-r--r--lib/libc/sys/bind.22
-rw-r--r--lib/libc/sys/chroot.28
-rw-r--r--lib/libc/sys/getpeername.24
-rw-r--r--lib/libc/sys/getsockname.24
-rw-r--r--lib/libc/sys/gettimeofday.c5
-rw-r--r--lib/libc/sys/kqueue.26
-rw-r--r--lib/libc/sys/mlock.217
-rw-r--r--lib/libc/sys/mlockall.217
-rw-r--r--lib/libc/sys/open.213
-rw-r--r--lib/libc/sys/posix_fadvise.22
-rw-r--r--lib/libc/sys/ptrace.212
-rw-r--r--lib/libc/sys/rtprio.212
-rw-r--r--lib/libc/sys/sendfile.22
-rw-r--r--lib/libc/sys/socket.219
-rw-r--r--lib/libc/sys/wait.2311
90 files changed, 2678 insertions, 1235 deletions
diff --git a/lib/libc/amd64/sys/__vdso_gettc.c b/lib/libc/amd64/sys/__vdso_gettc.c
index 091fe26..c6f2dfb 100644
--- a/lib/libc/amd64/sys/__vdso_gettc.c
+++ b/lib/libc/amd64/sys/__vdso_gettc.c
@@ -27,9 +27,11 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
+#include <sys/elf.h>
#include <sys/time.h>
#include <sys/vdso.h>
#include <machine/cpufunc.h>
+#include "libc_private.h"
static u_int
__vdso_gettc_low(const struct vdso_timehands *th)
@@ -41,9 +43,18 @@ __vdso_gettc_low(const struct vdso_timehands *th)
return (rv);
}
+#pragma weak __vdso_gettc
u_int
__vdso_gettc(const struct vdso_timehands *th)
{
return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libc/arm/Makefile.inc b/lib/libc/arm/Makefile.inc
index 4c72e56..1ae1298 100644
--- a/lib/libc/arm/Makefile.inc
+++ b/lib/libc/arm/Makefile.inc
@@ -8,3 +8,11 @@ SOFTFLOAT_BITS=32
# Long double is just double precision.
MDSRCS+=machdep_ldisd.c
SYM_MAPS+=${.CURDIR}/arm/Symbol.map
+
+.if ${MK_ARM_EABI} == "no"
+# This contains the symbols that were removed when moving to the ARM EABI
+SYM_MAPS+=${.CURDIR}/arm/Symbol_oabi.map
+.else
+.include "${.CURDIR}/arm/aeabi/Makefile.inc"
+.endif
+
diff --git a/lib/libc/arm/SYS.h b/lib/libc/arm/SYS.h
index 584c151..ed1a045 100644
--- a/lib/libc/arm/SYS.h
+++ b/lib/libc/arm/SYS.h
@@ -39,7 +39,15 @@
#include <sys/syscall.h>
#include <machine/swi.h>
+#ifdef __ARM_EABI__
+#define SYSTRAP(x) \
+ mov ip, r7; \
+ ldr r7, =SYS_ ## x; \
+ swi 0; \
+ mov r7, ip
+#else
#define SYSTRAP(x) swi 0 | SYS_ ## x
+#endif
#define CERROR _C_LABEL(cerror)
#define CURBRK _C_LABEL(curbrk)
diff --git a/lib/libc/arm/Symbol.map b/lib/libc/arm/Symbol.map
index b786afd..d652bc8 100644
--- a/lib/libc/arm/Symbol.map
+++ b/lib/libc/arm/Symbol.map
@@ -50,10 +50,6 @@ FBSDprivate_1.0 {
_set_tp;
__aeabi_read_tp;
___longjmp;
- __umodsi3;
- __modsi3;
- __udivsi3;
- __divsi3;
__makecontext;
__longjmp;
signalcontext;
diff --git a/lib/libc/arm/Symbol_oabi.map b/lib/libc/arm/Symbol_oabi.map
new file mode 100644
index 0000000..0c22e4a
--- /dev/null
+++ b/lib/libc/arm/Symbol_oabi.map
@@ -0,0 +1,16 @@
+/*
+ * $FreeBSD$
+ */
+
+/*
+ * This only needs to contain symbols that are not listed in
+ * symbol maps from other parts of libc (i.e., not found in
+ * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...)
+ * and are not used in the ARM EABI.
+ */
+FBSDprivate_1.0 {
+ __umodsi3;
+ __modsi3;
+ __udivsi3;
+ __divsi3;
+};
diff --git a/lib/libc/arm/aeabi/Makefile.inc b/lib/libc/arm/aeabi/Makefile.inc
new file mode 100644
index 0000000..ac147c0
--- /dev/null
+++ b/lib/libc/arm/aeabi/Makefile.inc
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/arm/aeabi
+
+SRCS+= aeabi_atexit.c \
+ aeabi_double.c \
+ aeabi_float.c \
+ aeabi_unwind_cpp.c
+
+SYM_MAPS+=${.CURDIR}/arm/aeabi/Symbol.map
+
diff --git a/lib/libc/arm/aeabi/Symbol.map b/lib/libc/arm/aeabi/Symbol.map
new file mode 100644
index 0000000..9493427
--- /dev/null
+++ b/lib/libc/arm/aeabi/Symbol.map
@@ -0,0 +1,47 @@
+/*
+ * $FreeBSD$
+ */
+
+/*
+ * This only needs to contain AEABI symbols that are not listed in
+ * symbol maps from other parts of libc (i.e., not found in
+ * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
+ */
+FBSDprivate_1.0 {
+ __aeabi_atexit;
+
+ __aeabi_dcmpeq;
+ __aeabi_dcmplt;
+ __aeabi_dcmple;
+ __aeabi_dcmpge;
+ __aeabi_dcmpgt;
+ __aeabi_dcmpun;
+
+ __aeabi_d2iz;
+ __aeabi_d2f;
+
+ __aeabi_dadd;
+ __aeabi_ddiv;
+ __aeabi_dmul;
+ __aeabi_dsub;
+
+
+ __aeabi_fcmpeq;
+ __aeabi_fcmplt;
+ __aeabi_fcmple;
+ __aeabi_fcmpge;
+ __aeabi_fcmpgt;
+ __aeabi_fcmpun;
+
+ __aeabi_f2iz;
+ __aeabi_f2d;
+
+ __aeabi_fadd;
+ __aeabi_fdiv;
+ __aeabi_fmul;
+ __aeabi_fsub;
+
+
+ __aeabi_i2d;
+ __aeabi_i2f;
+};
diff --git a/lib/libc/arm/aeabi/aeabi_atexit.c b/lib/libc/arm/aeabi/aeabi_atexit.c
new file mode 100644
index 0000000..8502595
--- /dev/null
+++ b/lib/libc/arm/aeabi/aeabi_atexit.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 Andrew Turner
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+int __cxa_atexit(void (*)(void *), void *, void *);
+
+int
+__aeabi_atexit(void *object, void (*func)(void*), void *dso)
+{
+ return __cxa_atexit(func, object, dso);
+}
+
diff --git a/lib/libc/arm/aeabi/aeabi_double.c b/lib/libc/arm/aeabi/aeabi_double.c
new file mode 100644
index 0000000..5f9065c
--- /dev/null
+++ b/lib/libc/arm/aeabi/aeabi_double.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2012 Andrew Turner
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+flag __unorddf2(float64, float64);
+
+int __aeabi_dcmpeq(float64 a, float64 b)
+{
+ return float64_eq(a, b);
+}
+
+int __aeabi_dcmplt(float64 a, float64 b)
+{
+ return float64_lt(a, b);
+}
+
+int __aeabi_dcmple(float64 a, float64 b)
+{
+ return float64_le(a, b);
+}
+
+int __aeabi_dcmpge(float64 a, float64 b)
+{
+ return float64_le(b, a);
+}
+
+int __aeabi_dcmpgt(float64 a, float64 b)
+{
+ return float64_lt(b, a);
+}
+
+int __aeabi_dcmpun(float64 a, float64 b)
+{
+ return __unorddf2(a, b);
+}
+
+int __aeabi_d2iz(float64 a)
+{
+ return float64_to_int32_round_to_zero(a);
+}
+
+float32 __aeabi_d2f(float64 a)
+{
+ return float64_to_float32(a);
+}
+
+float64 __aeabi_i2d(int a)
+{
+ return int32_to_float64(a);
+}
+
+float64 __aeabi_dadd(float64 a, float64 b)
+{
+ return float64_add(a, b);
+}
+
+float64 __aeabi_ddiv(float64 a, float64 b)
+{
+ return float64_div(a, b);
+}
+
+float64 __aeabi_dmul(float64 a, float64 b)
+{
+ return float64_mul(a, b);
+}
+
+float64 __aeabi_dsub(float64 a, float64 b)
+{
+ return float64_sub(a, b);
+}
+
diff --git a/lib/libc/arm/aeabi/aeabi_float.c b/lib/libc/arm/aeabi/aeabi_float.c
new file mode 100644
index 0000000..97751ad
--- /dev/null
+++ b/lib/libc/arm/aeabi/aeabi_float.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2012 Andrew Turner
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+flag __unordsf2(float32, float32);
+
+int __aeabi_fcmpeq(float32 a, float32 b)
+{
+ return float32_eq(a, b);
+}
+
+int __aeabi_fcmplt(float32 a, float32 b)
+{
+ return float32_lt(a, b);
+}
+
+int __aeabi_fcmple(float32 a, float32 b)
+{
+ return float32_le(a, b);
+}
+
+int __aeabi_fcmpge(float32 a, float32 b)
+{
+ return float32_le(b, a);
+}
+
+int __aeabi_fcmpgt(float32 a, float32 b)
+{
+ return float32_lt(b, a);
+}
+
+int __aeabi_fcmpun(float32 a, float32 b)
+{
+ return __unordsf2(a, b);
+}
+
+int __aeabi_f2iz(float32 a)
+{
+ return float32_to_int32_round_to_zero(a);
+}
+
+float32 __aeabi_f2d(float32 a)
+{
+ return float32_to_float64(a);
+}
+
+float32 __aeabi_i2f(int a)
+{
+ return int32_to_float32(a);
+}
+
+float32 __aeabi_fadd(float32 a, float32 b)
+{
+ return float32_add(a, b);
+}
+
+float32 __aeabi_fdiv(float32 a, float32 b)
+{
+ return float32_div(a, b);
+}
+
+float32 __aeabi_fmul(float32 a, float32 b)
+{
+ return float32_mul(a, b);
+}
+
+float32 __aeabi_fsub(float32 a, float32 b)
+{
+ return float32_sub(a, b);
+}
+
diff --git a/lib/libc/arm/aeabi/aeabi_unwind_cpp.c b/lib/libc/arm/aeabi/aeabi_unwind_cpp.c
new file mode 100644
index 0000000..c07cbbd
--- /dev/null
+++ b/lib/libc/arm/aeabi/aeabi_unwind_cpp.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Andrew Turner
+ * 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.
+ *
+ */
+
+/*
+ * Provide an implementation of __aeabi_unwind_cpp_pr{0,1,2}. These are
+ * required by libc but are implemented in libgcc_eh.a which we don't link
+ * against. The libgcc_eh.a version will be called so we call abort to
+ * check this.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stdlib.h>
+
+void __aeabi_unwind_cpp_pr0(void) __hidden;
+void __aeabi_unwind_cpp_pr1(void) __hidden;
+void __aeabi_unwind_cpp_pr2(void) __hidden;
+
+void
+__aeabi_unwind_cpp_pr0(void)
+{
+ abort();
+}
+
+void
+__aeabi_unwind_cpp_pr1(void)
+{
+ abort();
+}
+
+void
+__aeabi_unwind_cpp_pr2(void)
+{
+ abort();
+}
+
diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc
index a78cbb9..ec36d45 100644
--- a/lib/libc/arm/gen/Makefile.inc
+++ b/lib/libc/arm/gen/Makefile.inc
@@ -3,4 +3,8 @@
SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \
getcontextx.c infinity.c ldexp.c makecontext.c \
- __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S divsi3.S flt_rounds.c
+ __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c
+
+.if ${MK_ARM_EABI} == "no"
+SRCS+= divsi3.S
+.endif
diff --git a/lib/libc/arm/softfloat/arm-gcc.h b/lib/libc/arm/softfloat/arm-gcc.h
index 1204108..15bc509 100644
--- a/lib/libc/arm/softfloat/arm-gcc.h
+++ b/lib/libc/arm/softfloat/arm-gcc.h
@@ -95,7 +95,7 @@ what the endianness of the CPU. VFP is sane.
#define FLOAT64_DEMANGLE(a) (a)
#define FLOAT64_MANGLE(a) (a)
#else
-#define FLOAT64_DEMANGLE(a) (((a) << 32) | ((a) >> 32))
+#define FLOAT64_DEMANGLE(a) ((((a) & 0xfffffffful) << 32) | ((a) >> 32))
#define FLOAT64_MANGLE(a) FLOAT64_DEMANGLE(a)
#endif
#endif
diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc
index 1a58eae..fd251c8 100644
--- a/lib/libc/arm/sys/Makefile.inc
+++ b/lib/libc/arm/sys/Makefile.inc
@@ -1,5 +1,7 @@
# $FreeBSD$
+SRCS+= __vdso_gettc.c
+
MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S
# Don't generate default code for these syscalls:
diff --git a/lib/libc/arm/sys/__vdso_gettc.c b/lib/libc/arm/sys/__vdso_gettc.c
new file mode 100644
index 0000000..b99bbc4
--- /dev/null
+++ b/lib/libc/arm/sys/__vdso_gettc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (ENOSYS);
+}
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 2481f28..0bbbb33 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -32,13 +32,17 @@ SRCS+= __getosreldate.c __xuname.c \
sigsetops.c sleep.c srand48.c statvfs.c stringlist.c strtofflags.c \
sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
syslog.c telldir.c termios.c time.c times.c timezone.c tls.c \
- ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis.c \
- usleep.c utime.c utxdb.c valloc.c vis.c wait.c wait3.c waitpid.c \
- wordexp.c
+ ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis-compat.c \
+ usleep.c utime.c utxdb.c valloc.c wait.c wait3.c waitpid.c \
+ waitid.c wordexp.c
.PATH: ${.CURDIR}/../../contrib/libc-pwcache
SRCS+= pwcache.c pwcache.h
+.PATH: ${.CURDIR}/../../contrib/libc-vis
+CFLAGS+= -I${.CURDIR}/../../contrib/libc-vis
+SRCS+= unvis.c vis.c
+
MISRCS+=modf.c
CANCELPOINTS_SRCS=sem.c sem_new.c
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index b4f88ae..4cbf07c 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -298,7 +298,6 @@ FBSD_1.0 {
ualarm;
ulimit;
uname;
- unvis;
strunvis;
strunvisx;
usleep;
@@ -388,9 +387,22 @@ FBSD_1.3 {
__FreeBSD_libc_enter_restricted_mode;
getcontextx;
gid_from_group;
+ nvis;
pwcache_userdb;
pwcache_groupdb;
+ snvis;
+ strnunvis;
+ strnunvisx;
+ strnvis;
+ strnvisx;
+ strsnvis;
+ strsnvisx;
+ strsvis;
+ strsvisx;
+ svis;
uid_from_user;
+ unvis;
+ waitid;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/gen/check_utility_compat.c b/lib/libc/gen/check_utility_compat.c
index 0ccdec1..04c594b 100644
--- a/lib/libc/gen/check_utility_compat.c
+++ b/lib/libc/gen/check_utility_compat.c
@@ -35,32 +35,28 @@ __FBSDID("$FreeBSD$");
* are threaded, so I'm not concerned about cancellation points or other
* niceties.
*/
+#include <sys/limits.h>
+
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifndef LINE_MAX
-#define LINE_MAX _POSIX2_LINE_MAX
-#endif
-
#define _PATH_UTIL_COMPAT "/etc/compat-FreeBSD-4-util"
#define _ENV_UTIL_COMPAT "_COMPAT_FreeBSD_4"
int
check_utility_compat(const char *utility)
{
- char buf[LINE_MAX];
+ char buf[PATH_MAX];
char *p, *bp;
int len;
if ((p = getenv(_ENV_UTIL_COMPAT)) != NULL) {
strlcpy(buf, p, sizeof buf);
} else {
- if ((len = readlink(_PATH_UTIL_COMPAT, buf, sizeof buf)) < 0)
+ if ((len = readlink(_PATH_UTIL_COMPAT, buf, sizeof(buf) - 1)) < 0)
return 0;
- if (len > sizeof buf)
- len = sizeof buf;
buf[len] = '\0';
}
if (buf[0] == '\0')
diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c
index c6ecbd5..d2c67a6 100644
--- a/lib/libc/gen/fmtmsg.c
+++ b/lib/libc/gen/fmtmsg.c
@@ -83,7 +83,7 @@ def:
if (output == NULL)
return (MM_NOCON);
if (*output != '\0') {
- if ((fp = fopen("/dev/console", "a")) == NULL) {
+ if ((fp = fopen("/dev/console", "ae")) == NULL) {
free(output);
return (MM_NOCON);
}
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index b68db2e..6a77abd 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
#include <fstab.h>
#include <paths.h>
#include <stdio.h>
@@ -255,8 +254,6 @@ getfsfile(const char *name)
int
setfsent(void)
{
- int fd;
-
if (_fs_fp) {
rewind(_fs_fp);
LineNo = 0;
@@ -268,18 +265,11 @@ setfsent(void)
else
setfstab(getenv("PATH_FSTAB"));
}
- fd = _open(path_fstab, O_RDONLY | O_CLOEXEC);
- if (fd == -1) {
- error(errno);
- return (0);
- }
- _fs_fp = fdopen(fd, "r");
- if (_fs_fp != NULL) {
+ if ((_fs_fp = fopen(path_fstab, "re")) != NULL) {
LineNo = 0;
return (1);
}
error(errno);
- _close(fd);
return (0);
}
diff --git a/lib/libc/gen/getbsize.3 b/lib/libc/gen/getbsize.3
index 1407051..2caf5fe 100644
--- a/lib/libc/gen/getbsize.3
+++ b/lib/libc/gen/getbsize.3
@@ -28,12 +28,12 @@
.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd November 16, 2012
.Dt GETBSIZE 3
.Os
.Sh NAME
.Nm getbsize
-.Nd get user block size
+.Nd get preferred block size
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -43,11 +43,31 @@
.Sh DESCRIPTION
The
.Fn getbsize
-function determines the user's preferred block size based on the value of the
-.Dq BLOCKSIZE
-environment variable; see
-.Xr environ 7
-for details on its use and format.
+function returns a preferred block size for reporting by system utilities
+.Xr df 1 ,
+.Xr du 1 ,
+.Xr ls 1
+and
+.Xr systat 1 ,
+based on the value of the
+.Ev BLOCKSIZE
+environment variable.
+.Ev BLOCKSIZE
+may be specified directly in bytes, or in multiples of a kilobyte by
+specifying a number followed by ``K'' or ``k'', in multiples of a
+megabyte by specifying a number followed by ``M'' or ``m'' or in
+multiples of a gigabyte by specifying a number followed by ``G'' or
+``g''.
+Multiples must be integers.
+.Pp
+Valid values of
+.Ev BLOCKSIZE
+are 512 bytes to 1 gigabyte.
+Sizes less than 512 bytes are rounded up to 512 bytes, and sizes
+greater than 1 GB are rounded down to 1 GB.
+In each case
+.Fn getbsize
+produces a warning message.
.Pp
The
.Fn getbsize
@@ -61,10 +81,6 @@ terminating null).
The memory referenced by
.Fa blocksizep
is filled in with block size, in bytes.
-.Pp
-If the user's block size is unreasonable, a warning message is
-written to standard error and the returned information reflects
-a block size of 512 bytes.
.Sh SEE ALSO
.Xr df 1 ,
.Xr du 1 ,
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index c321d12..f2f3777 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -654,7 +654,7 @@ cgetnext(char **bp, char **db_array)
if (dbp == NULL)
dbp = db_array;
- if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) {
+ if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
}
@@ -679,7 +679,7 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (0);
} else if ((pfp =
- fopen(*dbp, "r")) == NULL) {
+ fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
} else
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 18f64a8..f9480c3 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -810,7 +810,7 @@ files_setgrent(void *retval, void *mdata, va_list ap)
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
break;
case ENDGRENT:
if (st->fp != NULL) {
@@ -861,7 +861,7 @@ files_group(void *retval, void *mdata, va_list ap)
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -1251,7 +1251,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
set_setent(dtab, mdata);
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
compatsrc, 0);
@@ -1335,7 +1335,7 @@ compat_group(void *retval, void *mdata, va_list ap)
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
rv = NS_UNAVAIL;
goto fin;
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 51b3e37..4c56461 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -173,7 +173,7 @@ setnetgrent(const char *group)
if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) &&
errno == ENOENT) || _yp_statp.st_size == 0)
_use_only_yp = _netgr_yp_enabled = 1;
- if ((netf = fopen(_PATH_NETGROUP,"r")) != NULL ||_use_only_yp){
+ if ((netf = fopen(_PATH_NETGROUP,"re")) != NULL ||_use_only_yp){
/*
* Icky: grab the first character of the netgroup file
* and turn on NIS if it's a '+'. rewind the stream
@@ -197,7 +197,7 @@ setnetgrent(const char *group)
return;
}
#else
- if ((netf = fopen(_PATH_NETGROUP, "r"))) {
+ if ((netf = fopen(_PATH_NETGROUP, "re"))) {
#endif
if (parse_netgrp(group))
endnetgrent();
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index f2fc298..b82c30a 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -211,7 +211,7 @@ setttyent(void)
if (tf) {
rewind(tf);
return (1);
- } else if ( (tf = fopen(_PATH_TTYS, "r")) )
+ } else if ( (tf = fopen(_PATH_TTYS, "re")) )
return (1);
return (0);
}
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index ce50069..53536e1 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -115,7 +115,7 @@ _local_initshells(rv, cb_data, ap)
sl_free(sl, 1);
sl = sl_init();
- if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
+ if ((fp = fopen(_PATH_SHELLS, "re")) == NULL)
return NS_UNAVAIL;
cp = line;
diff --git a/lib/libc/gen/getutxent.c b/lib/libc/gen/getutxent.c
index a2e938a..20e8859 100644
--- a/lib/libc/gen/getutxent.c
+++ b/lib/libc/gen/getutxent.c
@@ -71,7 +71,7 @@ setutxdb(int db, const char *file)
if (uf != NULL)
fclose(uf);
- uf = fopen(file, "r");
+ uf = fopen(file, "re");
if (uf == NULL)
return (-1);
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
index 211b535..832dc8d 100644
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -94,6 +94,25 @@ __FBSDID("$FreeBSD$");
#include "collate.h"
+/*
+ * glob(3) expansion limits. Stop the expansion if any of these limits
+ * is reached. This caps the runtime in the face of DoS attacks. See
+ * also CVE-2010-2632
+ */
+#define GLOB_LIMIT_BRACE 128 /* number of brace calls */
+#define GLOB_LIMIT_PATH 65536 /* number of path elements */
+#define GLOB_LIMIT_READDIR 16384 /* number of readdirs */
+#define GLOB_LIMIT_STAT 1024 /* number of stat system calls */
+#define GLOB_LIMIT_STRING ARG_MAX /* maximum total size for paths */
+
+struct glob_limit {
+ size_t l_brace_cnt;
+ size_t l_path_lim;
+ size_t l_readdir_cnt;
+ size_t l_stat_cnt;
+ size_t l_string_cnt;
+};
+
#define DOLLAR '$'
#define DOT '.'
#define EOS '\0'
@@ -153,15 +172,18 @@ static const Char *g_strchr(const Char *, wchar_t);
static Char *g_strcat(Char *, const Char *);
#endif
static int g_stat(Char *, struct stat *, glob_t *);
-static int glob0(const Char *, glob_t *, size_t *);
-static int glob1(Char *, glob_t *, size_t *);
-static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *);
-static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, size_t *);
-static int globextend(const Char *, glob_t *, size_t *);
-static const Char *
+static int glob0(const Char *, glob_t *, struct glob_limit *);
+static int glob1(Char *, glob_t *, struct glob_limit *);
+static int glob2(Char *, Char *, Char *, Char *, glob_t *,
+ struct glob_limit *);
+static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
+ struct glob_limit *);
+static int globextend(const Char *, glob_t *, struct glob_limit *);
+static const Char *
globtilde(const Char *, Char *, size_t, glob_t *);
-static int globexp1(const Char *, glob_t *, size_t *);
-static int globexp2(const Char *, const Char *, glob_t *, int *, size_t *);
+static int globexp1(const Char *, glob_t *, struct glob_limit *);
+static int globexp2(const Char *, const Char *, glob_t *, int *,
+ struct glob_limit *);
static int match(Char *, Char *, Char *);
#ifdef DEBUG
static void qprintf(const char *, Char *);
@@ -171,8 +193,8 @@ int
glob(const char * __restrict pattern, int flags,
int (*errfunc)(const char *, int), glob_t * __restrict pglob)
{
+ struct glob_limit limit = { 0, 0, 0, 0, 0 };
const char *patnext;
- size_t limit;
Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
mbstate_t mbs;
wchar_t wc;
@@ -186,11 +208,10 @@ glob(const char * __restrict pattern, int flags,
pglob->gl_offs = 0;
}
if (flags & GLOB_LIMIT) {
- limit = pglob->gl_matchc;
- if (limit == 0)
- limit = ARG_MAX;
- } else
- limit = 0;
+ limit.l_path_lim = pglob->gl_matchc;
+ if (limit.l_path_lim == 0)
+ limit.l_path_lim = GLOB_LIMIT_PATH;
+ }
pglob->gl_flags = flags & ~GLOB_MAGCHAR;
pglob->gl_errfunc = errfunc;
pglob->gl_matchc = 0;
@@ -243,11 +264,17 @@ glob(const char * __restrict pattern, int flags,
* characters
*/
static int
-globexp1(const Char *pattern, glob_t *pglob, size_t *limit)
+globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
{
const Char* ptr = pattern;
int rv;
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
+ errno = 0;
+ return (GLOB_NOSPACE);
+ }
+
/* Protect a single {}, for find(1), like csh */
if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
return glob0(pattern, pglob, limit);
@@ -266,7 +293,8 @@ globexp1(const Char *pattern, glob_t *pglob, size_t *limit)
* If it fails then it tries to glob the rest of the pattern and returns.
*/
static int
-globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *limit)
+globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
+ struct glob_limit *limit)
{
int i;
Char *lm, *ls;
@@ -436,7 +464,7 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
* if things went well, nonzero if errors occurred.
*/
static int
-glob0(const Char *pattern, glob_t *pglob, size_t *limit)
+glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
{
const Char *qpatnext;
int err;
@@ -529,7 +557,7 @@ compare(const void *p, const void *q)
}
static int
-glob1(Char *pattern, glob_t *pglob, size_t *limit)
+glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit)
{
Char pathbuf[MAXPATHLEN];
@@ -547,7 +575,7 @@ glob1(Char *pattern, glob_t *pglob, size_t *limit)
*/
static int
glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
- glob_t *pglob, size_t *limit)
+ glob_t *pglob, struct glob_limit *limit)
{
struct stat sb;
Char *p, *q;
@@ -563,6 +591,15 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
if (g_lstat(pathbuf, &sb, pglob))
return (0);
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
+ errno = 0;
+ if (pathend + 1 > pathend_last)
+ return (GLOB_ABORTED);
+ *pathend++ = SEP;
+ *pathend = EOS;
+ return (GLOB_NOSPACE);
+ }
if (((pglob->gl_flags & GLOB_MARK) &&
pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
|| (S_ISLNK(sb.st_mode) &&
@@ -606,7 +643,7 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
static int
glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
Char *pattern, Char *restpattern,
- glob_t *pglob, size_t *limit)
+ glob_t *pglob, struct glob_limit *limit)
{
struct dirent *dp;
DIR *dirp;
@@ -652,6 +689,19 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
size_t clen;
mbstate_t mbs;
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_readdir_cnt++ >= GLOB_LIMIT_READDIR) {
+ errno = 0;
+ if (pathend + 1 > pathend_last)
+ err = GLOB_ABORTED;
+ else {
+ *pathend++ = SEP;
+ *pathend = EOS;
+ err = GLOB_NOSPACE;
+ }
+ break;
+ }
+
/* Initial DOT must be matched literally. */
if (dp->d_name[0] == DOT && *pattern != DOT)
continue;
@@ -702,29 +752,24 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
* gl_pathv points to (gl_offs + gl_pathc + 1) items.
*/
static int
-globextend(const Char *path, glob_t *pglob, size_t *limit)
+globextend(const Char *path, glob_t *pglob, struct glob_limit *limit)
{
char **pathv;
size_t i, newsize, len;
char *copy;
const Char *p;
- if (*limit && pglob->gl_pathc > *limit) {
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ pglob->gl_matchc > limit->l_path_lim) {
errno = 0;
return (GLOB_NOSPACE);
}
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- pathv = pglob->gl_pathv ?
- realloc((char *)pglob->gl_pathv, newsize) :
- malloc(newsize);
- if (pathv == NULL) {
- if (pglob->gl_pathv) {
- free(pglob->gl_pathv);
- pglob->gl_pathv = NULL;
- }
+ /* realloc(NULL, newsize) is equivalent to malloc(newsize). */
+ pathv = realloc((void *)pglob->gl_pathv, newsize);
+ if (pathv == NULL)
return (GLOB_NOSPACE);
- }
if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
/* first time around -- clear initial gl_offs items */
@@ -737,6 +782,12 @@ globextend(const Char *path, glob_t *pglob, size_t *limit)
for (p = path; *p++;)
continue;
len = MB_CUR_MAX * (size_t)(p - path); /* XXX overallocation */
+ limit->l_string_cnt += len;
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_string_cnt >= GLOB_LIMIT_STRING) {
+ errno = 0;
+ return (GLOB_NOSPACE);
+ }
if ((copy = malloc(len)) != NULL) {
if (g_Ctoc(path, copy, len)) {
free(copy);
diff --git a/lib/libc/gen/isnan.c b/lib/libc/gen/isnan.c
index ec81362..72c2868 100644
--- a/lib/libc/gen/isnan.c
+++ b/lib/libc/gen/isnan.c
@@ -33,8 +33,14 @@
/*
* XXX These routines belong in libm, but they must remain in libc for
* binary compat until we can bump libm's major version number.
+ *
+ * Note this only applies to the dynamic versions of libm and libc, so
+ * for the static and profiled versions we stub out the definitions.
+ * Otherwise you cannot link statically to libm and libc at the same
+ * time, when calling both functions.
*/
+#ifdef PIC
__weak_reference(__isnan, isnan);
__weak_reference(__isnanf, isnanf);
@@ -55,3 +61,4 @@ __isnanf(float f)
u.f = f;
return (u.bits.exp == 255 && u.bits.man != 0);
}
+#endif /* PIC */
diff --git a/lib/libc/gen/sysctlbyname.c b/lib/libc/gen/sysctlbyname.c
index a2e0d5f..88b860d 100644
--- a/lib/libc/gen/sysctlbyname.c
+++ b/lib/libc/gen/sysctlbyname.c
@@ -19,13 +19,10 @@ sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
const void *newp, size_t newlen)
{
int real_oid[CTL_MAXNAME+2];
- int error;
size_t oidlen;
oidlen = sizeof(real_oid) / sizeof(int);
- error = sysctlnametomib(name, real_oid, &oidlen);
- if (error < 0)
- return (error);
- error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
- return (error);
+ if (sysctlnametomib(name, real_oid, &oidlen) < 0)
+ return (-1);
+ return (sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen));
}
diff --git a/lib/libc/gen/unvis-compat.c b/lib/libc/gen/unvis-compat.c
new file mode 100644
index 0000000..080143e
--- /dev/null
+++ b/lib/libc/gen/unvis-compat.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2012 SRI International
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <vis.h>
+
+#define _UNVIS_END 1
+
+int
+__unvis_44bsd(char *cp, int c, int *astate, int flag)
+{
+
+ if (flag & _UNVIS_END)
+ flag = (flag & ~_UNVIS_END) ^ UNVIS_END;
+ return unvis(cp, c, astate, flag);
+}
+
+__sym_compat(unvis, __vis_44bsd, FBSD_1.0);
diff --git a/lib/libc/gen/unvis.3 b/lib/libc/gen/unvis.3
deleted file mode 100644
index 9164f79..0000000
--- a/lib/libc/gen/unvis.3
+++ /dev/null
@@ -1,200 +0,0 @@
-.\" Copyright (c) 1989, 1991, 1993
-.\" The Regents of the University of California. 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.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
-.\"
-.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
-.Dd December 11, 1993
-.Dt UNVIS 3
-.Os
-.Sh NAME
-.Nm unvis ,
-.Nm strunvis
-.Nd decode a visual representation of characters
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In vis.h
-.Ft int
-.Fn unvis "char *cp" "int c" "int *astate" "int flag"
-.Ft int
-.Fn strunvis "char *dst" "const char *src"
-.Ft int
-.Fn strunvisx "char *dst" "const char *src" "int flag"
-.Sh DESCRIPTION
-The
-.Fn unvis ,
-.Fn strunvis
-and
-.Fn strunvisx
-functions
-are used to decode a visual representation of characters, as produced
-by the
-.Xr vis 3
-function, back into
-the original form.
-Unvis is called with successive characters in
-.Fa c
-until a valid
-sequence is recognized, at which time the decoded character is
-available at the character pointed to by
-.Fa cp .
-Strunvis decodes the
-characters pointed to by
-.Fa src
-into the buffer pointed to by
-.Fa dst .
-.Pp
-The
-.Fn strunvis
-function
-simply copies
-.Fa src
-to
-.Fa dst ,
-decoding any escape sequences along the way,
-and returns the number of characters placed into
-.Fa dst ,
-or \-1 if an
-invalid escape sequence was detected.
-The size of
-.Fa dst
-should be
-equal to the size of
-.Fa src
-(that is, no expansion takes place during
-decoding).
-.Pp
-The
-.Fn strunvisx
-function does the same as the
-.Fn strunvis
-function,
-but it allows you to add a flag that specifies the style the string
-.Fa src
-is encoded with.
-Currently, the only supported flag is
-.Dv VIS_HTTPSTYLE .
-.Pp
-The
-.Fn unvis
-function
-implements a state machine that can be used to decode an arbitrary
-stream of bytes.
-All state associated with the bytes being decoded
-is stored outside the
-.Fn unvis
-function (that is, a pointer to the state is passed in), so
-calls decoding different streams can be freely intermixed.
-To
-start decoding a stream of bytes, first initialize an integer
-to zero.
-Call
-.Fn unvis
-with each successive byte, along with a pointer
-to this integer, and a pointer to a destination character.
-The
-.Fn unvis
-function
-has several return codes that must be handled properly.
-They are:
-.Bl -tag -width UNVIS_VALIDPUSH
-.It Li \&0 (zero)
-Another character is necessary; nothing has been recognized yet.
-.It Dv UNVIS_VALID
-A valid character has been recognized and is available at the location
-pointed to by cp.
-.It Dv UNVIS_VALIDPUSH
-A valid character has been recognized and is available at the location
-pointed to by cp; however, the character currently passed in should
-be passed in again.
-.It Dv UNVIS_NOCHAR
-A valid sequence was detected, but no character was produced.
-This
-return code is necessary to indicate a logical break between characters.
-.It Dv UNVIS_SYNBAD
-An invalid escape sequence was detected, or the decoder is in an
-unknown state.
-The decoder is placed into the starting state.
-.El
-.Pp
-When all bytes in the stream have been processed, call
-.Fn unvis
-one more time with
-.Fa flag
-set to
-.Dv UNVIS_END
-to extract any remaining character (the character passed in is ignored).
-.Pp
-The
-.Fa flag
-argument is also used to specify the encoding style of the source.
-If set to
-.Dv VIS_HTTPSTYLE ,
-.Fn unvis
-will decode URI strings as specified in RFC 1808.
-.Pp
-The following code fragment illustrates a proper use of
-.Fn unvis .
-.Bd -literal -offset indent
-int state = 0;
-char out;
-
-while ((ch = getchar()) != EOF) {
-again:
- switch(unvis(&out, ch, &state, 0)) {
- case 0:
- case UNVIS_NOCHAR:
- break;
- case UNVIS_VALID:
- (void) putchar(out);
- break;
- case UNVIS_VALIDPUSH:
- (void) putchar(out);
- goto again;
- case UNVIS_SYNBAD:
- (void)fprintf(stderr, "bad sequence!\en");
- exit(1);
- }
-}
-if (unvis(&out, (char)0, &state, UNVIS_END) == UNVIS_VALID)
- (void) putchar(out);
-.Ed
-.Sh SEE ALSO
-.Xr vis 1 ,
-.Xr vis 3
-.Rs
-.%A R. Fielding
-.%T Relative Uniform Resource Locators
-.%O RFC1808
-.Re
-.Sh HISTORY
-The
-.Fn unvis
-function
-first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/gen/unvis.c b/lib/libc/gen/unvis.c
deleted file mode 100644
index 9069e55..0000000
--- a/lib/libc/gen/unvis.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <vis.h>
-
-/*
- * decode driven by state machine
- */
-#define S_GROUND 0 /* haven't seen escape char */
-#define S_START 1 /* start decoding special sequence */
-#define S_META 2 /* metachar started (M) */
-#define S_META1 3 /* metachar more, regular char (-) */
-#define S_CTRL 4 /* control char started (^) */
-#define S_OCTAL2 5 /* octal digit 2 */
-#define S_OCTAL3 6 /* octal digit 3 */
-#define S_HEX2 7 /* hex digit 2 */
-
-#define S_HTTP 0x080 /* %HEXHEX escape */
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define ishex(c) ((((u_char)(c)) >= '0' && ((u_char)(c)) <= '9') || (((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f'))
-
-/*
- * unvis - decode characters previously encoded by vis
- */
-int
-unvis(char *cp, int c, int *astate, int flag)
-{
-
- if (flag & UNVIS_END) {
- if (*astate == S_OCTAL2 || *astate == S_OCTAL3) {
- *astate = S_GROUND;
- return (UNVIS_VALID);
- }
- return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
- }
-
- switch (*astate & ~S_HTTP) {
-
- case S_GROUND:
- *cp = 0;
- if (c == '\\') {
- *astate = S_START;
- return (0);
- }
- if (flag & VIS_HTTPSTYLE && c == '%') {
- *astate = S_START | S_HTTP;
- return (0);
- }
- *cp = c;
- return (UNVIS_VALID);
-
- case S_START:
- if (*astate & S_HTTP) {
- if (ishex(tolower(c))) {
- *cp = isdigit(c) ? (c - '0') : (tolower(c) - 'a');
- *astate = S_HEX2;
- return (0);
- }
- }
- switch(c) {
- case '\\':
- *cp = c;
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- *cp = (c - '0');
- *astate = S_OCTAL2;
- return (0);
- case 'M':
- *cp = 0200;
- *astate = S_META;
- return (0);
- case '^':
- *astate = S_CTRL;
- return (0);
- case 'n':
- *cp = '\n';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'r':
- *cp = '\r';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'b':
- *cp = '\b';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'a':
- *cp = '\007';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'v':
- *cp = '\v';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 't':
- *cp = '\t';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'f':
- *cp = '\f';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 's':
- *cp = ' ';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'E':
- *cp = '\033';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '\n':
- /*
- * hidden newline
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- case '$':
- /*
- * hidden marker
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- }
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
-
- case S_META:
- if (c == '-')
- *astate = S_META1;
- else if (c == '^')
- *astate = S_CTRL;
- else {
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
- return (0);
-
- case S_META1:
- *astate = S_GROUND;
- *cp |= c;
- return (UNVIS_VALID);
-
- case S_CTRL:
- if (c == '?')
- *cp |= 0177;
- else
- *cp |= c & 037;
- *astate = S_GROUND;
- return (UNVIS_VALID);
-
- case S_OCTAL2: /* second possible octal digit */
- if (isoctal(c)) {
- /*
- * yes - and maybe a third
- */
- *cp = (*cp << 3) + (c - '0');
- *astate = S_OCTAL3;
- return (0);
- }
- /*
- * no - done with current sequence, push back passed char
- */
- *astate = S_GROUND;
- return (UNVIS_VALIDPUSH);
-
- case S_OCTAL3: /* third possible octal digit */
- *astate = S_GROUND;
- if (isoctal(c)) {
- *cp = (*cp << 3) + (c - '0');
- return (UNVIS_VALID);
- }
- /*
- * we were done, push back passed char
- */
- return (UNVIS_VALIDPUSH);
-
- case S_HEX2: /* second mandatory hex digit */
- if (ishex(tolower(c))) {
- *cp = (isdigit(c) ? (*cp << 4) + (c - '0') : (*cp << 4) + (tolower(c) - 'a' + 10));
- }
- *astate = S_GROUND;
- return (UNVIS_VALID);
-
- default:
- /*
- * decoder in unknown state - (probably uninitialized)
- */
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
-}
-
-/*
- * strunvis - decode src into dst
- *
- * Number of chars decoded into dst is returned, -1 on error.
- * Dst is null terminated.
- */
-
-int
-strunvis(char *dst, const char *src)
-{
- char c;
- char *start = dst;
- int state = 0;
-
- while ( (c = *src++) ) {
- again:
- switch (unvis(dst, c, &state, 0)) {
- case UNVIS_VALID:
- dst++;
- break;
- case UNVIS_VALIDPUSH:
- dst++;
- goto again;
- case 0:
- case UNVIS_NOCHAR:
- break;
- default:
- return (-1);
- }
- }
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
- *dst = '\0';
- return (dst - start);
-}
-
-int
-strunvisx(char *dst, const char *src, int flag)
-{
- char c;
- char *start = dst;
- int state = 0;
-
- while ( (c = *src++) ) {
- again:
- switch (unvis(dst, c, &state, flag)) {
- case UNVIS_VALID:
- dst++;
- break;
- case UNVIS_VALIDPUSH:
- dst++;
- goto again;
- case 0:
- case UNVIS_NOCHAR:
- break;
- default:
- return (-1);
- }
- }
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
- *dst = '\0';
- return (dst - start);
-}
diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3
deleted file mode 100644
index 8ec16eb..0000000
--- a/lib/libc/gen/vis.3
+++ /dev/null
@@ -1,308 +0,0 @@
-.\" Copyright (c) 1989, 1991, 1993
-.\" The Regents of the University of California. 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.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
-.\"
-.\" From: @(#)vis.3 8.1 (Berkeley) 6/9/93
-.\" $FreeBSD$
-.\"
-.Dd April 9, 2006
-.Dt VIS 3
-.Os
-.Sh NAME
-.Nm vis
-.Nd visually encode characters
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In vis.h
-.Ft char *
-.Fn vis "char *dst" "int c" "int flag" "int nextc"
-.Ft int
-.Fn strvis "char *dst" "const char *src" "int flag"
-.Ft int
-.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
-.Sh DESCRIPTION
-The
-.Fn vis
-function
-copies into
-.Fa dst
-a string which represents the character
-.Fa c .
-If
-.Fa c
-needs no encoding, it is copied in unaltered.
-The string is
-null terminated, and a pointer to the end of the string is
-returned.
-The maximum length of any encoding is four
-characters (not including the trailing
-.Dv NUL ) ;
-thus, when
-encoding a set of characters into a buffer, the size of the buffer should
-be four times the number of characters encoded, plus one for the trailing
-.Dv NUL .
-The
-.Fa flag
-argument is used for altering the default range of
-characters considered for encoding and for altering the visual
-representation.
-The additional character,
-.Fa nextc ,
-is only used when selecting the
-.Dv VIS_CSTYLE
-encoding format (explained below).
-.Pp
-The
-.Fn strvis
-and
-.Fn strvisx
-functions copy into
-.Fa dst
-a visual representation of
-the string
-.Fa src .
-The
-.Fn strvis
-function encodes characters from
-.Fa src
-up to the
-first
-.Dv NUL .
-The
-.Fn strvisx
-function encodes exactly
-.Fa len
-characters from
-.Fa src
-(this
-is useful for encoding a block of data that may contain
-.Dv NUL Ns 's ) .
-Both forms
-.Dv NUL
-terminate
-.Fa dst .
-The size of
-.Fa dst
-must be four times the number
-of characters encoded from
-.Fa src
-(plus one for the
-.Dv NUL ) .
-Both
-forms return the number of characters in dst (not including
-the trailing
-.Dv NUL ) .
-.Pp
-The encoding is a unique, invertible representation composed entirely of
-graphic characters; it can be decoded back into the original form using
-the
-.Xr unvis 3
-or
-.Xr strunvis 3
-functions.
-.Pp
-There are two parameters that can be controlled: the range of
-characters that are encoded, and the type
-of representation used.
-By default, all non-graphic characters
-except space, tab, and newline are encoded.
-(See
-.Xr isgraph 3 . )
-The following flags
-alter this:
-.Bl -tag -width VIS_WHITEX
-.It Dv VIS_GLOB
-Also encode magic characters
-.Ql ( * ,
-.Ql \&? ,
-.Ql \&[
-and
-.Ql # )
-recognized by
-.Xr glob 3 .
-.It Dv VIS_SP
-Also encode space.
-.It Dv VIS_TAB
-Also encode tab.
-.It Dv VIS_NL
-Also encode newline.
-.It Dv VIS_WHITE
-Synonym for
-.Dv VIS_SP
-\&|
-.Dv VIS_TAB
-\&|
-.Dv VIS_NL .
-.It Dv VIS_SAFE
-Only encode "unsafe" characters.
-Unsafe means control
-characters which may cause common terminals to perform
-unexpected functions.
-Currently this form allows space,
-tab, newline, backspace, bell, and return - in addition
-to all graphic characters - unencoded.
-.El
-.Pp
-There are four forms of encoding.
-Most forms use the backslash character
-.Ql \e
-to introduce a special
-sequence; two backslashes are used to represent a real backslash.
-These are the visual formats:
-.Bl -tag -width VIS_HTTPSTYLE
-.It (default)
-Use an
-.Ql M
-to represent meta characters (characters with the 8th
-bit set), and use caret
-.Ql ^
-to represent control characters see
-.Pf ( Xr iscntrl 3 ) .
-The following formats are used:
-.Bl -tag -width xxxxx
-.It Dv \e^C
-Represents the control character
-.Ql C .
-Spans characters
-.Ql \e000
-through
-.Ql \e037 ,
-and
-.Ql \e177
-(as
-.Ql \e^? ) .
-.It Dv \eM-C
-Represents character
-.Ql C
-with the 8th bit set.
-Spans characters
-.Ql \e241
-through
-.Ql \e376 .
-.It Dv \eM^C
-Represents control character
-.Ql C
-with the 8th bit set.
-Spans characters
-.Ql \e200
-through
-.Ql \e237 ,
-and
-.Ql \e377
-(as
-.Ql \eM^? ) .
-.It Dv \e040
-Represents
-.Tn ASCII
-space.
-.It Dv \e240
-Represents Meta-space.
-.El
-.Pp
-.It Dv VIS_CSTYLE
-Use C-style backslash sequences to represent standard non-printable
-characters.
-The following sequences are used to represent the indicated characters:
-.Pp
-.Bl -tag -width ".Li \e0" -offset indent -compact
-.It Li \ea
-.Dv BEL No (007)
-.It Li \eb
-.Dv BS No (010)
-.It Li \ef
-.Dv NP No (014)
-.It Li \en
-.Dv NL No (012)
-.It Li \er
-.Dv CR No (015)
-.It Li \es
-.Dv SP No (040)
-.It Li \et
-.Dv HT No (011)
-.It Li \ev
-.Dv VT No (013)
-.It Li \e0
-.Dv NUL No (000)
-.El
-.Pp
-When using this format, the
-.Fa nextc
-argument is looked at to determine
-if a
-.Dv NUL
-character can be encoded as
-.Ql \e0
-instead of
-.Ql \e000 .
-If
-.Fa nextc
-is an octal digit, the latter representation is used to
-avoid ambiguity.
-.It Dv VIS_HTTPSTYLE
-Use URI encoding as described in RFC 1808.
-The form is
-.Ql %dd
-where
-.Ar d
-represents a hexadecimal digit.
-.It Dv VIS_OCTAL
-Use a three digit octal sequence.
-The form is
-.Ql \eddd
-where
-.Ar d
-represents an octal digit.
-.El
-.Pp
-There is one additional flag,
-.Dv VIS_NOSLASH ,
-which inhibits the
-doubling of backslashes and the backslash before the default
-format (that is, control characters are represented by
-.Ql ^C
-and
-meta characters as
-.Ql M-C ) .
-With this flag set, the encoding is
-ambiguous and non-invertible.
-.Sh SEE ALSO
-.Xr unvis 1 ,
-.Xr unvis 3
-.Rs
-.%A R. Fielding
-.%T Relative Uniform Resource Locators
-.%O RFC1808
-.Re
-.Sh HISTORY
-These functions first appeared in
-.Bx 4.4 .
-.Sh BUGS
-The
-.Nm
-family of functions do not recognize multibyte characters, and thus
-may consider them to be non-printable when they are in fact printable
-(and vice versa.)
diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c
deleted file mode 100644
index 362f4dc..0000000
--- a/lib/libc/gen/vis.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 7/19/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <limits.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <vis.h>
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-
-/*
- * vis - visually encode characters
- */
-char *
-vis(dst, c, flag, nextc)
- char *dst;
- int c, nextc;
- int flag;
-{
- c = (unsigned char)c;
-
- if (flag & VIS_HTTPSTYLE) {
- /* Described in RFC 1808 */
- if (!(isalnum(c) /* alpha-numeric */
- /* safe */
- || c == '$' || c == '-' || c == '_' || c == '.' || c == '+'
- /* extra */
- || c == '!' || c == '*' || c == '\'' || c == '('
- || c == ')' || c == ',')) {
- *dst++ = '%';
- snprintf(dst, 4, (c < 16 ? "0%X" : "%X"), c);
- dst += 2;
- goto done;
- }
- }
-
- if ((flag & VIS_GLOB) &&
- (c == '*' || c == '?' || c == '[' || c == '#'))
- ;
- else if (isgraph(c) ||
- ((flag & VIS_SP) == 0 && c == ' ') ||
- ((flag & VIS_TAB) == 0 && c == '\t') ||
- ((flag & VIS_NL) == 0 && c == '\n') ||
- ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
- *dst++ = c;
- if (c == '\\' && (flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- *dst = '\0';
- return (dst);
- }
-
- if (flag & VIS_CSTYLE) {
- switch(c) {
- case '\n':
- *dst++ = '\\';
- *dst++ = 'n';
- goto done;
- case '\r':
- *dst++ = '\\';
- *dst++ = 'r';
- goto done;
- case '\b':
- *dst++ = '\\';
- *dst++ = 'b';
- goto done;
- case '\a':
- *dst++ = '\\';
- *dst++ = 'a';
- goto done;
- case '\v':
- *dst++ = '\\';
- *dst++ = 'v';
- goto done;
- case '\t':
- *dst++ = '\\';
- *dst++ = 't';
- goto done;
- case '\f':
- *dst++ = '\\';
- *dst++ = 'f';
- goto done;
- case ' ':
- *dst++ = '\\';
- *dst++ = 's';
- goto done;
- case '\0':
- *dst++ = '\\';
- *dst++ = '0';
- if (isoctal(nextc)) {
- *dst++ = '0';
- *dst++ = '0';
- }
- goto done;
- }
- }
- if (((c & 0177) == ' ') || isgraph(c) || (flag & VIS_OCTAL)) {
- *dst++ = '\\';
- *dst++ = ((u_char)c >> 6 & 07) + '0';
- *dst++ = ((u_char)c >> 3 & 07) + '0';
- *dst++ = ((u_char)c & 07) + '0';
- goto done;
- }
- if ((flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- if (c & 0200) {
- c &= 0177;
- *dst++ = 'M';
- }
- if (iscntrl(c)) {
- *dst++ = '^';
- if (c == 0177)
- *dst++ = '?';
- else
- *dst++ = c + '@';
- } else {
- *dst++ = '-';
- *dst++ = c;
- }
-done:
- *dst = '\0';
- return (dst);
-}
-
-/*
- * strvis, strvisx - visually encode characters from src into dst
- *
- * Dst must be 4 times the size of src to account for possible
- * expansion. The length of dst, not including the trailing NUL,
- * is returned.
- *
- * Strvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
- */
-int
-strvis(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
-{
- char c;
- char *start;
-
- for (start = dst; (c = *src); )
- dst = vis(dst, c, flag, *++src);
- *dst = '\0';
- return (dst - start);
-}
-
-int
-strvisx(dst, src, len, flag)
- char *dst;
- const char *src;
- size_t len;
- int flag;
-{
- int c;
- char *start;
-
- for (start = dst; len > 1; len--) {
- c = *src;
- dst = vis(dst, c, flag, *++src);
- }
- if (len)
- dst = vis(dst, *src, flag, '\0');
- *dst = '\0';
-
- return (dst - start);
-}
diff --git a/lib/libc/gen/waitid.c b/lib/libc/gen/waitid.c
new file mode 100644
index 0000000..795b208
--- /dev/null
+++ b/lib/libc/gen/waitid.c
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2012 Jukka A. Ukkonen
+ * All rights reserved.
+ *
+ * This software was developed by Jukka Ukkonen for FreeBSD.
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stddef.h>
+#include <string.h>
+#include <signal.h>
+#include <errno.h>
+#include "un-namespace.h"
+
+int
+__waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags)
+{
+ int status;
+ pid_t ret;
+
+ ret = _wait6(idtype, id, &status, flags, NULL, info);
+
+ /*
+ * According to SUSv4, waitid() shall not return a PID when a
+ * process is found, but only 0. If a process was actually
+ * found, siginfo_t fields si_signo and si_pid will be
+ * non-zero. In case WNOHANG was set in the flags and no
+ * process was found those fields are set to zero using
+ * memset() below.
+ */
+ if (ret == 0 && info != NULL)
+ memset(info, 0, sizeof(*info));
+ else if (ret > 0)
+ ret = 0;
+ return (ret);
+}
+
+__weak_reference(__waitid, waitid);
+__weak_reference(__waitid, _waitid);
diff --git a/lib/libc/i386/sys/__vdso_gettc.c b/lib/libc/i386/sys/__vdso_gettc.c
index 4419141..c6f2dfb 100644
--- a/lib/libc/i386/sys/__vdso_gettc.c
+++ b/lib/libc/i386/sys/__vdso_gettc.c
@@ -27,9 +27,11 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
+#include <sys/elf.h>
#include <sys/time.h>
#include <sys/vdso.h>
#include <machine/cpufunc.h>
+#include "libc_private.h"
static u_int
__vdso_gettc_low(const struct vdso_timehands *th)
@@ -48,3 +50,11 @@ __vdso_gettc(const struct vdso_timehands *th)
return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libc/ia64/sys/Makefile.inc b/lib/libc/ia64/sys/Makefile.inc
index 3876d3a..2846590 100644
--- a/lib/libc/ia64/sys/Makefile.inc
+++ b/lib/libc/ia64/sys/Makefile.inc
@@ -1,5 +1,7 @@
# $FreeBSD$
+SRCS+= __vdso_gettc.c
+
MDASM+= Ovfork.S brk.S cerror.S exect.S fork.S getcontext.S pipe.S ptrace.S \
sbrk.S setlogin.S sigreturn.S swapcontext.S
diff --git a/lib/libc/ia64/sys/__vdso_gettc.c b/lib/libc/ia64/sys/__vdso_gettc.c
new file mode 100644
index 0000000..b99bbc4
--- /dev/null
+++ b/lib/libc/ia64/sys/__vdso_gettc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (ENOSYS);
+}
diff --git a/lib/libc/iconv/citrus_mmap.c b/lib/libc/iconv/citrus_mmap.c
index dd5d059..2aaf73c 100644
--- a/lib/libc/iconv/citrus_mmap.c
+++ b/lib/libc/iconv/citrus_mmap.c
@@ -57,12 +57,8 @@ _citrus_map_file(struct _citrus_region * __restrict r,
_region_init(r, NULL, 0);
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1)
return (errno);
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
- ret = errno;
- goto error;
- }
if (fstat(fd, &st) == -1) {
ret = errno;
diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h
index 1e00030..739d7b1 100644
--- a/lib/libc/include/namespace.h
+++ b/lib/libc/include/namespace.h
@@ -229,6 +229,7 @@
#define socketpair _socketpair
#define usleep _usleep
#define wait4 _wait4
+#define wait6 _wait6
#define waitpid _waitpid
#define write _write
#define writev _writev
diff --git a/lib/libc/include/un-namespace.h b/lib/libc/include/un-namespace.h
index 9c9ce97..f31fa7a 100644
--- a/lib/libc/include/un-namespace.h
+++ b/lib/libc/include/un-namespace.h
@@ -210,6 +210,7 @@
#undef socketpair
#undef usleep
#undef wait4
+#undef wait6
#undef waitpid
#undef write
#undef writev
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index 676d41c..56513f4 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -135,7 +135,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
(void)strcat(buf, "/");
(void)strcat(buf, encoding);
(void)strcat(buf, "/LC_COLLATE");
- if ((fp = fopen(buf, "r")) == NULL)
+ if ((fp = fopen(buf, "re")) == NULL)
return (_LDP_ERROR);
if (fread(strbuf, sizeof(strbuf), 1, fp) != 1) {
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 3ffb649..49e6f6e 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -73,9 +73,11 @@ static int __setrunelocale(struct xlocale_ctype *l, const char *);
#define __collate_chain_pri_table (table->__collate_chain_pri_table)
-static void destruct_ctype(void *v)
+static void
+destruct_ctype(void *v)
{
struct xlocale_ctype *l = v;
+
if (strcmp(l->runes->__encoding, "EUC") == 0)
free(l->runes->__variable);
if (&_DefaultRuneLocale != l->runes)
@@ -83,13 +85,17 @@ static void destruct_ctype(void *v)
free(l);
}
-const _RuneLocale *__getCurrentRuneLocale(void)
+const _RuneLocale *
+__getCurrentRuneLocale(void)
{
+
return XLOCALE_CTYPE(__get_locale())->runes;
}
-static void free_runes(_RuneLocale *rl)
+static void
+free_runes(_RuneLocale *rl)
{
+
/* FIXME: The "EUC" check here is a hideous abstraction violation. */
if ((rl != &_DefaultRuneLocale) && (rl)) {
if (strcmp(rl->__encoding, "EUC") == 0) {
@@ -123,7 +129,7 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding)
(void) strcat(name, encoding);
(void) strcat(name, "/LC_CTYPE");
- if ((fp = fopen(name, "r")) == NULL)
+ if ((fp = fopen(name, "re")) == NULL)
return (errno == 0 ? ENOENT : errno);
if ((rl = _Read_RuneMagi(fp)) == NULL) {
@@ -191,7 +197,8 @@ __wrap_setrunelocale(const char *locale)
#ifndef __NO_TLS
void
-__set_thread_rune_locale(locale_t loc) {
+__set_thread_rune_locale(locale_t loc)
+{
if (loc == NULL) {
_ThreadRuneLocale = &_DefaultRuneLocale;
@@ -205,6 +212,7 @@ void *
__ctype_load(const char *locale, locale_t unused)
{
struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1);
+
l->header.header.destructor = destruct_ctype;
if (__setrunelocale(l, locale))
{
diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc
index 3601909..fc11349 100644
--- a/lib/libc/mips/sys/Makefile.inc
+++ b/lib/libc/mips/sys/Makefile.inc
@@ -1,5 +1,7 @@
# $FreeBSD$
+SRCS+= __vdso_gettc.c
+
MDASM= Ovfork.S brk.S cerror.S exect.S \
fork.S pipe.S ptrace.S sbrk.S syscall.S
diff --git a/lib/libc/mips/sys/__vdso_gettc.c b/lib/libc/mips/sys/__vdso_gettc.c
new file mode 100644
index 0000000..b99bbc4
--- /dev/null
+++ b/lib/libc/mips/sys/__vdso_gettc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (ENOSYS);
+}
diff --git a/lib/libc/net/getnetent.3 b/lib/libc/net/getnetent.3
index 2e9cd33..ec08b6b 100644
--- a/lib/libc/net/getnetent.3
+++ b/lib/libc/net/getnetent.3
@@ -73,7 +73,7 @@ The order of the lookups is controlled by the
`networks' entry in
.Xr nsswitch.conf 5 .
.Bd -literal -offset indent
-struct netent {
+struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
@@ -142,8 +142,7 @@ Network numbers are supplied in host order.
.It Pa /etc/resolv.conf
.El
.Sh DIAGNOSTICS
-Null pointer
-(0) returned on
+Null pointer returned on
.Dv EOF
or error.
.Sh SEE ALSO
diff --git a/lib/libc/net/getprotoent.3 b/lib/libc/net/getprotoent.3
index 9f9e00d..565e038 100644
--- a/lib/libc/net/getprotoent.3
+++ b/lib/libc/net/getprotoent.3
@@ -65,7 +65,7 @@ containing the broken-out
fields of a line in the network protocol data base,
.Pa /etc/protocols .
.Bd -literal -offset indent
-struct protoent {
+struct protoent {
char *p_name; /* official name of protocol */
char **p_aliases; /* alias list */
int p_proto; /* protocol number */
@@ -117,8 +117,7 @@ or until
.Dv EOF
is encountered.
.Sh RETURN VALUES
-Null pointer
-(0) returned on
+Null pointer returned on
.Dv EOF
or error.
.Sh FILES
diff --git a/lib/libc/net/getservent.3 b/lib/libc/net/getservent.3
index 65d40bb..5f5a452 100644
--- a/lib/libc/net/getservent.3
+++ b/lib/libc/net/getservent.3
@@ -65,7 +65,7 @@ containing the broken-out
fields of a line in the network services data base,
.Pa /etc/services .
.Bd -literal -offset indent
-struct servent {
+struct servent {
char *s_name; /* official name of service */
char **s_aliases; /* alias list */
int s_port; /* port service resides at */
@@ -130,8 +130,7 @@ searches must also match the protocol.
.It Pa /etc/services
.El
.Sh DIAGNOSTICS
-Null pointer
-(0) returned on
+Null pointer returned on
.Dv EOF
or error.
.Sh SEE ALSO
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c
index 0031f46..f360162 100644
--- a/lib/libc/net/name6.c
+++ b/lib/libc/net/name6.c
@@ -200,6 +200,7 @@ static struct hostent *_hpmapv6(struct hostent *, int *);
#endif
static struct hostent *_hpsort(struct hostent *, res_state);
+#ifdef INET6
static struct hostent *_hpreorder(struct hostent *);
static int get_addrselectpolicy(struct policyhead *);
static void free_addrselectpolicy(struct policyhead *);
@@ -209,6 +210,7 @@ static void set_source(struct hp_order *, struct policyhead *);
static int matchlen(struct sockaddr *, struct sockaddr *);
static int comp_dst(const void *, const void *);
static int gai_addr2scopetype(struct sockaddr *);
+#endif
/*
* Functions defined in RFC2553
@@ -285,8 +287,10 @@ getipnodebyname(const char *name, int af, int flags, int *errp)
hp = gethostbyname2(name, af);
hp = _hpcopy(hp, errp);
-
#ifdef INET6
+ if (af == AF_INET6)
+ hp = _hpreorder(hp);
+
if (af == AF_INET6 && ((flags & AI_ALL) || hp == NULL) &&
MAPADDRENABLED(flags)) {
struct hostent *hp2 = gethostbyname2(name, AF_INET);
@@ -309,7 +313,7 @@ getipnodebyname(const char *name, int af, int flags, int *errp)
*errp = statp->res_h_errno;
statp->options = options;
- return _hpreorder(_hpsort(hp, statp));
+ return _hpsort(hp, statp);
}
struct hostent *
@@ -632,6 +636,7 @@ _hpsort(struct hostent *hp, res_state statp)
return hp;
}
+#ifdef INET6
/*
* _hpreorder: sort address by default address selection
*/
@@ -1109,3 +1114,4 @@ gai_addr2scopetype(struct sockaddr *sa)
return(-1);
}
}
+#endif
diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c
index 1e06f44..beedf94 100644
--- a/lib/libc/net/sctp_sys_calls.c
+++ b/lib/libc/net/sctp_sys_calls.c
@@ -188,30 +188,34 @@ sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt,
cpto = ((caddr_t)buf + sizeof(int));
/* validate all the addresses and get the size */
for (i = 0; i < addrcnt; i++) {
- if (at->sa_family == AF_INET) {
+ switch (at->sa_family) {
+ case AF_INET:
if (at->sa_len != sizeof(struct sockaddr_in)) {
errno = EINVAL;
return (-1);
}
- memcpy(cpto, at, at->sa_len);
- cpto = ((caddr_t)cpto + at->sa_len);
- len += at->sa_len;
- } else if (at->sa_family == AF_INET6) {
+ memcpy(cpto, at, sizeof(struct sockaddr_in));
+ cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in));
+ len += sizeof(struct sockaddr_in);
+ at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in));
+ break;
+ case AF_INET6:
if (at->sa_len != sizeof(struct sockaddr_in6)) {
errno = EINVAL;
return (-1);
}
if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)at)->sin6_addr)) {
- len += sizeof(struct sockaddr_in);
in6_sin6_2_sin((struct sockaddr_in *)cpto, (struct sockaddr_in6 *)at);
cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in));
len += sizeof(struct sockaddr_in);
} else {
- memcpy(cpto, at, at->sa_len);
- cpto = ((caddr_t)cpto + at->sa_len);
- len += at->sa_len;
+ memcpy(cpto, at, sizeof(struct sockaddr_in6));
+ cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in6));
+ len += sizeof(struct sockaddr_in6);
}
- } else {
+ at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in6));
+ break;
+ default:
errno = EINVAL;
return (-1);
}
@@ -220,7 +224,6 @@ sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt,
errno = E2BIG;
return (-1);
}
- at = (struct sockaddr *)((caddr_t)at + at->sa_len);
cnt++;
}
/* do we have any? */
@@ -261,56 +264,57 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags)
errno = EINVAL;
return (-1);
}
- argsz = (sizeof(struct sockaddr_storage) +
- sizeof(struct sctp_getaddresses));
- gaddrs = (struct sctp_getaddresses *)calloc(1, argsz);
- if (gaddrs == NULL) {
- errno = ENOMEM;
- return (-1);
- }
/* First pre-screen the addresses */
sa = addrs;
for (i = 0; i < addrcnt; i++) {
- if (sa->sa_family == AF_INET) {
- if (sa->sa_len != sizeof(struct sockaddr_in))
- goto out_error;
+ switch (sa->sa_family) {
+ case AF_INET:
+ if (sa->sa_len != sizeof(struct sockaddr_in)) {
+ errno = EINVAL;
+ return (-1);
+ }
sin = (struct sockaddr_in *)sa;
if (sin->sin_port) {
/* non-zero port, check or save */
if (sport) {
/* Check against our port */
if (sport != sin->sin_port) {
- goto out_error;
+ errno = EINVAL;
+ return (-1);
}
} else {
/* save off the port */
sport = sin->sin_port;
}
}
- } else if (sa->sa_family == AF_INET6) {
- if (sa->sa_len != sizeof(struct sockaddr_in6))
- goto out_error;
+ break;
+ case AF_INET6:
+ if (sa->sa_len != sizeof(struct sockaddr_in6)) {
+ errno = EINVAL;
+ return (-1);
+ }
sin6 = (struct sockaddr_in6 *)sa;
if (sin6->sin6_port) {
/* non-zero port, check or save */
if (sport) {
/* Check against our port */
if (sport != sin6->sin6_port) {
- goto out_error;
+ errno = EINVAL;
+ return (-1);
}
} else {
/* save off the port */
sport = sin6->sin6_port;
}
}
- } else {
- /* invalid address family specified */
- goto out_error;
+ break;
+ default:
+ /* Invalid address family specified. */
+ errno = EINVAL;
+ return (-1);
}
-
sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len);
}
- sa = addrs;
/*
* Now if there was a port mentioned, assure that the first address
* has that port to make sure it fails or succeeds correctly.
@@ -319,20 +323,14 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags)
sin = (struct sockaddr_in *)sa;
sin->sin_port = sport;
}
+ argsz = sizeof(struct sctp_getaddresses) +
+ sizeof(struct sockaddr_storage);
+ if ((gaddrs = (struct sctp_getaddresses *)malloc(argsz)) == NULL) {
+ errno = ENOMEM;
+ return (-1);
+ }
+ sa = addrs;
for (i = 0; i < addrcnt; i++) {
- if (sa->sa_family == AF_INET) {
- if (sa->sa_len != sizeof(struct sockaddr_in))
- goto out_error;
- } else if (sa->sa_family == AF_INET6) {
- if (sa->sa_len != sizeof(struct sockaddr_in6))
- goto out_error;
- } else {
- /* invalid address family specified */
- out_error:
- free(gaddrs);
- errno = EINVAL;
- return (-1);
- }
memset(gaddrs, 0, argsz);
gaddrs->sget_assoc_id = 0;
memcpy(gaddrs->addr, sa, sa->sa_len);
diff --git a/lib/libc/nls/Makefile.inc b/lib/libc/nls/Makefile.inc
index f5c6885..962d16b 100644
--- a/lib/libc/nls/Makefile.inc
+++ b/lib/libc/nls/Makefile.inc
@@ -36,3 +36,6 @@ NLS+= ru_RU.KOI8-R
NLS+= sk_SK.ISO8859-2
NLS+= sv_SE.ISO8859-1
NLS+= uk_UA.UTF-8
+NLS+= zh_CN.GB18030
+NLS+= zh_CN.GB2312
+NLS+= zh_CN.UTF-8
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
index 44b1440..2859916 100644
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
if (np != NULL) { \
np->name = strdup(n); \
np->path = NULL; \
+ np->catd = NLERR; \
np->lang = (l == NULL) ? NULL : \
strdup(l); \
np->caterrno = e; \
diff --git a/lib/libc/nls/zh_CN.GB18030.msg b/lib/libc/nls/zh_CN.GB18030.msg
new file mode 100644
index 0000000..0e35d7e
--- /dev/null
+++ b/lib/libc/nls/zh_CN.GB18030.msg
@@ -0,0 +1,297 @@
+$ $FreeBSD$
+$
+$ Message catalog for zh_CN.GB18030 locale
+$
+$ Derived from FreeBSD: head/lib/libc/nls/zh_CN.UTF-8.msg 244756 2012-12-28 01:09:30Z delphij
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 ²»ÔÊÐíµÄ²Ù×÷
+$ ENOENT
+2 Îļþ»òĿ¼²»´æÔÚ
+$ ESRCH
+3 ½ø³Ì²»´æÔÚ
+$ EINTR
+4 ϵͳµ÷ÓÃÖÐÖ¹
+$ EIO
+5 ÊäÈë/Êä³ö´íÎó
+$ ENXIO
+6 δÅäÖõÄÉ豸
+$ E2BIG
+7 ²ÎÊý±í¹ý³¤
+$ ENOEXEC
+8 ¿ÉÖ´ÐÐÎļþ¸ñʽ´íÎó
+$ EBADF
+9 ÎļþÃèÊö·ûÎÞЧ
+$ ECHILD
+10 Ö¸¶¨×Ó½ø³Ì²»´æÔÚ
+$ EDEADLK
+11 ´Ë²Ù×÷»áµ¼ÖÂËÀËø
+$ ENOMEM
+12 ÎÞ·¨·ÖÅäÄÚ´æ
+$ EACCES
+13 ¾Ü¾ø·ÃÎÊ
+$ EFAULT
+14 ÎÞЧµØÖ·
+$ ENOTBLK
+15 ¸Ã²Ù×÷ÐèÒª¿éÉ豸
+$ EBUSY
+16 É豸ʹÓÃÖÐ
+$ EEXIST
+17 ÎļþÒÑ´æÔÚ
+$ EXDEV
+18 Á´½Ó¿çÉ豸
+$ ENODEV
+19 É豸²»Ö§³Ö´Ë²Ù×÷
+$ ENOTDIR
+20 ¶ÔÏó·ÇĿ¼
+$ EISDIR
+21 ¶ÔÏóΪĿ¼
+$ EINVAL
+22 ²ÎÊýÎÞЧ
+$ ENFILE
+23 ϵͳ´ò¿ªÎļþ¹ý¶à
+$ EMFILE
+24 ½ø³Ì´ò¿ªÎļþ¹ý¶à
+$ ENOTTY
+25 ÎÞЧÉ豸 ioctl
+$ ETXTBSY
+26 ¿ÉÖ´ÐÐÎļþæ
+$ EFBIG
+27 Îļþ¹ý´ó
+$ ENOSPC
+28 É豸ÎÞ¿ÉÓÿռä
+$ ESPIPE
+29 ²»ÔÊÐíÖ´ÐÐ seek ²Ù×÷
+$ EROFS
+30 Îļþϵͳֻ¶Á
+$ EMLINK
+31 ÎļþÁ´½Ó¹ý¶à
+$ EPIPE
+32 ¹ÜµÀÒÑÖÐÖ¹
+$ EDOM
+33 ÊýÖµ²ÎÊýÔ½½ç
+$ ERANGE
+34 ½á¹û¹ý´ó
+$ EAGAIN, EWOULDBLOCK
+35 ×ÊÔ´ÔÝʱ²»¿ÉÓÃ
+$ EINPROGRESS
+36 ²Ù×÷½øÐÐÖÐ
+$ EALREADY
+37 ²Ù×÷ÒÑ¿ªÊ¼
+$ ENOTSOCK
+38 ³¢ÊÔÔÚ·Ç socket ÉÏÖ´ÐÐ socket ²Ù×÷
+$ EDESTADDRREQ
+39 ÐèҪĿµÄµØÖ·
+$ EMSGSIZE
+40 ÏûÏ¢¹ý³¤
+$ EPROTOTYPE
+41 socketЭÒéÀàÐÍ´íÎó
+$ ENOPROTOOPT
+42 ЭÒé²»¿ÉÓÃ
+$ EPROTONOSUPPORT
+43 ²»Ö§³ÖµÄЭÒé
+$ ESOCKTNOSUPPORT
+44 ²»Ö§³ÖµÄ socket ÀàÐÍ
+$ EOPNOTSUPP
+45 ²»Ö§³ÖµÄ²Ù×÷
+$ EPFNOSUPPORT
+46 ²»Ö§³ÖµÄЭÒé×å
+$ EAFNOSUPPORT
+47 ЭÒé×å²»Ö§³ÖµÄµØÖ·×å
+$ EADDRINUSE
+48 µØÖ·Òѱ»Õ¼ÓÃ
+$ EADDRNOTAVAIL
+49 ÎÞ·¨Ö¸¶¨ÇëÇóµÄµØÖ·
+$ ENETDOWN
+50 ÍøÂçÒѹرÕ
+$ ENETUNREACH
+51 ÍøÂç²»¿É´ï
+$ ENETRESET
+52 ¸´Î»µ¼ÖÂÍøÂçÁ¬½Ó¶ªÊ§
+$ ECONNABORTED
+53 Èí¼þµ¼ÖµÄÁ¬½ÓÖÐÖ¹
+$ ECONNRESET
+54 ¶Ô·½¸´Î»ÁËÁ¬½Ó
+$ ENOBUFS
+55 »º³åÇø¿Õ¼ä²»×ã
+$ EISCONN
+56 socket ÒÑÁ¬½Ó
+$ ENOTCONN
+57 socket δÁ¬½Ó
+$ ESHUTDOWN
+58 socket shutdown Ö®ºóÎÞ·¨·¢ËÍÊý¾Ý
+$ ETOOMANYREFS
+59 ÒýÓÃÊý¹ý¶à£ºÎÞ·¨Æ´½Ó
+$ ETIMEDOUT
+60 ²Ù×÷³¬Ê±
+$ ECONNREFUSED
+61 ¾Ü¾øÁ¬½Ó
+$ ELOOP
+62 ·ûºÅÁ´½Ó²ãÊý¹ý¶à
+$ ENAMETOOLONG
+63 ÎļþÃû¹ý³¤
+$ EHOSTDOWN
+64 Ö÷»úÒѹرÕ
+$ EHOSTUNREACH
+65 ûÓе½Ö÷»úµÄ·ÓÉ
+$ ENOTEMPTY
+66 Ŀ¼·Ç¿Õ
+$ EPROCLIM
+67 ½ø³ÌÊý³¬ÏÞ
+$ EUSERS
+68 Óû§Êý³¬ÏÞ
+$ EDQUOT
+69 ´ÅÅÌ¿Õ¼äÅä¶î³¬ÏÞ
+$ ESTALE
+70 NFS Îļþ¾ä±úÒÑʧЧ
+$ EREMOTE
+71 Ô¶³ÌĿ¼²ãÊý¹ý¶à
+$ EBADRPC
+72 RPC ½á¹¹ÎÞЧ
+$ ERPCMISMATCH
+73 RPC °æ±¾´íÎó
+$ EPROGUNAVAIL
+74 RPC ³ÌÐò²»¿ÉÓÃ
+$ EPROGMISMATCH
+75 ³ÌÐò°æ±¾´íÎó
+$ EPROCUNAVAIL
+76 δÌṩµÄÔ¶³Ìº¯Êý
+$ ENOLCK
+77 ²»Ö§³ÖËø
+$ ENOSYS
+78 ¹¦ÄÜδʵÏÖ
+$ EFTYPE
+79 ÎļþÀàÐÍ»ò¸ñʽÎÞЧ
+$ EAUTH
+80 Éí·ÝÎÞЧ
+$ ENEEDAUTH
+81 ÎÞÐÅÈÎƾ¾Ý
+$ EIDRM
+82 ÎÞ±êʶ·û
+$ ENOMSG
+83 ÎÞÏûÏ¢ÀàÐÍ
+$ EOVERFLOW
+84 ÊýÖµÒç³ö
+$ ECANCELED
+85 ²Ù×÷ÒÑÈ¡Ïû
+$ EILSEQ
+86 ÎÞЧ×Ö·ûÐòÁÐ
+$ ENOATTR
+87 ÎÞÀ©Õ¹ÊôÐÔ
+$ EDOOFUS
+88 ³ÌÐòÉè¼Æ´íÎó
+$ EBADMSG
+89 ÎÞЧÏûÏ¢
+$ EMULTIHOP
+90 Multihop attempted
+$ ENOLINK
+91 Link has been severed
+$ EPROTO
+92 ЭÒé´íÎó
+$ ENOTCAPABLE
+93 ȨÄܲ»×ã
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+1 ÖÕ¶ËÏß·¹Ò¶Ï
+$ SIGINT
+2 ÖжÏ
+$ SIGQUIT
+3 Í˳ö
+$ SIGILL
+4 ÎÞЧָÁî
+$ SIGTRAP
+5 ¸ú×Ù/BPT ÏÝÚå
+$ SIGABRT
+6 ÖÕÖ¹ÏÝÚå
+$ SIGEMT
+7 EMT ÏÝÚå
+$ SIGFPE
+8 ¸¡µãÒì³£
+$ SIGKILL
+9 Ç¿ÖÆÖÕÖ¹½ø³Ì
+$ SIGBUS
+10 ϵͳÄÚ´æ·ÃÎÊÔ½½ç
+$ SIGSEGV
+11 ÄÚ´æ·ÃÎÊÔ½½ç
+$ SIGSYS
+12 ÎÞЧϵͳµ÷ÓÃ
+$ SIGPIPE
+13 д¹ÜµÀʱ¶ÁÈ¡Õß²»´æÔÚ
+$ SIGALRM
+14 ʵʱµ¹¼Æʱµ½ÆÚ
+$ SIGTERM
+15 ÖÕÖ¹
+$ SIGURG
+16 ÐèÁ¢¼´´¦ÀíµÄ I/O ½ô¼±×´¿ö
+$ SIGSTOP
+17 ¹ÒÆð (ÐźÅ)
+$ SIGTSTP
+18 ¹ÒÆð
+$ SIGCONT
+19 ¼ÌÐøÔËÐÐ
+$ SIGCHLD
+20 ×Ó½ø³ÌÖÕÖ¹
+$ SIGTTIN
+21 TTY ÊäÈë×èÈû
+$ SIGTTOU
+22 TTY Êä³ö×èÈû
+$ SIGIO
+23 I/O ¾ÍÐ÷
+$ SIGXCPU
+24 CPU ʹÓÃʱ¼ä¹ý³¤
+$ SIGXFSZ
+25 Îļþ³ß´ç¹ý´ó
+$ SIGVTALRM
+26 ÐéÄâµ¹¼Æʱµ½ÆÚ
+$ SIGPROF
+27 ÆÊÎöµ¹¼Æʱµ½ÆÚ
+$ SIGWINCH
+28 ´°¿Ú³ß´ç±ä»¯
+$ SIGINFO
+29 ÇëÇóÐÅÏ¢
+$ SIGUSR1
+30 Óû§×Ô¶¨ÒåÐźŠ1
+$ SIGUSR2
+31 Óû§×Ô¶¨ÒåÐźŠ2
+$
+$ gai_strerror() support catalog
+$
+$set 3
+$ 1 (obsolete)
+1 Ö÷»úÃûʹÓÃÁ˲»Ö§³ÖµÄµØÖ·ÀàÐÍ
+$ EAI_AGAIN
+2 ÔÝʱÎÞ·¨½âÎöÃû³Æ
+$ EAI_BADFLAGS
+3 ÎÞЧµÄ ai_flags Öµ
+$ EAI_FAIL
+4 ½âÎöÃû³Æʱ³öÏÖÎÞ·¨»Ö¸´µÄ´íÎó
+$ EAI_FAMILY
+5 ²»Ö§³ÖµÄµØÖ·ÐÅÏ¢ÀàÐÍ
+$ EAI_MEMORY
+6 ÄÚ´æ·ÖÅäʧ°Ü
+$ 7 (obsolete)
+7 Ö÷»úÃûÎÞÏà¹ØÁªµÄµØÖ·
+$ EAI_NONAME
+8 δ֪µÄÖ÷»úÃû»ò·þÎñÃû
+$ EAI_SERVICE
+9 Ì×½Ó×ÖÀàÐͲ»Ö§³Ö´Ë·þÎñÃû
+$ EAI_SOCKTYPE
+10 ²»Ö§³ÖµÄÌ×½Ó×ÖÀàÐÍ
+$ EAI_SYSTEM
+11 ϵͳµ÷Ó÷µ»ØÁË errno ´íÎó
+$ EAI_BADHINTS
+12 ÎÞЧÌáʾ²ÎÊý
+$ EAI_PROTOCOL
+13 δ֪ЭÒé
+$ EAI_OVERFLOW
+14 ²ÎÊý»º³åÒç³ö
+$ 0
+32766 ³É¹¦
+$ NL_MSGMAX
+32767 δ֪´íÎó
diff --git a/lib/libc/nls/zh_CN.GB2312.msg b/lib/libc/nls/zh_CN.GB2312.msg
new file mode 100644
index 0000000..46ebb42
--- /dev/null
+++ b/lib/libc/nls/zh_CN.GB2312.msg
@@ -0,0 +1,297 @@
+$ $FreeBSD$
+$
+$ Message catalog for zh_CN.GB2312 locale
+$
+$ Derived from FreeBSD: head/lib/libc/nls/zh_CN.UTF-8.msg 244756 2012-12-28 01:09:30Z delphij
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 ²»ÔÊÐíµÄ²Ù×÷
+$ ENOENT
+2 Îļþ»òĿ¼²»´æÔÚ
+$ ESRCH
+3 ½ø³Ì²»´æÔÚ
+$ EINTR
+4 ϵͳµ÷ÓÃÖÐÖ¹
+$ EIO
+5 ÊäÈë/Êä³ö´íÎó
+$ ENXIO
+6 δÅäÖõÄÉ豸
+$ E2BIG
+7 ²ÎÊý±í¹ý³¤
+$ ENOEXEC
+8 ¿ÉÖ´ÐÐÎļþ¸ñʽ´íÎó
+$ EBADF
+9 ÎļþÃèÊö·ûÎÞЧ
+$ ECHILD
+10 Ö¸¶¨×Ó½ø³Ì²»´æÔÚ
+$ EDEADLK
+11 ´Ë²Ù×÷»áµ¼ÖÂËÀËø
+$ ENOMEM
+12 ÎÞ·¨·ÖÅäÄÚ´æ
+$ EACCES
+13 ¾Ü¾ø·ÃÎÊ
+$ EFAULT
+14 ÎÞЧµØÖ·
+$ ENOTBLK
+15 ¸Ã²Ù×÷ÐèÒª¿éÉ豸
+$ EBUSY
+16 É豸ʹÓÃÖÐ
+$ EEXIST
+17 ÎļþÒÑ´æÔÚ
+$ EXDEV
+18 Á´½Ó¿çÉ豸
+$ ENODEV
+19 É豸²»Ö§³Ö´Ë²Ù×÷
+$ ENOTDIR
+20 ¶ÔÏó·ÇĿ¼
+$ EISDIR
+21 ¶ÔÏóΪĿ¼
+$ EINVAL
+22 ²ÎÊýÎÞЧ
+$ ENFILE
+23 ϵͳ´ò¿ªÎļþ¹ý¶à
+$ EMFILE
+24 ½ø³Ì´ò¿ªÎļþ¹ý¶à
+$ ENOTTY
+25 ÎÞЧÉ豸 ioctl
+$ ETXTBSY
+26 ¿ÉÖ´ÐÐÎļþæ
+$ EFBIG
+27 Îļþ¹ý´ó
+$ ENOSPC
+28 É豸ÎÞ¿ÉÓÿռä
+$ ESPIPE
+29 ²»ÔÊÐíÖ´ÐÐ seek ²Ù×÷
+$ EROFS
+30 Îļþϵͳֻ¶Á
+$ EMLINK
+31 ÎļþÁ´½Ó¹ý¶à
+$ EPIPE
+32 ¹ÜµÀÒÑÖÐÖ¹
+$ EDOM
+33 ÊýÖµ²ÎÊýÔ½½ç
+$ ERANGE
+34 ½á¹û¹ý´ó
+$ EAGAIN, EWOULDBLOCK
+35 ×ÊÔ´ÔÝʱ²»¿ÉÓÃ
+$ EINPROGRESS
+36 ²Ù×÷½øÐÐÖÐ
+$ EALREADY
+37 ²Ù×÷ÒÑ¿ªÊ¼
+$ ENOTSOCK
+38 ³¢ÊÔÔÚ·Ç socket ÉÏÖ´ÐÐ socket ²Ù×÷
+$ EDESTADDRREQ
+39 ÐèҪĿµÄµØÖ·
+$ EMSGSIZE
+40 ÏûÏ¢¹ý³¤
+$ EPROTOTYPE
+41 socketЭÒéÀàÐÍ´íÎó
+$ ENOPROTOOPT
+42 ЭÒé²»¿ÉÓÃ
+$ EPROTONOSUPPORT
+43 ²»Ö§³ÖµÄЭÒé
+$ ESOCKTNOSUPPORT
+44 ²»Ö§³ÖµÄ socket ÀàÐÍ
+$ EOPNOTSUPP
+45 ²»Ö§³ÖµÄ²Ù×÷
+$ EPFNOSUPPORT
+46 ²»Ö§³ÖµÄЭÒé×å
+$ EAFNOSUPPORT
+47 ЭÒé×å²»Ö§³ÖµÄµØÖ·×å
+$ EADDRINUSE
+48 µØÖ·Òѱ»Õ¼ÓÃ
+$ EADDRNOTAVAIL
+49 ÎÞ·¨Ö¸¶¨ÇëÇóµÄµØÖ·
+$ ENETDOWN
+50 ÍøÂçÒѹرÕ
+$ ENETUNREACH
+51 ÍøÂç²»¿É´ï
+$ ENETRESET
+52 ¸´Î»µ¼ÖÂÍøÂçÁ¬½Ó¶ªÊ§
+$ ECONNABORTED
+53 Èí¼þµ¼ÖµÄÁ¬½ÓÖÐÖ¹
+$ ECONNRESET
+54 ¶Ô·½¸´Î»ÁËÁ¬½Ó
+$ ENOBUFS
+55 »º³åÇø¿Õ¼ä²»×ã
+$ EISCONN
+56 socket ÒÑÁ¬½Ó
+$ ENOTCONN
+57 socket δÁ¬½Ó
+$ ESHUTDOWN
+58 socket shutdown Ö®ºóÎÞ·¨·¢ËÍÊý¾Ý
+$ ETOOMANYREFS
+59 ÒýÓÃÊý¹ý¶à£ºÎÞ·¨Æ´½Ó
+$ ETIMEDOUT
+60 ²Ù×÷³¬Ê±
+$ ECONNREFUSED
+61 ¾Ü¾øÁ¬½Ó
+$ ELOOP
+62 ·ûºÅÁ´½Ó²ãÊý¹ý¶à
+$ ENAMETOOLONG
+63 ÎļþÃû¹ý³¤
+$ EHOSTDOWN
+64 Ö÷»úÒѹرÕ
+$ EHOSTUNREACH
+65 ûÓе½Ö÷»úµÄ·ÓÉ
+$ ENOTEMPTY
+66 Ŀ¼·Ç¿Õ
+$ EPROCLIM
+67 ½ø³ÌÊý³¬ÏÞ
+$ EUSERS
+68 Óû§Êý³¬ÏÞ
+$ EDQUOT
+69 ´ÅÅÌ¿Õ¼äÅä¶î³¬ÏÞ
+$ ESTALE
+70 NFS Îļþ¾ä±úÒÑʧЧ
+$ EREMOTE
+71 Ô¶³ÌĿ¼²ãÊý¹ý¶à
+$ EBADRPC
+72 RPC ½á¹¹ÎÞЧ
+$ ERPCMISMATCH
+73 RPC °æ±¾´íÎó
+$ EPROGUNAVAIL
+74 RPC ³ÌÐò²»¿ÉÓÃ
+$ EPROGMISMATCH
+75 ³ÌÐò°æ±¾´íÎó
+$ EPROCUNAVAIL
+76 δÌṩµÄÔ¶³Ìº¯Êý
+$ ENOLCK
+77 ²»Ö§³ÖËø
+$ ENOSYS
+78 ¹¦ÄÜδʵÏÖ
+$ EFTYPE
+79 ÎļþÀàÐÍ»ò¸ñʽÎÞЧ
+$ EAUTH
+80 Éí·ÝÎÞЧ
+$ ENEEDAUTH
+81 ÎÞÐÅÈÎƾ¾Ý
+$ EIDRM
+82 ÎÞ±êʶ·û
+$ ENOMSG
+83 ÎÞÏûÏ¢ÀàÐÍ
+$ EOVERFLOW
+84 ÊýÖµÒç³ö
+$ ECANCELED
+85 ²Ù×÷ÒÑÈ¡Ïû
+$ EILSEQ
+86 ÎÞЧ×Ö·ûÐòÁÐ
+$ ENOATTR
+87 ÎÞÀ©Õ¹ÊôÐÔ
+$ EDOOFUS
+88 ³ÌÐòÉè¼Æ´íÎó
+$ EBADMSG
+89 ÎÞЧÏûÏ¢
+$ EMULTIHOP
+90 Multihop attempted
+$ ENOLINK
+91 Link has been severed
+$ EPROTO
+92 ЭÒé´íÎó
+$ ENOTCAPABLE
+93 ȨÄܲ»×ã
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+1 ÖÕ¶ËÏß·¹Ò¶Ï
+$ SIGINT
+2 ÖжÏ
+$ SIGQUIT
+3 Í˳ö
+$ SIGILL
+4 ÎÞЧָÁî
+$ SIGTRAP
+5 ¸ú×Ù/BPT ÏÝÚå
+$ SIGABRT
+6 ÖÕÖ¹ÏÝÚå
+$ SIGEMT
+7 EMT ÏÝÚå
+$ SIGFPE
+8 ¸¡µãÒì³£
+$ SIGKILL
+9 Ç¿ÖÆÖÕÖ¹½ø³Ì
+$ SIGBUS
+10 ϵͳÄÚ´æ·ÃÎÊÔ½½ç
+$ SIGSEGV
+11 ÄÚ´æ·ÃÎÊÔ½½ç
+$ SIGSYS
+12 ÎÞЧϵͳµ÷ÓÃ
+$ SIGPIPE
+13 д¹ÜµÀʱ¶ÁÈ¡Õß²»´æÔÚ
+$ SIGALRM
+14 ʵʱµ¹¼Æʱµ½ÆÚ
+$ SIGTERM
+15 ÖÕÖ¹
+$ SIGURG
+16 ÐèÁ¢¼´´¦ÀíµÄ I/O ½ô¼±×´¿ö
+$ SIGSTOP
+17 ¹ÒÆð (ÐźÅ)
+$ SIGTSTP
+18 ¹ÒÆð
+$ SIGCONT
+19 ¼ÌÐøÔËÐÐ
+$ SIGCHLD
+20 ×Ó½ø³ÌÖÕÖ¹
+$ SIGTTIN
+21 TTY ÊäÈë×èÈû
+$ SIGTTOU
+22 TTY Êä³ö×èÈû
+$ SIGIO
+23 I/O ¾ÍÐ÷
+$ SIGXCPU
+24 CPU ʹÓÃʱ¼ä¹ý³¤
+$ SIGXFSZ
+25 Îļþ³ß´ç¹ý´ó
+$ SIGVTALRM
+26 ÐéÄâµ¹¼Æʱµ½ÆÚ
+$ SIGPROF
+27 ÆÊÎöµ¹¼Æʱµ½ÆÚ
+$ SIGWINCH
+28 ´°¿Ú³ß´ç±ä»¯
+$ SIGINFO
+29 ÇëÇóÐÅÏ¢
+$ SIGUSR1
+30 Óû§×Ô¶¨ÒåÐźŠ1
+$ SIGUSR2
+31 Óû§×Ô¶¨ÒåÐźŠ2
+$
+$ gai_strerror() support catalog
+$
+$set 3
+$ 1 (obsolete)
+1 Ö÷»úÃûʹÓÃÁ˲»Ö§³ÖµÄµØÖ·ÀàÐÍ
+$ EAI_AGAIN
+2 ÔÝʱÎÞ·¨½âÎöÃû³Æ
+$ EAI_BADFLAGS
+3 ÎÞЧµÄ ai_flags Öµ
+$ EAI_FAIL
+4 ½âÎöÃû³Æʱ³öÏÖÎÞ·¨»Ö¸´µÄ´íÎó
+$ EAI_FAMILY
+5 ²»Ö§³ÖµÄµØÖ·ÐÅÏ¢ÀàÐÍ
+$ EAI_MEMORY
+6 ÄÚ´æ·ÖÅäʧ°Ü
+$ 7 (obsolete)
+7 Ö÷»úÃûÎÞÏà¹ØÁªµÄµØÖ·
+$ EAI_NONAME
+8 δ֪µÄÖ÷»úÃû»ò·þÎñÃû
+$ EAI_SERVICE
+9 Ì×½Ó×ÖÀàÐͲ»Ö§³Ö´Ë·þÎñÃû
+$ EAI_SOCKTYPE
+10 ²»Ö§³ÖµÄÌ×½Ó×ÖÀàÐÍ
+$ EAI_SYSTEM
+11 ϵͳµ÷Ó÷µ»ØÁË errno ´íÎó
+$ EAI_BADHINTS
+12 ÎÞЧÌáʾ²ÎÊý
+$ EAI_PROTOCOL
+13 δ֪ЭÒé
+$ EAI_OVERFLOW
+14 ²ÎÊý»º³åÒç³ö
+$ 0
+32766 ³É¹¦
+$ NL_MSGMAX
+32767 δ֪´íÎó
diff --git a/lib/libc/nls/zh_CN.UTF-8.msg b/lib/libc/nls/zh_CN.UTF-8.msg
new file mode 100644
index 0000000..9475ea8
--- /dev/null
+++ b/lib/libc/nls/zh_CN.UTF-8.msg
@@ -0,0 +1,295 @@
+$ $FreeBSD$
+$
+$ Message catalog for zh_CN.UTF-8 locale
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 ä¸å…许的æ“作
+$ ENOENT
+2 文件或目录ä¸å­˜åœ¨
+$ ESRCH
+3 进程ä¸å­˜åœ¨
+$ EINTR
+4 系统调用中止
+$ EIO
+5 输入/输出错误
+$ ENXIO
+6 未é…置的设备
+$ E2BIG
+7 å‚数表过长
+$ ENOEXEC
+8 å¯æ‰§è¡Œæ–‡ä»¶æ ¼å¼é”™è¯¯
+$ EBADF
+9 文件æ述符无效
+$ ECHILD
+10 指定å­è¿›ç¨‹ä¸å­˜åœ¨
+$ EDEADLK
+11 æ­¤æ“作会导致死é”
+$ ENOMEM
+12 无法分é…内存
+$ EACCES
+13 æ‹’ç»è®¿é—®
+$ EFAULT
+14 无效地å€
+$ ENOTBLK
+15 该æ“作需è¦å—设备
+$ EBUSY
+16 设备使用中
+$ EEXIST
+17 文件已存在
+$ EXDEV
+18 链接跨设备
+$ ENODEV
+19 设备ä¸æ”¯æŒæ­¤æ“作
+$ ENOTDIR
+20 对象éžç›®å½•
+$ EISDIR
+21 对象为目录
+$ EINVAL
+22 å‚数无效
+$ ENFILE
+23 系统打开文件过多
+$ EMFILE
+24 进程打开文件过多
+$ ENOTTY
+25 无效设备 ioctl
+$ ETXTBSY
+26 å¯æ‰§è¡Œæ–‡ä»¶å¿™
+$ EFBIG
+27 文件过大
+$ ENOSPC
+28 设备无å¯ç”¨ç©ºé—´
+$ ESPIPE
+29 ä¸å…许执行 seek æ“作
+$ EROFS
+30 文件系统åªè¯»
+$ EMLINK
+31 文件链接过多
+$ EPIPE
+32 管é“已中止
+$ EDOM
+33 数值å‚数越界
+$ ERANGE
+34 结果过大
+$ EAGAIN, EWOULDBLOCK
+35 资æºæš‚æ—¶ä¸å¯ç”¨
+$ EINPROGRESS
+36 æ“作进行中
+$ EALREADY
+37 æ“作已开始
+$ ENOTSOCK
+38 å°è¯•åœ¨éž socket 上执行 socket æ“作
+$ EDESTADDRREQ
+39 需è¦ç›®çš„地å€
+$ EMSGSIZE
+40 消æ¯è¿‡é•¿
+$ EPROTOTYPE
+41 socketå议类型错误
+$ ENOPROTOOPT
+42 åè®®ä¸å¯ç”¨
+$ EPROTONOSUPPORT
+43 ä¸æ”¯æŒçš„åè®®
+$ ESOCKTNOSUPPORT
+44 ä¸æ”¯æŒçš„ socket 类型
+$ EOPNOTSUPP
+45 ä¸æ”¯æŒçš„æ“作
+$ EPFNOSUPPORT
+46 ä¸æ”¯æŒçš„åè®®æ—
+$ EAFNOSUPPORT
+47 åè®®æ—ä¸æ”¯æŒçš„地å€æ—
+$ EADDRINUSE
+48 地å€å·²è¢«å ç”¨
+$ EADDRNOTAVAIL
+49 无法指定请求的地å€
+$ ENETDOWN
+50 网络已关闭
+$ ENETUNREACH
+51 网络ä¸å¯è¾¾
+$ ENETRESET
+52 å¤ä½å¯¼è‡´ç½‘络连接丢失
+$ ECONNABORTED
+53 软件导致的连接中止
+$ ECONNRESET
+54 对方å¤ä½äº†è¿žæŽ¥
+$ ENOBUFS
+55 缓冲区空间ä¸è¶³
+$ EISCONN
+56 socket 已连接
+$ ENOTCONN
+57 socket 未连接
+$ ESHUTDOWN
+58 socket shutdown 之åŽæ— æ³•å‘é€æ•°æ®
+$ ETOOMANYREFS
+59 引用数过多:无法拼接
+$ ETIMEDOUT
+60 æ“作超时
+$ ECONNREFUSED
+61 æ‹’ç»è¿žæŽ¥
+$ ELOOP
+62 符å·é“¾æŽ¥å±‚数过多
+$ ENAMETOOLONG
+63 文件å过长
+$ EHOSTDOWN
+64 主机已关闭
+$ EHOSTUNREACH
+65 没有到主机的路由
+$ ENOTEMPTY
+66 目录éžç©º
+$ EPROCLIM
+67 进程数超é™
+$ EUSERS
+68 用户数超é™
+$ EDQUOT
+69 ç£ç›˜ç©ºé—´é…é¢è¶…é™
+$ ESTALE
+70 NFS 文件å¥æŸ„已失效
+$ EREMOTE
+71 远程目录层数过多
+$ EBADRPC
+72 RPC 结构无效
+$ ERPCMISMATCH
+73 RPC 版本错误
+$ EPROGUNAVAIL
+74 RPC 程åºä¸å¯ç”¨
+$ EPROGMISMATCH
+75 程åºç‰ˆæœ¬é”™è¯¯
+$ EPROCUNAVAIL
+76 未æ供的远程函数
+$ ENOLCK
+77 ä¸æ”¯æŒé”
+$ ENOSYS
+78 功能未实现
+$ EFTYPE
+79 文件类型或格å¼æ— æ•ˆ
+$ EAUTH
+80 身份无效
+$ ENEEDAUTH
+81 无信任凭æ®
+$ EIDRM
+82 无标识符
+$ ENOMSG
+83 无消æ¯ç±»åž‹
+$ EOVERFLOW
+84 数值溢出
+$ ECANCELED
+85 æ“作已å–消
+$ EILSEQ
+86 无效字符åºåˆ—
+$ ENOATTR
+87 无扩展属性
+$ EDOOFUS
+88 程åºè®¾è®¡é”™è¯¯
+$ EBADMSG
+89 无效消æ¯
+$ EMULTIHOP
+90 Multihop attempted
+$ ENOLINK
+91 Link has been severed
+$ EPROTO
+92 å议错误
+$ ENOTCAPABLE
+93 æƒèƒ½ä¸è¶³
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+1 终端线路挂断
+$ SIGINT
+2 中断
+$ SIGQUIT
+3 退出
+$ SIGILL
+4 无效指令
+$ SIGTRAP
+5 跟踪/BPT 陷阱
+$ SIGABRT
+6 终止陷阱
+$ SIGEMT
+7 EMT 陷阱
+$ SIGFPE
+8 浮点异常
+$ SIGKILL
+9 强制终止进程
+$ SIGBUS
+10 系统内存访问越界
+$ SIGSEGV
+11 内存访问越界
+$ SIGSYS
+12 无效系统调用
+$ SIGPIPE
+13 写管é“时读å–者ä¸å­˜åœ¨
+$ SIGALRM
+14 实时倒计时到期
+$ SIGTERM
+15 终止
+$ SIGURG
+16 需立å³å¤„ç†çš„ I/O 紧急状况
+$ SIGSTOP
+17 挂起 (ä¿¡å·)
+$ SIGTSTP
+18 挂起
+$ SIGCONT
+19 继续è¿è¡Œ
+$ SIGCHLD
+20 å­è¿›ç¨‹ç»ˆæ­¢
+$ SIGTTIN
+21 TTY 输入阻塞
+$ SIGTTOU
+22 TTY 输出阻塞
+$ SIGIO
+23 I/O 就绪
+$ SIGXCPU
+24 CPU 使用时间过长
+$ SIGXFSZ
+25 文件尺寸过大
+$ SIGVTALRM
+26 虚拟倒计时到期
+$ SIGPROF
+27 剖æžå€’计时到期
+$ SIGWINCH
+28 窗å£å°ºå¯¸å˜åŒ–
+$ SIGINFO
+29 请求信æ¯
+$ SIGUSR1
+30 ç”¨æˆ·è‡ªå®šä¹‰ä¿¡å· 1
+$ SIGUSR2
+31 ç”¨æˆ·è‡ªå®šä¹‰ä¿¡å· 2
+$
+$ gai_strerror() support catalog
+$
+$set 3
+$ 1 (obsolete)
+1 主机å使用了ä¸æ”¯æŒçš„地å€ç±»åž‹
+$ EAI_AGAIN
+2 暂时无法解æžå称
+$ EAI_BADFLAGS
+3 无效的 ai_flags 值
+$ EAI_FAIL
+4 解æžå称时出现无法æ¢å¤çš„错误
+$ EAI_FAMILY
+5 ä¸æ”¯æŒçš„地å€ä¿¡æ¯ç±»åž‹
+$ EAI_MEMORY
+6 内存分é…失败
+$ 7 (obsolete)
+7 主机å无相关è”的地å€
+$ EAI_NONAME
+8 未知的主机å或æœåŠ¡å
+$ EAI_SERVICE
+9 套接字类型ä¸æ”¯æŒæ­¤æœåŠ¡å
+$ EAI_SOCKTYPE
+10 ä¸æ”¯æŒçš„套接字类型
+$ EAI_SYSTEM
+11 系统调用返回了 errno 错误
+$ EAI_BADHINTS
+12 无效æ示å‚æ•°
+$ EAI_PROTOCOL
+13 未知åè®®
+$ EAI_OVERFLOW
+14 å‚数缓冲溢出
+$ 0
+32766 æˆåŠŸ
+$ NL_MSGMAX
+32767 未知错误
diff --git a/lib/libc/powerpc/Makefile.inc b/lib/libc/powerpc/Makefile.inc
index 453726a..104f80c 100644
--- a/lib/libc/powerpc/Makefile.inc
+++ b/lib/libc/powerpc/Makefile.inc
@@ -1,5 +1,7 @@
# $FreeBSD$
+SRCS+= __vdso_gettc.c
+
# Long double is 64-bits
MDSRCS+=machdep_ldisd.c
SYM_MAPS+=${.CURDIR}/powerpc/Symbol.map
diff --git a/lib/libc/powerpc/sys/__vdso_gettc.c b/lib/libc/powerpc/sys/__vdso_gettc.c
new file mode 100644
index 0000000..b99bbc4
--- /dev/null
+++ b/lib/libc/powerpc/sys/__vdso_gettc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (ENOSYS);
+}
diff --git a/lib/libc/powerpc64/Makefile.inc b/lib/libc/powerpc64/Makefile.inc
index e4ccbb9..a30779d 100644
--- a/lib/libc/powerpc64/Makefile.inc
+++ b/lib/libc/powerpc64/Makefile.inc
@@ -1,5 +1,7 @@
# $FreeBSD$
+SRCS+= __vdso_gettc.c
+
# Long double is 64-bits
MDSRCS+=machdep_ldisd.c
SYM_MAPS+=${.CURDIR}/powerpc64/Symbol.map
diff --git a/lib/libc/powerpc64/sys/__vdso_gettc.c b/lib/libc/powerpc64/sys/__vdso_gettc.c
new file mode 100644
index 0000000..b99bbc4
--- /dev/null
+++ b/lib/libc/powerpc64/sys/__vdso_gettc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (ENOSYS);
+}
diff --git a/lib/libc/quad/Makefile.inc b/lib/libc/quad/Makefile.inc
index 016fa34..9cef22e 100644
--- a/lib/libc/quad/Makefile.inc
+++ b/lib/libc/quad/Makefile.inc
@@ -8,6 +8,10 @@
SRCS+= cmpdi2.c divdi3.c moddi3.c qdivrem.c ucmpdi2.c udivdi3.c umoddi3.c
+.elif ${LIBC_ARCH} == "arm" && ${MK_ARM_EABI} != "no"
+
+SRCS+= adddi3.c anddi3.c floatunsdidf.c iordi3.c lshldi3.c notdi2.c \
+ qdivrem.c subdi3.c xordi3.c
.else
SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c fixdfdi.c \
diff --git a/lib/libc/sparc64/Makefile.inc b/lib/libc/sparc64/Makefile.inc
index 76cc8b9..84a0e06 100644
--- a/lib/libc/sparc64/Makefile.inc
+++ b/lib/libc/sparc64/Makefile.inc
@@ -5,6 +5,8 @@
.include "fpu/Makefile.inc"
+SRCS+= __vdso_gettc.c
+
# Long double is quad precision
GDTOASRCS+=strtorQ.c
MDSRCS+=machdep_ldisQ.c
diff --git a/lib/libc/sparc64/sys/__vdso_gettc.c b/lib/libc/sparc64/sys/__vdso_gettc.c
new file mode 100644
index 0000000..b99bbc4
--- /dev/null
+++ b/lib/libc/sparc64/sys/__vdso_gettc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (ENOSYS);
+}
diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc
index 6570051..bc3b9e5 100644
--- a/lib/libc/stdio/Makefile.inc
+++ b/lib/libc/stdio/Makefile.inc
@@ -8,7 +8,8 @@ SRCS+= _flock_stub.c asprintf.c clrerr.c dprintf.c \
fclose.c fcloseall.c fdopen.c \
feof.c ferror.c fflush.c fgetc.c fgetln.c fgetpos.c fgets.c fgetwc.c \
fgetwln.c fgetws.c \
- fileno.c findfp.c flags.c fopen.c fprintf.c fpurge.c fputc.c fputs.c \
+ fileno.c findfp.c flags.c fmemopen.c fopen.c fprintf.c fpurge.c \
+ fputc.c fputs.c \
fputwc.c fputws.c fread.c freopen.c fscanf.c fseek.c fsetpos.c \
ftell.c funopen.c fvwrite.c fwalk.c fwide.c fwprintf.c fwscanf.c \
fwrite.c getc.c getchar.c getdelim.c getline.c \
@@ -48,7 +49,7 @@ MLINKS+=ferror.3 ferror_unlocked.3 \
MLINKS+=fflush.3 fpurge.3
MLINKS+=fgets.3 gets.3
MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3
-MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3
+MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3
MLINKS+=fputs.3 puts.3
MLINKS+=fread.3 fwrite.3
MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \
diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map
index cafb0c6..b78de5a 100644
--- a/lib/libc/stdio/Symbol.map
+++ b/lib/libc/stdio/Symbol.map
@@ -155,6 +155,7 @@ FBSD_1.3 {
getwchar_l;
putwc_l;
putwchar_l;
+ fmemopen;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c
index 26e2cd7..8fc90a4 100644
--- a/lib/libc/stdio/fdopen.c
+++ b/lib/libc/stdio/fdopen.c
@@ -80,6 +80,12 @@ fdopen(fd, mode)
if ((fp = __sfp()) == NULL)
return (NULL);
+
+ if ((oflags & O_CLOEXEC) && _fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+ fp->_flags = 0;
+ return (NULL);
+ }
+
fp->_flags = flags;
/*
* If opened for appending, but underlying descriptor does not have
diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c
index 0b6b075..e445fed 100644
--- a/lib/libc/stdio/flags.c
+++ b/lib/libc/stdio/flags.c
@@ -97,6 +97,7 @@ __sflags(mode, optr)
/* 'x' means exclusive (fail if the file exists) */
if (*mode == 'x') {
+ mode++;
if (m == O_RDONLY) {
errno = EINVAL;
return (0);
@@ -104,6 +105,10 @@ __sflags(mode, optr)
o |= O_EXCL;
}
+ /* set close-on-exec */
+ if (*mode == 'e')
+ o |= O_CLOEXEC;
+
*optr = m | o;
return (ret);
}
diff --git a/lib/libc/stdio/fmemopen.c b/lib/libc/stdio/fmemopen.c
new file mode 100644
index 0000000..581a91e
--- /dev/null
+++ b/lib/libc/stdio/fmemopen.c
@@ -0,0 +1,258 @@
+/*-
+ * Copyright (C) 2013 Pietro Cerutti <gahr@FreeBSD.org>
+ *
+ * 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 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 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "local.h"
+
+struct fmemopen_cookie
+{
+ char *buf; /* pointer to the memory region */
+ bool own; /* did we allocate the buffer ourselves? */
+ char bin; /* is this a binary buffer? */
+ size_t size; /* buffer length in bytes */
+ size_t len; /* data length in bytes */
+ size_t off; /* current offset into the buffer */
+};
+
+static int fmemopen_read(void *cookie, char *buf, int nbytes);
+static int fmemopen_write(void *cookie, const char *buf, int nbytes);
+static fpos_t fmemopen_seek(void *cookie, fpos_t offset, int whence);
+static int fmemopen_close(void *cookie);
+
+FILE *
+fmemopen(void * __restrict buf, size_t size, const char * __restrict mode)
+{
+ struct fmemopen_cookie *ck;
+ FILE *f;
+ int flags, rc;
+
+ /*
+ * Retrieve the flags as used by open(2) from the mode argument, and
+ * validate them.
+ */
+ rc = __sflags(mode, &flags);
+ if (rc == 0) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ /*
+ * There's no point in requiring an automatically allocated buffer
+ * in write-only mode.
+ */
+ if (!(flags & O_RDWR) && buf == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ ck = malloc(sizeof(struct fmemopen_cookie));
+ if (ck == NULL) {
+ return (NULL);
+ }
+
+ ck->off = 0;
+ ck->size = size;
+
+ /* Check whether we have to allocate the buffer ourselves. */
+ ck->own = ((ck->buf = buf) == NULL);
+ if (ck->own) {
+ ck->buf = malloc(size);
+ if (ck->buf == NULL) {
+ free(ck);
+ return (NULL);
+ }
+ }
+
+ /*
+ * POSIX distinguishes between w+ and r+, in that w+ is supposed to
+ * truncate the buffer.
+ */
+ if (ck->own || mode[0] == 'w') {
+ ck->buf[0] = '\0';
+ }
+
+ /* Check for binary mode. */
+ ck->bin = strchr(mode, 'b') != NULL;
+
+ /*
+ * The size of the current buffer contents is set depending on the
+ * mode:
+ *
+ * for append (text-mode), the position of the first NULL byte, or the
+ * size of the buffer if none is found
+ *
+ * for append (binary-mode), the size of the buffer
+ *
+ * for read, the size of the buffer
+ *
+ * for write, 0
+ */
+ switch (mode[0]) {
+ case 'a':
+ if (ck->bin) {
+ /*
+ * This isn't useful, since the buffer isn't allowed
+ * to grow.
+ */
+ ck->off = ck->len = size;
+ } else
+ ck->off = ck->len = strnlen(ck->buf, ck->size);
+ break;
+ case 'r':
+ ck->len = size;
+ break;
+ case 'w':
+ ck->len = 0;
+ break;
+ }
+
+ f = funopen(ck,
+ flags & O_WRONLY ? NULL : fmemopen_read,
+ flags & O_RDONLY ? NULL : fmemopen_write,
+ fmemopen_seek, fmemopen_close);
+
+ if (f == NULL) {
+ if (ck->own)
+ free(ck->buf);
+ free(ck);
+ return (NULL);
+ }
+
+ /*
+ * Turn off buffering, so a write past the end of the buffer
+ * correctly returns a short object count.
+ */
+ setvbuf(f, NULL, _IONBF, 0);
+
+ return (f);
+}
+
+static int
+fmemopen_read(void *cookie, char *buf, int nbytes)
+{
+ struct fmemopen_cookie *ck = cookie;
+
+ if (nbytes > ck->len - ck->off)
+ nbytes = ck->len - ck->off;
+
+ if (nbytes == 0)
+ return (0);
+
+ memcpy(buf, ck->buf + ck->off, nbytes);
+
+ ck->off += nbytes;
+
+ return (nbytes);
+}
+
+static int
+fmemopen_write(void *cookie, const char *buf, int nbytes)
+{
+ struct fmemopen_cookie *ck = cookie;
+
+ if (nbytes > ck->size - ck->off)
+ nbytes = ck->size - ck->off;
+
+ if (nbytes == 0)
+ return (0);
+
+ memcpy(ck->buf + ck->off, buf, nbytes);
+
+ ck->off += nbytes;
+
+ if (ck->off > ck->len)
+ ck->len = ck->off;
+
+ /*
+ * We append a NULL byte if all these conditions are met:
+ * - the buffer is not binary
+ * - the buffer is not full
+ * - the data just written doesn't already end with a NULL byte
+ */
+ if (!ck->bin && ck->off < ck->size && ck->buf[ck->off - 1] != '\0')
+ ck->buf[ck->off] = '\0';
+
+ return (nbytes);
+}
+
+static fpos_t
+fmemopen_seek(void *cookie, fpos_t offset, int whence)
+{
+ struct fmemopen_cookie *ck = cookie;
+
+
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > ck->size) {
+ errno = EINVAL;
+ return (-1);
+ }
+ ck->off = offset;
+ break;
+
+ case SEEK_CUR:
+ if (ck->off + offset > ck->size) {
+ errno = EINVAL;
+ return (-1);
+ }
+ ck->off += offset;
+ break;
+
+ case SEEK_END:
+ if (offset > 0 || -offset > ck->len) {
+ errno = EINVAL;
+ return (-1);
+ }
+ ck->off = ck->len + offset;
+ break;
+
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
+
+ return (ck->off);
+}
+
+static int
+fmemopen_close(void *cookie)
+{
+ struct fmemopen_cookie *ck = cookie;
+
+ if (ck->own)
+ free(ck->buf);
+
+ free(ck);
+
+ return (0);
+}
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index 08438e7..a07be38 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -32,13 +32,14 @@
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd October 17, 2011
+.Dd January 30, 2013
.Dt FOPEN 3
.Os
.Sh NAME
.Nm fopen ,
.Nm fdopen ,
-.Nm freopen
+.Nm freopen ,
+.Nm fmemopen
.Nd stream open functions
.Sh LIBRARY
.Lb libc
@@ -50,6 +51,8 @@
.Fn fdopen "int fildes" "const char *mode"
.Ft FILE *
.Fn freopen "const char *path" "const char *mode" "FILE *stream"
+.Ft FILE *
+.Fn fmemopen "void *restrict *buf" "size_t size" "const char * restrict mode"
.Sh DESCRIPTION
The
.Fn fopen
@@ -97,6 +100,14 @@ or
causes the
.Fn fopen
call to fail if the file already exists.
+An optional
+.Dq Li e
+following the above
+causes the
+.Fn fopen
+call to set the
+.Dv FD_CLOEXEC
+flag on the underlying file descriptor.
.Pp
The
.Fa mode
@@ -107,7 +118,9 @@ after either the
or the first letter.
This is strictly for compatibility with
.St -isoC
-and has no effect; the ``b'' is ignored.
+and has effect only for
+.Fn fmemopen
+; otherwise the ``b'' is ignored.
.Pp
Any created files will have mode
.Do Dv S_IRUSR
@@ -144,6 +157,11 @@ of the stream must be compatible with the mode of the file descriptor.
The
.Dq Li x
mode option is ignored.
+If the
+.Dq Li e
+mode option is present, the
+.Dv FD_CLOEXEC
+flag is set, otherwise it remains unchanged.
When the stream is closed via
.Xr fclose 3 ,
.Fa fildes
@@ -189,6 +207,34 @@ standard text stream
.Dv ( stderr , stdin ,
or
.Dv stdout ) .
+.Pp
+The
+.Fn fmemopen
+function
+associates the buffer given by the
+.Fa buf
+and
+.Fa size
+arguments with a stream.
+The
+.Fa buf
+argument is either a null pointer or point to a buffer that
+is at least
+.Fa size
+bytes long.
+If a null pointer is specified as the
+.Fa buf
+argument,
+.Fn fmemopen
+allocates
+.Fa size
+bytes of memory. This buffer is automatically freed when the
+stream is closed. Buffers can be opened in text-mode (default) or binary-mode
+(if ``b'' is present in the second or third position of the
+.Fa mode
+argument). Buffers opened in text-mode make sure that writes are terminated with
+a NULL byte, if the last write hasn't filled up the whole buffer. Buffers
+opened in binary-mode never append a NULL byte.
.Sh RETURN VALUES
Upon successful completion
.Fn fopen ,
@@ -212,16 +258,18 @@ argument
to
.Fn fopen ,
.Fn fdopen ,
+.Fn freopen ,
or
-.Fn freopen
+.Fn fmemopen
was invalid.
.El
.Pp
The
.Fn fopen ,
-.Fn fdopen
-and
+.Fn fdopen ,
.Fn freopen
+and
+.Fn fmemopen
functions
may also fail and set
.Va errno
@@ -277,3 +325,14 @@ The
function
conforms to
.St -p1003.1-88 .
+The
+.Dq Li e
+mode option does not conform to any standard
+but is also supported by glibc.
+The
+.Fn fmemopen
+function
+conforms to
+.St -p1003.1-2008 .
+The ``b'' mode does not conform to any standard
+but is also supported by glibc.
diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c
index be7bc8a..8d1ec91 100644
--- a/lib/libc/stdio/freopen.c
+++ b/lib/libc/stdio/freopen.c
@@ -118,6 +118,8 @@ freopen(file, mode, fp)
(void) ftruncate(fp->_file, (off_t)0);
if (!(oflags & O_APPEND))
(void) _sseek(fp, (fpos_t)0, SEEK_SET);
+ if (oflags & O_CLOEXEC)
+ (void) _fcntl(fp->_file, F_SETFD, FD_CLOEXEC);
f = fp->_file;
isopen = 0;
wantfd = -1;
@@ -194,7 +196,8 @@ finish:
* assume stderr is always fd STDERR_FILENO, even if being freopen'd.
*/
if (wantfd >= 0) {
- if (_dup2(f, wantfd) >= 0) {
+ if ((oflags & O_CLOEXEC ? _fcntl(f, F_DUP2FD_CLOEXEC, wantfd) :
+ _dup2(f, wantfd)) >= 0) {
(void)_close(f);
f = wantfd;
} else
diff --git a/lib/libc/stdio/getline.3 b/lib/libc/stdio/getline.3
index 6061bfc..2161999 100644
--- a/lib/libc/stdio/getline.3
+++ b/lib/libc/stdio/getline.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 30, 2010
+.Dd November 30, 2012
.Dt GETLINE 3
.Os
.Sh NAME
@@ -76,7 +76,7 @@ The
.Fn getdelim
and
.Fn getline
-functions return the number of characters written, excluding the
+functions return the number of characters stored in the buffer, excluding the
terminating
.Dv NUL
character.
diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3
index 0d9339e..05c30dc 100644
--- a/lib/libc/stdio/printf.3
+++ b/lib/libc/stdio/printf.3
@@ -267,7 +267,7 @@ number produced by a signed conversion.
A
.Cm +
overrides a space if both are used.
-.It Sq Cm '
+.It So "'" Sc (apostrophe)
Decimal conversions
.Cm ( d , u ,
or
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index df4ef42..a35ed5d 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -217,5 +217,6 @@ MLINKS+=timer_settime.2 timer_getoverrun.2 timer_settime.2 timer_gettime.2
MLINKS+=truncate.2 ftruncate.2
MLINKS+=unlink.2 unlinkat.2
MLINKS+=utimes.2 futimes.2 utimes.2 futimesat.2 utimes.2 lutimes.2
-MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2
+MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2 \
+ wait.2 waitid.2 wait.2 wait6.2
MLINKS+=write.2 pwrite.2 write.2 pwritev.2 write.2 writev.2
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index 008b8da..babae30 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -384,6 +384,7 @@ FBSD_1.3 {
ffclock_getestimate;
ffclock_setestimate;
posix_fadvise;
+ wait6;
};
FBSDprivate_1.0 {
@@ -1019,6 +1020,8 @@ FBSDprivate_1.0 {
__sys_vadvise;
_wait4;
__sys_wait4;
+ _wait6;
+ __sys_wait6;
_write;
__sys_write;
_writev;
diff --git a/lib/libc/sys/__vdso_gettimeofday.c b/lib/libc/sys/__vdso_gettimeofday.c
index 32abb69..a305173 100644
--- a/lib/libc/sys/__vdso_gettimeofday.c
+++ b/lib/libc/sys/__vdso_gettimeofday.c
@@ -79,6 +79,7 @@ binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs)
static struct vdso_timekeep *tk;
+#pragma weak __vdso_gettimeofday
int
__vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
{
@@ -88,7 +89,7 @@ __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
if (tz != NULL)
return (ENOSYS);
if (tk == NULL) {
- error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk));
+ error = __vdso_gettimekeep(&tk);
if (error != 0 || tk == NULL)
return (ENOSYS);
}
@@ -101,6 +102,7 @@ __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
return (0);
}
+#pragma weak __vdso_clock_gettime
int
__vdso_clock_gettime(clockid_t clock_id, struct timespec *ts)
{
diff --git a/lib/libc/sys/bind.2 b/lib/libc/sys/bind.2
index fecc5fa..896b005 100644
--- a/lib/libc/sys/bind.2
+++ b/lib/libc/sys/bind.2
@@ -94,6 +94,8 @@ is not a socket.
The specified address is not available from the local machine.
.It Bq Er EADDRINUSE
The specified address is already in use.
+.It Bq Er EAFNOSUPPORT
+Addresses in the specified address family cannot be used with this socket.
.It Bq Er EACCES
The requested address is protected, and the current user
has inadequate permission to access it.
diff --git a/lib/libc/sys/chroot.2 b/lib/libc/sys/chroot.2
index 060d064..36d0364 100644
--- a/lib/libc/sys/chroot.2
+++ b/lib/libc/sys/chroot.2
@@ -92,12 +92,8 @@ system call.
Any other value for
.Ql kern.chroot_allow_open_directories
will bypass the check for open directories
-.Pp
-Upon successful completion, a value of 0 is returned.
-Otherwise,
-a value of -1 is returned and
-.Va errno
-is set to indicate an error.
+.Sh RETURN VALUES
+.Rv -std
.Sh ERRORS
The
.Fn chroot
diff --git a/lib/libc/sys/getpeername.2 b/lib/libc/sys/getpeername.2
index 9037119..255c7a0 100644
--- a/lib/libc/sys/getpeername.2
+++ b/lib/libc/sys/getpeername.2
@@ -67,6 +67,10 @@ The argument
is not a valid descriptor.
.It Bq Er ECONNRESET
The connection has been reset by the peer.
+.It Bq Er EINVAL
+The value of the
+.Fa namelen
+argument is not valid.
.It Bq Er ENOTSOCK
The argument
.Fa s
diff --git a/lib/libc/sys/getsockname.2 b/lib/libc/sys/getsockname.2
index f1537c7..1de0257 100644
--- a/lib/libc/sys/getsockname.2
+++ b/lib/libc/sys/getsockname.2
@@ -66,6 +66,10 @@ The argument
is not a valid descriptor.
.It Bq Er ECONNRESET
The connection has been reset by the peer.
+.It Bq Er EINVAL
+The value of the
+.Fa namelen
+argument is not valid.
.It Bq Er ENOTSOCK
The argument
.Fa s
diff --git a/lib/libc/sys/gettimeofday.c b/lib/libc/sys/gettimeofday.c
index 4cc87e1..5b12523 100644
--- a/lib/libc/sys/gettimeofday.c
+++ b/lib/libc/sys/gettimeofday.c
@@ -41,10 +41,7 @@ __gettimeofday(struct timeval *tv, struct timezone *tz)
{
int error;
- if (__vdso_gettimeofday != NULL && __vdso_gettc != NULL)
- error = __vdso_gettimeofday(tv, tz);
- else
- error = ENOSYS;
+ error = __vdso_gettimeofday(tv, tz);
if (error == ENOSYS)
error = __sys_gettimeofday(tv, tz);
return (error);
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
index 63a662f..6ae7914 100644
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 15, 2012
+.Dd January 21, 2013
.Dt KQUEUE 2
.Os
.Sh NAME
@@ -417,7 +417,9 @@ and
facilities, and has a lower precedence.
The filter will record
all attempts to deliver a signal to a process, even if the signal has
-been marked as SIG_IGN.
+been marked as SIG_IGN, except for the
+.Dv SIGCHLD
+signal, which, if ignored, won't be recorded by the filter.
Event notification happens after normal
signal delivery processing.
.Va data
diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2
index ed9c15a..0e5fef8 100644
--- a/lib/libc/sys/mlock.2
+++ b/lib/libc/sys/mlock.2
@@ -28,7 +28,7 @@
.\" @(#)mlock.2 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd July 27, 2010
+.Dd December 25, 2012
.Dt MLOCK 2
.Os
.Sh NAME
@@ -94,12 +94,15 @@ limited in how much they can lock down.
A single process can
.Fn mlock
the minimum of
-a system-wide ``wired pages'' limit and
-the per-process
+a system-wide ``wired pages'' limit
+.Va vm.max_wired
+and the per-process
.Li RLIMIT_MEMLOCK
resource limit.
.Pp
-These calls are only available to the super-user.
+If
+.Va security.bsd.unprivileged_mlock
+is set to 0 these calls are only available to the super-user.
.Sh RETURN VALUES
.Rv -std
.Pp
@@ -112,7 +115,8 @@ system call
will fail if:
.Bl -tag -width Er
.It Bq Er EPERM
-The caller is not the super-user.
+.Va security.bsd.unprivileged_mlock
+is set to 0 and the caller is not the super-user.
.It Bq Er EINVAL
The address given is not page aligned or the length is negative.
.It Bq Er EAGAIN
@@ -129,7 +133,8 @@ system call
will fail if:
.Bl -tag -width Er
.It Bq Er EPERM
-The caller is not the super-user.
+.Va security.bsd.unprivileged_mlock
+is set to 0 and the caller is not the super-user.
.It Bq Er EINVAL
The address given is not page aligned or the length is negative.
.It Bq Er ENOMEM
diff --git a/lib/libc/sys/mlockall.2 b/lib/libc/sys/mlockall.2
index 54ae23e..23c644a 100644
--- a/lib/libc/sys/mlockall.2
+++ b/lib/libc/sys/mlockall.2
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 27, 2010
+.Dd December 25, 2012
.Dt MLOCKALL 2
.Os
.Sh NAME
@@ -68,11 +68,22 @@ Since physical memory is a potentially scarce resource, processes are
limited in how much they can lock down.
A single process can lock the minimum of a system-wide
.Dq wired pages
-limit and the per-process
+limit
+.Va vm.max_wired
+and the per-process
.Dv RLIMIT_MEMLOCK
resource limit.
.Pp
-These calls are only available to the super-user.
+If
+.Va security.bsd.unprivileged_mlock
+is set to 0 these calls are only available to the super-user.
+If
+.Va vm.old_mlock
+is set to 1 the per-process
+.Dv RLIMIT_MEMLOCK
+resource limit will not be applied for
+.Fn mlockall
+calls.
.Pp
The
.Fn munlockall
diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index 041f9dc..41a6c64 100644
--- a/lib/libc/sys/open.2
+++ b/lib/libc/sys/open.2
@@ -28,7 +28,7 @@
.\" @(#)open.2 8.2 (Berkeley) 11/16/93
.\" $FreeBSD$
.\"
-.Dd March 25, 2011
+.Dd February 7, 2013
.Dt OPEN 2
.Os
.Sh NAME
@@ -244,6 +244,17 @@ It returns \-1 on failure.
The file pointer used to mark the current position within the
file is set to the beginning of the file.
.Pp
+If a sleeping open of a device node from
+.Xr devfs 5
+is interrupted by a signal, the call always fails with
+.Er EINTR ,
+even if the
+.Dv SA_RESTART
+flag is set for the signal.
+A sleeping open of a fifo (see
+.Xr mkfifo 2 )
+is restarted as normal.
+.Pp
When a new file is created it is given the group of the directory
which contains it.
.Pp
diff --git a/lib/libc/sys/posix_fadvise.2 b/lib/libc/sys/posix_fadvise.2
index f303f42..7a9a648 100644
--- a/lib/libc/sys/posix_fadvise.2
+++ b/lib/libc/sys/posix_fadvise.2
@@ -134,4 +134,4 @@ interface conforms to
The
.Fn posix_fadvise
system call first appeared in
-.Fx 10.0 .
+.Fx 9.1 .
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
index 9dda8ee..90c4544 100644
--- a/lib/libc/sys/ptrace.2
+++ b/lib/libc/sys/ptrace.2
@@ -2,7 +2,7 @@
.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
.\"
.\" This file is in the public domain.
-.Dd February 19, 2012
+.Dd February 7, 2013
.Dt PTRACE 2
.Os
.Sh NAME
@@ -100,6 +100,16 @@ or any of the routines built on it
it will stop before executing the first instruction of the new image.
Also, any setuid or setgid bits on the executable being executed will
be ignored.
+If the child was created by
+.Xr vfork 2
+system call or
+.Xr rfork(2)
+call with the
+.Dv RFMEM
+flag specified, the debugging events are reported to the parent
+only after the
+.Xr execve 2
+is executed.
.It Dv PT_READ_I , Dv PT_READ_D
These requests read a single
.Vt int
diff --git a/lib/libc/sys/rtprio.2 b/lib/libc/sys/rtprio.2
index ac78b50..f30ed22 100644
--- a/lib/libc/sys/rtprio.2
+++ b/lib/libc/sys/rtprio.2
@@ -145,13 +145,21 @@ Higher real/idle priority threads
preempt lower real/idle priority threads.
Threads of equal real/idle priority are run round-robin.
.Sh RETURN VALUES
-.Rv -std rtprio
+.Rv -std rtprio rtprio_thread
.Sh ERRORS
The
.Fn rtprio
-system call
+and
+.Fn rtprio_thread
+system calls
will fail if:
.Bl -tag -width Er
+.It Bq Er EFAULT
+The rtp pointer passed to
+.Fn rtprio
+or
+.Fn rtprio_thread
+was invalid.
.It Bq Er EINVAL
The specified
.Fa prio
diff --git a/lib/libc/sys/sendfile.2 b/lib/libc/sys/sendfile.2
index 9d1fba5..0e7dbe3 100644
--- a/lib/libc/sys/sendfile.2
+++ b/lib/libc/sys/sendfile.2
@@ -265,6 +265,8 @@ is negative.
.It Bq Er EIO
An error occurred while reading from
.Fa fd .
+.It Bq Er ENOBUFS
+The system was unable to allocate an internal buffer.
.It Bq Er ENOTCONN
The
.Fa s
diff --git a/lib/libc/sys/socket.2 b/lib/libc/sys/socket.2
index dae33d0..24e4293 100644
--- a/lib/libc/sys/socket.2
+++ b/lib/libc/sys/socket.2
@@ -28,7 +28,7 @@
.\" From: @(#)socket.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd January 5, 2009
+.Dd December 7, 2012
.Dt SOCKET 2
.Os
.Sh NAME
@@ -248,21 +248,26 @@ The
.Fn socket
system call fails if:
.Bl -tag -width Er
-.It Bq Er EPROTONOSUPPORT
-The protocol type or the specified protocol is not supported
-within this domain.
+.It Bq Er EACCES
+Permission to create a socket of the specified type and/or protocol
+is denied.
+.It Bq Er EAFNOSUPPORT
+The address family (domain) is not supported or the
+specified domain is not supported by this protocol family.
.It Bq Er EMFILE
The per-process descriptor table is full.
.It Bq Er ENFILE
The system file table is full.
-.It Bq Er EACCES
-Permission to create a socket of the specified type and/or protocol
-is denied.
.It Bq Er ENOBUFS
Insufficient buffer space is available.
The socket cannot be created until sufficient resources are freed.
.It Bq Er EPERM
User has insufficient privileges to carry out the requested operation.
+.It Bq Er EPROTONOSUPPORT
+The protocol type or the specified protocol is not supported
+within this domain.
+.It Bq Er EPROTOTYPE
+The socket type is not supported by the protocol.
.El
.Sh SEE ALSO
.Xr accept 2 ,
diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2
index 71bd529..0c494bb 100644
--- a/lib/libc/sys/wait.2
+++ b/lib/libc/sys/wait.2
@@ -28,15 +28,17 @@
.\" @(#)wait.2 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd November 12, 2005
+.Dd November 10, 2012
.Dt WAIT 2
.Os
.Sh NAME
.Nm wait ,
+.Nm waitid ,
.Nm waitpid ,
+.Nm wait3 ,
.Nm wait4 ,
-.Nm wait3
-.Nd wait for process termination
+.Nm wait6
+.Nd wait for processes to change status
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -46,12 +48,17 @@
.Fn wait "int *status"
.Ft pid_t
.Fn waitpid "pid_t wpid" "int *status" "int options"
+.In sys/signal.h
+.Ft int
+.Fn waitid "idtype_t idtype" "id_t id" "siginfo_t *info" "int options"
.In sys/time.h
.In sys/resource.h
.Ft pid_t
.Fn wait3 "int *status" "int options" "struct rusage *rusage"
.Ft pid_t
.Fn wait4 "pid_t wpid" "int *status" "int options" "struct rusage *rusage"
+.Ft pid_t
+.Fn wait6 "idtype_t idtype" "id_t id" "int *status" "int options" "struct __wrusage *wrusage" "siginfo_t *infop"
.Sh DESCRIPTION
The
.Fn wait
@@ -86,28 +93,172 @@ system call provides a more general interface for programs
that need to wait for certain child processes,
that need resource utilization statistics accumulated by child processes,
or that require options.
-The other wait functions are implemented using
-.Fn wait4 .
.Pp
+The broadest interface of all functions in this family is
+.Fn wait6
+which is otherwise very much like
+.Fn wait4
+but with a few very important distinctions.
+To wait for exited processes, the option flag
+.Dv WEXITED
+need to be explicitly specified.
+This allows for waiting for processes which have experienced other
+status changes without having to handle also the exit status from
+the terminated processes.
+Instead of the traditional
+.Dv rusage
+argument, a pointer to a new structure
+.Bd -literal
+struct __wrusage {
+ struct rusage wru_self;
+ struct rusage wru_children;
+};
+.Ed
+can be passed.
+This allows the calling process to collect resource usage statistics
+from both its own child process as well as from its grand children.
+When no resource usage statistics are needed this pointer can be
+.Dv NULL .
+The last argument
+.Fa infop
+must be either
+.Dv NULL
+or a pointer to a
+.Fa siginfo_t
+structure.
+When specified, the structure is filled the same as for
+.Dv SIGNCHLD
+signal, delivered at the process state change.
+.br
+The process, which state is queried, is specified by two arguments
+.Fa idtype
+and
+.Fa id .
+The separate
+.Fa idtype
+and
+.Fa id
+arguments allows to support many other types of
+IDs as well in addition to PID and PGID.
+.Bl -bullet -offset indent
+.It
+If
+.Fa idtype
+is
+.Dv P_PID ,
+.Fn waitid
+and
+.Fn wait6
+wait for the child process with a process ID equal to
+.Dv (pid_t)id .
+.It
+If
+.Fa idtype
+is
+.Dv P_PGID ,
+.Fn waitid
+and
+.Fn wait6
+wait for the child process with a process group ID equal to
+.Dv (pid_t)id .
+.It
+If
+.Fa idtype
+is
+.Dv P_ALL ,
+.Fn waitid
+and
+.Fn wait6
+wait for any child process and the
+.Dv id
+is ignored.
+.It
+If
+.Fa idtype
+is
+.Dv P_PID
+or
+.Dv P_PGID
+and the
+.Dv id
+is zero,
+.Fn waitid
+and
+.Fn wait6
+wait for any child process in the same process group as the caller.
+.El
+.Pp
+Non-standard specifiers for the process to wait for, supported by this
+implementation of
+.Fn waitid
+and
+.Fn wait6 ,
+are:
+.Bl -bullet -offset indent
+.It
The
+.Fa idtype
+value
+.Dv P_UID
+waits for processes which effective UID is equal to
+.Dv (uid_t)id .
+.It
+The
+.Fa idtype
+value
+.Dv P_GID
+waits for processes which effective GID is equal to
+.Dv (gid_t)id .
+.It
+The
+.Fa idtype
+value
+.Dv P_SID
+waits for processes which session ID is equal to
+.Dv id .
+In case the child process started its own new session,
+SID will be the same as its own PID.
+Otherwise the SID of a child process will match the caller's SID.
+.It
+The
+.Fa idtype
+value
+.Dv P_JAILID
+waits for processes within a jail which jail identifier is equal
+to
+.Dv id .
+.El
+.Pp
+For
+.Fn wait ,
+.Fn wait3 ,
+and
+.Fn wait4
+functions, the single
.Fa wpid
argument specifies the set of child processes for which to wait.
+.Bl -bullet -offset indent
+.It
If
.Fa wpid
is -1, the call waits for any child process.
+.It
If
.Fa wpid
is 0,
the call waits for any child process in the process group of the caller.
+.It
If
.Fa wpid
is greater than zero, the call waits for the process with process id
.Fa wpid .
+.It
If
.Fa wpid
is less than -1, the call waits for any process whose process group id
equals the absolute value of
.Fa wpid .
+.El
.Pp
The
.Fa status
@@ -116,41 +267,102 @@ argument is defined below.
The
.Fa options
argument contains the bitwise OR of any of the following options.
-The
-.Dv WCONTINUED
-option indicates that children of the current process that
+.Bl -tag -width Ds
+.It Dv WCONTINUED
+indicates that children of the current process that
have continued from a job control stop, by receiving a
.Dv SIGCONT
signal, should also have their status reported.
-The
-.Dv WNOHANG
-option
-is used to indicate that the call should not block if
-there are no processes that wish to report status.
-If the
-.Dv WUNTRACED
-option is set,
-children of the current process that are stopped
+.It Dv WNOHANG
+is used to indicate that the call should not block when
+there are no processes wishing to report status.
+.It Dv WUNTRACED
+indicates that children of the current process which are stopped
due to a
.Dv SIGTTIN , SIGTTOU , SIGTSTP ,
or
.Dv SIGSTOP
-signal also have their status reported.
-The
-.Dv WSTOPPED
-option is an alias for
+signal shall have their status reported.
+.It Dv WSTOPPED
+is an alias for
.Dv WUNTRACED .
-The
-.Dv WNOWAIT
-option keeps the process whose status is returned in a waitable state.
+.It Dv WTRAPPED
+allows waiting for processes which have trapped or reached a breakpoint.
+.It Dv WEXITED
+indicates that the caller is wants to receive status reports from
+terminated processes.
+This flag is implicitly set for the functions
+.Fn wait ,
+.Fn waitpid ,
+.Fn wait3 ,
+and
+.Fn wait4 .
+.br
+For the
+.Fn waitid
+and
+.Fn wait6
+functions, the flag has to be explicitly included in the
+.Fa options ,
+if status reports from terminated processes are expected.
+.It Dv WNOWAIT
+keeps the process whose status is returned in a waitable state.
The process may be waited for again after this call completes.
+.El
+.sp
+For the
+.Fn waitid
+and
+.Fn wait6
+functions, at least one of the options
+.Dv WEXITED ,
+.Dv WUNTRACED ,
+.Dv WSTOPPED ,
+.Dv WTRAPPED ,
+or
+.Dv WCONTINUED
+must be specified.
+Otherwise there will be no events for the call to report.
+To avoid hanging indefinitely in such a case these functions
+return -1 with
+.Dv errno
+set to
+.Dv EINVAL .
.Pp
If
.Fa rusage
-is non-zero, a summary of the resources used by the terminated
-process and all its
-children is returned (this information is currently not available
-for stopped or continued processes).
+is non-NULL, a summary of the resources used by the terminated
+process and all its children is returned.
+.Pp
+If
+.Fa wrusage
+argument is non-NULL, a resource usage statistics
+from both its own child process as well as from its grand children
+is returned.
+.Pp
+If
+.Fa infop
+is non-NULL, it must point to a
+.Dv siginfo_t
+structure which is filled on return such that the
+.Dv si_signo
+field is always
+.Dv SIGCHLD
+and the field
+.Dv si_pid
+if be non-zero, if there is a status change to report.
+If there are no status changes to report and WNOHANG is applied,
+both of these fields are returned zero.
+When using the
+.Fn waitid
+function with the
+.Dv WNOHANG
+option set, checking these fields is the only way to know whether
+there were any status changes to report, because the return value
+from
+.Fn waitid
+is be zero as it is for any successful return from
+.Fn waitid .
.Pp
When the
.Dv WNOHANG
@@ -175,6 +387,20 @@ call is the same as
with a
.Fa wpid
value of -1.
+The
+.Fn wait6
+call, with the bits
+.Dv WEXITED
+and
+.Dv WTRAPPED
+set in the
+.Fa options
+and with
+.Fa infop
+set to
+.Dv NULL ,
+is similar to
+.Fn wait4 .
.Pp
The following macros may be used to test the manner of exit of the process.
One of the first four macros will evaluate to a non-zero (true) value:
@@ -284,6 +510,7 @@ is returned and
is set to indicate the error.
.Pp
If
+.Fn wait6 ,
.Fn wait4 ,
.Fn wait3 ,
or
@@ -306,6 +533,18 @@ a value of -1
is returned and
.Va errno
is set to indicate the error.
+.Pp
+If
+.Fn waitid
+returns because one or more processes have a state change to report,
+0 is returned.
+To indicate an error, -1 will be returned and
+.Dv errno
+set to an appropriate value.
+If
+.Dv WNOHANG
+was used, 0 can be returned indicating no error, but no processes
+may have changed state either, if si_signo and/or si_pid are zero.
.Sh ERRORS
The
.Fn wait
@@ -335,6 +574,14 @@ The call was interrupted by a caught signal,
or the signal did not have the
.Dv SA_RESTART
flag set.
+.It Bq Er EINVAL
+An invalid value was specified for
+.Fa options ,
+or
+.Fa idtype
+and
+.Fa id
+do not specify a valid set of processes.
.El
.Sh SEE ALSO
.Xr _exit 2 ,
@@ -344,11 +591,13 @@ flag set.
.Xr siginfo 3
.Sh STANDARDS
The
-.Fn wait
+.Fn wait ,
+.Fn waitpid ,
and
-.Fn waitpid
+.Fn waitid
functions are defined by POSIX;
-.Fn wait4
+.Fn wait6 ,
+.Fn wait4 ,
and
.Fn wait3
are not specified by POSIX.
OpenPOWER on IntegriCloud