diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2013-09-05 20:18:59 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2013-09-05 20:18:59 +0000 |
commit | d1d015864103b253b3fcb2f72a0da5b0cfeb31b6 (patch) | |
tree | 22b131dceb13c3df96da594fbaadb693504797c7 /lib/libc | |
parent | 12d4083451fc39b3e831d4ea0bfa67d3b32cfb54 (diff) | |
parent | b6f49c23a36f329cbf1e7f28078e17fd87f0e245 (diff) | |
download | src-test2-d1d015864103b253b3fcb2f72a0da5b0cfeb31b6.tar.gz src-test2-d1d015864103b253b3fcb2f72a0da5b0cfeb31b6.zip |
Notes
Diffstat (limited to 'lib/libc')
372 files changed, 2729 insertions, 1092 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile index ad98d41f802e..ba4dd0ae16c3 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -23,6 +23,7 @@ LIBC_ARCH=${MACHINE_CPUARCH} # to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs. LIB=c SHLIB_MAJOR= 7 +SHLIB_LDSCRIPT=libc.ldscript WARNS?= 2 CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include CFLAGS+=-I${.CURDIR}/${LIBC_ARCH} @@ -99,6 +100,7 @@ NOASM= CFLAGS+= -DYP .include "${.CURDIR}/yp/Makefile.inc" .endif +.include "${.CURDIR}/capability/Makefile.inc" .if ${MK_HESIOD} != "no" CFLAGS+= -DHESIOD .endif diff --git a/lib/libc/amd64/gen/getcontextx.c b/lib/libc/amd64/gen/getcontextx.c index 7412560b80dd..749bfbda0c51 100644 --- a/lib/libc/amd64/gen/getcontextx.c +++ b/lib/libc/amd64/gen/getcontextx.c @@ -57,14 +57,12 @@ __getcontextx_size(void) } int -__fillcontextx(char *ctx) +__fillcontextx2(char *ctx) { struct amd64_get_xfpustate xfpu; ucontext_t *ucp; ucp = (ucontext_t *)ctx; - if (getcontext(ucp) == -1) - return (-1); if (xstate_sz != 0) { xfpu.addr = (char *)(ucp + 1); xfpu.len = xstate_sz; @@ -80,6 +78,18 @@ __fillcontextx(char *ctx) return (0); } +int +__fillcontextx(char *ctx) +{ + ucontext_t *ucp; + + ucp = (ucontext_t *)ctx; + if (getcontext(ucp) == -1) + return (-1); + __fillcontextx2(ctx); + return (0); +} + __weak_reference(__getcontextx, getcontextx); ucontext_t * diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S index a451491658d7..73b53641ad73 100644 --- a/lib/libc/amd64/sys/setlogin.S +++ b/lib/libc/amd64/sys/setlogin.S @@ -48,12 +48,7 @@ ENTRY(__sys_setlogin) mov $SYS_setlogin,%rax KERNCALL jb HIDENAME(cerror) -#ifdef PIC - movq PIC_GOT(CNAME(_logname_valid)),%rdx - movl $0,(%rdx) -#else movl $0,CNAME(_logname_valid)(%rip) -#endif ret /* setlogin(name) */ END(__sys_setlogin) diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc index ec36d4508216..cfc8a46575f3 100644 --- a/lib/libc/arm/gen/Makefile.inc +++ b/lib/libc/arm/gen/Makefile.inc @@ -3,7 +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 flt_rounds.c + __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \ + arm_initfini.c .if ${MK_ARM_EABI} == "no" SRCS+= divsi3.S diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S index 6594afba0744..b475f1eb4dfd 100644 --- a/lib/libc/arm/gen/_setjmp.S +++ b/lib/libc/arm/gen/_setjmp.S @@ -1,4 +1,4 @@ -/* $NetBSD: _setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */ +/* $NetBSD: _setjmp.S,v 1.12 2013/04/19 13:45:45 matt Exp $ */ /* * Copyright (c) 1997 Mark Brinicombe @@ -32,7 +32,17 @@ * SUCH DAMAGE. */ +#if !defined(__SOFTFP__) && !defined(__VFP_FP__) && !defined(__ARM_PCS) +#error FPA is not supported anymore +#endif + +#if defined(__ARM_EABI__) && !defined(_STANDALONE) + .fpu vfp +#endif + #include <machine/asm.h> +#include <machine/setjmp.h> + __FBSDID("$FreeBSD$"); /* @@ -45,21 +55,35 @@ __FBSDID("$FreeBSD$"); * The previous signal state is NOT restored. * * Note: r0 is the return value - * r1-r3 are scratch registers in functions + * r1-r3,ip are scratch registers in functions */ ENTRY(_setjmp) ldr r1, .L_setjmp_magic - str r1, [r0], #4 -#ifdef __SOFTFP__ - add r0, r0, #52 + +#if defined(__ARM_EABI__) && !defined(_STANDALONE) + ldr r2, .Lfpu_present +#ifdef PIC + GOT_INIT(r3, .L_setjmp_got, .L_setjmp_gotinit) + ldr r2, [r2, r3] #else - /* Store fp registers */ - sfm f4, 4, [r0], #48 - /* Store fpsr */ - rfs r1 - str r1, [r0], #0x0004 -#endif /* __SOFTFP__ */ + ldr r2, [r2] +#endif + teq r2, #0 /* do we have a FPU? */ + beq 1f /* no, don't save VFP registers */ + + orr r1, r1, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP) + /* change magic to VFP magic */ + add r2, r0, #(_JB_REG_D8 * 4) + vstmia r2, {d8-d15} + vmrs r2, fpscr + str r2, [r0, #(_JB_REG_FPSCR * 4)] +1: +#endif /* __ARM_EABI__ */ + + str r1, [r0] + + add r0, r0, #(_JB_REG_R4 * 4) /* Store integer registers */ stmia r0, {r4-r14} @@ -68,23 +92,32 @@ ENTRY(_setjmp) .L_setjmp_magic: .word _JB_MAGIC__SETJMP +#if defined(__ARM_EABI__) && !defined(_STANDALONE) + GOT_INITSYM(.L_setjmp_got, .L_setjmp_gotinit) +.Lfpu_present: + .word PIC_SYM(_libc_arm_fpu_present, GOTOFF) +#endif /* __ARM_EABI__ */ WEAK_ALIAS(___longjmp, _longjmp) ENTRY(_longjmp) - ldr r2, .L_setjmp_magic - ldr r3, [r0], #4 - teq r2, r3 - bne botch + ldr r2, [r0] /* get magic from jmp_buf */ + bic r3, r2, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP) + /* ignore VFP-ness of magic */ + ldr ip, .L_setjmp_magic /* load magic */ + teq ip, r3 /* magic correct? */ + bne botch /* no, botch */ -#ifdef __SOFTFP__ - add r0, r0, #52 -#else - /* Restore fp registers */ - lfm f4, 4, [r0], #48 - /* Restore fpsr */ - ldr r4, [r0], #0x0004 - wfs r4 -#endif /* __SOFTFP__ */ +#if defined(__ARM_EABI__) && !defined(_STANDALONE) + teq r3, r2 /* did magic change? */ + beq 1f /* no, don't restore VFP */ + add ip, r0, #(_JB_REG_D8 * 4) + vldmia ip, {d8-d15} + ldr ip, [r0, #(_JB_REG_FPSCR * 4)] + vmsr fpscr, ip +1: +#endif /* __ARM_EABI__ */ + + add r0, r0, #(_JB_REG_R4 * 4) /* Restore integer registers */ ldmia r0, {r4-r14} @@ -94,8 +127,7 @@ ENTRY(_longjmp) beq botch /* Set return value */ - mov r0, r1 - teq r0, #0x00000000 + movs r0, r1 moveq r0, #0x00000001 RET diff --git a/lib/libc/arm/gen/arm_initfini.c b/lib/libc/arm/gen/arm_initfini.c new file mode 100644 index 000000000000..9def8c8dfbcb --- /dev/null +++ b/lib/libc/arm/gen/arm_initfini.c @@ -0,0 +1,78 @@ +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * Copyright (c) 2013 Andrew Turner + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + * + * Bases on NetBSD lib/libc/arch/arm/misc/arm_initfini.c + * $NetBSD: arm_initfini.c,v 1.2 2013/01/31 06:47:55 matt Exp $ + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +/* + * To properly implement setjmp/longjmp for the ARM AAPCS ABI, it has to be + * aware of whether there is a FPU is present or not. Regardless of whether + * the hard-float ABI is being used, setjmp needs to save D8-D15. But it can + * only do this if those instructions won't cause an exception. + */ + +#include <sys/param.h> +#include <sys/sysctl.h> + +#include <stdbool.h> +#include <stddef.h> + +extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen); + +int _libc_arm_fpu_present; +static bool _libc_aapcs_initialized; + +void _libc_aapcs_init(void) __attribute__((__constructor__, __used__)); + +void +_libc_aapcs_init(void) +{ + int mib[2]; + size_t len; + + if (_libc_aapcs_initialized) + return; + + mib[0] = CTL_HW; + mib[1] = HW_FLOATINGPT; + + len = sizeof(_libc_arm_fpu_present); + if (__sysctl(mib, 2, &_libc_arm_fpu_present, &len, NULL, 0) == -1 || + len != sizeof(_libc_arm_fpu_present)) { + /* sysctl failed, assume no vfp */ + _libc_arm_fpu_present = 0; + } + + _libc_aapcs_initialized = true; +} diff --git a/lib/libc/arm/gen/getcontextx.c b/lib/libc/arm/gen/getcontextx.c index 307978a466dd..54f851384811 100644 --- a/lib/libc/arm/gen/getcontextx.c +++ b/lib/libc/arm/gen/getcontextx.c @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S index e5f581f0e3f2..b7af33b8856a 100644 --- a/lib/libc/arm/gen/setjmp.S +++ b/lib/libc/arm/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $NetBSD: setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */ +/* $NetBSD: setjmp.S,v 1.14 2013/04/19 13:45:45 matt Exp $ */ /* * Copyright (c) 1997 Mark Brinicombe @@ -32,8 +32,19 @@ * SUCH DAMAGE. */ +#if !defined(__SOFTFP__) && !defined(__VFP_FP__) && !defined(__ARM_PCS) +#error FPA is not supported anymore +#endif + +#ifdef __ARM_EABI__ + .fpu vfp +#endif + #include <machine/asm.h> +#include <machine/setjmp.h> + __FBSDID("$FreeBSD$"); + /* * C library -- setjmp, longjmp * @@ -47,83 +58,95 @@ __FBSDID("$FreeBSD$"); ENTRY(setjmp) /* Block all signals and retrieve the old signal mask */ stmfd sp!, {r0, r14} - add r2, r0, #(25 * 4) /* oset */ - mov r0, #0x00000001 /* SIG_BLOCK */ - mov r1, #0 /* set */ - + add r2, r0, #(_JB_SIGMASK * 4) /* oset */ + mov r1, #0x00000000 /* set */ + mov r0, #0x00000001 /* SIG_BLOCK */ bl PIC_SYM(_C_LABEL(sigprocmask), PLT) - ldmfd sp!, {r0, r14} ldr r1, .Lsetjmp_magic - str r1, [r0], #4 -#ifdef __SOFTFP__ - add r0, r0, #52 +#ifdef __ARM_EABI__ + ldr r2, .Lfpu_present +#ifdef PIC + GOT_INIT(r3, .Lsetjmp_got, .Lsetjmp_gotinit) + ldr r2, [r2, r3] #else - /* Store fp registers */ - sfm f4, 4, [r0], #48 - /* Store fpsr */ - rfs r1 - str r1, [r0], #0x0004 -#endif /* __SOFTFP__ */ + ldr r2, [r2] +#endif + teq r2, #0 /* do we have a FPU? */ + beq 1f /* no, don't save VFP registers */ + + orr r1, r1, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) + /* change magic to VFP magic */ + add r2, r0, #(_JB_REG_D8 * 4) + vstmia r2, {d8-d15} + vmrs r2, fpscr + str r2, [r0, #(_JB_REG_FPSCR * 4)] +1: +#endif /* __ARM_EABI__ */ + + str r1, [r0] /* store magic */ + /* Store integer registers */ + add r0, r0, #(_JB_REG_R4 * 4) stmia r0, {r4-r14} mov r0, #0x00000000 RET .Lsetjmp_magic: .word _JB_MAGIC_SETJMP +#ifdef __ARM_EABI__ + GOT_INITSYM(.Lsetjmp_got, .Lsetjmp_gotinit) +.Lfpu_present: + .word PIC_SYM(_libc_arm_fpu_present, GOTOFF) +#endif /* __ARM_EABI__ */ .weak _C_LABEL(longjmp) .set _C_LABEL(longjmp), _C_LABEL(__longjmp) ENTRY(__longjmp) - ldr r2, .Lsetjmp_magic - ldr r3, [r0] - teq r2, r3 - bne botch - - - /* Set signal mask */ - stmfd sp!, {r0, r1, r14} - sub sp, sp, #4 /* align the stack */ - - add r1, r0, #(25 * 4) /* Signal mask */ - mov r0, #3 /* SIG_SETMASK */ - mov r2, #0 + ldr r2, [r0] + ldr ip, .Lsetjmp_magic + bic r3, r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) + teq r3, ip + bne .Lbotch + + /* Restore the signal mask. */ + stmfd sp!, {r0-r2, r14} + mov r2, #0x00000000 + add r1, r0, #(_JB_SIGMASK * 4) /* Signal mask */ + mov r0, #3 /* SIG_SETMASK */ bl PIC_SYM(_C_LABEL(sigprocmask), PLT) - - add sp, sp, #4 /* unalign the stack */ - ldmfd sp!, {r0, r1, r14} - - add r0, r0, #4 -#ifdef __SOFTFP__ - add r0, r0, #52 -#else - /* Restore fp registers */ - lfm f4, 4, [r0], #48 - /* Restore FPSR */ - ldr r4, [r0], #0x0004 - wfs r4 -#endif /* __SOFTFP__ */ + ldmfd sp!, {r0-r2, r14} + +#ifdef __ARM_EABI__ + tst r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) + /* is this a VFP magic? */ + beq 1f /* no, don't restore VFP */ + add ip, r0, #(_JB_REG_D8 * 4) + vldmia ip, {d8-d15} + ldr ip, [r0, #(_JB_REG_FPSCR * 4)] + vmsr fpscr, ip +1: +#endif /* __ARM_EABI__ */ + + add r0, r0, #(_JB_REG_R4 * 4) /* Restore integer registers */ ldmia r0, {r4-r14} /* Validate sp and r14 */ teq sp, #0 teqne r14, #0 - beq botch + beq .Lbotch /* Set return value */ - - mov r0, r1 - teq r0, #0x00000000 + movs r0, r1 moveq r0, #0x00000001 RET /* validation failed, die die die. */ -botch: +.Lbotch: bl PIC_SYM(_C_LABEL(longjmperror), PLT) bl PIC_SYM(_C_LABEL(abort), PLT) b . - 8 /* Cannot get here */ diff --git a/lib/libc/arm/gen/sigsetjmp.S b/lib/libc/arm/gen/sigsetjmp.S index 09ec2561029b..79f1f9d4cebe 100644 --- a/lib/libc/arm/gen/sigsetjmp.S +++ b/lib/libc/arm/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $NetBSD: sigsetjmp.S,v 1.3 2002/08/17 19:54:30 thorpej Exp $ */ +/* $NetBSD: sigsetjmp.S,v 1.6 2013/04/19 16:50:22 matt Exp $ */ /* * Copyright (c) 1997 Mark Brinicombe @@ -35,6 +35,8 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +#include <machine/setjmp.h> + /* * C library -- sigsetjmp, siglongjmp * @@ -55,8 +57,10 @@ ENTRY(sigsetjmp) WEAK_ALIAS(__siglongjmp, siglongjmp) ENTRY(siglongjmp) - ldr r2, .L_setjmp_magic - ldr r3, [r0] - teq r2, r3 + ldr r2, .L_setjmp_magic /* load magic */ + ldr r3, [r0] /* get magic from jmp_buf */ + bic r3, r3, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP) + /* ignore VFP-ness of magic */ + teq r2, r3 /* magic correct? */ beq PIC_SYM(_C_LABEL(_longjmp), PLT) b PIC_SYM(_C_LABEL(longjmp), PLT) diff --git a/lib/libc/capability/Makefile.inc b/lib/libc/capability/Makefile.inc new file mode 100644 index 000000000000..934fc8b91767 --- /dev/null +++ b/lib/libc/capability/Makefile.inc @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# capability sources +.PATH: ${.CURDIR}/../../sys/kern + +SRCS+= subr_capability.c + +SYM_MAPS+= ${.CURDIR}/capability/Symbol.map + +#MAN+= cap_rights_init.3 + +#MLINKS+=cap_rights_init.3 cap_rights_set.3 +#MLINKS+=cap_rights_init.3 cap_rights_clear.3 +#MLINKS+=cap_rights_init.3 cap_rights_is_set.3 +#MLINKS+=cap_rights_init.3 cap_rights_is_valid.3 +#MLINKS+=cap_rights_init.3 cap_rights_merge.3 +#MLINKS+=cap_rights_init.3 cap_rights_remove.3 +#MLINKS+=cap_rights_init.3 cap_rights_contains.3 + diff --git a/lib/libc/capability/Symbol.map b/lib/libc/capability/Symbol.map new file mode 100644 index 000000000000..c5c18c2f5315 --- /dev/null +++ b/lib/libc/capability/Symbol.map @@ -0,0 +1,14 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.3 { + __cap_rights_clear; + cap_rights_contains; + __cap_rights_init; + __cap_rights_is_set; + cap_rights_is_valid; + cap_rights_merge; + cap_rights_remove; + __cap_rights_set; +}; diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index 47f3646ac46a..94ba014ed3af 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -196,7 +196,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int goto einval; } - if ((t->bt_fd = _open(fname, flags, mode)) < 0) + if ((t->bt_fd = _open(fname, flags | O_CLOEXEC, mode)) < 0) goto err; } else { @@ -207,9 +207,6 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int F_SET(t, B_INMEM); } - if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - if (_fstat(t->bt_fd, &sb)) goto err; if (sb.st_size) { @@ -405,7 +402,7 @@ tmp(void) (void)sigfillset(&set); (void)_sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) + if ((fd = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); (void)_sigprocmask(SIG_SETMASK, &oset, NULL); return(fd); diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 638814ceb5d2..af80929112b0 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -121,9 +121,8 @@ __hash_open(const char *file, int flags, int mode, hashp->flags = flags; if (file) { - if ((hashp->fp = _open(file, flags, mode)) == -1) + if ((hashp->fp = _open(file, flags | O_CLOEXEC, mode)) == -1) RETURN_ERROR(errno, error0); - (void)_fcntl(hashp->fp, F_SETFD, 1); new_table = _fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY; } else diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index fa01775fe8b3..d319d988c165 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -862,10 +862,8 @@ open_temp(HTAB *hashp) /* Block signals; make sure file goes away at process exit. */ (void)sigfillset(&set); (void)_sigprocmask(SIG_BLOCK, &set, &oset); - if ((hashp->fp = mkstemp(path)) != -1) { + if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); - (void)_fcntl(hashp->fp, F_SETFD, 1); - } (void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); return (hashp->fp != -1 ? 0 : -1); } diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index fac1e43f2fd0..a88150c2035c 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -31,6 +31,7 @@ SRCS+= __getosreldate.c \ disklabel.c \ dlfcn.c \ drand48.c \ + dup3.c \ elf_utils.c \ erand48.c \ err.c \ @@ -184,6 +185,7 @@ MAN+= alarm.3 \ dlinfo.3 \ dllockinit.3 \ dlopen.3 \ + dup3.3 \ err.3 \ exec.3 \ feature_present.3 \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 243895137210..5885420bb24a 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -383,7 +383,9 @@ FBSD_1.2 { FBSD_1.3 { clock_getcpuclockid; dirfd; - fdlopen; + dup3; + fdclosedir; + fdlopen; __FreeBSD_libc_enter_restricted_mode; getcontextx; gid_from_group; @@ -529,5 +531,6 @@ FBSDprivate_1.0 { __elf_aux_vector; __pthread_map_stacks_exec; __fillcontextx; + __fillcontextx2; __getcontextx_size; }; diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c index 4b520cc458ae..88ded37be51f 100644 --- a/lib/libc/gen/closedir.c +++ b/lib/libc/gen/closedir.c @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); * close a directory. */ int -closedir(DIR *dirp) +fdclosedir(DIR *dirp) { int fd; @@ -65,5 +65,12 @@ closedir(DIR *dirp) _pthread_mutex_destroy(&dirp->dd_lock); } free((void *)dirp); - return(_close(fd)); + return (fd); +} + +int +closedir(DIR *dirp) +{ + + return (_close(fdclosedir(dirp))); } diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3 index 0fd5bba32b7a..4573d4513fe2 100644 --- a/lib/libc/gen/directory.3 +++ b/lib/libc/gen/directory.3 @@ -28,7 +28,7 @@ .\" @(#)directory.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 5, 2012 +.Dd August 18, 2013 .Dt DIRECTORY 3 .Os .Sh NAME @@ -40,6 +40,7 @@ .Nm seekdir , .Nm rewinddir , .Nm closedir , +.Nm fdclosedir , .Nm dirfd .Nd directory operations .Sh LIBRARY @@ -64,6 +65,8 @@ .Ft int .Fn closedir "DIR *dirp" .Ft int +.Fn fdclosedir "DIR *dirp" +.Ft int .Fn dirfd "DIR *dirp" .Sh DESCRIPTION The @@ -208,6 +211,13 @@ On failure, \-1 is returned and the global variable is set to indicate the error. .Pp The +.Fn fdclosedir +function is equivalent to the +.Fn closedir +function except that this function returns directory file descriptor instead of +closing it. +.Pp +The .Fn dirfd function returns the integer file descriptor associated with the named @@ -252,6 +262,9 @@ The .Fn fdopendir function appeared in .Fx 8.0 . +.Fn fdclosedir +function appeared in +.Fx 10.0 . .Sh BUGS The invalidation of .Fn telldir diff --git a/lib/libc/gen/dl_iterate_phdr.3 b/lib/libc/gen/dl_iterate_phdr.3 index f148ab104c4e..5b8afc6a09f4 100644 --- a/lib/libc/gen/dl_iterate_phdr.3 +++ b/lib/libc/gen/dl_iterate_phdr.3 @@ -29,7 +29,7 @@ Statically linked programs use an implementation of .Fn dl_iterate_phdr from libc. .Sh SYNOPSIS -.Fd #include <link.h> +.In link.h .Ft int .Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data" .Sh DESCRIPTION diff --git a/lib/libc/gen/dup3.3 b/lib/libc/gen/dup3.3 new file mode 100644 index 000000000000..d3bb116189b7 --- /dev/null +++ b/lib/libc/gen/dup3.3 @@ -0,0 +1,116 @@ +.\" Copyright (c) 2013 Jilles Tjoelker +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd August 16, 2013 +.Dt DUP3 3 +.Os +.Sh NAME +.Nm dup3 +.Nd duplicate an existing file descriptor +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In fcntl.h +.In unistd.h +.Ft int +.Fn dup3 "int oldd" "int newd" "int flags" +.Sh DESCRIPTION +The +.Fn dup3 +function +duplicates an existing object descriptor +while allowing the value of the new descriptor to be specified. +.Pp +The close-on-exec flag on the new file descriptor is determined by the +.Dv O_CLOEXEC +bit in +.Fa flags . +.Pp +If +.Fa oldd +\*(Ne +.Fa newd +and +.Fa flags +== 0, +the behavior is identical to +.Li dup2(oldd, newd) . +.Pp +If +.Fa oldd +== +.Fa newd , +then +.Fn dup3 +fails, unlike +.Xr dup2 2 . +.Sh RETURN VALUES +The value -1 is returned if an error occurs. +The external variable +.Va errno +indicates the cause of the error. +.Sh ERRORS +The +.Fn dup3 +function fails if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa oldd +argument is not a valid active descriptor or the +.Fa newd +argument is negative or exceeds the maximum allowable descriptor number +.It Bq Er EINVAL +The +.Fa oldd +argument is equal to the +.Fa newd +argument. +.It Bq Er EINVAL +The +.Fa flags +argument has bits set other than +.Dv O_CLOEXEC . +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr close 2 , +.Xr dup2 2 , +.Xr fcntl 2 , +.Xr getdtablesize 2 , +.Xr open 2 , +.Xr pipe 2 , +.Xr socket 2 , +.Xr socketpair 2 +.Sh STANDARDS +The +.Fn dup3 +function does not conform to any standard. +.Sh HISTORY +The +.Fn dup3 +function appeared in +.Fx 10.0 . diff --git a/lib/libc/gen/dup3.c b/lib/libc/gen/dup3.c new file mode 100644 index 000000000000..ac8877cdc8a6 --- /dev/null +++ b/lib/libc/gen/dup3.c @@ -0,0 +1,59 @@ +/*- + * 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 <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include "un-namespace.h" + +int +__dup3(int oldfd, int newfd, int flags) +{ + int how; + + if (oldfd == newfd) { + errno = EINVAL; + return (-1); + } + + if (flags & ~O_CLOEXEC) { + errno = EINVAL; + return (-1); + } + + how = (flags & O_CLOEXEC) ? F_DUP2FD_CLOEXEC : F_DUP2FD; + + return (_fcntl(oldfd, how, newfd)); +} + +__weak_reference(__dup3, dup3); +__weak_reference(__dup3, _dup3); diff --git a/lib/libc/gen/errlst.c b/lib/libc/gen/errlst.c index d8178236deed..f8fe9684a26a 100644 --- a/lib/libc/gen/errlst.c +++ b/lib/libc/gen/errlst.c @@ -34,6 +34,7 @@ static char sccsid[] = "@(#)errlst.c 8.2 (Berkeley) 11/16/93"; __FBSDID("$FreeBSD$"); #include <stdio.h> +#include "errlst.h" const char *const sys_errlist[] = { "No error: 0", /* 0 - ENOERROR */ @@ -152,5 +153,12 @@ const char *const sys_errlist[] = { "Protocol error", /* 92 - EPROTO */ "Capabilities insufficient", /* 93 - ENOTCAPABLE */ "Not permitted in capability mode", /* 94 - ECAPMODE */ + "State not recoverable", /* 95 - ENOTRECOVERABLE */ + "Previous owner died", /* 96 - EOWNERDEAD */ }; const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); + +#ifdef PIC +__strong_reference(sys_errlist, __hidden_sys_errlist); +__strong_reference(sys_nerr, __hidden_sys_nerr); +#endif diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c index c38aafc8b0b5..47d0a4131f5c 100644 --- a/lib/libc/gen/fnmatch.c +++ b/lib/libc/gen/fnmatch.c @@ -194,8 +194,6 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) &patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) return (FNM_NOMATCH); - if (pclen == 0) - pc = '\\'; pattern += pclen; } /* FALLTHROUGH */ diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h index dfdd53bfb65c..d8fe6895f11c 100644 --- a/lib/libc/gen/fts-compat.h +++ b/lib/libc/gen/fts-compat.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. 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. * diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3 index 35e4d459238f..9133e378f66b 100644 --- a/lib/libc/gen/fts.3 +++ b/lib/libc/gen/fts.3 @@ -28,7 +28,7 @@ .\" @(#)fts.3 8.5 (Berkeley) 4/16/94 .\" $FreeBSD$ .\" -.Dd March 18, 2012 +.Dd May 21, 2013 .Dt FTS 3 .Os .Sh NAME @@ -37,8 +37,6 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h -.In sys/stat.h .In fts.h .Ft FTS * .Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)" diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c index 569cf4276ad9..4dab3cb07f28 100644 --- a/lib/libc/gen/getlogin.c +++ b/lib/libc/gen/getlogin.c @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); extern int _getlogin(char *, int); -int _logname_valid; /* known to setlogin() */ +int _logname_valid __hidden; /* known to setlogin() */ static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER; static char * diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3 index 90297e46f728..386a0bdf9857 100644 --- a/lib/libc/gen/popen.3 +++ b/lib/libc/gen/popen.3 @@ -28,7 +28,7 @@ .\" @(#)popen.3 8.2 (Berkeley) 5/3/95 .\" $FreeBSD$ .\" -.Dd May 3, 1995 +.Dd May 20, 2013 .Dt POPEN 3 .Os .Sh NAME @@ -79,6 +79,11 @@ for writing, or .Ql r+ for reading and writing. .Pp +A letter +.Ql e +may be appended to that to request that the underlying file descriptor +be set close-on-exec. +.Pp The .Fa command argument is a pointer to a null-terminated string diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index b123234837ee..b0597c80783f 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <errno.h> +#include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -71,10 +72,11 @@ popen(command, type) { struct pid *cur; FILE *iop; - int pdes[2], pid, twoway; + int pdes[2], pid, twoway, cloexec; char *argv[4]; struct pid *p; + cloexec = strchr(type, 'e') != NULL; /* * Lite2 introduced two-way popen() pipes using _socketpair(). * FreeBSD's pipe() is bidirectional, so we use that. @@ -84,10 +86,11 @@ popen(command, type) type = "r+"; } else { twoway = 0; - if ((*type != 'r' && *type != 'w') || type[1]) + if ((*type != 'r' && *type != 'w') || + (type[1] && (type[1] != 'e' || type[2]))) return (NULL); } - if (pipe(pdes) < 0) + if ((cloexec ? pipe2(pdes, O_CLOEXEC) : pipe(pdes)) < 0) return (NULL); if ((cur = malloc(sizeof(struct pid))) == NULL) { @@ -120,20 +123,29 @@ popen(command, type) * the compiler is free to corrupt all the local * variables. */ - (void)_close(pdes[0]); + if (!cloexec) + (void)_close(pdes[0]); if (pdes[1] != STDOUT_FILENO) { (void)_dup2(pdes[1], STDOUT_FILENO); - (void)_close(pdes[1]); + if (!cloexec) + (void)_close(pdes[1]); if (twoway) (void)_dup2(STDOUT_FILENO, STDIN_FILENO); - } else if (twoway && (pdes[1] != STDIN_FILENO)) + } else if (twoway && (pdes[1] != STDIN_FILENO)) { (void)_dup2(pdes[1], STDIN_FILENO); + if (cloexec) + (void)_fcntl(pdes[1], F_SETFD, 0); + } else if (cloexec) + (void)_fcntl(pdes[1], F_SETFD, 0); } else { if (pdes[0] != STDIN_FILENO) { (void)_dup2(pdes[0], STDIN_FILENO); - (void)_close(pdes[0]); - } - (void)_close(pdes[1]); + if (!cloexec) + (void)_close(pdes[0]); + } else if (cloexec) + (void)_fcntl(pdes[0], F_SETFD, 0); + if (!cloexec) + (void)_close(pdes[1]); } SLIST_FOREACH(p, &pidlist, next) (void)_close(fileno(p->fp)); diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3 index c6fd017f22d1..9cd47efb02da 100644 --- a/lib/libc/gen/posix_spawn_file_actions_addopen.3 +++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 24, 2008 +.Dd May 9, 2013 .Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3 .Os .Sh NAME @@ -123,7 +123,19 @@ to be duplicated as dup2(fildes, newfildes) .Ed .Pp -had been called) when a new process is spawned using this file actions object. +had been called) when a new process is spawned using this file actions object, +except that the +.Dv FD_CLOEXEC +flag for +.Fa newfildes +is cleared even if +.Fa fildes +is equal to +.Fa newfildes . +The difference from +.Fn dup2 +is useful for passing a particular file descriptor +to a particular child process. .Pp The .Fn posix_spawn_file_actions_addclose @@ -145,7 +157,7 @@ otherwise, an error number is returned to indicate the error. These functions fail if: .Bl -tag -width Er -.It Bq Er EINVAL +.It Bq Er EBADF The value specified by .Fa fildes or @@ -169,7 +181,16 @@ The and .Fn posix_spawn_file_actions_addclose functions conform to -.St -p1003.1-2001 . +.St -p1003.1-2001 , +with the exception of the behavior of +.Fn posix_spawn_file_actions_adddup2 +if +.Fa fildes +is equal to +.Fa newfildes +(clearing +.Dv FD_CLOEXEC ) . +A future update of the Standard is expected to require this behavior. .Sh HISTORY The .Fn posix_spawn_file_actions_addopen , diff --git a/lib/libc/gen/pututxline.c b/lib/libc/gen/pututxline.c index 555386c549c0..4982c0276fbf 100644 --- a/lib/libc/gen/pututxline.c +++ b/lib/libc/gen/pututxline.c @@ -131,7 +131,8 @@ exact: else error = 0; fclose(fp); - errno = error; + if (error != 0) + errno = error; return (error == 0 ? 0 : 1); } @@ -169,7 +170,8 @@ utx_active_remove(struct futx *fu) } fclose(fp); - errno = error; + if (ret != 0) + errno = error; return (ret); } @@ -225,7 +227,8 @@ utx_lastlogin_add(const struct futx *fu) ret = -1; } fclose(fp); - errno = error; + if (ret == -1) + errno = error; return (ret); } @@ -277,7 +280,8 @@ utx_log_add(const struct futx *fu) else error = 0; _close(fd); - errno = error; + if (error != 0) + errno = error; return (error == 0 ? 0 : 1); } diff --git a/lib/libc/gen/sem_wait.3 b/lib/libc/gen/sem_wait.3 index 18e95868f202..993ac4a15a29 100644 --- a/lib/libc/gen/sem_wait.3 +++ b/lib/libc/gen/sem_wait.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 15, 2000 +.Dd April 16, 2013 .Dt SEM_WAIT 3 .Os .Sh NAME @@ -75,6 +75,13 @@ points to an invalid semaphore. .El .Pp Additionally, +.Fn sem_wait +will fail if: +.Bl -tag -width Er +.It Bq Er EINTR +A signal interrupted this function. +.El +Additionally, .Fn sem_trywait will fail if: .Bl -tag -width Er diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c index dde474c43e0c..fde33ca567ce 100644 --- a/lib/libc/gen/siginterrupt.c +++ b/lib/libc/gen/siginterrupt.c @@ -46,7 +46,7 @@ int siginterrupt(sig, flag) int sig, flag; { - extern sigset_t _sigintr; + extern sigset_t _sigintr __hidden; struct sigaction sa; int ret; diff --git a/lib/libc/gen/signal.3 b/lib/libc/gen/signal.3 index a41d2589778a..ea6df4410b2c 100644 --- a/lib/libc/gen/signal.3 +++ b/lib/libc/gen/signal.3 @@ -132,6 +132,7 @@ is possible on a descriptor (see .It 30 Ta Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1" .It 31 Ta Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2" .It 32 Ta Dv SIGTHR Ta "terminate process" Ta "thread interrupt" +.It 33 Ta Dv SIGLIBRT Ta "terminate process" Ta "real-time library interrupt" .El .Pp The diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c index c93633e23bbb..ee96dcc3c5b6 100644 --- a/lib/libc/gen/signal.c +++ b/lib/libc/gen/signal.c @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" -sigset_t _sigintr; /* shared with siginterrupt */ +sigset_t _sigintr __hidden; /* shared with siginterrupt */ sig_t signal(s, a) diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3 index 82465b6055e0..d4480beb0e2d 100644 --- a/lib/libc/gen/stringlist.3 +++ b/lib/libc/gen/stringlist.3 @@ -49,7 +49,7 @@ .Ft void .Fn sl_free "StringList *sl" "int freeall" .Ft char * -.Fn sl_find "StringList *sl" "char *item" +.Fn sl_find "StringList *sl" "const char *item" .Sh DESCRIPTION The .Nm diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c index e0db3b675942..a09a8e705e36 100644 --- a/lib/libc/gen/stringlist.c +++ b/lib/libc/gen/stringlist.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); * sl_init(): Initialize a string list */ StringList * -sl_init() +sl_init(void) { StringList *sl; @@ -67,9 +67,7 @@ sl_init() * sl_add(): Add an item to the string list */ int -sl_add(sl, name) - StringList *sl; - char *name; +sl_add(StringList *sl, char *name) { if (sl->sl_cur == sl->sl_max - 1) { sl->sl_max += _SL_CHUNKSIZE; @@ -86,9 +84,7 @@ sl_add(sl, name) * sl_free(): Free a stringlist */ void -sl_free(sl, all) - StringList *sl; - int all; +sl_free(StringList *sl, int all) { size_t i; @@ -108,9 +104,7 @@ sl_free(sl, all) * sl_find(): Find a name in the string list */ char * -sl_find(sl, name) - StringList *sl; - char *name; +sl_find(StringList *sl, const char *name) { size_t i; diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c index 1edaa5a91154..55e99451b13d 100644 --- a/lib/libc/gen/strtofflags.c +++ b/lib/libc/gen/strtofflags.c @@ -62,13 +62,29 @@ static struct { #endif { "nouappnd", 0, UF_APPEND }, { "nouappend", 0, UF_APPEND }, + { "nouarch", 0, UF_ARCHIVE }, + { "nouarchive", 0, UF_ARCHIVE }, + { "nohidden", 0, UF_HIDDEN }, + { "nouhidden", 0, UF_HIDDEN }, { "nouchg", 0, UF_IMMUTABLE }, { "nouchange", 0, UF_IMMUTABLE }, { "nouimmutable", 0, UF_IMMUTABLE }, { "nodump", 1, UF_NODUMP }, - { "noopaque", 0, UF_OPAQUE }, { "nouunlnk", 0, UF_NOUNLINK }, - { "nouunlink", 0, UF_NOUNLINK } + { "nouunlink", 0, UF_NOUNLINK }, + { "nooffline", 0, UF_OFFLINE }, + { "nouoffline", 0, UF_OFFLINE }, + { "noopaque", 0, UF_OPAQUE }, + { "nordonly", 0, UF_READONLY }, + { "nourdonly", 0, UF_READONLY }, + { "noreadonly", 0, UF_READONLY }, + { "noureadonly", 0, UF_READONLY }, + { "noreparse", 0, UF_REPARSE }, + { "noureparse", 0, UF_REPARSE }, + { "nosparse", 0, UF_SPARSE }, + { "nousparse", 0, UF_SPARSE }, + { "nosystem", 0, UF_SYSTEM }, + { "nousystem", 0, UF_SYSTEM } }; #define nmappings (sizeof(mapping) / sizeof(mapping[0])) diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3 index 4af6f821f138..4631aeb6bf1b 100644 --- a/lib/libc/gen/sysconf.3 +++ b/lib/libc/gen/sysconf.3 @@ -28,7 +28,7 @@ .\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd February 13, 2011 +.Dd April 26, 2013 .Dt SYSCONF 3 .Os .Sh NAME @@ -82,7 +82,7 @@ The number of processors configured. .It Li _SC_NPROCESSORS_ONLN The number of processors currently online. .It Li _SC_OPEN_MAX -The maximum number of open files per user id. +One more than the maximum value the system may assign to a new file descriptor. .It Li _SC_PAGESIZE The size of a system page in bytes. .It Li _SC_PAGE_SIZE diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index b3737e2d1aaa..7d7b90a7442e 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -28,7 +28,7 @@ .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd February 11, 2012 +.Dd May 17, 2013 .Dt SYSCTL 3 .Os .Sh NAME @@ -547,14 +547,14 @@ The length of each message is contained in the message header. The third level name is a protocol number, which is currently always 0. The fourth level name is an address family, which may be set to 0 to select all address families. -The fifth and sixth level names are as follows: -.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent -.It Sy "Fifth level name Sixth level is:" -.It "NET_RT_FLAGS rtflags" -.It "NET_RT_DUMP None" -.It "NET_RT_IFLIST 0 or if_index" -.It "NET_RT_IFMALIST 0 or if_index" -.It "NET_RT_IFLISTL 0 or if_index" +The fifth, sixth, and seventh level names are as follows: +.Bl -column -offset indent "Fifth level Sixth level" "Seventh level" +.It Sy "Fifth level Sixth level" Ta Sy "Seventh level" +.It "NET_RT_FLAGS rtflags" Ta "None" +.It "NET_RT_DUMP None" Ta "None or fib number" +.It "NET_RT_IFLIST 0 or if_index" Ta None +.It "NET_RT_IFMALIST 0 or if_index" Ta None +.It "NET_RT_IFLISTL 0 or if_index" Ta None .El .Pp The @@ -735,7 +735,6 @@ privilege may change the value. .It Sy "Second level name Type Changeable" .It "VM_LOADAVG struct loadavg no" .It "VM_TOTAL struct vmtotal no" -.It "VM_PAGEOUT_ALGORITHM integer yes" .It "VM_SWAPPING_ENABLED integer maybe" .It "VM_V_CACHE_MAX integer yes" .It "VM_V_CACHE_MIN integer yes" @@ -754,9 +753,6 @@ The returned data consists of a Return the system wide virtual memory statistics. The returned data consists of a .Va struct vmtotal . -.It Li VM_PAGEOUT_ALGORITHM -0 if the statistics-based page management algorithm is in use -or 1 if the near-LRU algorithm is in use. .It Li VM_SWAPPING_ENABLED 1 if process swapping is enabled or 0 if disabled. This variable is diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c index b518b57ae5ea..377caff51cc5 100644 --- a/lib/libc/gen/wordexp.c +++ b/lib/libc/gen/wordexp.c @@ -121,7 +121,7 @@ we_askshell(const char *words, wordexp_t *we, int flags) serrno = errno; - if (pipe(pdes) < 0) + if (pipe2(pdes, O_CLOEXEC) < 0) return (WRDE_NOSPACE); /* XXX */ (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); @@ -139,25 +139,15 @@ we_askshell(const char *words, wordexp_t *we, int flags) * We are the child; just get /bin/sh to run the wordexp * builtin on `words'. */ - int devnull; - char *cmd; - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); - _close(pdes[0]); - if (_dup2(pdes[1], STDOUT_FILENO) < 0) + if ((pdes[1] != STDOUT_FILENO ? + _dup2(pdes[1], STDOUT_FILENO) : + _fcntl(pdes[1], F_SETFD, 0)) < 0) _exit(1); - _close(pdes[1]); - if (asprintf(&cmd, "wordexp %s\n", words) < 0) - _exit(1); - if ((flags & WRDE_SHOWERR) == 0) { - if ((devnull = _open(_PATH_DEVNULL, O_RDWR, 0666)) < 0) - _exit(1); - if (_dup2(devnull, STDERR_FILENO) < 0) - _exit(1); - _close(devnull); - } execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u", - "-c", cmd, (char *)NULL); + "-c", "eval \"$1\";eval \"wordexp $2\"", "", + flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words, + (char *)NULL); _exit(1); } @@ -261,7 +251,8 @@ we_check(const char *words, int flags) while ((c = *words++) != '\0') { switch (c) { case '\\': - quote ^= 1; + if (squote == 0) + quote ^= 1; continue; case '\'': if (quote + dquote == 0) diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 8f508b065a0d..1f56bc2c3617 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -163,13 +163,13 @@ _mcleanup(void) else snprintf(outname, sizeof(outname), "%s.gmon", _getprogname()); - fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); + fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0666); if (fd < 0) { _warn("_mcleanup: %s", outname); return; } #ifdef DEBUG - log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); + log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0664); if (log < 0) { _warn("_mcleanup: gmon.log"); return; diff --git a/lib/libc/i386/gen/getcontextx.c b/lib/libc/i386/gen/getcontextx.c index 2d3b5625bbad..3c6dd33ef10f 100644 --- a/lib/libc/i386/gen/getcontextx.c +++ b/lib/libc/i386/gen/getcontextx.c @@ -89,14 +89,12 @@ __getcontextx_size(void) } int -__fillcontextx(char *ctx) +__fillcontextx2(char *ctx) { struct i386_get_xfpustate xfpu; ucontext_t *ucp; ucp = (ucontext_t *)ctx; - if (getcontext(ucp) == -1) - return (-1); if (xstate_sz != 0) { xfpu.addr = (char *)(ucp + 1); xfpu.len = xstate_sz; @@ -112,6 +110,18 @@ __fillcontextx(char *ctx) return (0); } +int +__fillcontextx(char *ctx) +{ + ucontext_t *ucp; + + ucp = (ucontext_t *)ctx; + if (getcontext(ucp) == -1) + return (-1); + __fillcontextx2(ctx); + return (0); +} + __weak_reference(__getcontextx, getcontextx); ucontext_t * diff --git a/lib/libc/i386/string/memchr.S b/lib/libc/i386/string/memchr.S index 03828db95c72..3bd4d9c3a4d6 100644 --- a/lib/libc/i386/string/memchr.S +++ b/lib/libc/i386/string/memchr.S @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$"); /* * memchr (b, c, len) - * locates the first occurance of c in string b. + * locates the first occurrence of c in string b. * * Written by: * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. diff --git a/lib/libc/i386/string/strchr.S b/lib/libc/i386/string/strchr.S index 57fc6dd6fbea..f57c2cd8abe4 100644 --- a/lib/libc/i386/string/strchr.S +++ b/lib/libc/i386/string/strchr.S @@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$"); /* * strchr(s, c) - * return a pointer to the first occurance of the character c in + * return a pointer to the first occurrence of the character c in * string s, or NULL if c does not occur in the string. * * %edx - pointer iterating through string - * %eax - pointer to first occurance of 'c' + * %eax - pointer to first occurrence of 'c' * %cl - character we're comparing against * %bl - character at %edx * diff --git a/lib/libc/i386/string/strrchr.S b/lib/libc/i386/string/strrchr.S index 29942c498004..5ec5287a4c68 100644 --- a/lib/libc/i386/string/strrchr.S +++ b/lib/libc/i386/string/strrchr.S @@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$"); /* * strrchr(s, c) - * return a pointer to the last occurance of the character c in + * return a pointer to the last occurrence of the character c in * string s, or NULL if c does not occur in the string. * * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' + * %eax - pointer to last occurrence of 'c' * %cl - character we're comparing against * %bl - character at %edx * diff --git a/lib/libc/i386/sys/setlogin.S b/lib/libc/i386/sys/setlogin.S index c6436b51cfac..9247955c5664 100644 --- a/lib/libc/i386/sys/setlogin.S +++ b/lib/libc/i386/sys/setlogin.S @@ -41,16 +41,9 @@ __FBSDID("$FreeBSD$"); .globl CNAME(_logname_valid) /* in _getlogin() */ SYSCALL(setlogin) -#ifdef PIC PIC_PROLOGUE - pushl %eax - movl PIC_GOT(CNAME(_logname_valid)),%eax - movl $0,(%eax) - popl %eax + movl $0,PIC_GOTOFF(CNAME(_logname_valid)) PIC_EPILOGUE -#else - movl $0,CNAME(_logname_valid) -#endif ret /* setlogin(name) */ END(__sys_setlogin) diff --git a/lib/libc/ia64/gen/getcontextx.c b/lib/libc/ia64/gen/getcontextx.c index 307978a466dd..54f851384811 100644 --- a/lib/libc/ia64/gen/getcontextx.c +++ b/lib/libc/ia64/gen/getcontextx.c @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; diff --git a/lib/libc/iconv/Symbol.map b/lib/libc/iconv/Symbol.map index 73e0e225ffe2..05df2eac2f7c 100644 --- a/lib/libc/iconv/Symbol.map +++ b/lib/libc/iconv/Symbol.map @@ -17,6 +17,17 @@ FBSD_1.2 { libiconvlist; }; +FBSD_1.3 { + _iconv_version; + iconv; + iconv_open; + iconv_close; + iconv_open_into; + iconv_set_relocation_prefix; + iconvctl; + iconvlist; +}; + FBSDprivate_1.0 { _citrus_bcs_convert_to_lower; _citrus_bcs_convert_to_upper; @@ -39,6 +50,7 @@ FBSDprivate_1.0 { _citrus_bcs_strtoul; _citrus_bcs_tolower; _citrus_bcs_toupper; + _citrus_bcs_trunc_rws_len; _citrus_bcs_trunc_ws_len; _citrus_csmapper_open; _citrus_csmapper_close; diff --git a/lib/libc/iconv/citrus_csmapper.c b/lib/libc/iconv/citrus_csmapper.c index 5e0a01ad8a90..e2d10d5a4ba7 100644 --- a/lib/libc/iconv/citrus_csmapper.c +++ b/lib/libc/iconv/citrus_csmapper.c @@ -58,6 +58,8 @@ static struct _citrus_mapper_area *maparea = NULL; +static pthread_rwlock_t ma_lock = PTHREAD_RWLOCK_INITIALIZER; + #define CS_ALIAS _PATH_CSMAPPER "/charset.alias" #define CS_PIVOT _PATH_CSMAPPER "/charset.pivot" @@ -314,7 +316,7 @@ get_none(struct _citrus_mapper_area *__restrict ma, { int ret; - WLOCK; + WLOCK(&ma_lock); if (csm_none) { *rcsm = csm_none; ret = 0; @@ -329,7 +331,7 @@ get_none(struct _citrus_mapper_area *__restrict ma, *rcsm = csm_none; ret = 0; quit: - UNLOCK; + UNLOCK(&ma_lock); return (ret); } diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c index 941ee0255ecb..e4bd24f4a39a 100644 --- a/lib/libc/iconv/citrus_iconv.c +++ b/lib/libc/iconv/citrus_iconv.c @@ -68,11 +68,13 @@ static int shared_max_reuse, shared_num_unused; static _CITRUS_HASH_HEAD(, _citrus_iconv_shared, CI_HASH_SIZE) shared_pool; static TAILQ_HEAD(, _citrus_iconv_shared) shared_unused; +static pthread_rwlock_t ci_lock = PTHREAD_RWLOCK_INITIALIZER; + static __inline void init_cache(void) { - WLOCK; + WLOCK(&ci_lock); if (!isinit) { _CITRUS_HASH_INIT(&shared_pool, CI_HASH_SIZE); TAILQ_INIT(&shared_unused); @@ -83,7 +85,7 @@ init_cache(void) shared_max_reuse = CI_INITIAL_MAX_REUSE; isinit = true; } - UNLOCK; + UNLOCK(&ci_lock); } static __inline void @@ -114,7 +116,20 @@ open_shared(struct _citrus_iconv_shared * __restrict * __restrict rci, size_t len_convname; int ret; +#ifdef INCOMPATIBLE_WITH_GNU_ICONV + /* + * Sadly, the gnu tools expect iconv to actually parse the + * byte stream and don't allow for a pass-through when + * the (src,dest) encodings are the same. + * See gettext-0.18.3+ NEWS: + * msgfmt now checks PO file headers more strictly with less + * false-positives. + * NetBSD don't do this either. + */ module = (strcmp(src, dst) != 0) ? "iconv_std" : "iconv_none"; +#else + module = "iconv_std"; +#endif /* initialize iconv handle */ len_convname = strlen(convname); @@ -195,7 +210,7 @@ get_shared(struct _citrus_iconv_shared * __restrict * __restrict rci, snprintf(convname, sizeof(convname), "%s/%s", src, dst); - WLOCK; + WLOCK(&ci_lock); /* lookup alread existing entry */ hashval = hash_func(convname); @@ -222,7 +237,7 @@ get_shared(struct _citrus_iconv_shared * __restrict * __restrict rci, *rci = ci; quit: - UNLOCK; + UNLOCK(&ci_lock); return (ret); } @@ -231,7 +246,7 @@ static void release_shared(struct _citrus_iconv_shared * __restrict ci) { - WLOCK; + WLOCK(&ci_lock); ci->ci_used_count--; if (ci->ci_used_count == 0) { /* put it into unused list */ @@ -247,7 +262,7 @@ release_shared(struct _citrus_iconv_shared * __restrict ci) } } - UNLOCK; + UNLOCK(&ci_lock); } /* @@ -258,7 +273,7 @@ int _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv, const char * __restrict src, const char * __restrict dst) { - struct _citrus_iconv *cv; + struct _citrus_iconv *cv = NULL; struct _citrus_iconv_shared *ci = NULL; char realdst[PATH_MAX], realsrc[PATH_MAX]; char buf[PATH_MAX], path[PATH_MAX]; @@ -301,7 +316,7 @@ _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv, ret = (*ci->ci_ops->io_init_context)(*rcv); if (ret) { release_shared(ci); - free(*rcv); + free(cv); return (ret); } return (0); diff --git a/lib/libc/iconv/citrus_iconv.h b/lib/libc/iconv/citrus_iconv.h index 99604e92063d..ac14ac318ac5 100644 --- a/lib/libc/iconv/citrus_iconv.h +++ b/lib/libc/iconv/citrus_iconv.h @@ -52,7 +52,7 @@ __END_DECLS */ static __inline int _citrus_iconv_convert(struct _citrus_iconv * __restrict cv, - char * __restrict * __restrict in, size_t * __restrict inbytes, + const char * __restrict * __restrict in, size_t * __restrict inbytes, char * __restrict * __restrict out, size_t * __restrict outbytes, uint32_t flags, size_t * __restrict nresults) { diff --git a/lib/libc/iconv/citrus_iconv_local.h b/lib/libc/iconv/citrus_iconv_local.h index db2036384e5b..52ac8251cd24 100644 --- a/lib/libc/iconv/citrus_iconv_local.h +++ b/lib/libc/iconv/citrus_iconv_local.h @@ -45,7 +45,7 @@ static void _citrus_##_m_##_iconv_uninit_shared \ (struct _citrus_iconv_shared *); \ static int _citrus_##_m_##_iconv_convert \ (struct _citrus_iconv * __restrict, \ - char * __restrict * __restrict, \ + const char * __restrict * __restrict, \ size_t * __restrict, \ char * __restrict * __restrict, \ size_t * __restrict outbytes, \ @@ -57,6 +57,7 @@ static void _citrus_##_m_##_iconv_uninit_context \ #define _CITRUS_ICONV_DEF_OPS(_m_) \ +extern struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops; \ struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \ /* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \ /* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \ @@ -73,7 +74,7 @@ typedef void (*_citrus_iconv_uninit_shared_t) (struct _citrus_iconv_shared *); typedef int (*_citrus_iconv_convert_t) (struct _citrus_iconv * __restrict, - char *__restrict* __restrict, size_t * __restrict, + const char *__restrict* __restrict, size_t * __restrict, char * __restrict * __restrict, size_t * __restrict, uint32_t, size_t * __restrict); typedef int (*_citrus_iconv_init_context_t)(struct _citrus_iconv *); diff --git a/lib/libc/iconv/citrus_lock.h b/lib/libc/iconv/citrus_lock.h index ad9443ab01ef..395064453b67 100644 --- a/lib/libc/iconv/citrus_lock.h +++ b/lib/libc/iconv/citrus_lock.h @@ -27,9 +27,7 @@ #include <pthread.h> -static pthread_rwlock_t lock; - -#define WLOCK if (__isthreaded) \ - pthread_rwlock_wrlock(&lock); -#define UNLOCK if (__isthreaded) \ - pthread_rwlock_unlock(&lock); +#define WLOCK(lock) if (__isthreaded) \ + pthread_rwlock_wrlock(lock); +#define UNLOCK(lock) if (__isthreaded) \ + pthread_rwlock_unlock(lock); diff --git a/lib/libc/iconv/citrus_mapper.c b/lib/libc/iconv/citrus_mapper.c index b5ae96d920f7..b1ee8fbe7ecf 100644 --- a/lib/libc/iconv/citrus_mapper.c +++ b/lib/libc/iconv/citrus_mapper.c @@ -55,6 +55,8 @@ #define CM_HASH_SIZE 101 #define REFCOUNT_PERSISTENT -1 +static pthread_rwlock_t cm_lock = PTHREAD_RWLOCK_INITIALIZER; + struct _citrus_mapper_area { _CITRUS_HASH_HEAD(, _citrus_mapper, CM_HASH_SIZE) ma_cache; char *ma_dir; @@ -75,7 +77,7 @@ _citrus_mapper_create_area( char path[PATH_MAX]; int ret; - WLOCK; + WLOCK(&cm_lock); if (*rma != NULL) { ret = 0; @@ -96,7 +98,7 @@ _citrus_mapper_create_area( ma->ma_dir = strdup(area); if (ma->ma_dir == NULL) { ret = errno; - free(ma->ma_dir); + free(ma); goto quit; } _CITRUS_HASH_INIT(&ma->ma_cache, CM_HASH_SIZE); @@ -104,7 +106,7 @@ _citrus_mapper_create_area( *rma = ma; ret = 0; quit: - UNLOCK; + UNLOCK(&cm_lock); return (ret); } @@ -316,7 +318,7 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma, variable = NULL; - WLOCK; + WLOCK(&cm_lock); /* search in the cache */ hashval = hash_func(mapname); @@ -337,9 +339,9 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma, goto quit; /* open mapper */ - UNLOCK; + UNLOCK(&cm_lock); ret = mapper_open(ma, &cm, module, variable); - WLOCK; + WLOCK(&cm_lock); if (ret) goto quit; cm->cm_key = strdup(mapname); @@ -356,7 +358,7 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma, *rcm = cm; ret = 0; quit: - UNLOCK; + UNLOCK(&cm_lock); return (ret); } @@ -370,7 +372,7 @@ _citrus_mapper_close(struct _citrus_mapper *cm) { if (cm) { - WLOCK; + WLOCK(&cm_lock); if (cm->cm_refcount == REFCOUNT_PERSISTENT) goto quit; if (cm->cm_refcount > 0) { @@ -381,7 +383,7 @@ _citrus_mapper_close(struct _citrus_mapper *cm) } mapper_close(cm); quit: - UNLOCK; + UNLOCK(&cm_lock); } } @@ -393,7 +395,7 @@ void _citrus_mapper_set_persistent(struct _citrus_mapper * __restrict cm) { - WLOCK; + WLOCK(&cm_lock); cm->cm_refcount = REFCOUNT_PERSISTENT; - UNLOCK; + UNLOCK(&cm_lock); } diff --git a/lib/libc/iconv/citrus_mapper_local.h b/lib/libc/iconv/citrus_mapper_local.h index 887a35d376a4..8d29e63a4a96 100644 --- a/lib/libc/iconv/citrus_mapper_local.h +++ b/lib/libc/iconv/citrus_mapper_local.h @@ -52,6 +52,7 @@ static void _citrus_##_m_##_mapper_init_state \ (void); #define _CITRUS_MAPPER_DEF_OPS(_m_) \ +extern struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops; \ struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = { \ /* mo_init */ &_citrus_##_m_##_mapper_init, \ /* mo_uninit */ &_citrus_##_m_##_mapper_uninit, \ diff --git a/lib/libc/iconv/citrus_none.c b/lib/libc/iconv/citrus_none.c index 9ec4bd360cb8..4f9b254fc133 100644 --- a/lib/libc/iconv/citrus_none.c +++ b/lib/libc/iconv/citrus_none.c @@ -83,7 +83,7 @@ _citrus_NONE_stdenc_init_state(struct _citrus_stdenc * __restrict ce __unused, static int _citrus_NONE_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce __unused, - _csid_t *csid, _index_t *idx, char **s, size_t n, + _csid_t *csid, _index_t *idx, const char **s, size_t n, void *ps __unused, size_t *nresult, struct iconv_hooks *hooks) { @@ -159,7 +159,7 @@ _citrus_NONE_stdenc_cstomb(struct _citrus_stdenc * __restrict ce __unused, static int _citrus_NONE_stdenc_mbtowc(struct _citrus_stdenc * __restrict ce __unused, - _wc_t * __restrict pwc, char ** __restrict s, size_t n, + _wc_t * __restrict pwc, const char ** __restrict s, size_t n, void * __restrict pspriv __unused, size_t * __restrict nresult, struct iconv_hooks *hooks) { diff --git a/lib/libc/iconv/citrus_stdenc.h b/lib/libc/iconv/citrus_stdenc.h index 50f4dffa4e16..28fa29d8cc94 100644 --- a/lib/libc/iconv/citrus_stdenc.h +++ b/lib/libc/iconv/citrus_stdenc.h @@ -69,7 +69,7 @@ _citrus_stdenc_init_state(struct _citrus_stdenc * __restrict ce, static __inline int _citrus_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce, _citrus_csid_t * __restrict csid, _citrus_index_t * __restrict idx, - char ** __restrict s, size_t n, void * __restrict ps, + const char ** __restrict s, size_t n, void * __restrict ps, size_t * __restrict nresult, struct iconv_hooks *hooks) { diff --git a/lib/libc/iconv/citrus_stdenc_local.h b/lib/libc/iconv/citrus_stdenc_local.h index c55387a10bf2..7b627a05fd19 100644 --- a/lib/libc/iconv/citrus_stdenc_local.h +++ b/lib/libc/iconv/citrus_stdenc_local.h @@ -55,7 +55,7 @@ static int _citrus_##_e_##_stdenc_mbtocs \ (struct _citrus_stdenc * __restrict, \ _citrus_csid_t * __restrict, \ _citrus_index_t * __restrict, \ - char ** __restrict, size_t, \ + const char ** __restrict, size_t, \ void * __restrict, size_t * __restrict, \ struct iconv_hooks *); \ static int _citrus_##_e_##_stdenc_cstomb \ @@ -66,7 +66,7 @@ static int _citrus_##_e_##_stdenc_cstomb \ static int _citrus_##_e_##_stdenc_mbtowc \ (struct _citrus_stdenc * __restrict, \ _citrus_wc_t * __restrict, \ - char ** __restrict, size_t, \ + const char ** __restrict, size_t, \ void * __restrict, size_t * __restrict, \ struct iconv_hooks *); \ static int _citrus_##_e_##_stdenc_wctomb \ @@ -84,6 +84,7 @@ static int _citrus_##_e_##_stdenc_get_state_desc \ struct _citrus_stdenc_state_desc * __restrict) #define _CITRUS_STDENC_DEF_OPS(_e_) \ +extern struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops; \ struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \ /* eo_init */ &_citrus_##_e_##_stdenc_init, \ /* eo_uninit */ &_citrus_##_e_##_stdenc_uninit, \ @@ -105,7 +106,7 @@ typedef int (*_citrus_stdenc_init_state_t) typedef int (*_citrus_stdenc_mbtocs_t) (struct _citrus_stdenc * __restrict, _citrus_csid_t * __restrict, _citrus_index_t * __restrict, - char ** __restrict, size_t, + const char ** __restrict, size_t, void * __restrict, size_t * __restrict, struct iconv_hooks *); typedef int (*_citrus_stdenc_cstomb_t) @@ -115,7 +116,7 @@ typedef int (*_citrus_stdenc_cstomb_t) typedef int (*_citrus_stdenc_mbtowc_t) (struct _citrus_stdenc * __restrict, _citrus_wc_t * __restrict, - char ** __restrict, size_t, + const char ** __restrict, size_t, void * __restrict, size_t * __restrict, struct iconv_hooks *); typedef int (*_citrus_stdenc_wctomb_t) diff --git a/lib/libc/iconv/citrus_stdenc_template.h b/lib/libc/iconv/citrus_stdenc_template.h index 9a05fa789fa6..21bc5cc95cd9 100644 --- a/lib/libc/iconv/citrus_stdenc_template.h +++ b/lib/libc/iconv/citrus_stdenc_template.h @@ -112,7 +112,7 @@ _FUNCNAME(stdenc_init_state)(struct _citrus_stdenc * __restrict ce, static int _FUNCNAME(stdenc_mbtocs)(struct _citrus_stdenc * __restrict ce, _citrus_csid_t * __restrict csid, _citrus_index_t * __restrict idx, - char ** __restrict s, size_t n, void * __restrict ps, + const char ** __restrict s, size_t n, void * __restrict ps, size_t * __restrict nresult, struct iconv_hooks *hooks) { wchar_t wc; @@ -151,7 +151,7 @@ _FUNCNAME(stdenc_cstomb)(struct _citrus_stdenc * __restrict ce, static int _FUNCNAME(stdenc_mbtowc)(struct _citrus_stdenc * __restrict ce, - _citrus_wc_t * __restrict wc, char ** __restrict s, size_t n, + _citrus_wc_t * __restrict wc, const char ** __restrict s, size_t n, void * __restrict ps, size_t * __restrict nresult, struct iconv_hooks *hooks) { diff --git a/lib/libc/iconv/iconv.c b/lib/libc/iconv/iconv.c index d1e01e88d10c..f388e8b59d0f 100644 --- a/lib/libc/iconv/iconv.c +++ b/lib/libc/iconv/iconv.c @@ -47,56 +47,51 @@ #include "citrus_hash.h" #include "citrus_iconv.h" -#ifdef __weak_alias -__weak_alias(libiconv, _iconv) -__weak_alias(libiconv_open, _iconv_open) -__weak_alias(libiconv_open_into, _iconv_open_into) -__weak_alias(libiconv_close, _iconv_close) -__weak_alias(libiconvlist, _iconvlist) -__weak_alias(libiconvctl, _iconvctl) -__weak_alias(libiconv_set_relocation_prefix, _iconv_set_relocation_prefix) -__weak_alias(iconv_canonicalize, _iconv_canonicalize) +#include <_libiconv_compat.h> +#ifdef __LIBICONV_COMPAT +__weak_reference(iconv, libiconv); +__weak_reference(iconv_open, libiconv_open); +__weak_reference(iconv_open_into, libiconv_open_into); +__weak_reference(iconv_close, libiconv_close); +__weak_reference(iconvlist, libiconvlist); +__weak_reference(iconvctl, libiconvctl); +__weak_reference(iconv_set_relocation_prefix, libiconv_set_relocation_prefix); +__weak_reference(_iconv_version, _libiconv_version); #endif #define ISBADF(_h_) (!(_h_) || (_h_) == (iconv_t)-1) -int _libiconv_version = _LIBICONV_VERSION; +int _iconv_version = _ICONV_VERSION; iconv_t _iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc); iconv_t -_iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc) +_iconv_open(const char *out, const char *in, struct _citrus_iconv *handle) { - struct _citrus_iconv *handle; - char *out_truncated, *p; + const char *out_slashes; + char *out_noslashes; int ret; - handle = prealloc; - /* * Remove anything following a //, as these are options (like * //ignore, //translate, etc) and we just don't handle them. - * This is for compatibilty with software that uses thees + * This is for compatibility with software that uses these * blindly. */ - out_truncated = strdup(out); - if (out_truncated == NULL) { - errno = ENOMEM; - return ((iconv_t)-1); + out_slashes = strstr(out, "//"); + if (out_slashes != NULL) { + out_noslashes = strndup(out, out_slashes - out); + if (out_noslashes == NULL) { + errno = ENOMEM; + return ((iconv_t)-1); + } + ret = _citrus_iconv_open(&handle, in, out_noslashes); + free(out_noslashes); + } else { + ret = _citrus_iconv_open(&handle, in, out); } - p = out_truncated; - while (*p != 0) { - if (p[0] == '/' && p[1] == '/') { - *p = '\0'; - break; - } - p++; - } - - ret = _citrus_iconv_open(&handle, in, out_truncated); - free(out_truncated); if (ret) { errno = ret == ENOENT ? EINVAL : ret; return ((iconv_t)-1); @@ -109,14 +104,14 @@ _iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc) } iconv_t -libiconv_open(const char *out, const char *in) +iconv_open(const char *out, const char *in) { return (_iconv_open(out, in, NULL)); } int -libiconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr) +iconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr) { struct _citrus_iconv *handle; @@ -125,7 +120,7 @@ libiconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr) } int -libiconv_close(iconv_t handle) +iconv_close(iconv_t handle) { if (ISBADF(handle)) { @@ -139,7 +134,7 @@ libiconv_close(iconv_t handle) } size_t -libiconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout) +iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout) { size_t ret; int err; @@ -160,7 +155,7 @@ libiconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout) } size_t -__iconv(iconv_t handle, char **in, size_t *szin, char **out, +__iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout, uint32_t flags, size_t *invalids) { size_t ret; @@ -219,7 +214,7 @@ qsort_helper(const void *first, const void *second) } void -libiconvlist(int (*do_one) (unsigned int, const char * const *, +iconvlist(int (*do_one) (unsigned int, const char * const *, void *), void *data) { char **list, **names; @@ -273,7 +268,7 @@ __inline const char } int -libiconvctl(iconv_t cd, int request, void *argument) +iconvctl(iconv_t cd, int request, void *argument) { struct _citrus_iconv *cv; struct iconv_hooks *hooks; @@ -325,7 +320,7 @@ libiconvctl(iconv_t cd, int request, void *argument) } void -libiconv_set_relocation_prefix(const char *orig_prefix __unused, +iconv_set_relocation_prefix(const char *orig_prefix __unused, const char *curr_prefix __unused) { diff --git a/lib/libc/include/compat.h b/lib/libc/include/compat.h index 3739fe105c8f..769454002788 100644 --- a/lib/libc/include/compat.h +++ b/lib/libc/include/compat.h @@ -42,8 +42,6 @@ __sym_compat(__semctl, freebsd7___semctl, FBSD_1.0); __sym_compat(msgctl, freebsd7_msgctl, FBSD_1.0); __sym_compat(shmctl, freebsd7_shmctl, FBSD_1.0); -__sym_compat(cap_getrights, cap_rights_get, FBSD_1.2); - #undef __sym_compat #endif /* __LIBC_COMPAT_H__ */ diff --git a/lib/libc/include/errlst.h b/lib/libc/include/errlst.h new file mode 100644 index 000000000000..4e9e29fc3345 --- /dev/null +++ b/lib/libc/include/errlst.h @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 2013 Jilles Tjoelker + * 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. + * + * $FreeBSD$ + */ + +#ifndef __ERRLST_H__ +#define __ERRLST_H__ + +#include <sys/cdefs.h> + +#ifdef PIC +/* If the main executable imports these, do not use its copy from libc.so. */ +extern const char *const __hidden_sys_errlist[] __hidden; +extern const int __hidden_sys_nerr __hidden; +#else +#define __hidden_sys_errlist sys_errlist +#define __hidden_sys_nerr sys_nerr +#endif + +#endif /* __ERRLST_H__ */ diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index faae02811d17..40a5f7266709 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -83,7 +83,7 @@ void _rtld_error(const char *fmt, ...); #define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) struct _spinlock; -extern struct _spinlock __stdio_thread_lock; +extern struct _spinlock __stdio_thread_lock __hidden; #define STDIO_THREAD_LOCK() \ do { \ if (__isthreaded) \ @@ -218,7 +218,7 @@ void _malloc_postfork(void); /* * Function to clean up streams, called from abort() and exit(). */ -extern void (*__cleanup)(void); +extern void (*__cleanup)(void) __hidden; /* * Get kern.osreldate to detect ABI revisions. Explicitly diff --git a/lib/libc/libc.ldscript b/lib/libc/libc.ldscript new file mode 100644 index 000000000000..a5c8a274db74 --- /dev/null +++ b/lib/libc/libc.ldscript @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +GROUP ( @@SHLIB@@ @@LIBDIR@@/libssp_nonshared.a ) diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index f2161be470ae..c2f2f4e61727 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -23,6 +23,12 @@ SRCS+= ascii.c big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c \ wcwidth.c\ xlocale.c +.if ${MK_ICONV} != "no" +SRCS+= c16rtomb_iconv.c c32rtomb_iconv.c mbrtoc16_iconv.c mbrtoc32_iconv.c +.else +SRCS+= c16rtomb.c c32rtomb.c mbrtoc16.c mbrtoc32.c +.endif + SYM_MAPS+=${.CURDIR}/locale/Symbol.map MAN+= btowc.3 \ @@ -72,7 +78,9 @@ MLINKS+=iswalnum_l.3 iswalpha_l.3 iswalnum_l.3 iswcntrl_l.3 \ iswalnum_l.3 iswspecial_l.3 iswalnum_l.3 nextwctype_l.3 \ iswalnum_l.3 towctrans_l.3 iswalnum_l.3 wctrans_l.3 MLINKS+=isxdigit.3 ishexnumber.3 +MLINKS+=mbrtowc.3 mbrtoc16.3 mbrtowc.3 mbrtoc32.3 MLINKS+=mbsrtowcs.3 mbsnrtowcs.3 +MLINKS+=wcrtomb.3 c16rtomb.3 wcrtomb.3 c32rtomb.3 MLINKS+=wcsrtombs.3 wcsnrtombs.3 MLINKS+=wcstod.3 wcstof.3 wcstod.3 wcstold.3 MLINKS+=wcstol.3 wcstoul.3 wcstol.3 wcstoll.3 wcstol.3 wcstoull.3 \ diff --git a/lib/libc/locale/Symbol.map b/lib/libc/locale/Symbol.map index f6367dacf3fd..b2f2a35f2fe4 100644 --- a/lib/libc/locale/Symbol.map +++ b/lib/libc/locale/Symbol.map @@ -199,6 +199,14 @@ FBSD_1.3 { __istype_l; __runes_for_locale; _ThreadRuneLocale; + c16rtomb; + c16rtomb_l; + c32rtomb; + c32rtomb_l; + mbrtoc16; + mbrtoc16_l; + mbrtoc32; + mbrtoc32_l; }; FBSDprivate_1.0 { diff --git a/lib/libc/locale/c16rtomb.c b/lib/libc/locale/c16rtomb.c new file mode 100644 index 000000000000..8bad98267b69 --- /dev/null +++ b/lib/libc/locale/c16rtomb.c @@ -0,0 +1,81 @@ +/*- + * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <errno.h> +#include <uchar.h> +#include "xlocale_private.h" + +typedef struct { + char16_t lead_surrogate; + mbstate_t c32_mbstate; +} _Char16State; + +size_t +c16rtomb_l(char * __restrict s, char16_t c16, mbstate_t * __restrict ps, + locale_t locale) +{ + _Char16State *cs; + char32_t c32; + + FIX_LOCALE(locale); + if (ps == NULL) + ps = &locale->c16rtomb; + cs = (_Char16State *)ps; + + /* If s is a null pointer, the value of parameter c16 is ignored. */ + if (s == NULL) { + c32 = 0; + } else if (cs->lead_surrogate >= 0xd800 && + cs->lead_surrogate <= 0xdbff) { + /* We should see a trail surrogate now. */ + if (c16 < 0xdc00 || c16 > 0xdfff) { + errno = EILSEQ; + return ((size_t)-1); + } + c32 = 0x10000 + ((cs->lead_surrogate & 0x3ff) << 10 | + (c16 & 0x3ff)); + } else if (c16 >= 0xd800 && c16 <= 0xdbff) { + /* Store lead surrogate for next invocation. */ + cs->lead_surrogate = c16; + return (0); + } else { + /* Regular character. */ + c32 = c16; + } + cs->lead_surrogate = 0; + + return (c32rtomb_l(s, c32, &cs->c32_mbstate, locale)); +} + +size_t +c16rtomb(char * __restrict s, char16_t c16, mbstate_t * __restrict ps) +{ + + return (c16rtomb_l(s, c16, ps, __get_locale())); +} diff --git a/lib/libc/locale/c16rtomb_iconv.c b/lib/libc/locale/c16rtomb_iconv.c new file mode 100644 index 000000000000..86bd9dab2a52 --- /dev/null +++ b/lib/libc/locale/c16rtomb_iconv.c @@ -0,0 +1,8 @@ +/* $FreeBSD$ */ +#define charXX_t char16_t +#define cXXrtomb c16rtomb +#define cXXrtomb_l c16rtomb_l +#define SRCBUF_LEN 2 +#define UTF_XX_INTERNAL "UTF-16-INTERNAL" + +#include "cXXrtomb_iconv.h" diff --git a/lib/libc/locale/c32rtomb.c b/lib/libc/locale/c32rtomb.c new file mode 100644 index 000000000000..c5f008fdea69 --- /dev/null +++ b/lib/libc/locale/c32rtomb.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <errno.h> +#include <uchar.h> +#include <wchar.h> +#include "xlocale_private.h" + +size_t +c32rtomb_l(char * __restrict s, char32_t c32, mbstate_t * __restrict ps, + locale_t locale) +{ + + /* Unicode Standard 5.0, D90: ill-formed characters. */ + if ((c32 >= 0xd800 && c32 <= 0xdfff) || c32 > 0x10ffff) { + errno = EILSEQ; + return ((size_t)-1); + } + + FIX_LOCALE(locale); + if (ps == NULL) + ps = &locale->c32rtomb; + + /* Assume wchar_t uses UTF-32. */ + return (wcrtomb_l(s, c32, ps, locale)); +} + +size_t +c32rtomb(char * __restrict s, char32_t c32, mbstate_t * __restrict ps) +{ + + return (c32rtomb_l(s, c32, ps, __get_locale())); +} diff --git a/lib/libc/locale/c32rtomb_iconv.c b/lib/libc/locale/c32rtomb_iconv.c new file mode 100644 index 000000000000..dabbfd7f7ab4 --- /dev/null +++ b/lib/libc/locale/c32rtomb_iconv.c @@ -0,0 +1,8 @@ +/* $FreeBSD$ */ +#define charXX_t char32_t +#define cXXrtomb c32rtomb +#define cXXrtomb_l c32rtomb_l +#define SRCBUF_LEN 1 +#define UTF_XX_INTERNAL "UTF-32-INTERNAL" + +#include "cXXrtomb_iconv.h" diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h new file mode 100644 index 000000000000..0ea553bc0809 --- /dev/null +++ b/lib/libc/locale/cXXrtomb_iconv.h @@ -0,0 +1,116 @@ +/*- + * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/queue.h> + +#include <assert.h> +#include <errno.h> +#include <langinfo.h> +#include <uchar.h> + +#include "../iconv/citrus_hash.h" +#include "../iconv/citrus_module.h" +#include "../iconv/citrus_iconv.h" +#include "xlocale_private.h" + +typedef struct { + bool initialized; + struct _citrus_iconv iconv; + union { + charXX_t widechar[SRCBUF_LEN]; + char bytes[sizeof(charXX_t) * SRCBUF_LEN]; + } srcbuf; + size_t srcbuf_len; +} _ConversionState; +_Static_assert(sizeof(_ConversionState) <= sizeof(mbstate_t), + "Size of _ConversionState must not exceed mbstate_t's size."); + +size_t +cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps, + locale_t locale) +{ + _ConversionState *cs; + struct _citrus_iconv *handle; + const char *src; + char *dst; + size_t srcleft, dstleft, invlen; + int err; + + FIX_LOCALE(locale); + if (ps == NULL) + ps = &locale->cXXrtomb; + cs = (_ConversionState *)ps; + handle = &cs->iconv; + + /* Reinitialize mbstate_t. */ + if (s == NULL || !cs->initialized) { + if (_citrus_iconv_open(&handle, UTF_XX_INTERNAL, + nl_langinfo_l(CODESET, locale)) != 0) { + cs->initialized = false; + errno = EINVAL; + return (-1); + } + handle->cv_shared->ci_discard_ilseq = true; + handle->cv_shared->ci_hooks = NULL; + cs->srcbuf_len = 0; + cs->initialized = true; + if (s == NULL) + return (1); + } + + assert(cs->srcbuf_len < sizeof(cs->srcbuf.widechar) / sizeof(charXX_t)); + cs->srcbuf.widechar[cs->srcbuf_len++] = c; + + /* Perform conversion. */ + src = cs->srcbuf.bytes; + srcleft = cs->srcbuf_len * sizeof(charXX_t); + dst = s; + dstleft = MB_CUR_MAX_L(locale); + err = _citrus_iconv_convert(handle, &src, &srcleft, &dst, &dstleft, + 0, &invlen); + + /* Character is part of a surrogate pair. We need more input. */ + if (err == EINVAL) + return (0); + cs->srcbuf_len = 0; + + /* Illegal sequence. */ + if (dst == s) { + errno = EILSEQ; + return ((size_t)-1); + } + return (dst - s); +} + +size_t +cXXrtomb(char * __restrict s, charXX_t c, mbstate_t * __restrict ps) +{ + + return (cXXrtomb_l(s, c, ps, __get_locale())); +} diff --git a/lib/libc/locale/duplocale.3 b/lib/libc/locale/duplocale.3 index 1e149c05d7cb..f2e82158ae0e 100644 --- a/lib/libc/locale/duplocale.3 +++ b/lib/libc/locale/duplocale.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17 2011 +.Dd September 17, 2011 .Dt DUPLOCALE 3 .Os .Sh NAME @@ -66,8 +66,8 @@ The locale returned by this call must be freed with .Xr uselocale 3 , .Xr xlocale 3 .Sh STANDARDS -This function, conforms to -.St -p1003.1-2008 +This function conforms to +.St -p1003.1-2008 . .Sh BUGS Ideally, .Xr uselocale 3 diff --git a/lib/libc/locale/freelocale.3 b/lib/libc/locale/freelocale.3 index 26060e87731f..86f4809d6cac 100644 --- a/lib/libc/locale/freelocale.3 +++ b/lib/libc/locale/freelocale.3 @@ -26,7 +26,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd September 17 2011 +.Dd September 17, 2011 .Dt FREELOCALE 3 .Os .Sh NAME @@ -57,5 +57,12 @@ Returns 0 on success or -1 on error. .Xr uselocale 3 , .Xr xlocale 3 .Sh STANDARDS -This function, conforms to -.St -p1003.1-2008 . +The +.Fn freelocale +function +differs from +.St -p1003.1-2008 +in that its return type is +.Vt int +rather than +.Vt void . diff --git a/lib/libc/locale/mbrtoc16.c b/lib/libc/locale/mbrtoc16.c new file mode 100644 index 000000000000..a47514c3d93b --- /dev/null +++ b/lib/libc/locale/mbrtoc16.c @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <uchar.h> +#include "xlocale_private.h" + +typedef struct { + char16_t trail_surrogate; + mbstate_t c32_mbstate; +} _Char16State; + +size_t +mbrtoc16_l(char16_t * __restrict pc16, const char * __restrict s, size_t n, + mbstate_t * __restrict ps, locale_t locale) +{ + _Char16State *cs; + char32_t c32; + ssize_t len; + + FIX_LOCALE(locale); + if (ps == NULL) + ps = &locale->mbrtoc16; + cs = (_Char16State *)ps; + + /* + * Call straight into mbrtoc32_l() if we don't need to return a + * character value. According to the spec, if s is a null + * pointer, the value of parameter pc16 is also ignored. + */ + if (pc16 == NULL || s == NULL) { + cs->trail_surrogate = 0; + return (mbrtoc32_l(NULL, s, n, &cs->c32_mbstate, locale)); + } + + /* Return the trail surrogate from the previous invocation. */ + if (cs->trail_surrogate >= 0xdc00 && cs->trail_surrogate <= 0xdfff) { + *pc16 = cs->trail_surrogate; + cs->trail_surrogate = 0; + return ((size_t)-3); + } + + len = mbrtoc32_l(&c32, s, n, &cs->c32_mbstate, locale); + if (len >= 0) { + if (c32 < 0x10000) { + /* Fits in one UTF-16 character. */ + *pc16 = c32; + } else { + /* Split up in a surrogate pair. */ + c32 -= 0x10000; + *pc16 = 0xd800 | (c32 >> 10); + cs->trail_surrogate = 0xdc00 | (c32 & 0x3ff); + } + } + return (len); +} + +size_t +mbrtoc16(char16_t * __restrict pc16, const char * __restrict s, size_t n, + mbstate_t * __restrict ps) +{ + + return (mbrtoc16_l(pc16, s, n, ps, __get_locale())); +} diff --git a/lib/libc/locale/mbrtoc16_iconv.c b/lib/libc/locale/mbrtoc16_iconv.c new file mode 100644 index 000000000000..f1eaf1925496 --- /dev/null +++ b/lib/libc/locale/mbrtoc16_iconv.c @@ -0,0 +1,8 @@ +/* $FreeBSD$ */ +#define charXX_t char16_t +#define mbrtocXX mbrtoc16 +#define mbrtocXX_l mbrtoc16_l +#define DSTBUF_LEN 2 +#define UTF_XX_INTERNAL "UTF-16-INTERNAL" + +#include "mbrtocXX_iconv.h" diff --git a/lib/libc/locale/mbrtoc32.c b/lib/libc/locale/mbrtoc32.c new file mode 100644 index 000000000000..ee9e47d6a3e5 --- /dev/null +++ b/lib/libc/locale/mbrtoc32.c @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <uchar.h> +#include <wchar.h> +#include "xlocale_private.h" + +size_t +mbrtoc32_l(char32_t * __restrict pc32, const char * __restrict s, size_t n, + mbstate_t * __restrict ps, locale_t locale) +{ + + FIX_LOCALE(locale); + if (ps == NULL) + ps = &locale->mbrtoc32; + + /* Assume wchar_t uses UTF-32. */ + return (mbrtowc_l(pc32, s, n, ps, locale)); +} + +size_t +mbrtoc32(char32_t * __restrict pc32, const char * __restrict s, size_t n, + mbstate_t * __restrict ps) +{ + + return (mbrtoc32_l(pc32, s, n, ps, __get_locale())); +} diff --git a/lib/libc/locale/mbrtoc32_iconv.c b/lib/libc/locale/mbrtoc32_iconv.c new file mode 100644 index 000000000000..ec2c0145d9d6 --- /dev/null +++ b/lib/libc/locale/mbrtoc32_iconv.c @@ -0,0 +1,8 @@ +/* $FreeBSD$ */ +#define charXX_t char32_t +#define mbrtocXX mbrtoc32 +#define mbrtocXX_l mbrtoc32_l +#define DSTBUF_LEN 1 +#define UTF_XX_INTERNAL "UTF-32-INTERNAL" + +#include "mbrtocXX_iconv.h" diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h new file mode 100644 index 000000000000..ac85a5a5a782 --- /dev/null +++ b/lib/libc/locale/mbrtocXX_iconv.h @@ -0,0 +1,159 @@ +/*- + * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/queue.h> + +#include <assert.h> +#include <errno.h> +#include <langinfo.h> +#include <limits.h> +#include <string.h> +#include <uchar.h> + +#include "../iconv/citrus_hash.h" +#include "../iconv/citrus_module.h" +#include "../iconv/citrus_iconv.h" +#include "xlocale_private.h" + +typedef struct { + bool initialized; + struct _citrus_iconv iconv; + char srcbuf[MB_LEN_MAX]; + size_t srcbuf_len; + union { + charXX_t widechar[DSTBUF_LEN]; + char bytes[sizeof(charXX_t) * DSTBUF_LEN]; + } dstbuf; + size_t dstbuf_len; +} _ConversionState; +_Static_assert(sizeof(_ConversionState) <= sizeof(mbstate_t), + "Size of _ConversionState must not exceed mbstate_t's size."); + +size_t +mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n, + mbstate_t * __restrict ps, locale_t locale) +{ + _ConversionState *cs; + struct _citrus_iconv *handle; + size_t i, retval; + charXX_t retchar; + + FIX_LOCALE(locale); + if (ps == NULL) + ps = &locale->mbrtocXX; + cs = (_ConversionState *)ps; + handle = &cs->iconv; + + /* Reinitialize mbstate_t. */ + if (s == NULL || !cs->initialized) { + if (_citrus_iconv_open(&handle, + nl_langinfo_l(CODESET, locale), UTF_XX_INTERNAL) != 0) { + cs->initialized = false; + errno = EINVAL; + return (-1); + } + handle->cv_shared->ci_discard_ilseq = true; + handle->cv_shared->ci_hooks = NULL; + cs->srcbuf_len = cs->dstbuf_len = 0; + cs->initialized = true; + if (s == NULL) + return (0); + } + + /* See if we still have characters left from the previous invocation. */ + if (cs->dstbuf_len > 0) { + retval = (size_t)-3; + goto return_char; + } + + /* Fill up the read buffer as far as possible. */ + if (n > sizeof(cs->srcbuf) - cs->srcbuf_len) + n = sizeof(cs->srcbuf) - cs->srcbuf_len; + memcpy(cs->srcbuf + cs->srcbuf_len, s, n); + + /* Convert as few characters to the dst buffer as possible. */ + for (i = 0; ; i++) { + const char *src; + char *dst; + size_t srcleft, dstleft, invlen; + int err; + + src = cs->srcbuf; + srcleft = cs->srcbuf_len + n; + dst = cs->dstbuf.bytes; + dstleft = i * sizeof(charXX_t); + assert(srcleft <= sizeof(cs->srcbuf) && + dstleft <= sizeof(cs->dstbuf.bytes)); + err = _citrus_iconv_convert(handle, &src, &srcleft, + &dst, &dstleft, 0, &invlen); + cs->dstbuf_len = (dst - cs->dstbuf.bytes) / sizeof(charXX_t); + + /* Got new character(s). Return the first. */ + if (cs->dstbuf_len > 0) { + assert(src - cs->srcbuf > cs->srcbuf_len); + retval = src - cs->srcbuf - cs->srcbuf_len; + cs->srcbuf_len = 0; + goto return_char; + } + + /* Increase dst buffer size, to obtain the surrogate pair. */ + if (err == E2BIG) + continue; + + /* Illegal sequence. */ + if (invlen > 0) { + cs->srcbuf_len = 0; + errno = EILSEQ; + return ((size_t)-1); + } + + /* Save unprocessed remainder for the next invocation. */ + memmove(cs->srcbuf, src, srcleft); + cs->srcbuf_len = srcleft; + return ((size_t)-2); + } + +return_char: + retchar = cs->dstbuf.widechar[0]; + memmove(&cs->dstbuf.widechar[0], &cs->dstbuf.widechar[1], + --cs->dstbuf_len * sizeof(charXX_t)); + if (pc != NULL) + *pc = retchar; + if (retchar == 0) + return (0); + return (retval); +} + +size_t +mbrtocXX(charXX_t * __restrict pc, const char * __restrict s, size_t n, + mbstate_t * __restrict ps) +{ + + return (mbrtocXX_l(pc, s, n, ps, __get_locale())); +} diff --git a/lib/libc/locale/mbrtowc.3 b/lib/libc/locale/mbrtowc.3 index 10160d1916fd..22b26cd2a244 100644 --- a/lib/libc/locale/mbrtowc.3 +++ b/lib/libc/locale/mbrtowc.3 @@ -24,11 +24,13 @@ .\" .\" $FreeBSD$ .\" -.Dd April 8, 2004 +.Dd May 21, 2013 .Dt MBRTOWC 3 .Os .Sh NAME -.Nm mbrtowc +.Nm mbrtowc , +.Nm mbrtoc16 , +.Nm mbrtoc32 .Nd "convert a character to a wide-character code (restartable)" .Sh LIBRARY .Lb libc @@ -36,35 +38,51 @@ .In wchar.h .Ft size_t .Fo mbrtowc -.Fa "wchar_t * restrict pwc" "const char * restrict s" "size_t n" +.Fa "wchar_t * restrict pc" "const char * restrict s" "size_t n" +.Fa "mbstate_t * restrict ps" +.Fc +.In uchar.h +.Ft size_t +.Fo mbrtoc16 +.Fa "char16_t * restrict pc" "const char * restrict s" "size_t n" +.Fa "mbstate_t * restrict ps" +.Fc +.Ft size_t +.Fo mbrtoc32 +.Fa "char32_t * restrict pc" "const char * restrict s" "size_t n" .Fa "mbstate_t * restrict ps" .Fc .Sh DESCRIPTION The -.Fn mbrtowc -function inspects at most +.Fn mbrtowc , +.Fn mbrtoc16 +and +.Fn mbrtoc32 +functions inspect at most .Fa n bytes pointed to by .Fa s to determine the number of bytes needed to complete the next multibyte character. If a character can be completed, and -.Fa pwc +.Fa pc is not .Dv NULL , the wide character which is represented by .Fa s is stored in the -.Vt wchar_t +.Vt wchar_t , +.Vt char16_t +or +.Vt char32_t it points to. .Pp If .Fa s is .Dv NULL , -.Fn mbrtowc -behaves as if -.Fa pwc +these functions behave as if +.Fa pc was .Dv NULL , .Fa s @@ -81,15 +99,24 @@ argument, is used to keep track of the shift state. If it is .Dv NULL , -.Fn mbrtowc -uses an internal, static +these functions use an internal, static .Vt mbstate_t object, which is initialized to the initial conversion state at program startup. +.Pp +As a single +.Vt char16_t +is not large enough to represent certain multibyte characters, the +.Fn mbrtoc16 +function may need to be invoked multiple times to convert a single +multibyte character sequence. .Sh RETURN VALUES The -.Fn mbrtowc -functions returns: +.Fn mbrtowc , +.Fn mbrtoc16 +and +.Fn mbrtoc32 +functions return: .Bl -tag -width indent .It 0 The next @@ -100,10 +127,13 @@ represent the null wide character .It >0 The next .Fa n -or fewer bytes -represent a valid character, -.Fn mbrtowc -returns the number of bytes used to complete the multibyte character. +or fewer bytes represent a valid character, these functions +return the number of bytes used to complete the multibyte character. +.It Po Vt size_t Pc Ns \-1 +An encoding error has occurred. +The next +.Fa n +or fewer bytes do not contribute to a valid multibyte character. .It Po Vt size_t Pc Ns \-2 The next .Fa n @@ -111,16 +141,23 @@ contribute to, but do not complete, a valid multibyte character sequence, and all .Fa n bytes have been processed. -.It Po Vt size_t Pc Ns \-1 -An encoding error has occurred. -The next -.Fa n -or fewer bytes do not contribute to a valid multibyte character. +.El +.Pp +The +.Fn mbrtoc16 +function also returns: +.Bl -tag -width indent +.It Po Vt size_t Pc Ns \-3 +The next character resulting from a previous call has been stored. +No bytes from the input have been consumed. .El .Sh ERRORS The -.Fn mbrtowc -function will fail if: +.Fn mbrtowc , +.Fn mbrtoc16 +and +.Fn mbrtoc32 +functions will fail if: .Bl -tag -width Er .It Bq Er EILSEQ An invalid multibyte sequence was detected. @@ -134,6 +171,9 @@ The conversion state is invalid. .Xr wcrtomb 3 .Sh STANDARDS The -.Fn mbrtowc -function conforms to -.St -isoC-99 . +.Fn mbrtowc , +.Fn mbrtoc16 +and +.Fn mbrtoc32 +functions conform to +.St -isoC-2011 . diff --git a/lib/libc/locale/newlocale.3 b/lib/libc/locale/newlocale.3 index e2d7ebbb0561..a639c372a6c6 100644 --- a/lib/libc/locale/newlocale.3 +++ b/lib/libc/locale/newlocale.3 @@ -26,7 +26,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd September 17 2011 +.Dd September 17, 2011 .Dt NEWLOCALE 3 .Os .Sh NAME @@ -108,5 +108,5 @@ You must free the returned locale with .Xr uselocale 3 , .Xr xlocale 3 .Sh STANDARDS -This function, conforms to -.St -p1003.1-2008 +This function conforms to +.St -p1003.1-2008 . diff --git a/lib/libc/locale/querylocale.3 b/lib/libc/locale/querylocale.3 index 4f9775595e5f..f90d626d1ac6 100644 --- a/lib/libc/locale/querylocale.3 +++ b/lib/libc/locale/querylocale.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17 2011 +.Dd May 3, 2013 .Dt QUERYLOCALE 3 .Os .Sh NAME @@ -52,6 +52,3 @@ If more than one bit in the mask is set, the returned value is undefined. .Xr newlocale 3 , .Xr uselocale 3 , .Xr xlocale 3 -.Sh STANDARDS -This function, conforms to -.St -p1003.1-2008 diff --git a/lib/libc/locale/uselocale.3 b/lib/libc/locale/uselocale.3 index 9b4f43038823..df29a625e17e 100644 --- a/lib/libc/locale/uselocale.3 +++ b/lib/libc/locale/uselocale.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17 2011 +.Dd September 17, 2011 .Dt USELOCALE 3 .Os .Sh NAME @@ -57,4 +57,4 @@ or LC_GLOBAL_LOCALE if this thread has no locale associated with it. .Xr xlocale 3 .Sh STANDARDS This function conforms to -.St -p1003.1-2008 +.St -p1003.1-2008 . diff --git a/lib/libc/locale/wcrtomb.3 b/lib/libc/locale/wcrtomb.3 index c89614e2d34b..bc741740a249 100644 --- a/lib/libc/locale/wcrtomb.3 +++ b/lib/libc/locale/wcrtomb.3 @@ -24,24 +24,34 @@ .\" .\" $FreeBSD$ .\" -.Dd April 8, 2004 +.Dd May 21, 2013 .Dt WCRTOMB 3 .Os .Sh NAME -.Nm wcrtomb +.Nm wcrtomb , +.Nm c16rtomb , +.Nm c32rtomb .Nd "convert a wide-character code to a character (restartable)" .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In wchar.h .Ft size_t -.Fn wcrtomb "char * restrict s" "wchar_t wc" "mbstate_t * restrict ps" +.Fn wcrtomb "char * restrict s" "wchar_t c" "mbstate_t * restrict ps" +.In uchar.h +.Ft size_t +.Fn c16rtomb "char * restrict s" "char16_t c" "mbstate_t * restrict ps" +.Ft size_t +.Fn c32rtomb "char * restrict s" "char32_t c" "mbstate_t * restrict ps" .Sh DESCRIPTION The -.Fn wcrtomb -function stores a multibyte sequence representing the +.Fn wcrtomb , +.Fn c16rtomb +and +.Fn c32rtomb +functions store a multibyte sequence representing the wide character -.Fa wc , +.Fa c , including any necessary shift sequences, to the character array .Fa s , @@ -53,11 +63,10 @@ If .Fa s is .Dv NULL , -.Fn wcrtomb -behaves as if +these functions behave as if .Fa s pointed to an internal buffer and -.Fa wc +.Fa c was a null wide character (L'\e0'). .Pp The @@ -67,26 +76,32 @@ argument, is used to keep track of the shift state. If it is .Dv NULL , -.Fn wcrtomb -uses an internal, static +these functions use an internal, static .Vt mbstate_t object, which is initialized to the initial conversion state at program startup. +.Pp +As certain multibyte characters may only be represented by a series of +16-bit characters, the +.Fn c16rtomb +may need to invoked multiple times before a multibyte sequence is +returned. .Sh RETURN VALUES -The -.Fn wcrtomb -functions returns the length (in bytes) of the multibyte sequence +These functions return the length (in bytes) of the multibyte sequence needed to represent -.Fa wc , +.Fa c , or .Po Vt size_t Pc Ns \-1 if -.Fa wc +.Fa c is not a valid wide character code. .Sh ERRORS The -.Fn wcrtomb -function will fail if: +.Fn wcrtomb , +.Fn c16rtomb +and +.Fn c32rtomb +functions will fail if: .Bl -tag -width Er .It Bq Er EILSEQ An invalid wide character code was specified. @@ -100,6 +115,9 @@ The conversion state is invalid. .Xr wctomb 3 .Sh STANDARDS The -.Fn wcrtomb -function conforms to -.St -isoC-99 . +.Fn wcrtomb , +.Fn c16rtomb +and +.Fn c32rtomb +functions conform to +.St -isoC-2011 . diff --git a/lib/libc/locale/xlocale.3 b/lib/libc/locale/xlocale.3 index 9648cc7a7926..d467a1004f24 100644 --- a/lib/libc/locale/xlocale.3 +++ b/lib/libc/locale/xlocale.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17 2011 +.Dd September 17, 2011 .Dt XLOCALE 3 .Os .Sh NAME diff --git a/lib/libc/locale/xlocale_private.h b/lib/libc/locale/xlocale_private.h index 813f71994052..502b5486e684 100644 --- a/lib/libc/locale/xlocale_private.h +++ b/lib/libc/locale/xlocale_private.h @@ -109,6 +109,10 @@ struct _xlocale { __mbstate_t mblen; /** Persistent state used by mbrlen() calls. */ __mbstate_t mbrlen; + /** Persistent state used by mbrtoc16() calls. */ + __mbstate_t mbrtoc16; + /** Persistent state used by mbrtoc32() calls. */ + __mbstate_t mbrtoc32; /** Persistent state used by mbrtowc() calls. */ __mbstate_t mbrtowc; /** Persistent state used by mbsnrtowcs() calls. */ @@ -117,6 +121,10 @@ struct _xlocale { __mbstate_t mbsrtowcs; /** Persistent state used by mbtowc() calls. */ __mbstate_t mbtowc; + /** Persistent state used by c16rtomb() calls. */ + __mbstate_t c16rtomb; + /** Persistent state used by c32rtomb() calls. */ + __mbstate_t c32rtomb; /** Persistent state used by wcrtomb() calls. */ __mbstate_t wcrtomb; /** Persistent state used by wcsnrtombs() calls. */ diff --git a/lib/libc/mips/gen/getcontextx.c b/lib/libc/mips/gen/getcontextx.c index 307978a466dd..54f851384811 100644 --- a/lib/libc/mips/gen/getcontextx.c +++ b/lib/libc/mips/gen/getcontextx.c @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; diff --git a/lib/libc/mips/gen/longjmp.c b/lib/libc/mips/gen/longjmp.c index ee01ad55002c..7c684706c042 100644 --- a/lib/libc/mips/gen/longjmp.c +++ b/lib/libc/mips/gen/longjmp.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/mips/net/htonl.S b/lib/libc/mips/net/htonl.S index 858892009edf..66c4f90fd65f 100644 --- a/lib/libc/mips/net/htonl.S +++ b/lib/libc/mips/net/htonl.S @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/mips/net/htons.S b/lib/libc/mips/net/htons.S index 592c44eeeb8b..0449c4d82e5c 100644 --- a/lib/libc/mips/net/htons.S +++ b/lib/libc/mips/net/htons.S @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/mips/net/ntohl.S b/lib/libc/mips/net/ntohl.S index bacda3eb6c19..39001aa86bbe 100644 --- a/lib/libc/mips/net/ntohl.S +++ b/lib/libc/mips/net/ntohl.S @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/mips/net/ntohs.S b/lib/libc/mips/net/ntohs.S index 28aac3dffdc6..4761371be1af 100644 --- a/lib/libc/mips/net/ntohs.S +++ b/lib/libc/mips/net/ntohs.S @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c index d769f2781a44..5d72606af050 100644 --- a/lib/libc/net/ether_addr.c +++ b/lib/libc/net/ether_addr.c @@ -148,7 +148,7 @@ ether_ntohost(char *hostname, const struct ether_addr *e) char *yp_domain; #endif - if ((fp = fopen(_PATH_ETHERS, "r")) == NULL) + if ((fp = fopen(_PATH_ETHERS, "re")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { if (buf[0] == '#') @@ -197,7 +197,7 @@ ether_hostton(const char *hostname, struct ether_addr *e) char *yp_domain; #endif - if ((fp = fopen(_PATH_ETHERS, "r")) == NULL) + if ((fp = fopen(_PATH_ETHERS, "re")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { if (buf[0] == '#') diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c index 50851674de69..d9ed76c915aa 100644 --- a/lib/libc/net/eui64.c +++ b/lib/libc/net/eui64.c @@ -227,7 +227,7 @@ eui64_ntohost(char *hostname, size_t len, const struct eui64 *id) char eui64_a[24]; char *yp_domain; #endif - if ((fp = fopen(_PATH_EUI64, "r")) == NULL) + if ((fp = fopen(_PATH_EUI64, "re")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { @@ -277,7 +277,7 @@ eui64_hostton(const char *hostname, struct eui64 *id) int resultlen; char *yp_domain; #endif - if ((fp = fopen(_PATH_EUI64, "r")) == NULL) + if ((fp = fopen(_PATH_EUI64, "re")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index 3419809915f2..5d03aab2a42c 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -26,9 +26,9 @@ .Nm freeaddrinfo .Nd socket address structure to host and service name .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/socket.h> -.Fd #include <netdb.h> +.In sys/types.h +.In sys/socket.h +.In netdb.h .Ft int .Fo getaddrinfo .Fa "const char *hostname" "const char *servname" @@ -255,7 +255,7 @@ member points to a filled-in socket address structure of length This implementation of .Fn getaddrinfo allows numeric IPv6 address notation with scope identifier, -as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt. +as documented in chapter 11 of RFC 4007. By appending the percent character and scope identifier to addresses, one can fill the .Li sin6_scope_id @@ -441,9 +441,8 @@ freeaddrinfo(res0); .%A E. Nordmark .%A B. Zill .%T "IPv6 Scoped Address Architecture" -.%R internet draft -.%N draft-ietf-ipv6-scoping-arch-02.txt -.%O work in progress material +.%R RFC 4007 +.%D March 2005 .Re .Rs .%A Craig Metz diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index d11ff780d8bb..c6af6d8f6435 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -2240,7 +2240,7 @@ static void _sethtent(FILE **hostf) { if (!*hostf) - *hostf = fopen(_PATH_HOSTS, "r"); + *hostf = fopen(_PATH_HOSTS, "re"); else rewind(*hostf); } @@ -2264,7 +2264,7 @@ _gethtent(FILE **hostf, const char *name, const struct addrinfo *pai) const char *addr; char hostbuf[8*1024]; - if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r"))) + if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re"))) return (NULL); again: if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf))) diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c index 4253d4933d52..1468afb6304f 100644 --- a/lib/libc/net/gethostbyht.c +++ b/lib/libc/net/gethostbyht.c @@ -72,7 +72,7 @@ void _sethosthtent(int f, struct hostent_data *hed) { if (!hed->hostf) - hed->hostf = fopen(_PATH_HOSTS, "r"); + hed->hostf = fopen(_PATH_HOSTS, "re"); else rewind(hed->hostf); hed->stayopen = f; @@ -96,7 +96,7 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped, int af, len; char hostbuf[BUFSIZ + 1]; - if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "r"))) { + if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "re"))) { RES_SET_H_ERRNO(statp, NETDB_INTERNAL); return (-1); } diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3 index 9b8c0b915333..35f031b5727a 100644 --- a/lib/libc/net/gethostbyname.3 +++ b/lib/libc/net/gethostbyname.3 @@ -51,7 +51,7 @@ .Ft struct hostent * .Fn gethostbyname2 "const char *name" "int af" .Ft struct hostent * -.Fn gethostbyaddr "const void *addr" "socklen_t len" "int type" +.Fn gethostbyaddr "const void *addr" "socklen_t len" "int af" .Ft struct hostent * .Fn gethostent void .Ft void @@ -107,7 +107,7 @@ in binary form .Tn ASCII form). The -.Fa type +.Fa af argument specifies the address family (e.g.\& .Dv AF_INET , AF_INET6 , diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3 index a12cd00bfb4c..ff3f77493a77 100644 --- a/lib/libc/net/getifaddrs.3 +++ b/lib/libc/net/getifaddrs.3 @@ -24,15 +24,13 @@ .\" .\" $FreeBSD$ .\" -.Dd October 12, 1995 +.Dd May 21, 2013 .Dt GETIFADDRS 3 .Os .Sh NAME .Nm getifaddrs .Nd get interface addresses .Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h .In ifaddrs.h .Ft int .Fn getifaddrs "struct ifaddrs **ifap" diff --git a/lib/libc/net/getifmaddrs.3 b/lib/libc/net/getifmaddrs.3 index 2d2a93681297..14c40875439c 100644 --- a/lib/libc/net/getifmaddrs.3 +++ b/lib/libc/net/getifmaddrs.3 @@ -20,15 +20,13 @@ .\" .\" $FreeBSD$ .\" -.Dd November 14, 2003 +.Dd May 21, 2013 .Dt GETIFMADDRS 3 .Os .Sh NAME .Nm getifmaddrs .Nd get multicast group memberships .Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h .In ifaddrs.h .Ft int .Fn getifmaddrs "struct ifmaddrs **ifmap" diff --git a/lib/libc/net/getifmaddrs.c b/lib/libc/net/getifmaddrs.c index adbc4a5dde6e..c05d6de57b25 100644 --- a/lib/libc/net/getifmaddrs.c +++ b/lib/libc/net/getifmaddrs.c @@ -10,24 +10,18 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bruce M. Simpson. - * 4. Neither the name of Bruce M. Simpson nor the names of other - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON AND AFFILIATES - * ``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 BRUCE M. SIMPSON 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. + * 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> diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3 index e508e5ddbd84..0549ccd2219b 100644 --- a/lib/libc/net/getnameinfo.3 +++ b/lib/libc/net/getnameinfo.3 @@ -25,9 +25,9 @@ .Nm getnameinfo .Nd socket address structure to hostname and service name .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/socket.h> -.Fd #include <netdb.h> +.In sys/types.h +.In sys/socket.h +.In netdb.h .Ft int .Fo getnameinfo .Fa "const struct sockaddr *sa" "socklen_t salen" "char *host" @@ -191,10 +191,11 @@ printf("host=%s\en", hbuf); .%A R. Gilligan .%A S. Thomson .%A J. Bound +.%A J. McCann .%A W. Stevens .%T Basic Socket Interface Extensions for IPv6 -.%R RFC 2553 -.%D March 1999 +.%R RFC 3493 +.%D February 2003 .Re .Rs .%A S. Deering @@ -203,9 +204,8 @@ printf("host=%s\en", hbuf); .%A E. Nordmark .%A B. Zill .%T "IPv6 Scoped Address Architecture" -.%R internet draft -.%N draft-ietf-ipv6-scoping-arch-02.txt -.%O work in progress material +.%R RFC 4007 +.%D March 2005 .Re .Rs .%A Craig Metz @@ -217,9 +217,9 @@ printf("host=%s\en", hbuf); The .Fn getnameinfo function is defined by the -.St -p1003.1g-2000 -draft specification and documented in -.Tn "RFC 2553" , +.St -p1003.1-2004 +specification and documented in +.Tn "RFC 3493" , .Dq Basic Socket Interface Extensions for IPv6 . .Sh CAVEATS .Fn getnameinfo diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c index d2df570e7e28..bee00e807fe3 100644 --- a/lib/libc/net/getnetbyht.c +++ b/lib/libc/net/getnetbyht.c @@ -63,7 +63,7 @@ _setnethtent(int f, struct netent_data *ned) { if (ned->netf == NULL) - ned->netf = fopen(_PATH_NETWORKS, "r"); + ned->netf = fopen(_PATH_NETWORKS, "re"); else rewind(ned->netf); ned->stayopen |= f; @@ -89,7 +89,7 @@ getnetent_p(struct netent *ne, struct netent_data *ned) char line[BUFSIZ + 1]; if (ned->netf == NULL && - (ned->netf = fopen(_PATH_NETWORKS, "r")) == NULL) + (ned->netf = fopen(_PATH_NETWORKS, "re")) == NULL) return (-1); again: p = fgets(line, sizeof line, ned->netf); diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c index 0cfca458898f..114069acc255 100644 --- a/lib/libc/net/getprotoent.c +++ b/lib/libc/net/getprotoent.c @@ -342,7 +342,7 @@ void __setprotoent_p(int f, struct protoent_data *ped) { if (ped->fp == NULL) - ped->fp = fopen(_PATH_PROTOCOLS, "r"); + ped->fp = fopen(_PATH_PROTOCOLS, "re"); else rewind(ped->fp); ped->stayopen |= f; @@ -365,7 +365,7 @@ __getprotoent_p(struct protoent *pe, struct protoent_data *ped) char *cp, **q, *endp; long l; - if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "r")) == NULL) + if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL) return (-1); again: if ((p = fgets(ped->line, sizeof ped->line, ped->fp)) == NULL) diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c index 3228bdc2eea7..005de9870064 100644 --- a/lib/libc/net/getservent.c +++ b/lib/libc/net/getservent.c @@ -335,7 +335,7 @@ files_servent(void *retval, void *mdata, va_list ap) if (st->fp == NULL) st->compat_mode_active = 0; - if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "r")) == NULL) { + if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "re")) == NULL) { *errnop = errno; return (NS_UNAVAIL); } @@ -449,7 +449,7 @@ files_setservent(void *retval, void *mdata, va_list ap) case SETSERVENT: f = va_arg(ap,int); if (st->fp == NULL) - st->fp = fopen(_PATH_SERVICES, "r"); + st->fp = fopen(_PATH_SERVICES, "re"); else rewind(st->fp); st->stayopen |= f; diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c index 24137279d8f3..4258993a4368 100644 --- a/lib/libc/net/hesiod.c +++ b/lib/libc/net/hesiod.c @@ -286,7 +286,7 @@ read_config_file(ctx, filename) ctx->classes[1] = C_HS; /* Try to open the configuration file. */ - fp = fopen(filename, "r"); + fp = fopen(filename, "re"); if (!fp) { /* Use compiled in default domain names. */ ctx->lhs = strdup(DEF_LHS); diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index f36016249602..118e033e128d 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -42,11 +42,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. 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. * diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c index f9d787a0fdff..4fbc9baa27eb 100644 --- a/lib/libc/net/nsdispatch.c +++ b/lib/libc/net/nsdispatch.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -368,7 +361,7 @@ nss_configure(void) if (result != 0) goto fin2; } - _nsyyin = fopen(path, "r"); + _nsyyin = fopen(path, "re"); if (_nsyyin == NULL) goto fin; VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap), diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l index 0f705cf72dcf..3983fa257903 100644 --- a/lib/libc/net/nslexer.l +++ b/lib/libc/net/nslexer.l @@ -16,13 +16,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -53,11 +46,10 @@ static char *rcsid = #include "nsparser.h" -#define YY_NO_INPUT -#define YY_NO_UNPUT - %} +%option noinput +%option nounput %option yylineno BLANK [ \t] diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y index 2e57cd26dd3d..c1d84247bd8c 100644 --- a/lib/libc/net/nsparser.y +++ b/lib/libc/net/nsparser.y @@ -16,13 +16,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 990289a7edcc..2885dc331e08 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -458,7 +458,7 @@ iruserok_sa(ra, rlen, superuser, ruser, luser) raddr = (struct sockaddr *)&ss; first = 1; - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); + hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re"); again: if (hostf) { if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) { @@ -481,7 +481,7 @@ again: */ uid = geteuid(); (void)seteuid(pwd->pw_uid); - hostf = fopen(pbuf, "r"); + hostf = fopen(pbuf, "re"); (void)seteuid(uid); if (hostf == NULL) diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c index c8230d683b94..f71d4780bb7c 100644 --- a/lib/libc/net/recv.c +++ b/lib/libc/net/recv.c @@ -33,12 +33,10 @@ static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "namespace.h" #include <sys/types.h> #include <sys/socket.h> #include <stddef.h> -#include "un-namespace.h" ssize_t recv(s, buf, len, flags) @@ -46,5 +44,9 @@ recv(s, buf, len, flags) size_t len; void *buf; { - return (_recvfrom(s, buf, len, flags, NULL, 0)); + /* + * POSIX says recv() shall be a cancellation point, so call the + * cancellation-enabled recvfrom() and not _recvfrom(). + */ + return (recvfrom(s, buf, len, flags, NULL, 0)); } diff --git a/lib/libc/net/sctp_bindx.3 b/lib/libc/net/sctp_bindx.3 index 403cf7d1e758..263cb6398806 100644 --- a/lib/libc/net/sctp_bindx.3 +++ b/lib/libc/net/sctp_bindx.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_connectx.3 b/lib/libc/net/sctp_connectx.3 index 6ea1bb622f28..0c298e1ea00a 100644 --- a/lib/libc/net/sctp_connectx.3 +++ b/lib/libc/net/sctp_connectx.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_freepaddrs.3 b/lib/libc/net/sctp_freepaddrs.3 index 77a8488177a0..400f21d8d808 100644 --- a/lib/libc/net/sctp_freepaddrs.3 +++ b/lib/libc/net/sctp_freepaddrs.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_getaddrlen.3 b/lib/libc/net/sctp_getaddrlen.3 index 7259635f79fb..70e3688c74d6 100644 --- a/lib/libc/net/sctp_getaddrlen.3 +++ b/lib/libc/net/sctp_getaddrlen.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_getassocid.3 b/lib/libc/net/sctp_getassocid.3 index f347a1341c58..3c89fdc0c057 100644 --- a/lib/libc/net/sctp_getassocid.3 +++ b/lib/libc/net/sctp_getassocid.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_getpaddrs.3 b/lib/libc/net/sctp_getpaddrs.3 index 8bdf2ccf370a..0c7b8ecb5051 100644 --- a/lib/libc/net/sctp_getpaddrs.3 +++ b/lib/libc/net/sctp_getpaddrs.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_opt_info.3 b/lib/libc/net/sctp_opt_info.3 index 02b0f852156f..170692cfd3fc 100644 --- a/lib/libc/net/sctp_opt_info.3 +++ b/lib/libc/net/sctp_opt_info.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3 index eda3e5cc34c4..e3ced9c42a96 100644 --- a/lib/libc/net/sctp_recvmsg.3 +++ b/lib/libc/net/sctp_recvmsg.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3 index d195b7ab4899..37b0b7185b00 100644 --- a/lib/libc/net/sctp_send.3 +++ b/lib/libc/net/sctp_send.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_sendmsg.3 b/lib/libc/net/sctp_sendmsg.3 index 4158932ebc64..bc61061c2718 100644 --- a/lib/libc/net/sctp_sendmsg.3 +++ b/lib/libc/net/sctp_sendmsg.3 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 6b938a4e7169..1b65b07325f0 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -274,6 +274,11 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size) errno = EINVAL; return (-1); } + if ((id == SCTP_CURRENT_ASSOC) || + (id == SCTP_ALL_ASSOC)) { + errno = EINVAL; + return (-1); + } switch (opt) { case SCTP_RTOINFO: ((struct sctp_rtoinfo *)arg)->srto_assoc_id = id; @@ -338,6 +343,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size) case SCTP_MAX_BURST: ((struct sctp_assoc_value *)arg)->assoc_id = id; break; + case SCTP_ENABLE_STREAM_RESET: + ((struct sctp_assoc_value *)arg)->assoc_id = id; + break; default: break; } diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c index 101b0ceb45ff..93cdfda17532 100644 --- a/lib/libc/net/send.c +++ b/lib/libc/net/send.c @@ -33,12 +33,10 @@ static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "namespace.h" #include <sys/types.h> #include <sys/socket.h> #include <stddef.h> -#include "un-namespace.h" ssize_t send(s, msg, len, flags) @@ -46,5 +44,9 @@ send(s, msg, len, flags) size_t len; const void *msg; { - return (_sendto(s, msg, len, flags, NULL, 0)); + /* + * POSIX says send() shall be a cancellation point, so call the + * cancellation-enabled sendto() and not _sendto(). + */ + return (sendto(s, msg, len, flags, NULL, 0)); } diff --git a/lib/libc/nls/C.msg b/lib/libc/nls/C.msg index 2210df6cc463..d08c5719225e 100644 --- a/lib/libc/nls/C.msg +++ b/lib/libc/nls/C.msg @@ -191,6 +191,12 @@ $ EPROTO 92 Protocol error $ ENOTCAPABLE 93 Capabilities insufficient +$ ECAPMODE +94 Not permitted in capability mode +$ ENOTRECOVERABLE +95 State not recoverable +$ EOWNERDEAD +96 Previous owner died $ $ strsignal() support catalog $ diff --git a/lib/libc/nls/fr_FR.ISO8859-1.msg b/lib/libc/nls/fr_FR.ISO8859-1.msg index 35a8c4a46cb3..ebc1739ea28c 100644 --- a/lib/libc/nls/fr_FR.ISO8859-1.msg +++ b/lib/libc/nls/fr_FR.ISO8859-1.msg @@ -94,7 +94,7 @@ $ EPROTONOSUPPORT $ ESOCKTNOSUPPORT 44 Type de socket non supporté $ EOPNOTSUPP -45 Opération non supporté +45 Opération non supportée $ EPFNOSUPPORT 46 Famille de protocole non supportée $ EAFNOSUPPORT diff --git a/lib/libc/posix1e/acl_is_trivial_np.3 b/lib/libc/posix1e/acl_is_trivial_np.3 index 4ad1a632291b..a9cd4dfe3549 100644 --- a/lib/libc/posix1e/acl_is_trivial_np.3 +++ b/lib/libc/posix1e/acl_is_trivial_np.3 @@ -52,7 +52,7 @@ will be set to 1, if the ACL .Fa aclp points to is trivial, or 0 if it's not. .Pp -ACL is trivial if it can be fully expressed as a file mode without loosing +ACL is trivial if it can be fully expressed as a file mode without losing any access rules. For POSIX.1e ACLs, ACL is trivial if it has the three required entries, one for owner, one for owning group, and one for other. diff --git a/lib/libc/posix1e/mac.c b/lib/libc/posix1e/mac.c index 62a74eee1944..6bc9b773c22a 100644 --- a/lib/libc/posix1e/mac.c +++ b/lib/libc/posix1e/mac.c @@ -179,7 +179,7 @@ mac_init_internal(int ignore_errors) filename = getenv("MAC_CONFFILE"); else filename = MAC_CONFFILE; - file = fopen(filename, "r"); + file = fopen(filename, "re"); if (file == NULL) return (0); diff --git a/lib/libc/powerpc/gen/getcontextx.c b/lib/libc/powerpc/gen/getcontextx.c index 307978a466dd..54f851384811 100644 --- a/lib/libc/powerpc/gen/getcontextx.c +++ b/lib/libc/powerpc/gen/getcontextx.c @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; diff --git a/lib/libc/powerpc64/gen/fpgetmask.c b/lib/libc/powerpc64/gen/fpgetmask.c index aa7623b2706f..b67b1bcb4dc0 100644 --- a/lib/libc/powerpc64/gen/fpgetmask.c +++ b/lib/libc/powerpc64/gen/fpgetmask.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/powerpc64/gen/fpgetround.c b/lib/libc/powerpc64/gen/fpgetround.c index 538137827a8d..097e82aa9a41 100644 --- a/lib/libc/powerpc64/gen/fpgetround.c +++ b/lib/libc/powerpc64/gen/fpgetround.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/powerpc64/gen/fpgetsticky.c b/lib/libc/powerpc64/gen/fpgetsticky.c index feb2ccca43a1..57152ac50104 100644 --- a/lib/libc/powerpc64/gen/fpgetsticky.c +++ b/lib/libc/powerpc64/gen/fpgetsticky.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/powerpc64/gen/fpsetmask.c b/lib/libc/powerpc64/gen/fpsetmask.c index e1433a543192..81cd19e57f1b 100644 --- a/lib/libc/powerpc64/gen/fpsetmask.c +++ b/lib/libc/powerpc64/gen/fpsetmask.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/powerpc64/gen/fpsetround.c b/lib/libc/powerpc64/gen/fpsetround.c index b4f00d4e74bc..17f70a0cab64 100644 --- a/lib/libc/powerpc64/gen/fpsetround.c +++ b/lib/libc/powerpc64/gen/fpsetround.c @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED diff --git a/lib/libc/powerpc64/gen/getcontextx.c b/lib/libc/powerpc64/gen/getcontextx.c index 307978a466dd..54f851384811 100644 --- a/lib/libc/powerpc64/gen/getcontextx.c +++ b/lib/libc/powerpc64/gen/getcontextx.c @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c index 661e880f37e4..5193c1d739e8 100644 --- a/lib/libc/resolv/res_init.c +++ b/lib/libc/resolv/res_init.c @@ -304,7 +304,7 @@ __res_vinit(res_state statp, int preinit) { line[sizeof(name) - 1] == '\t')) nserv = 0; - if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { + if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* skip comments */ diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c index 746a2be76b18..854909ccb136 100644 --- a/lib/libc/resolv/res_query.c +++ b/lib/libc/resolv/res_query.c @@ -457,7 +457,7 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) { if (issetugid()) return (NULL); file = getenv("HOSTALIASES"); - if (file == NULL || (fp = fopen(file, "r")) == NULL) + if (file == NULL || (fp = fopen(file, "re")) == NULL) return (NULL); setbuf(fp, NULL); buf[sizeof(buf) - 1] = '\0'; diff --git a/lib/libc/sparc64/gen/getcontextx.c b/lib/libc/sparc64/gen/getcontextx.c index 307978a466dd..54f851384811 100644 --- a/lib/libc/sparc64/gen/getcontextx.c +++ b/lib/libc/sparc64/gen/getcontextx.c @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; diff --git a/lib/libc/sparc64/gen/makecontext.c b/lib/libc/sparc64/gen/makecontext.c index 95795de992cf..42bcc8803060 100644 --- a/lib/libc/sparc64/gen/makecontext.c +++ b/lib/libc/sparc64/gen/makecontext.c @@ -54,12 +54,12 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...) mc = &ucp->uc_mcontext; if (ucp == NULL || - (mc->mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION) + (mc->_mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION) return; if ((argc < 0) || (argc > 6) || (ucp->uc_stack.ss_sp == NULL) || (ucp->uc_stack.ss_size < MINSIGSTKSZ)) { - mc->mc_flags = 0; + mc->_mc_flags = 0; return; } mc = &ucp->uc_mcontext; @@ -71,8 +71,8 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...) mc->mc_global[1] = (uint64_t)start; mc->mc_global[2] = (uint64_t)ucp; mc->mc_out[6] = sp - SPOFF - sizeof(struct frame); - mc->mc_tnpc = (uint64_t)_ctx_start + 4; - mc->mc_tpc = (uint64_t)_ctx_start; + mc->_mc_tnpc = (uint64_t)_ctx_start + 4; + mc->_mc_tpc = (uint64_t)_ctx_start; } void @@ -82,7 +82,7 @@ _ctx_done(ucontext_t *ucp) if (ucp->uc_link == NULL) exit(0); else { - ucp->uc_mcontext.mc_flags = 0; + ucp->uc_mcontext._mc_flags = 0; setcontext((const ucontext_t *)ucp->uc_link); abort(); } diff --git a/lib/libc/sparc64/gen/signalcontext.c b/lib/libc/sparc64/gen/signalcontext.c index 622f36f5bd75..159184513807 100644 --- a/lib/libc/sparc64/gen/signalcontext.c +++ b/lib/libc/sparc64/gen/signalcontext.c @@ -52,7 +52,7 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func) mcontext_t *mc; mc = &ucp->uc_mcontext; - sfp = (struct sigframe *)(mc->mc_sp + SPOFF) - 1; + sfp = (struct sigframe *)(mc->_mc_sp + SPOFF) - 1; fp = (struct frame *)sfp - 1; bzero(fp, sizeof(*fp)); @@ -67,8 +67,8 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func) mc->mc_out[1] = (uint64_t)&sfp->sf_si; mc->mc_out[2] = (uint64_t)&sfp->sf_uc; mc->mc_out[6] = (uint64_t)fp - SPOFF; - mc->mc_tnpc = (uint64_t)_ctx_start + 4; - mc->mc_tpc = (uint64_t)_ctx_start; + mc->_mc_tnpc = (uint64_t)_ctx_start + 4; + mc->_mc_tpc = (uint64_t)_ctx_start; ucp->uc_link = &sfp->sf_uc; sigdelset(&ucp->uc_sigmask, sig); diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc index 0062d3dd8dd8..419d03194b76 100644 --- a/lib/libc/stdio/Makefile.inc +++ b/lib/libc/stdio/Makefile.inc @@ -60,7 +60,8 @@ MLINKS+=getc.3 fgetc.3 getc.3 getc_unlocked.3 getc.3 getchar.3 \ getc.3 getchar_unlocked.3 getc.3 getw.3 MLINKS+=getline.3 getdelim.3 MLINKS+=getwc.3 fgetwc.3 getwc.3 getwchar.3 -MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 +MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 \ + mktemp.3 mkostemp.3 mktemp.3 mkostemps.3 MLINKS+=open_memstream.3 open_wmemstream.3 MLINKS+=printf.3 asprintf.3 printf.3 dprintf.3 printf.3 fprintf.3 \ printf.3 snprintf.3 printf.3 sprintf.3 \ diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map index 538b29aac4cb..d2a8c92b2411 100644 --- a/lib/libc/stdio/Symbol.map +++ b/lib/libc/stdio/Symbol.map @@ -158,6 +158,8 @@ FBSD_1.3 { fmemopen; open_memstream; open_wmemstream; + mkostemp; + mkostemps; }; FBSDprivate_1.0 { diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c index cd475cd2117e..242127f36025 100644 --- a/lib/libc/stdio/asprintf.c +++ b/lib/libc/stdio/asprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/clrerr.c b/lib/libc/stdio/clrerr.c index 1b318e6a85db..f161a6e1e802 100644 --- a/lib/libc/stdio/clrerr.c +++ b/lib/libc/stdio/clrerr.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$"); #undef clearerr_unlocked void -clearerr(fp) - FILE *fp; +clearerr(FILE *fp) { FLOCKFILE(fp); __sclearerr(fp); diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c index 3957b6a427e3..5ed8b2c548f6 100644 --- a/lib/libc/stdio/fclose.c +++ b/lib/libc/stdio/fclose.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c index 8fc90a438b99..2e19b9febcd8 100644 --- a/lib/libc/stdio/fdopen.c +++ b/lib/libc/stdio/fdopen.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$"); #include "local.h" FILE * -fdopen(fd, mode) - int fd; - const char *mode; +fdopen(int fd, const char *mode) { FILE *fp; int flags, oflags, fdflags, tmp; diff --git a/lib/libc/stdio/feof.c b/lib/libc/stdio/feof.c index 502f1e5a3ada..b970248a3128 100644 --- a/lib/libc/stdio/feof.c +++ b/lib/libc/stdio/feof.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c index d155ff0c3b4c..7e0f8f957165 100644 --- a/lib/libc/stdio/ferror.c +++ b/lib/libc/stdio/ferror.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c index c0237cf5a264..456b031dd01b 100644 --- a/lib/libc/stdio/fflush.c +++ b/lib/libc/stdio/fflush.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fgetc.c b/lib/libc/stdio/fgetc.c index 8024df152395..2ee4d7a78cb5 100644 --- a/lib/libc/stdio/fgetc.c +++ b/lib/libc/stdio/fgetc.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -43,8 +43,7 @@ __FBSDID("$FreeBSD$"); #include "local.h" int -fgetc(fp) - FILE *fp; +fgetc(FILE *fp) { int retval; FLOCKFILE(fp); diff --git a/lib/libc/stdio/fgetln.c b/lib/libc/stdio/fgetln.c index 0cd04b8b6efc..1779de2ae559 100644 --- a/lib/libc/stdio/fgetln.c +++ b/lib/libc/stdio/fgetln.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fgetpos.c b/lib/libc/stdio/fgetpos.c index 9053be84a5de..f161f4325fd3 100644 --- a/lib/libc/stdio/fgetpos.c +++ b/lib/libc/stdio/fgetpos.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c index a0cc72452516..9abf559bf108 100644 --- a/lib/libc/stdio/fgets.c +++ b/lib/libc/stdio/fgets.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,10 +49,7 @@ __FBSDID("$FreeBSD$"); * Return first argument, or NULL if no characters were read. */ char * -fgets(buf, n, fp) - char *buf; - int n; - FILE *fp; +fgets(char * __restrict buf, int n, FILE * __restrict fp) { size_t len; char *s; diff --git a/lib/libc/stdio/fileno.c b/lib/libc/stdio/fileno.c index 1962bb79b8b5..3ac183010ef6 100644 --- a/lib/libc/stdio/fileno.c +++ b/lib/libc/stdio/fileno.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index 6d0b673395f6..be196b73c687 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -91,8 +91,7 @@ spinlock_t __stdio_thread_lock = _SPINLOCK_INITIALIZER; #endif static struct glue * -moreglue(n) - int n; +moreglue(int n) { struct glue *g; static FILE empty = { ._fl_mutex = PTHREAD_MUTEX_INITIALIZER }; diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c index e445fedd0794..1878c2f4e134 100644 --- a/lib/libc/stdio/flags.c +++ b/lib/libc/stdio/flags.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$"); * Return 0 on error. */ int -__sflags(mode, optr) - const char *mode; - int *optr; +__sflags(const char *mode, int *optr) { int ret, m, o; diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index 6fe536a0c907..b08e3366ac68 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$"); #include "local.h" FILE * -fopen(file, mode) - const char * __restrict file; - const char * __restrict mode; +fopen(const char * __restrict file, const char * __restrict mode) { FILE *fp; int f; diff --git a/lib/libc/stdio/fprintf.c b/lib/libc/stdio/fprintf.c index 169532d1cd1b..739e1f555e09 100644 --- a/lib/libc/stdio/fprintf.c +++ b/lib/libc/stdio/fprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fpurge.c b/lib/libc/stdio/fpurge.c index 148e490eafe2..f205bdfc3bf5 100644 --- a/lib/libc/stdio/fpurge.c +++ b/lib/libc/stdio/fpurge.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$"); * given FILE's buffer empty. */ int -fpurge(fp) - FILE *fp; +fpurge(FILE *fp) { int retval; FLOCKFILE(fp); diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c index 66d9a2f773cf..3b6101f92f4d 100644 --- a/lib/libc/stdio/fputc.c +++ b/lib/libc/stdio/fputc.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" int -fputc(c, fp) - int c; - FILE *fp; +fputc(int c, FILE *fp) { int retval; FLOCKFILE(fp); diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c index eb20f9eb4a1e..3b8f2c9d1b68 100644 --- a/lib/libc/stdio/fputs.c +++ b/lib/libc/stdio/fputs.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$"); * Write the given string to the given file. */ int -fputs(s, fp) - const char * __restrict s; - FILE * __restrict fp; +fputs(const char * __restrict s, FILE * __restrict fp) { int retval; struct __suio uio; diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c index ad3ea29de3e0..c24df9914b48 100644 --- a/lib/libc/stdio/fread.c +++ b/lib/libc/stdio/fread.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c index 8d1ec917086a..dc5508d4d25b 100644 --- a/lib/libc/stdio/freopen.c +++ b/lib/libc/stdio/freopen.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -55,10 +55,8 @@ __FBSDID("$FreeBSD$"); * all possible, no matter what. */ FILE * -freopen(file, mode, fp) - const char * __restrict file; - const char * __restrict mode; - FILE *fp; +freopen(const char * __restrict file, const char * __restrict mode, + FILE * __restrict fp) { int f; int dflags, flags, isopen, oflags, sverrno, wantfd; diff --git a/lib/libc/stdio/fscanf.c b/lib/libc/stdio/fscanf.c index c5fa85f5629d..014f09415048 100644 --- a/lib/libc/stdio/fscanf.c +++ b/lib/libc/stdio/fscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index c9343490e6b0..2897eebf9c88 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -51,10 +51,7 @@ __FBSDID("$FreeBSD$"); #define POS_ERR (-(fpos_t)1) int -fseek(fp, offset, whence) - FILE *fp; - long offset; - int whence; +fseek(FILE *fp, long offset, int whence) { int ret; int serrno = errno; @@ -72,10 +69,7 @@ fseek(fp, offset, whence) } int -fseeko(fp, offset, whence) - FILE *fp; - off_t offset; - int whence; +fseeko(FILE *fp, off_t offset, int whence) { int ret; int serrno = errno; @@ -97,11 +91,7 @@ fseeko(fp, offset, whence) * `Whence' must be one of the three SEEK_* macros. */ int -_fseeko(fp, offset, whence, ltest) - FILE *fp; - off_t offset; - int whence; - int ltest; +_fseeko(FILE *fp, off_t offset, int whence, int ltest) { fpos_t (*seekfn)(void *, fpos_t, int); fpos_t target, curoff, ret; diff --git a/lib/libc/stdio/fsetpos.c b/lib/libc/stdio/fsetpos.c index f9a742e53a04..c6b8b785918d 100644 --- a/lib/libc/stdio/fsetpos.c +++ b/lib/libc/stdio/fsetpos.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$"); * fsetpos: like fseek. */ int -fsetpos(iop, pos) - FILE *iop; - const fpos_t *pos; +fsetpos(FILE *iop, const fpos_t *pos) { return (fseeko(iop, (off_t)*pos, SEEK_SET)); } diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c index a9ff6ed5c37c..2c8800ccfe19 100644 --- a/lib/libc/stdio/ftell.c +++ b/lib/libc/stdio/ftell.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$"); * standard ftell function. */ long -ftell(fp) - FILE *fp; +ftell(FILE *fp) { off_t rv; @@ -66,8 +65,7 @@ ftell(fp) * ftello: return current offset. */ off_t -ftello(fp) - FILE *fp; +ftello(FILE *fp) { fpos_t rv; int ret; @@ -85,9 +83,7 @@ ftello(fp) } int -_ftello(fp, offset) - FILE *fp; - fpos_t *offset; +_ftello(FILE *fp, fpos_t *offset) { fpos_t pos; size_t n; diff --git a/lib/libc/stdio/funopen.c b/lib/libc/stdio/funopen.c index 573589f14d53..983fe5011902 100644 --- a/lib/libc/stdio/funopen.c +++ b/lib/libc/stdio/funopen.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c index 7206676869e6..1a28b6a79c01 100644 --- a/lib/libc/stdio/fvwrite.c +++ b/lib/libc/stdio/fvwrite.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$"); * to the three different kinds of output buffering is handled here. */ int -__sfvwrite(fp, uio) - FILE *fp; - struct __suio *uio; +__sfvwrite(FILE *fp, struct __suio *uio) { size_t len; char *p; diff --git a/lib/libc/stdio/fwalk.c b/lib/libc/stdio/fwalk.c index cb200710de3b..151837b29025 100644 --- a/lib/libc/stdio/fwalk.c +++ b/lib/libc/stdio/fwalk.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$"); #include "glue.h" int -_fwalk(function) - int (*function)(FILE *); +_fwalk(int (*function)(FILE *)) { FILE *fp; int n, ret; diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c index acac94398ea4..5b57fab0b9e1 100644 --- a/lib/libc/stdio/fwrite.c +++ b/lib/libc/stdio/fwrite.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$"); * Return the number of whole objects written. */ size_t -fwrite(buf, size, count, fp) - const void * __restrict buf; - size_t size, count; - FILE * __restrict fp; +fwrite(const void * __restrict buf, size_t size, size_t count, FILE * __restrict fp) { size_t n; struct __suio uio; @@ -68,7 +65,7 @@ fwrite(buf, size, count, fp) /* * Check for integer overflow. As an optimization, first check that * at least one of {count, size} is at least 2^16, since if both - * values are less than that, their product can't possible overflow + * values are less than that, their product can't possibly overflow * (size_t is always at least 32 bits on FreeBSD). */ if (((count | size) > 0xFFFF) && diff --git a/lib/libc/stdio/getc.c b/lib/libc/stdio/getc.c index 5c94e6017149..4963c8ce68e7 100644 --- a/lib/libc/stdio/getc.c +++ b/lib/libc/stdio/getc.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c index 90c84ab9fe44..21040bc8c416 100644 --- a/lib/libc/stdio/getchar.c +++ b/lib/libc/stdio/getchar.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/gets.c b/lib/libc/stdio/gets.c index 6a617cec9974..c7c1c2fa38c8 100644 --- a/lib/libc/stdio/gets.c +++ b/lib/libc/stdio/gets.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); __warn_references(gets, "warning: this program uses gets(), which is unsafe."); char * -gets(buf) - char *buf; +gets(char *buf) { int c; char *s; diff --git a/lib/libc/stdio/getw.c b/lib/libc/stdio/getw.c index d2c69426db3f..ed0313eb60c2 100644 --- a/lib/libc/stdio/getw.c +++ b/lib/libc/stdio/getw.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -39,8 +39,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> int -getw(fp) - FILE *fp; +getw(FILE *fp) { int x; diff --git a/lib/libc/stdio/makebuf.c b/lib/libc/stdio/makebuf.c index 92e6c4be5618..a92087e0eae7 100644 --- a/lib/libc/stdio/makebuf.c +++ b/lib/libc/stdio/makebuf.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -55,8 +55,7 @@ __FBSDID("$FreeBSD$"); * optimisation) right after the _fstat() that finds the buffer size. */ void -__smakebuf(fp) - FILE *fp; +__smakebuf(FILE *fp) { void *p; int flags; @@ -88,10 +87,7 @@ __smakebuf(fp) * Internal routine to determine `proper' buffering for a file. */ int -__swhatbuf(fp, bufsize, couldbetty) - FILE *fp; - size_t *bufsize; - int *couldbetty; +__swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty) { struct stat st; diff --git a/lib/libc/stdio/mktemp.3 b/lib/libc/stdio/mktemp.3 index b51a177b4cdc..816a6b6fcd08 100644 --- a/lib/libc/stdio/mktemp.3 +++ b/lib/libc/stdio/mktemp.3 @@ -28,7 +28,7 @@ .\" @(#)mktemp.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 4, 2012 +.Dd August 8, 2013 .Dt MKTEMP 3 .Os .Sh NAME @@ -37,15 +37,20 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In unistd.h +.In stdlib.h .Ft char * .Fn mktemp "char *template" .Ft int .Fn mkstemp "char *template" .Ft int -.Fn mkstemps "char *template" "int suffixlen" +.Fn mkostemp "char *template" "int oflags" +.Ft int +.Fn mkostemps "char *template" "int suffixlen" "int oflags" .Ft char * .Fn mkdtemp "char *template" +.In unistd.h +.Ft int +.Fn mkstemps "char *template" "int suffixlen" .Sh DESCRIPTION The .Fn mktemp @@ -84,16 +89,41 @@ This avoids the race between testing for a file's existence and opening it for use. .Pp The +.Fn mkostemp +function +is like +.Fn mkstemp +but allows specifying additional +.Xr open 2 +flags (defined in +.In fcntl.h ) . +The permitted flags are +.Dv O_APPEND , +.Dv O_DIRECT , +.Dv O_SHLOCK , +.Dv O_EXLOCK , +.Dv O_SYNC +and +.Dv O_CLOEXEC . +.Pp +The .Fn mkstemps -function acts the same as -.Fn mkstemp , -except it permits a suffix to exist in the template. +and +.Fn mkostemps +functions act the same as +.Fn mkstemp +and +.Fn mkostemp +respectively, +except they permit a suffix to exist in the template. The template should be of the form .Pa /tmp/tmpXXXXXXsuffix . The .Fn mkstemps +and +.Fn mkostemps function -is told the length of the suffix string. +are told the length of the suffix string. .Pp The .Fn mkdtemp @@ -109,9 +139,11 @@ functions return a pointer to the template on success and .Dv NULL on failure. The -.Fn mkstemp -and +.Fn mkstemp , +.Fn mkostemp .Fn mkstemps +and +.Fn mkostemps functions return \-1 if no suitable file could be created. If either call fails an error code is placed in the global variable @@ -119,7 +151,9 @@ If either call fails an error code is placed in the global variable .Sh ERRORS The .Fn mkstemp , -.Fn mkstemps +.Fn mkostemp , +.Fn mkstemps , +.Fn mkostemps and .Fn mkdtemp functions @@ -132,8 +166,25 @@ The pathname portion of the template is not an existing directory. .El .Pp The +.Fn mkostemp +and +.Fn mkostemps +functions +may also set +.Va errno +to the following value: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa oflags +argument is invalid. +.El +.Pp +The .Fn mkstemp , -.Fn mkstemps +.Fn mkostemp , +.Fn mkstemps , +.Fn mkostemps and .Fn mkdtemp functions @@ -144,9 +195,11 @@ to any value specified by the function. .Pp The -.Fn mkstemp -and +.Fn mkstemp , +.Fn mkostemp , .Fn mkstemps +and +.Fn mkostemps functions may also set .Va errno @@ -180,12 +233,39 @@ with an argument of will result in a core dump due to .Fn mkstemp attempting to modify the string constant that was given. +.Pp +The +.Fn mkdtemp , +.Fn mkstemp +and +.Fn mktemp +function prototypes are also available from +.In unistd.h . .Sh SEE ALSO .Xr chmod 2 , .Xr getpid 2 , .Xr mkdir 2 , .Xr open 2 , .Xr stat 2 +.Sh STANDARDS +The +.Fn mkstemp +and +.Fn mkdtemp +functions are expected to conform to +.St -p1003.1-2008 . +The +.Fn mktemp +function is expected to conform to +.St -p1003.1-2001 +and is not specified by +.St -p1003.1-2008 . +The +.Fn mkostemp , +.Fn mkstemps +and +.Fn mkostemps +functions do not conform to any standard. .Sh HISTORY A .Fn mktemp @@ -207,6 +287,12 @@ function first appeared in .Ox 2.4 , and later in .Fx 3.4 . +The +.Fn mkostemp +and +.Fn mkostemps +functions appeared in +.Fx 10.0 . .Sh BUGS This family of functions produces filenames which can be guessed, though the risk is minimized when large numbers of @@ -223,6 +309,8 @@ and opening it for use particularly dangerous from a security perspective. Whenever it is possible, .Fn mkstemp +or +.Fn mkostemp should be used instead, since it does not have the race condition. If .Fn mkstemp diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index a30b930354e3..6fc552a18b2f 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * @@ -47,60 +47,66 @@ __FBSDID("$FreeBSD$"); char *_mktemp(char *); -static int _gettemp(char *, int *, int, int); +static int _gettemp(char *, int *, int, int, int); static const unsigned char padchar[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; int -mkstemps(path, slen) - char *path; - int slen; +mkostemps(char *path, int slen, int oflags) { int fd; - return (_gettemp(path, &fd, 0, slen) ? fd : -1); + return (_gettemp(path, &fd, 0, slen, oflags) ? fd : -1); } int -mkstemp(path) - char *path; +mkstemps(char *path, int slen) { int fd; - return (_gettemp(path, &fd, 0, 0) ? fd : -1); + return (_gettemp(path, &fd, 0, slen, 0) ? fd : -1); +} + +int +mkostemp(char *path, int oflags) +{ + int fd; + + return (_gettemp(path, &fd, 0, 0, oflags) ? fd : -1); +} + +int +mkstemp(char *path) +{ + int fd; + + return (_gettemp(path, &fd, 0, 0, 0) ? fd : -1); } char * -mkdtemp(path) - char *path; +mkdtemp(char *path) { - return (_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL); + return (_gettemp(path, (int *)NULL, 1, 0, 0) ? path : (char *)NULL); } char * -_mktemp(path) - char *path; +_mktemp(char *path) { - return (_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL); + return (_gettemp(path, (int *)NULL, 0, 0, 0) ? path : (char *)NULL); } __warn_references(mktemp, "warning: mktemp() possibly used unsafely; consider using mkstemp()"); char * -mktemp(path) - char *path; +mktemp(char *path) { return (_mktemp(path)); } static int -_gettemp(path, doopen, domkdir, slen) - char *path; - int *doopen; - int domkdir; - int slen; +_gettemp(char *path, int *doopen, int domkdir, int slen, int oflags) { char *start, *trv, *suffp, *carryp; char *pad; @@ -109,7 +115,9 @@ _gettemp(path, doopen, domkdir, slen) uint32_t rand; char carrybuf[MAXPATHLEN]; - if ((doopen != NULL && domkdir) || slen < 0) { + if ((doopen != NULL && domkdir) || slen < 0 || + (oflags & ~(O_APPEND | O_DIRECT | O_SHLOCK | O_EXLOCK | O_SYNC | + O_CLOEXEC)) != 0) { errno = EINVAL; return (0); } @@ -161,7 +169,8 @@ _gettemp(path, doopen, domkdir, slen) for (;;) { if (doopen) { if ((*doopen = - _open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + _open(path, O_CREAT|O_EXCL|O_RDWR|oflags, 0600)) >= + 0) return (1); if (errno != EEXIST) return (0); diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c index 9f1855196ffc..89c079818fb7 100644 --- a/lib/libc/stdio/perror.c +++ b/lib/libc/stdio/perror.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * @@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$"); #include "local.h" void -perror(s) - const char *s; +perror(const char *s) { char msgbuf[NL_TEXTMAX]; struct iovec *v; diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c index c42bd850786d..3a476496219c 100644 --- a/lib/libc/stdio/printf-pos.c +++ b/lib/libc/stdio/printf-pos.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/printf.c b/lib/libc/stdio/printf.c index f623f2f94c25..83147b2314c1 100644 --- a/lib/libc/stdio/printf.c +++ b/lib/libc/stdio/printf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c index d0882f0d3b1e..aaffece49d76 100644 --- a/lib/libc/stdio/putc.c +++ b/lib/libc/stdio/putc.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -46,9 +46,7 @@ __FBSDID("$FreeBSD$"); #undef putc_unlocked int -putc(c, fp) - int c; - FILE *fp; +putc(int c, FILE *fp) { int retval; FLOCKFILE(fp); diff --git a/lib/libc/stdio/putchar.c b/lib/libc/stdio/putchar.c index d263970edff0..756155902f29 100644 --- a/lib/libc/stdio/putchar.c +++ b/lib/libc/stdio/putchar.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$"); * A subroutine version of the macro putchar */ int -putchar(c) - int c; +putchar(int c) { int retval; FILE *so = stdout; diff --git a/lib/libc/stdio/puts.c b/lib/libc/stdio/puts.c index 2dc945b86b5c..5ee7fc1c63f0 100644 --- a/lib/libc/stdio/puts.c +++ b/lib/libc/stdio/puts.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -48,8 +48,7 @@ __FBSDID("$FreeBSD$"); * Write the given string to stdout, appending a newline. */ int -puts(s) - char const *s; +puts(char const *s) { int retval; size_t c = strlen(s); diff --git a/lib/libc/stdio/putw.c b/lib/libc/stdio/putw.c index 8fc1b4da1a6e..0360cafc4052 100644 --- a/lib/libc/stdio/putw.c +++ b/lib/libc/stdio/putw.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" int -putw(w, fp) - int w; - FILE *fp; +putw(int w, FILE *fp) { int retval; struct __suio uio; diff --git a/lib/libc/stdio/refill.c b/lib/libc/stdio/refill.c index f2a1f16f21e6..71eb2e53dab6 100644 --- a/lib/libc/stdio/refill.c +++ b/lib/libc/stdio/refill.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c index f08e47c4e8c8..2e984baf9360 100644 --- a/lib/libc/stdio/remove.c +++ b/lib/libc/stdio/remove.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> int -remove(file) - const char *file; +remove(const char *file) { struct stat sb; diff --git a/lib/libc/stdio/rewind.c b/lib/libc/stdio/rewind.c index 73ef2c657bfc..ff4c9072c76b 100644 --- a/lib/libc/stdio/rewind.c +++ b/lib/libc/stdio/rewind.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/rget.c b/lib/libc/stdio/rget.c index 71c75e0ac9e1..bdc0311674e1 100644 --- a/lib/libc/stdio/rget.c +++ b/lib/libc/stdio/rget.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c index ba33caae7988..e377724ac5be 100644 --- a/lib/libc/stdio/scanf.c +++ b/lib/libc/stdio/scanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/setbuf.c b/lib/libc/stdio/setbuf.c index 0daef5422ec2..5c65f976c9de 100644 --- a/lib/libc/stdio/setbuf.c +++ b/lib/libc/stdio/setbuf.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/setbuffer.c b/lib/libc/stdio/setbuffer.c index dd1caa01f806..af5eb3cabf6e 100644 --- a/lib/libc/stdio/setbuffer.c +++ b/lib/libc/stdio/setbuffer.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -39,10 +39,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> void -setbuffer(fp, buf, size) - FILE *fp; - char *buf; - int size; +setbuffer(FILE *fp, char *buf, int size) { (void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, (size_t)size); @@ -52,8 +49,7 @@ setbuffer(fp, buf, size) * set line buffering */ int -setlinebuf(fp) - FILE *fp; +setlinebuf(FILE *fp) { return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0)); diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c index d897925fa363..d39696058616 100644 --- a/lib/libc/stdio/setvbuf.c +++ b/lib/libc/stdio/setvbuf.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c index d0ae5a663103..e2dd2ddd6c0c 100644 --- a/lib/libc/stdio/snprintf.c +++ b/lib/libc/stdio/snprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/sprintf.c b/lib/libc/stdio/sprintf.c index 6e20e04651e0..0f38d15cd2ce 100644 --- a/lib/libc/stdio/sprintf.c +++ b/lib/libc/stdio/sprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c index 1c339eb5069b..ae79451a47fc 100644 --- a/lib/libc/stdio/sscanf.c +++ b/lib/libc/stdio/sscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index 2447d180ef56..44ee0ab41210 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$"); * Small standard I/O/seek/close functions. */ int -__sread(cookie, buf, n) - void *cookie; - char *buf; - int n; +__sread(void *cookie, char *buf, int n) { FILE *fp = cookie; @@ -61,10 +58,7 @@ __sread(cookie, buf, n) } int -__swrite(cookie, buf, n) - void *cookie; - char const *buf; - int n; +__swrite(void *cookie, char const *buf, int n) { FILE *fp = cookie; @@ -72,10 +66,7 @@ __swrite(cookie, buf, n) } fpos_t -__sseek(cookie, offset, whence) - void *cookie; - fpos_t offset; - int whence; +__sseek(void *cookie, fpos_t offset, int whence) { FILE *fp = cookie; @@ -83,8 +74,7 @@ __sseek(cookie, offset, whence) } int -__sclose(cookie) - void *cookie; +__sclose(void *cookie) { return (_close(((FILE *)cookie)->_file)); @@ -94,10 +84,7 @@ __sclose(cookie) * Higher level wrappers. */ int -_sread(fp, buf, n) - FILE *fp; - char *buf; - int n; +_sread(FILE *fp, char *buf, int n) { int ret; @@ -115,10 +102,7 @@ _sread(fp, buf, n) } int -_swrite(fp, buf, n) - FILE *fp; - char const *buf; - int n; +_swrite(FILE *fp, char const *buf, int n) { int ret; int serrno; @@ -145,10 +129,7 @@ _swrite(fp, buf, n) } fpos_t -_sseek(fp, offset, whence) - FILE *fp; - fpos_t offset; - int whence; +_sseek(FILE *fp, fpos_t offset, int whence) { fpos_t ret; int serrno, errret; diff --git a/lib/libc/stdio/tempnam.c b/lib/libc/stdio/tempnam.c index ea4a2c8ca63a..e15746f31a4d 100644 --- a/lib/libc/stdio/tempnam.c +++ b/lib/libc/stdio/tempnam.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * @@ -47,8 +47,7 @@ __warn_references(tempnam, extern char *_mktemp(char *); char * -tempnam(dir, pfx) - const char *dir, *pfx; +tempnam(const char *dir, const char *pfx) { int sverrno; char *f, *name; diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c index 7ff297fe15d6..c67d1e456a34 100644 --- a/lib/libc/stdio/tmpfile.c +++ b/lib/libc/stdio/tmpfile.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/tmpnam.c b/lib/libc/stdio/tmpnam.c index 05bcb5bad6c4..ce32dcc28149 100644 --- a/lib/libc/stdio/tmpnam.c +++ b/lib/libc/stdio/tmpnam.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -47,8 +47,7 @@ __warn_references(tmpnam, extern char *_mktemp(char *); char * -tmpnam(s) - char *s; +tmpnam(char *s) { static u_long tmpcount; static char buf[L_tmpnam]; diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c index 1353b7ecd7a3..1695af772daa 100644 --- a/lib/libc/stdio/ungetc.c +++ b/lib/libc/stdio/ungetc.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 4ad0ee16b1ab..ea47d36ea14a 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 8f9d3d0e32cb..50f0690b6678 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index cc96b63bd1e4..4350c48acafc 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c index 28e2c036439b..63b5dd1be28a 100644 --- a/lib/libc/stdio/vfwscanf.c +++ b/lib/libc/stdio/vfwscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vprintf.c b/lib/libc/stdio/vprintf.c index c15ef4d6cc77..f98f1107c872 100644 --- a/lib/libc/stdio/vprintf.c +++ b/lib/libc/stdio/vprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vscanf.c b/lib/libc/stdio/vscanf.c index d56bb3b51639..8729c9ca6ba8 100644 --- a/lib/libc/stdio/vscanf.c +++ b/lib/libc/stdio/vscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * @@ -49,10 +49,7 @@ __FBSDID("$FreeBSD$"); #include "xlocale_private.h" int -vscanf_l(locale, fmt, ap) - locale_t locale; - const char * __restrict fmt; - __va_list ap; +vscanf_l(locale_t locale, const char * __restrict fmt, __va_list ap) { int retval; FIX_LOCALE(locale); @@ -63,9 +60,7 @@ vscanf_l(locale, fmt, ap) return (retval); } int -vscanf(fmt, ap) - const char * __restrict fmt; - __va_list ap; +vscanf(const char * __restrict fmt, __va_list ap) { return vscanf_l(__get_locale(), fmt, ap); } diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c index 82959d1d082c..8d13a5041cd3 100644 --- a/lib/libc/stdio/vsnprintf.c +++ b/lib/libc/stdio/vsnprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c index 04f2df3cca17..906a74c24b38 100644 --- a/lib/libc/stdio/vsprintf.c +++ b/lib/libc/stdio/vsprintf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c index 5668ab5b9825..4328fc15bfad 100644 --- a/lib/libc/stdio/vsscanf.c +++ b/lib/libc/stdio/vsscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/vswscanf.c b/lib/libc/stdio/vswscanf.c index f646e852c781..c4a10379c2fc 100644 --- a/lib/libc/stdio/vswscanf.c +++ b/lib/libc/stdio/vswscanf.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index 58e2da569df5..3f697e287a1f 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$"); * Non-MT-safe */ int -__swbuf(c, fp) - int c; - FILE *fp; +__swbuf(int c, FILE *fp) { int n; diff --git a/lib/libc/stdio/wsetup.c b/lib/libc/stdio/wsetup.c index 37bfc58bc360..70f8247c076b 100644 --- a/lib/libc/stdio/wsetup.c +++ b/lib/libc/stdio/wsetup.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); * _wsetup returns 0 if OK to write; otherwise, it returns EOF and sets errno. */ int -__swsetup(fp) - FILE *fp; +__swsetup(FILE *fp) { /* make sure stdio is set up */ if (!__sdidinit) diff --git a/lib/libc/stdio/xprintf_errno.c b/lib/libc/stdio/xprintf_errno.c index 0c2be46a6d70..3c831d129388 100644 --- a/lib/libc/stdio/xprintf_errno.c +++ b/lib/libc/stdio/xprintf_errno.c @@ -34,6 +34,7 @@ #include <vis.h> #include <assert.h> #include <sys/time.h> +#include "errlst.h" #include "printf.h" int @@ -54,7 +55,7 @@ __printf_render_errno(struct __printf_io *io, const struct printf_info *pi __unu ret = 0; error = *((const int *)arg[0]); - if (error >= 0 && error < sys_nerr) { + if (error >= 0 && error < __hidden_sys_nerr) { p = strerror(error); return (__printf_out(io, pi, p, strlen(p))); } diff --git a/lib/libc/stdlib/abort.3 b/lib/libc/stdlib/abort.3 index b939e9c23ebf..e177137849a1 100644 --- a/lib/libc/stdlib/abort.3 +++ b/lib/libc/stdlib/abort.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c index eba53e5afa13..b137e490eb2f 100644 --- a/lib/libc/stdlib/abort.c +++ b/lib/libc/stdlib/abort.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/abs.3 b/lib/libc/stdlib/abs.3 index 4f0212253544..eca85e1e7a59 100644 --- a/lib/libc/stdlib/abs.3 +++ b/lib/libc/stdlib/abs.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c index 5ca9596cb226..87589474eb3c 100644 --- a/lib/libc/stdlib/abs.c +++ b/lib/libc/stdlib/abs.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/alloca.3 b/lib/libc/stdlib/alloca.3 index 95594443b0a0..38f5aee3a797 100644 --- a/lib/libc/stdlib/alloca.3 +++ b/lib/libc/stdlib/alloca.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/atexit.3 b/lib/libc/stdlib/atexit.3 index 3a514b95a1e5..d6dab56e9cf2 100644 --- a/lib/libc/stdlib/atexit.3 +++ b/lib/libc/stdlib/atexit.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index 511172aef9ae..18c31c3b1ffb 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h index f34194f7b991..29610676edaa 100644 --- a/lib/libc/stdlib/atexit.h +++ b/lib/libc/stdlib/atexit.h @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/atof.3 b/lib/libc/stdlib/atof.3 index abf5b7c97b6b..b02cf0277656 100644 --- a/lib/libc/stdlib/atof.3 +++ b/lib/libc/stdlib/atof.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c index 746ceac385f2..3514ae3b6927 100644 --- a/lib/libc/stdlib/atof.c +++ b/lib/libc/stdlib/atof.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/atoi.3 b/lib/libc/stdlib/atoi.3 index b0d1d383f3d0..025019f4bfea 100644 --- a/lib/libc/stdlib/atoi.3 +++ b/lib/libc/stdlib/atoi.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c index 31a8676b98b9..564273e952cf 100644 --- a/lib/libc/stdlib/atoi.c +++ b/lib/libc/stdlib/atoi.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/atol.3 b/lib/libc/stdlib/atol.3 index cc49fe2eecd0..e2ac0e54a35c 100644 --- a/lib/libc/stdlib/atol.3 +++ b/lib/libc/stdlib/atol.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" @@ -32,7 +32,7 @@ .\" @(#)atol.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd February 1, 2009 +.Dd May 14, 2013 .Dt ATOL 3 .Os .Sh NAME @@ -88,13 +88,13 @@ and functions are thin wrappers around .Fn strtol and -.Fn stroll +.Fn strtoll respectively, so these functions will affect the value of .Va errno in the same way that the .Fn strtol and -.Fn stroll +.Fn strtoll functions are able to. This behavior of .Fn atol diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c index 7ebbe01ec9e2..d30aa18a8398 100644 --- a/lib/libc/stdlib/atol.c +++ b/lib/libc/stdlib/atol.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c index cbb5459cb12a..af528382bd7c 100644 --- a/lib/libc/stdlib/atoll.c +++ b/lib/libc/stdlib/atoll.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/bsearch.3 b/lib/libc/stdlib/bsearch.3 index 25be84206874..2fdf2c4842c0 100644 --- a/lib/libc/stdlib/bsearch.3 +++ b/lib/libc/stdlib/bsearch.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c index ff021688f306..4bcaaf3669dd 100644 --- a/lib/libc/stdlib/bsearch.c +++ b/lib/libc/stdlib/bsearch.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/div.3 b/lib/libc/stdlib/div.3 index 46a145f39cf4..ddd92a008790 100644 --- a/lib/libc/stdlib/div.3 +++ b/lib/libc/stdlib/div.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/div.c b/lib/libc/stdlib/div.c index ef93d736f6cc..7dfe553f4a05 100644 --- a/lib/libc/stdlib/div.c +++ b/lib/libc/stdlib/div.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3 index 4547efe60bd9..07ce0d77d106 100644 --- a/lib/libc/stdlib/exit.3 +++ b/lib/libc/stdlib/exit.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 26c346ac072f..145eb9d7c7cb 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/getenv.3 b/lib/libc/stdlib/getenv.3 index 19496489457d..e662b86d214b 100644 --- a/lib/libc/stdlib/getenv.3 +++ b/lib/libc/stdlib/getenv.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index 47963d53dd62..845110388a20 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -505,9 +505,8 @@ __setenv(const char *name, size_t nameLen, const char *value, int overwrite) envVars[envNdx].valueSize = valueLen; /* Save name of name/value pair. */ - env = stpcpy(envVars[envNdx].name, name); - if ((envVars[envNdx].name)[nameLen] != '=') - env = stpcpy(env, "="); + env = stpncpy(envVars[envNdx].name, name, nameLen); + *env++ = '='; } else env = envVars[envNdx].value; diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3 index 3fe44533f1b7..03a63abb19c5 100644 --- a/lib/libc/stdlib/getopt.3 +++ b/lib/libc/stdlib/getopt.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index 4d319a45ffc3..b9d2ae31fc64 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -12,7 +12,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/getsubopt.3 b/lib/libc/stdlib/getsubopt.3 index 86894ebbc8f6..43ea2c2a9e2c 100644 --- a/lib/libc/stdlib/getsubopt.3 +++ b/lib/libc/stdlib/getsubopt.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/getsubopt.c b/lib/libc/stdlib/getsubopt.c index 6d0ab75668d0..efff9dab54ac 100644 --- a/lib/libc/stdlib/getsubopt.c +++ b/lib/libc/stdlib/getsubopt.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c index f65687689c55..4bad8a768006 100644 --- a/lib/libc/stdlib/heapsort.c +++ b/lib/libc/stdlib/heapsort.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/jemalloc/Symbol.map b/lib/libc/stdlib/jemalloc/Symbol.map index b98d37ae5bf0..617194f87a46 100644 --- a/lib/libc/stdlib/jemalloc/Symbol.map +++ b/lib/libc/stdlib/jemalloc/Symbol.map @@ -26,6 +26,17 @@ FBSD_1.3 { sallocm; dallocm; nallocm; + __malloc; + __calloc; + __realloc; + __free; + __posix_memalign; + __malloc_usable_size; + __allocm; + __rallocm; + __sallocm; + __dallocm; + __nallocm; }; FBSDprivate_1.0 { diff --git a/lib/libc/stdlib/labs.3 b/lib/libc/stdlib/labs.3 index b714fe382a23..bbd32124f476 100644 --- a/lib/libc/stdlib/labs.3 +++ b/lib/libc/stdlib/labs.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c index d22975e24d42..816370eee2b2 100644 --- a/lib/libc/stdlib/labs.c +++ b/lib/libc/stdlib/labs.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/ldiv.3 b/lib/libc/stdlib/ldiv.3 index 221e68d27d5a..ce4d01771b11 100644 --- a/lib/libc/stdlib/ldiv.3 +++ b/lib/libc/stdlib/ldiv.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/ldiv.c b/lib/libc/stdlib/ldiv.c index 0311d06e086d..0ec98e65547d 100644 --- a/lib/libc/stdlib/ldiv.c +++ b/lib/libc/stdlib/ldiv.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/lsearch.3 b/lib/libc/stdlib/lsearch.3 index 5e76724dc115..2a1a7312c3ac 100644 --- a/lib/libc/stdlib/lsearch.3 +++ b/lib/libc/stdlib/lsearch.3 @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 11, 2002 +.Dd April 21, 2013 .Dt LSEARCH 3 .Os .Sh NAME @@ -81,6 +81,47 @@ returns Both functions return .Dv NULL if an error occurs. +.Sh EXAMPLES +.Bd -literal +#include <search.h> +#include <stdio.h> +#include <stdlib.h> + +static int +element_compare(const void *p1, const void *p2) +{ + int left = *(const int *)p1; + int right = *(const int *)p2; + + return (left - right); +} + +int +main(int argc, char **argv) +{ + const int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + size_t element_size = sizeof(array[0]); + size_t array_size = sizeof(array) / element_size; + int key; + void *element; + + printf("Enter a number: "); + if (scanf("%d", &key) != 1) { + printf("Bad input\n"); + return (EXIT_FAILURE); + } + + element = lfind(&key, array, &array_size, element_size, + element_compare); + + if (element != NULL) + printf("Element found: %d\n", *(int *)element); + else + printf("Element not found\n"); + + return (EXIT_SUCCESS); +} +.Ed .Sh SEE ALSO .Xr bsearch 3 , .Xr hsearch 3 , diff --git a/lib/libc/stdlib/memory.3 b/lib/libc/stdlib/memory.3 index 9f42fa6abdab..b78ddae8aab0 100644 --- a/lib/libc/stdlib/memory.3 +++ b/lib/libc/stdlib/memory.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index e1078e7ccacd..01a902854222 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/qsort.3 b/lib/libc/stdlib/qsort.3 index f34d260b7fc9..ac019121f537 100644 --- a/lib/libc/stdlib/qsort.3 +++ b/lib/libc/stdlib/qsort.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index 3687b0579ffd..93e22cdf9315 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/radixsort.3 b/lib/libc/stdlib/radixsort.3 index dfa65f1359b3..5b85bf85f81c 100644 --- a/lib/libc/stdlib/radixsort.3 +++ b/lib/libc/stdlib/radixsort.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index 82ff1bc673a7..8310e6dea16c 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/rand.3 b/lib/libc/stdlib/rand.3 index bf50e3d87e72..a8c4a4cb5686 100644 --- a/lib/libc/stdlib/rand.3 +++ b/lib/libc/stdlib/rand.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 0cbd94883125..4f4aa8dc2d91 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * @@ -67,15 +67,15 @@ do_rand(unsigned long *ctx) */ long hi, lo, x; - /* Can't be initialized with 0, so use another value. */ - if (*ctx == 0) - *ctx = 123459876; + /* Must be in [1, 0x7ffffffe] range at this point. */ hi = *ctx / 127773; lo = *ctx % 127773; x = 16807 * lo - 2836 * hi; if (x < 0) x += 0x7fffffff; - return ((*ctx = x) % ((u_long)RAND_MAX + 1)); + *ctx = x; + /* Transform to [0, 0x7ffffffd] range. */ + return (x - 1); #endif /* !USE_WEAK_SEEDING */ } @@ -83,15 +83,32 @@ do_rand(unsigned long *ctx) int rand_r(unsigned int *ctx) { - u_long val = (u_long) *ctx; - int r = do_rand(&val); + u_long val; + int r; - *ctx = (unsigned int) val; +#ifdef USE_WEAK_SEEDING + val = *ctx; +#else + /* Transform to [1, 0x7ffffffe] range. */ + val = (*ctx % 0x7ffffffe) + 1; +#endif + r = do_rand(&val); + +#ifdef USE_WEAK_SEEDING + *ctx = (unsigned int)val; +#else + *ctx = (unsigned int)(val - 1); +#endif return (r); } -static u_long next = 1; +static u_long next = +#ifdef USE_WEAK_SEEDING + 1; +#else + 2; +#endif int rand() @@ -104,6 +121,10 @@ srand(seed) u_int seed; { next = seed; +#ifndef USE_WEAK_SEEDING + /* Transform to [1, 0x7ffffffe] range. */ + next = (next % 0x7ffffffe) + 1; +#endif } @@ -125,6 +146,10 @@ sranddev() mib[0] = CTL_KERN; mib[1] = KERN_ARND; sysctl(mib, 2, (void *)&next, &len, NULL, 0); +#ifndef USE_WEAK_SEEDING + /* Transform to [1, 0x7ffffffe] range. */ + next = (next % 0x7ffffffe) + 1; +#endif } diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3 index a1e585bbd24a..dc8e961d8cec 100644 --- a/lib/libc/stdlib/random.3 +++ b/lib/libc/stdlib/random.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 4c88ecbbc881..580f26e32ce9 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/realpath.3 b/lib/libc/stdlib/realpath.3 index 33970fd946a5..c0a5770ac83f 100644 --- a/lib/libc/stdlib/realpath.3 +++ b/lib/libc/stdlib/realpath.3 @@ -12,7 +12,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 8fd5457af9c3..a2a93293172b 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -139,7 +139,7 @@ realpath(const char * __restrict path, char * __restrict resolved) * Only the trailing slashes are not covered * by other checks in the loop, but we verify * the prefix for any (rare) "//" or "/\0" - * occurence to not implement lookahead. + * occurrence to not implement lookahead. */ if (lstat(resolved, &sb) != 0) { if (m) diff --git a/lib/libc/stdlib/strtod.3 b/lib/libc/stdlib/strtod.3 index e19e5febb136..549c640f8358 100644 --- a/lib/libc/stdlib/strtod.3 +++ b/lib/libc/stdlib/strtod.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c index 9be773b00254..72903e8df00e 100644 --- a/lib/libc/stdlib/strtoimax.c +++ b/lib/libc/stdlib/strtoimax.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtol.3 b/lib/libc/stdlib/strtol.3 index 02316f58e4f5..3b7af7d30f01 100644 --- a/lib/libc/stdlib/strtol.3 +++ b/lib/libc/stdlib/strtol.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c index f80ecb440f83..e0c9978458e3 100644 --- a/lib/libc/stdlib/strtol.c +++ b/lib/libc/stdlib/strtol.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c index 67833275e3ae..16a8196a3562 100644 --- a/lib/libc/stdlib/strtoll.c +++ b/lib/libc/stdlib/strtoll.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtonum.3 b/lib/libc/stdlib/strtonum.3 index b83aadda42e5..ed2699559bee 100644 --- a/lib/libc/stdlib/strtonum.3 +++ b/lib/libc/stdlib/strtonum.3 @@ -97,7 +97,7 @@ int iterations; const char *errstr; iterations = strtonum(optarg, 1, 64, &errstr); -if (errstr) +if (errstr != NULL) errx(1, "number of iterations is %s: %s", errstr, optarg); .Ed .Pp diff --git a/lib/libc/stdlib/strtoq.c b/lib/libc/stdlib/strtoq.c index afad51fb80c0..7bc1c80a3a32 100644 --- a/lib/libc/stdlib/strtoq.c +++ b/lib/libc/stdlib/strtoq.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtoul.3 b/lib/libc/stdlib/strtoul.3 index 2c0f348961df..6d269656ddf6 100644 --- a/lib/libc/stdlib/strtoul.3 +++ b/lib/libc/stdlib/strtoul.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c index 0ae0661c2c08..ed58dd8ae662 100644 --- a/lib/libc/stdlib/strtoul.c +++ b/lib/libc/stdlib/strtoul.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c index 4b7f1c9082d7..dc40e0e98919 100644 --- a/lib/libc/stdlib/strtoull.c +++ b/lib/libc/stdlib/strtoull.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c index d4362bb333c4..769967727ac5 100644 --- a/lib/libc/stdlib/strtoumax.c +++ b/lib/libc/stdlib/strtoumax.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/strtouq.c b/lib/libc/stdlib/strtouq.c index 9638c1198ae2..9371680b9721 100644 --- a/lib/libc/stdlib/strtouq.c +++ b/lib/libc/stdlib/strtouq.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/stdlib/system.3 b/lib/libc/stdlib/system.3 index 3d13489bad85..3cea71ec79a9 100644 --- a/lib/libc/stdlib/system.3 +++ b/lib/libc/stdlib/system.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index 4f47edffe196..e018e6ff0b72 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <stdlib.h> #include <stddef.h> +#include <string.h> #include <unistd.h> #include <paths.h> #include <errno.h> @@ -56,37 +57,38 @@ __system(const char *command) if (!command) /* just checking... */ return(1); - /* - * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save - * existing signal dispositions. - */ - ign.sa_handler = SIG_IGN; - (void)sigemptyset(&ign.sa_mask); - ign.sa_flags = 0; - (void)_sigaction(SIGINT, &ign, &intact); - (void)_sigaction(SIGQUIT, &ign, &quitact); (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); + (void)sigaddset(&newsigblock, SIGINT); + (void)sigaddset(&newsigblock, SIGQUIT); (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); - switch(pid = fork()) { + switch(pid = vfork()) { case -1: /* error */ - break; + (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + return (-1); case 0: /* child */ /* * Restore original signal dispositions and exec the command. */ - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); _exit(127); - default: /* parent */ - savedpid = pid; - do { - pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); - } while (pid == -1 && errno == EINTR); - break; } + /* + * If we are running means that the child has either completed + * its execve, or has failed. + * Block SIGINT/QUIT because sh -c handles it and wait for + * it to clean up. + */ + memset(&ign, 0, sizeof(ign)); + ign.sa_handler = SIG_IGN; + (void)sigemptyset(&ign.sa_mask); + (void)_sigaction(SIGINT, &ign, &intact); + (void)_sigaction(SIGQUIT, &ign, &quitact); + savedpid = pid; + do { + pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); + } while (pid == -1 && errno == EINTR); (void)_sigaction(SIGINT, &intact, NULL); (void)_sigaction(SIGQUIT, &quitact, NULL); (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); diff --git a/lib/libc/string/bcmp.3 b/lib/libc/string/bcmp.3 index d043c2cc1b62..fa5666c57ea0 100644 --- a/lib/libc/string/bcmp.3 +++ b/lib/libc/string/bcmp.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/bcmp.c b/lib/libc/string/bcmp.c index 117a9a1d0cfc..f1178a660b2b 100644 --- a/lib/libc/string/bcmp.c +++ b/lib/libc/string/bcmp.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/bcopy.3 b/lib/libc/string/bcopy.3 index 23f7ac22a131..1608fad2d79f 100644 --- a/lib/libc/string/bcopy.3 +++ b/lib/libc/string/bcopy.3 @@ -12,7 +12,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/bcopy.c b/lib/libc/string/bcopy.c index bb1209cdc575..c424de560f6c 100644 --- a/lib/libc/string/bcopy.c +++ b/lib/libc/string/bcopy.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/bstring.3 b/lib/libc/string/bstring.3 index b1aef1b5f9ef..b8ed0908c88a 100644 --- a/lib/libc/string/bstring.3 +++ b/lib/libc/string/bstring.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/bzero.3 b/lib/libc/string/bzero.3 index bc61d82b62af..029644a5b7bf 100644 --- a/lib/libc/string/bzero.3 +++ b/lib/libc/string/bzero.3 @@ -12,7 +12,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/ffs.3 b/lib/libc/string/ffs.3 index d8e11d80e406..192771ffaeea 100644 --- a/lib/libc/string/ffs.3 +++ b/lib/libc/string/ffs.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/ffs.c b/lib/libc/string/ffs.c index 9c3e0b3182e7..42a94ef7383d 100644 --- a/lib/libc/string/ffs.c +++ b/lib/libc/string/ffs.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/ffsl.c b/lib/libc/string/ffsl.c index 6a25afddc57b..3fd94521d623 100644 --- a/lib/libc/string/ffsl.c +++ b/lib/libc/string/ffsl.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/ffsll.c b/lib/libc/string/ffsll.c index 59e03bcb23c0..e19df91d1f03 100644 --- a/lib/libc/string/ffsll.c +++ b/lib/libc/string/ffsll.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/fls.c b/lib/libc/string/fls.c index 2a3a3f755a7f..7145b909f026 100644 --- a/lib/libc/string/fls.c +++ b/lib/libc/string/fls.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/flsl.c b/lib/libc/string/flsl.c index 8f60e33edaaa..19485b2f787e 100644 --- a/lib/libc/string/flsl.c +++ b/lib/libc/string/flsl.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/flsll.c b/lib/libc/string/flsll.c index ab5562782d2b..b12f12f2d0d7 100644 --- a/lib/libc/string/flsll.c +++ b/lib/libc/string/flsll.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/index.3 b/lib/libc/string/index.3 index 25f6f65ac493..dcce40031983 100644 --- a/lib/libc/string/index.3 +++ b/lib/libc/string/index.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memccpy.3 b/lib/libc/string/memccpy.3 index 40a25be4361a..5bf323115746 100644 --- a/lib/libc/string/memccpy.3 +++ b/lib/libc/string/memccpy.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memccpy.c b/lib/libc/string/memccpy.c index 539d33e4701f..6102a5bdedaf 100644 --- a/lib/libc/string/memccpy.c +++ b/lib/libc/string/memccpy.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/memchr.3 b/lib/libc/string/memchr.3 index 9f31fd156639..de571ca66e96 100644 --- a/lib/libc/string/memchr.3 +++ b/lib/libc/string/memchr.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c index d98d85317e5a..8020333dec3b 100644 --- a/lib/libc/string/memchr.c +++ b/lib/libc/string/memchr.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/memcmp.3 b/lib/libc/string/memcmp.3 index 88ed9a25934e..00e8e1a1d759 100644 --- a/lib/libc/string/memcmp.3 +++ b/lib/libc/string/memcmp.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c index 4a1b66e6548b..d2d0f27d35ef 100644 --- a/lib/libc/string/memcmp.c +++ b/lib/libc/string/memcmp.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3 index 3f2e2ddf7586..25a6c359f1da 100644 --- a/lib/libc/string/memcpy.3 +++ b/lib/libc/string/memcpy.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memmove.3 b/lib/libc/string/memmove.3 index 8a1d52bcd959..8d1c33cd9d4e 100644 --- a/lib/libc/string/memmove.3 +++ b/lib/libc/string/memmove.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memset.3 b/lib/libc/string/memset.3 index 07bd7aa7d624..28d1919f706b 100644 --- a/lib/libc/string/memset.3 +++ b/lib/libc/string/memset.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c index 89f7e45a9be8..ad0d513933fe 100644 --- a/lib/libc/string/memset.c +++ b/lib/libc/string/memset.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strcasecmp.3 b/lib/libc/string/strcasecmp.3 index 760b9d402720..598f76f80747 100644 --- a/lib/libc/string/strcasecmp.3 +++ b/lib/libc/string/strcasecmp.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strcasecmp.c b/lib/libc/string/strcasecmp.c index 65e042e42a42..c72a660508c4 100644 --- a/lib/libc/string/strcasecmp.c +++ b/lib/libc/string/strcasecmp.c @@ -15,7 +15,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strcasestr.c b/lib/libc/string/strcasestr.c index 5f39648a69bd..cca16dc7bb63 100644 --- a/lib/libc/string/strcasestr.c +++ b/lib/libc/string/strcasestr.c @@ -18,7 +18,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strcat.3 b/lib/libc/string/strcat.3 index dfa55a470a09..14ce340955e7 100644 --- a/lib/libc/string/strcat.3 +++ b/lib/libc/string/strcat.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c index 1578276c1724..07a3c08c1a2f 100644 --- a/lib/libc/string/strcat.c +++ b/lib/libc/string/strcat.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strchr.3 b/lib/libc/string/strchr.3 index 019b9236f425..6117831233a1 100644 --- a/lib/libc/string/strchr.3 +++ b/lib/libc/string/strchr.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c index 1245f136b7ef..ab83b3995a44 100644 --- a/lib/libc/string/strchr.c +++ b/lib/libc/string/strchr.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strcmp.3 b/lib/libc/string/strcmp.3 index 74d1a5c4d18d..a79852d2a240 100644 --- a/lib/libc/string/strcmp.3 +++ b/lib/libc/string/strcmp.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c index 95c778dc2296..9daf624acce0 100644 --- a/lib/libc/string/strcmp.c +++ b/lib/libc/string/strcmp.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strcoll.3 b/lib/libc/string/strcoll.3 index 20f188896ad6..d53a23d11b2f 100644 --- a/lib/libc/string/strcoll.3 +++ b/lib/libc/string/strcoll.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strcpy.3 b/lib/libc/string/strcpy.3 index 395e2f9b7b57..efc95dfbdd22 100644 --- a/lib/libc/string/strcpy.3 +++ b/lib/libc/string/strcpy.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c index fec284e22525..8a48d0d0d732 100644 --- a/lib/libc/string/strcpy.c +++ b/lib/libc/string/strcpy.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strcspn.3 b/lib/libc/string/strcspn.3 index d1df19813e4a..0331ca1b60c8 100644 --- a/lib/libc/string/strcspn.3 +++ b/lib/libc/string/strcspn.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3 index 04a2816ae6eb..f9ed5c208362 100644 --- a/lib/libc/string/strdup.3 +++ b/lib/libc/string/strdup.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strdup.c b/lib/libc/string/strdup.c index 570ad838527d..8e90aa05fcb9 100644 --- a/lib/libc/string/strdup.c +++ b/lib/libc/string/strdup.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3 index cc2560266e77..50b155530017 100644 --- a/lib/libc/string/strerror.3 +++ b/lib/libc/string/strerror.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index bfca871ad31a..1d7a385bd9ea 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <stdio.h> +#include "errlst.h" + #define UPREFIX "Unknown error" /* @@ -87,7 +89,7 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen) catd = catopen("libc", NL_CAT_LOCALE); #endif - if (errnum < 0 || errnum >= sys_nerr) { + if (errnum < 0 || errnum >= __hidden_sys_nerr) { errstr(errnum, #if defined(NLS) catgets(catd, 1, 0xffff, UPREFIX), @@ -99,9 +101,9 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen) } else { if (strlcpy(strerrbuf, #if defined(NLS) - catgets(catd, 1, errnum, sys_errlist[errnum]), + catgets(catd, 1, errnum, __hidden_sys_errlist[errnum]), #else - sys_errlist[errnum], + __hidden_sys_errlist[errnum], #endif buflen) >= buflen) retval = ERANGE; diff --git a/lib/libc/string/string.3 b/lib/libc/string/string.3 index b0e25a9bc2dd..e9ef152bb8ee 100644 --- a/lib/libc/string/string.3 +++ b/lib/libc/string/string.3 @@ -11,7 +11,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strlen.3 b/lib/libc/string/strlen.3 index bdbf4ff2fa4d..fb2fa3cd2acb 100644 --- a/lib/libc/string/strlen.3 +++ b/lib/libc/string/strlen.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strmode.3 b/lib/libc/string/strmode.3 index 1a072d828644..e963d28b9cde 100644 --- a/lib/libc/string/strmode.3 +++ b/lib/libc/string/strmode.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strmode.c b/lib/libc/string/strmode.c index 3aaa77e436da..a73dd0ede401 100644 --- a/lib/libc/string/strmode.c +++ b/lib/libc/string/strmode.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strncat.c b/lib/libc/string/strncat.c index fb2802c6110b..6a0e553daa3f 100644 --- a/lib/libc/string/strncat.c +++ b/lib/libc/string/strncat.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c index 5bc3d5e61a85..4967a9483e64 100644 --- a/lib/libc/string/strncmp.c +++ b/lib/libc/string/strncmp.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c index 980dbc7d58e8..39074035084c 100644 --- a/lib/libc/string/strncpy.c +++ b/lib/libc/string/strncpy.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strndup.c b/lib/libc/string/strndup.c index abb1e030eeec..2897e933193c 100644 --- a/lib/libc/string/strndup.c +++ b/lib/libc/string/strndup.c @@ -12,7 +12,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strnstr.c b/lib/libc/string/strnstr.c index 45be95d12a1d..4de757d5996f 100644 --- a/lib/libc/string/strnstr.c +++ b/lib/libc/string/strnstr.c @@ -14,7 +14,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strpbrk.3 b/lib/libc/string/strpbrk.3 index 7ed0ec709c71..bfa50990a71d 100644 --- a/lib/libc/string/strpbrk.3 +++ b/lib/libc/string/strpbrk.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c index 2069bee7233a..565ef82f11d3 100644 --- a/lib/libc/string/strpbrk.c +++ b/lib/libc/string/strpbrk.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c index be9f9781f6e9..f84ffb78c438 100644 --- a/lib/libc/string/strrchr.c +++ b/lib/libc/string/strrchr.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3 index 9432a88380bd..4e9dad9db5ae 100644 --- a/lib/libc/string/strsep.3 +++ b/lib/libc/string/strsep.3 @@ -12,7 +12,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strsep.c b/lib/libc/string/strsep.c index 670ab04ae9f8..73c61af8115f 100644 --- a/lib/libc/string/strsep.c +++ b/lib/libc/string/strsep.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strsignal.c b/lib/libc/string/strsignal.c index 8fc1f851ca6f..7c461a3dbb80 100644 --- a/lib/libc/string/strsignal.c +++ b/lib/libc/string/strsignal.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strspn.3 b/lib/libc/string/strspn.3 index 72a1d32941eb..2ba6a6b5575a 100644 --- a/lib/libc/string/strspn.3 +++ b/lib/libc/string/strspn.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strstr.3 b/lib/libc/string/strstr.3 index 376def6f2362..b1106b3c5759 100644 --- a/lib/libc/string/strstr.3 +++ b/lib/libc/string/strstr.3 @@ -14,7 +14,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c index 82b4c5a2085e..18e60d579881 100644 --- a/lib/libc/string/strstr.c +++ b/lib/libc/string/strstr.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/strtok.3 b/lib/libc/string/strtok.3 index e19579f8ece5..97a8b156b929 100644 --- a/lib/libc/string/strtok.3 +++ b/lib/libc/string/strtok.3 @@ -22,7 +22,7 @@ .\" disclaimer in the documentation and/or other materials provided .\" with the distribution. .\" -.\" 4. Neither the name of Softweyr LLC, the University nor the names +.\" 3. Neither the name of Softweyr LLC, 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. diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c index b0c428b770ce..063a554339a6 100644 --- a/lib/libc/string/strtok.c +++ b/lib/libc/string/strtok.c @@ -15,7 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notices, 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 + * 3. 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. * diff --git a/lib/libc/string/strxfrm.3 b/lib/libc/string/strxfrm.3 index da7c82ada5ce..f2750f4a385a 100644 --- a/lib/libc/string/strxfrm.3 +++ b/lib/libc/string/strxfrm.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/swab.3 b/lib/libc/string/swab.3 index 0c9deea8463b..204b976ab1f4 100644 --- a/lib/libc/string/swab.3 +++ b/lib/libc/string/swab.3 @@ -9,7 +9,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c index ec6cbf0f536f..84633094be3b 100644 --- a/lib/libc/string/swab.c +++ b/lib/libc/string/swab.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/wcscmp.c b/lib/libc/string/wcscmp.c index 2d489149d066..c2abe4c797f7 100644 --- a/lib/libc/string/wcscmp.c +++ b/lib/libc/string/wcscmp.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/wcscoll.3 b/lib/libc/string/wcscoll.3 index 6a3eedbfec58..ba89fb3c268e 100644 --- a/lib/libc/string/wcscoll.3 +++ b/lib/libc/string/wcscoll.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/wcsncmp.c b/lib/libc/string/wcsncmp.c index 86d7a51cec43..8236d969feef 100644 --- a/lib/libc/string/wcsncmp.c +++ b/lib/libc/string/wcsncmp.c @@ -10,7 +10,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/wcsncpy.c b/lib/libc/string/wcsncpy.c index 00d986b654b2..215e9a115156 100644 --- a/lib/libc/string/wcsncpy.c +++ b/lib/libc/string/wcsncpy.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/wcsstr.c b/lib/libc/string/wcsstr.c index a9dc27bbf498..ce598a698969 100644 --- a/lib/libc/string/wcsstr.c +++ b/lib/libc/string/wcsstr.c @@ -13,7 +13,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/wcstok.c b/lib/libc/string/wcstok.c index 5a77117f320e..441fbd444854 100644 --- a/lib/libc/string/wcstok.c +++ b/lib/libc/string/wcstok.c @@ -15,7 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notices, 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 + * 3. 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. * diff --git a/lib/libc/string/wcswidth.c b/lib/libc/string/wcswidth.c index 4095c8d8cb17..bac979b5b9f0 100644 --- a/lib/libc/string/wcswidth.c +++ b/lib/libc/string/wcswidth.c @@ -23,7 +23,7 @@ * 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 + * 3. 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. * diff --git a/lib/libc/string/wcsxfrm.3 b/lib/libc/string/wcsxfrm.3 index b5add9cebb45..ac30d38e1131 100644 --- a/lib/libc/string/wcsxfrm.3 +++ b/lib/libc/string/wcsxfrm.3 @@ -13,7 +13,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/string/wmemchr.3 b/lib/libc/string/wmemchr.3 index 30fb0917cf7f..37ba05031ca9 100644 --- a/lib/libc/string/wmemchr.3 +++ b/lib/libc/string/wmemchr.3 @@ -15,7 +15,7 @@ .\" 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 +.\" 3. 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. .\" diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index fef0f3c08e37..4cc87ae27860 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -85,6 +85,7 @@ MAN+= abort2.2 \ adjtime.2 \ aio_cancel.2 \ aio_error.2 \ + aio_mlock.2 \ aio_read.2 \ aio_return.2 \ aio_suspend.2 \ @@ -270,6 +271,7 @@ MAN+= sctp_generic_recvmsg.2 \ wait.2 \ write.2 +MLINKS+=accept.2 accept4.2 MLINKS+=access.2 eaccess.2 \ access.2 faccessat.2 MLINKS+=brk.2 sbrk.2 @@ -351,6 +353,7 @@ MLINKS+=pathconf.2 lpathconf.2 MLINKS+=pdfork.2 pdgetpid.2\ pdfork.2 pdkill.2 \ pdfork.2 pdwait4.2 +MLINKS+=pipe.2 pipe2.2 MLINKS+=read.2 pread.2 \ read.2 preadv.2 \ read.2 readv.2 diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 6faa0af50c50..222f5f0811f5 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -363,7 +363,6 @@ FBSD_1.1 { FBSD_1.2 { cap_enter; cap_getmode; - cap_new; getloginclass; pdfork; pdgetpid; @@ -378,12 +377,14 @@ FBSD_1.2 { }; FBSD_1.3 { + accept4; + aio_mlock; bindat; cap_fcntls_get; cap_fcntls_limit; cap_ioctls_get; cap_ioctls_limit; - cap_rights_get; + __cap_rights_get; cap_rights_limit; cap_sandboxed; chflagsat; @@ -392,6 +393,7 @@ FBSD_1.3 { ffclock_getcounter; ffclock_getestimate; ffclock_setestimate; + pipe2; posix_fadvise; wait6; }; @@ -461,6 +463,8 @@ FBSDprivate_1.0 { __sys_abort2; _accept; __sys_accept; + _accept4; + __sys_accept4; _access; __sys_access; _acct; diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2 index 978b94801960..76fb463a1ef2 100644 --- a/lib/libc/sys/accept.2 +++ b/lib/libc/sys/accept.2 @@ -28,7 +28,7 @@ .\" @(#)accept.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd March 26, 2013 +.Dd May 1, 2013 .Dt ACCEPT 2 .Os .Sh NAME @@ -41,6 +41,8 @@ .In sys/socket.h .Ft int .Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" +.Ft int +.Fn accept4 "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "int flags" .Sh DESCRIPTION The argument .Fa s @@ -66,6 +68,26 @@ and signals from the original socket .Fa s . .Pp +The +.Fn accept4 +system call is similar, +but the +.Dv O_NONBLOCK +property of the new socket is instead determined by the +.Dv SOCK_NONBLOCK +flag in the +.Fa flags +argument, +the +.Dv O_ASYNC +property is cleared, +the signal destination is cleared +and the close-on-exec flag on the new file descriptor can be set via the +.Dv SOCK_CLOEXEC +flag in the +.Fa flags +argument. +.Pp If no pending connections are present on the queue, and the original socket is not marked as non-blocking, @@ -141,13 +163,15 @@ properties and the signal destination being inherited, but should set them explicitly using .Xr fcntl 2 . .Sh RETURN VALUES -The call returns \-1 on error. -If it succeeds, it returns a non-negative +These calls return \-1 on error. +If they succeed, they return a non-negative integer that is a descriptor for the accepted socket. .Sh ERRORS The .Fn accept -system call will fail if: +and +.Fn accept4 +system calls will fail if: .Bl -tag -width Er .It Bq Er EBADF The descriptor is invalid. @@ -164,10 +188,6 @@ The descriptor references a file, not a socket. .It Bq Er EINVAL .Xr listen 2 has not been called on the socket descriptor. -.It Bq Er EINVAL -The -.Fa addrlen -argument is negative. .It Bq Er EFAULT The .Fa addr @@ -180,6 +200,16 @@ are present to be accepted. A connection arrived, but it was closed while waiting on the listen queue. .El +.Pp +The +.Fn accept4 +system call will also fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa flags +argument is invalid. +.El .Sh SEE ALSO .Xr bind 2 , .Xr connect 2 , @@ -194,3 +224,8 @@ The .Fn accept system call appeared in .Bx 4.2 . +.Pp +The +.Fn accept4 +system call appeared in +.Fx 10.0 . diff --git a/lib/libc/sys/aio_mlock.2 b/lib/libc/sys/aio_mlock.2 new file mode 100644 index 000000000000..e24f95a191f5 --- /dev/null +++ b/lib/libc/sys/aio_mlock.2 @@ -0,0 +1,133 @@ +.\" Copyright (c) 2013 Gleb Smirnoff <glebius@FreeBSD.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd June 3, 2013 +.Dt AIO_MLOCK 2 +.Os +.Sh NAME +.Nm aio_mlock +.Nd asynchronous +.Xr mlock 2 +operation +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In aio.h +.Ft int +.Fn aio_mlock "struct aiocb *iocb" +.Sh DESCRIPTION +The +.Fn aio_mlock +system call allows the calling process to lock into memory the +physical pages associated with the virtual address range starting at +.Fa iocb->aio_buf +for +.Fa iocb->aio_nbytes +bytes. +The call returns immediately after the locking request has +been enqueued; the operation may or may not have completed at the time +the call returns. +.Pp +The +.Fa iocb +pointer may be subsequently used as an argument to +.Fn aio_return +and +.Fn aio_error +in order to determine return or error status for the enqueued operation +while it is in progress. +.Pp +If the request could not be enqueued (generally due to +.Xr aio 4 +limits), +then the call returns without having enqueued the request. +.Sh RESTRICTIONS +The Asynchronous I/O Control Block structure pointed to by +.Fa iocb +and the buffer that the +.Fa iocb->aio_buf +member of that structure references must remain valid until the +operation has completed. +For this reason, use of auto (stack) variables +for these objects is discouraged. +.Pp +The asynchronous I/O control buffer +.Fa iocb +should be zeroed before the +.Fn aio_mlock +call to avoid passing bogus context information to the kernel. +.Pp +Modifications of the Asynchronous I/O Control Block structure or the +buffer contents after the request has been enqueued, but before the +request has completed, are not allowed. +.Sh RETURN VALUES +.Rv -std aio_mlock +.Sh ERRORS +The +.Fn aio_read +system call will fail if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The request was not queued because of system resource limitations. +.It Bq Er ENOSYS +The +.Fn aio_mlock +system call is not supported. +.El +.Pp +If the request is successfully enqueued, but subsequently cancelled +or an error occurs, the value returned by the +.Fn aio_return +system call is per the +.Xr mlock 2 +system call, and the value returned by the +.Fn aio_error +system call is one of the error returns from the +.Xr mlock 2 +system call, or +.Er ECANCELED +if the request was explicitly cancelled via a call to +.Fn aio_cancel . +.Sh SEE ALSO +.Xr aio_cancel 2 , +.Xr aio_error 2 , +.Xr aio_return 2 , +.Xr mlock 2 , +.Xr aio 4 +.Sh PORTABILITY +The +.Fn aio_mlock +system call is a +.Fx +extension, and should not be used in portable code. +.Sh HISTORY +The +.Fn aio_mlock +system call first appeared in +.Fx 10.0 . +.Sh AUTHORS +The system call was introduced by +.An Gleb Smirnoff Aq glebius@FreeBSD.org . diff --git a/lib/libc/sys/cap_ioctls_limit.2 b/lib/libc/sys/cap_ioctls_limit.2 index 2c21211956cf..771736acebb9 100644 --- a/lib/libc/sys/cap_ioctls_limit.2 +++ b/lib/libc/sys/cap_ioctls_limit.2 @@ -99,10 +99,10 @@ argument. .Rv -std cap_ioctls_limit .Pp The -.Fn cap_ioctls_limit +.Fn cap_ioctls_get function, if successfull, returns the total number of allowed ioctl commands or the value -.Dv INT_MAX +.Dv CAP_IOCTLS_ALL if all ioctls commands are allowed. On failure the value .Va -1 diff --git a/lib/libc/sys/cap_rights_limit.2 b/lib/libc/sys/cap_rights_limit.2 index 2e18dd2d306e..225efad1df94 100644 --- a/lib/libc/sys/cap_rights_limit.2 +++ b/lib/libc/sys/cap_rights_limit.2 @@ -77,7 +77,9 @@ The following rights may be specified in a rights mask: .Bl -tag -width CAP_EXTATTR_DELETE .It Dv CAP_ACCEPT Permit -.Xr accept 2 . +.Xr accept 2 +and +.Xr accept4 2 . .It Dv CAP_ACL_CHECK Permit checking of an ACL on a file descriptor; there is no cross-reference for this system call. diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2 index 5bc2ba225e6c..2fcc89f2f46c 100644 --- a/lib/libc/sys/chflags.2 +++ b/lib/libc/sys/chflags.2 @@ -112,26 +112,61 @@ The flags specified are formed by the following values .Pp .Bl -tag -width ".Dv SF_IMMUTABLE" -compact -offset indent -.It Dv UF_NODUMP -Do not dump the file. -.It Dv UF_IMMUTABLE -The file may not be changed. -.It Dv UF_APPEND +.It Dv SF_APPEND The file may only be appended to. -.It Dv UF_NOUNLINK -The file may not be renamed or deleted. -.It Dv UF_OPAQUE -The directory is opaque when viewed through a union stack. .It Dv SF_ARCHIVED -The file may be archived. +The file has been archived. +This flag means the opposite of the DOS, Windows and CIFS +FILE_ATTRIBUTE_ARCHIVE attribute. +This flag has been deprecated, and may be removed in a future release. .It Dv SF_IMMUTABLE The file may not be changed. -.It Dv SF_APPEND -The file may only be appended to. .It Dv SF_NOUNLINK The file may not be renamed or deleted. .It Dv SF_SNAPSHOT The file is a snapshot file. +.It Dv UF_APPEND +The file may only be appended to. +.It Dv UF_ARCHIVE +The file needs to be archived. +This flag has the same meaning as the DOS, Windows and CIFS +FILE_ATTRIBUTE_ARCHIVE attribute. +Filesystems in FreeBSD may or may not have special handling for this flag. +For instance, ZFS tracks changes to files and will set this bit when a +file is updated. +UFS only stores the flag, and relies on the application to change it when +needed. +.It Dv UF_HIDDEN +The file may be hidden from directory listings at the application's +discretion. +The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_HIDDEN attribute. +.It Dv UF_IMMUTABLE +The file may not be changed. +.It Dv UF_NODUMP +Do not dump the file. +.It Dv UF_NOUNLINK +The file may not be renamed or deleted. +.It Dv UF_OFFLINE +The file is offline, or has the Windows and CIFS FILE_ATTRIBUTE_OFFLINE +attribute. +Filesystems in FreeBSD store and display this flag, but do not provide any +special handling when it is set. +.It Dv UF_OPAQUE +The directory is opaque when viewed through a union stack. +.It Dv UF_READONLY +The file is read only, and may not be written or appended. +Filesystems may use this flag to maintain compatibility with the DOS, Windows +and CIFS FILE_ATTRIBUTE_READONLY attribute. +.It Dv UF_REPARSE +The file contains a Windows reparse point and has the Windows and CIFS +FILE_ATTRIBUTE_REPARSE_POINT attribute. +.It Dv UF_SPARSE +The file has the Windows FILE_ATTRIBUTE_SPARSE_FILE attribute. +This may also be used by a filesystem to indicate a sparse file. +.It Dv UF_SYSTEM +The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_SYSTEM attribute. +Filesystems in FreeBSD may store and display this flag, but do not provide +any special handling when it is set. .El .Pp If one of @@ -162,6 +197,13 @@ the system is in single-user mode. .Xr init 8 for details.) .Pp +The implementation of all flags is filesystem-dependent. +See the description of the +.Dv UF_ARCHIVE +flag above for one example of the differences in behavior. +Care should be exercised when writing applications to account for +support or lack of support of these flags in various filesystems. +.Pp The .Dv SF_SNAPSHOT flag is maintained by the system and cannot be toggled. diff --git a/lib/libc/sys/cpuset.2 b/lib/libc/sys/cpuset.2 index 652d3aea7738..5a1d6955c984 100644 --- a/lib/libc/sys/cpuset.2 +++ b/lib/libc/sys/cpuset.2 @@ -216,7 +216,6 @@ for allocation. .Xr cpuset 1 , .Xr cpuset_getaffinity 2 , .Xr cpuset_setaffinity 2 , -.Xr CPU_SET 3 , .Xr pthread_affinity_np 3 , .Xr pthread_attr_affinity_np 3 .Sh HISTORY diff --git a/lib/libc/sys/cpuset_getaffinity.2 b/lib/libc/sys/cpuset_getaffinity.2 index 4fbbc4e851e2..93cfe95dae22 100644 --- a/lib/libc/sys/cpuset_getaffinity.2 +++ b/lib/libc/sys/cpuset_getaffinity.2 @@ -26,7 +26,7 @@ .\" $FreeBSD$ .\" .Dd September 10, 2010 -.Dt CPUSET 2 +.Dt CPUSET_GETAFFINITY 2 .Os .Sh NAME .Nm cpuset_getaffinity , @@ -69,7 +69,7 @@ All resources, however, have a mask which may be manipulated with Masks of type .Ft cpuset_t are composed using the -.Xr CPU_SET 2 +.Dv CPU_SET macros. The kernel tolerates large sets as long as all CPUs specified in the set exist. @@ -152,7 +152,6 @@ operation. .Xr cpuset 2 , .Xr cpuset_getid 2 , .Xr cpuset_setid 2 , -.Xr CPU_SET 3 , .Xr pthread_affinity_np 3 , .Xr pthread_attr_affinity_np 3 .Sh HISTORY diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index 6e1de206470e..f21c93b5868b 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -28,7 +28,7 @@ .\" @(#)dup.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd August 14, 2011 +.Dd June 1, 2013 .Dt DUP 2 .Os .Sh NAME @@ -56,9 +56,6 @@ The argument .Fa oldd is a small non-negative integer index in the per-process descriptor table. -The value must be less -than the size of the table, which is returned by -.Xr getdtablesize 2 . The new descriptor returned by the call is the lowest numbered descriptor currently not in use by the process. @@ -116,10 +113,11 @@ is a valid descriptor, then .Fn dup2 is successful, and does nothing. .Sh RETURN VALUES -The value -1 is returned if an error occurs in either call. -The external variable +These calls return the new file descriptor if successful; +otherwise the value -1 is returned and +the external variable .Va errno -indicates the cause of the error. +is set to indicate the cause of the error. .Sh ERRORS The .Fn dup @@ -153,7 +151,8 @@ argument is negative or exceeds the maximum allowable descriptor number .Xr open 2 , .Xr pipe 2 , .Xr socket 2 , -.Xr socketpair 2 +.Xr socketpair 2 , +.Xr dup3 3 .Sh STANDARDS The .Fn dup diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index 4a8a646edb4a..1ad2052ff069 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -28,7 +28,7 @@ .\" @(#)fork.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd May 31, 2013 .Dt FORK 2 .Os .Sh NAME @@ -37,7 +37,6 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In unistd.h .Ft pid_t .Fn fork void @@ -74,6 +73,17 @@ are set to 0; see .It All interval timers are cleared; see .Xr setitimer 2 . +.It +The child process has only one thread, +corresponding to the calling thread in the parent process. +If the process has more than one thread, +locks and other resources held by the other threads are not released +and therefore only async-signal-safe functions +(see +.Xr sigaction 2 ) +are guaranteed to work in the child process until a call to +.Xr execve 2 +or a similar function. .El .Sh RETURN VALUES Upon successful completion, @@ -125,6 +135,7 @@ There is insufficient swap space for the new process. .Xr rfork 2 , .Xr setitimer 2 , .Xr setrlimit 2 , +.Xr sigaction 2 , .Xr vfork 2 , .Xr wait 2 .Sh HISTORY diff --git a/lib/libc/sys/getdtablesize.2 b/lib/libc/sys/getdtablesize.2 index 916b91ef356d..d52da83000a3 100644 --- a/lib/libc/sys/getdtablesize.2 +++ b/lib/libc/sys/getdtablesize.2 @@ -28,12 +28,12 @@ .\" @(#)getdtablesize.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd April 24, 2013 .Dt GETDTABLESIZE 2 .Os .Sh NAME .Nm getdtablesize -.Nd get descriptor table size +.Nd get file descriptor limit .Sh LIBRARY .Lb libc .Sh SYNOPSIS @@ -41,18 +41,20 @@ .Ft int .Fn getdtablesize void .Sh DESCRIPTION -Each process has a fixed size descriptor table, -which is guaranteed to have at least 20 slots. -The entries in -the descriptor table are numbered with small integers starting at 0. The .Fn getdtablesize -system call returns the size of this table. +system call returns the maximum number of file descriptors +that the current process may open. +The maximum file descriptor number that the system may assign +is the return value minus one. +Existing file descriptor numbers may be higher +if the limit was lowered after they were opened. .Sh SEE ALSO .Xr close 2 , +.Xr closefrom 2 , .Xr dup 2 , -.Xr open 2 , -.Xr select 2 +.Xr getrlimit 2 , +.Xr sysconf 2 .Sh HISTORY The .Fn getdtablesize diff --git a/lib/libc/sys/intro.2 b/lib/libc/sys/intro.2 index 1a22ea2d7ba2..bc10b1de59de 100644 --- a/lib/libc/sys/intro.2 +++ b/lib/libc/sys/intro.2 @@ -28,7 +28,7 @@ .\" @(#)intro.2 8.5 (Berkeley) 2/27/95 .\" $FreeBSD$ .\" -.Dd February 27, 1995 +.Dd May 4, 2013 .Dt INTRO 2 .Os .Sh NAME @@ -189,12 +189,13 @@ or a .Xr kill 2 system call). .It Er 23 ENFILE Em "Too many open files in system" . -Maximum number of file descriptors allowable on the system -has been reached and a requests for an open cannot be satisfied +Maximum number of open files allowable on the system +has been reached and requests for an open cannot be satisfied until at least one has been closed. .It Er 24 EMFILE Em "Too many open files" . -(As released, the limit on the number of -open files per process is 64.) +Maximum number of file descriptors allowable in the process +has been reached and requests for an open cannot be satisfied +until at least one has been closed. The .Xr getdtablesize 2 system call will obtain the current limit. @@ -469,6 +470,10 @@ An operation on a capability file descriptor requires greater privilege than the capability allows. .It Er 94 ECAPMODE Em "Not permitted in capability mode" . The system call or operation is not permitted for capability mode processes. +.It Er 95 ENOTRECOVERABLE Em "State not recoverable" . +The state protected by a robust mutex is not recoverable. +.It Er 96 EOWNERDEAD Em "Previous owner died" . +The owner of a robust mutex terminated while holding the mutex lock. .El .Sh DEFINITIONS .Bl -tag -width Ds diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index 6ae79143d621..ed3a8adfa730 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -388,20 +388,25 @@ The process has called .It NOTE_EXEC The process has executed a new process via .Xr execve 2 -or similar call. +or a similar call. .It NOTE_TRACK Follow a process across .Fn fork calls. -The parent process will return with NOTE_TRACK set in the +The parent process registers a new kevent to monitor the child process +using the same .Va fflags -field, while the child process will return with NOTE_CHILD set in +as the original event. +The child process will signal an event with NOTE_CHILD set in .Va fflags and the parent PID in .Va data . -.It NOTE_TRACKERR -This flag is returned if the system was unable to attach an event to -the child process, usually due to resource limitations. +.Pp +If the parent process fails to register a new kevent +.Pq usually due to resource limitations , +it will signal an event with NOTE_TRACKERR set in +.Va fflags , +and the child process will not signal a NOTE_CHILD event. .El .Pp On return, diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 73ffb2ead67b..130f70bcaa88 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -28,7 +28,7 @@ .\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 .\" $FreeBSD$ .\" -.Dd March 18, 2012 +.Dd August 16, 2013 .Dt MMAP 2 .Os .Sh NAME @@ -97,7 +97,30 @@ Sharing, mapping type and options are specified in the argument by .Em or Ns 'ing the following values: -.Bl -tag -width MAP_HASSEMAPHORE +.Bl -tag -width MAP_PREFAULT_READ +.It Dv MAP_ALIGNED Ns Pq Fa n +Align the region on a requested boundary. +If a suitable region cannot be found, +.Fn mmap +will fail. +The +.Fa n +argument specifies the binary logarithm of the desired alignment. +.It Dv MAP_ALIGNED_SUPER +Align the region to maximize the potential use of large +.Pq Dq super +pages. +If a suitable region cannot be found, +.Fn mmap +will fail. +The system will choose a suitable page size based on the size of +mapping. +The page size used as well as the alignment of the region may both be +affected by properties of the file being mapped. +In particular, +the physical address of existing pages of a file may require a specific +alignment. +The region is not guaranteed to be aligned on any specific boundary. .It Dv MAP_ANON Map anonymous memory not associated with any specific file. The file descriptor used for creating @@ -274,6 +297,25 @@ Although this implementation does not impose any alignment restrictions on the .Fa offset argument, a portable program must only use page-aligned values. +.Pp +Large page mappings require that the pages backing an object be +aligned in matching blocks in both the virtual address space and RAM. +The system will automatically attempt to use large page mappings when +mapping an object that is already backed by large pages in RAM by +aligning the mapping request in the virtual address space to match the +alignment of the large physical pages. +The system may also use large page mappings when mapping portions of an +object that are not yet backed by pages in RAM. +The +.Dv MAP_ALIGNED_SUPER +flag is an optimization that will align the mapping request to the +size of a large page similar to +.Dv MAP_ALIGNED , +except that the system will override this alignment if an object already +uses large pages so that the mapping will be consistent with the existing +large pages. +This flag is mostly useful for maximizing the use of large pages on the +first mapping of objects that do not yet have pages present in RAM. .Sh RETURN VALUES Upon successful completion, .Fn mmap @@ -325,6 +367,10 @@ The argument was equal to zero. .It Bq Er EINVAL +.Dv MAP_ALIGNED +was specified and the desired alignment was either larger than the +virtual address size of the machine or smaller than a page. +.It Bq Er EINVAL .Dv MAP_ANON was specified and the .Fa fd @@ -356,7 +402,8 @@ was specified and insufficient memory was available. .Xr msync 2 , .Xr munlock 2 , .Xr munmap 2 , -.Xr getpagesize 3 +.Xr getpagesize 3 , +.Xr getpagesizes 3 .Sh BUGS The .Fa len diff --git a/lib/libc/sys/pdfork.2 b/lib/libc/sys/pdfork.2 index ad33566cc096..26d0eb0fe363 100644 --- a/lib/libc/sys/pdfork.2 +++ b/lib/libc/sys/pdfork.2 @@ -1,10 +1,14 @@ .\" -.\" Copyright (c) 2009-2010, 2012 Robert N. M. Watson +.\" Copyright (c) 2009-2010, 2012-2013 Robert N. M. Watson .\" All rights reserved. .\" .\" This software was developed at the University of Cambridge Computer .\" Laboratory with support from a grant from Google, Inc. .\" +.\" 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: @@ -28,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd August 28, 2013 .Dt PDFORK 2 .Os .Sh NAME @@ -71,7 +75,9 @@ Instead of the default terminate-on-close behaviour, allow the process to live until it is explicitly killed with .Xr kill 2 . .Pp -This option is not permitted in Capsicum capability mode (see +This option is not permitted in +.Xr capsicum 4 +capability mode (see .Xr cap_enter 2 ) . .El .Pp @@ -119,6 +125,12 @@ is set; if the process is still alive and this is the last reference to the process descriptor, the process will be terminated with the signal .Dv SIGKILL . +.Pp +.Nm +and associated functions depend on +.Cd "options PROCDESC" +described in +.Xr procdesc 4 . .Sh RETURN VALUES .Fn pdfork returns a PID, 0 or -1, as @@ -156,7 +168,9 @@ for .Xr fstat 2 , .Xr kill 2 , .Xr poll 2 , -.Xr wait4 2 +.Xr wait4 2 , +.Xr capsicum 4 , +.Xr procdesc 4 .Sh HISTORY The .Fn pdfork , diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2 index 92d137fda091..6ea0f14136ad 100644 --- a/lib/libc/sys/pipe.2 +++ b/lib/libc/sys/pipe.2 @@ -28,7 +28,7 @@ .\" @(#)pipe.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 30, 2006 +.Dd May 1, 2013 .Dt PIPE 2 .Os .Sh NAME @@ -40,6 +40,8 @@ .In unistd.h .Ft int .Fn pipe "int fildes[2]" +.Ft int +.Fn pipe2 "int fildes[2]" "int flags" .Sh DESCRIPTION The .Fn pipe @@ -50,6 +52,29 @@ which is an object allowing bidirectional data flow, and allocates a pair of file descriptors. .Pp +The +.Fn pipe2 +system call allows control over the attributes of the file descriptors +via the +.Fa flags +argument. +Values for +.Fa flags +are constructed by a bitwise-inclusive OR of flags from the following +list, defined in +.In fcntl.h : +.Bl -tag -width ".Dv O_NONBLOCK" +.It Dv O_CLOEXEC +Set the close-on-exec flag for the new file descriptors. +.It Dv O_NONBLOCK +Set the non-blocking flag for the ends of the pipe. +.El +.Pp +If the +.Fa flags +argument is 0, the behavior is identical to a call to +.Fn pipe . +.Pp By convention, the first descriptor is normally used as the .Em read end of the pipe, @@ -88,7 +113,9 @@ pipe in one direction. .Sh ERRORS The .Fn pipe -system call will fail if: +and +.Fn pipe2 +system calls will fail if: .Bl -tag -width Er .It Bq Er EMFILE Too many descriptors are active. @@ -97,6 +124,16 @@ The system file table is full. .It Bq Er ENOMEM Not enough kernel memory to establish a pipe. .El +.Pp +The +.Fn pipe2 +system call will also fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa flags +argument is invalid. +.El .Sh SEE ALSO .Xr sh 1 , .Xr fork 2 , @@ -111,3 +148,8 @@ function appeared in .Pp Bidirectional pipes were first used on .At V.4 . +.Pp +The +.Fn pipe2 +function appeared in +.Fx 10.0 . diff --git a/lib/libc/sys/pselect.2 b/lib/libc/sys/pselect.2 index cf784a5dcd7f..ed66aade1cde 100644 --- a/lib/libc/sys/pselect.2 +++ b/lib/libc/sys/pselect.2 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 27, 2009 +.Dd August 16, 2013 .Dt PSELECT 2 .Os .Sh NAME @@ -104,7 +104,8 @@ and (if a signal mask is provided) .Xr kqueue 2 , .Xr poll 2 , .Xr select 2 , -.Xr sigprocmask 2 +.Xr sigprocmask 2 , +.Xr sigsuspend 2 .Sh STANDARDS The .Fn pselect diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 90c45442561e..458ad8dbaf3d 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 7, 2013 +.Dd July 22, 2013 .Dt PTRACE 2 .Os .Sh NAME @@ -556,6 +556,14 @@ was attempted on a process with no valid register set. was given an invalid value for .Fa pve_entry . This can also be caused by changes to the VM map of the process. +.It +The size (in +.Fa data ) +provided to +.Dv PT_LWPINFO +was less than or equal to zero, or larger than the +.Vt ptrace_lwpinfo +structure known to the kernel. .El .It Bq Er EBUSY .Bl -bullet -compact diff --git a/lib/libc/sys/sctp_generic_recvmsg.2 b/lib/libc/sys/sctp_generic_recvmsg.2 index d6fd1b564de2..8ee3d36f90e9 100644 --- a/lib/libc/sys/sctp_generic_recvmsg.2 +++ b/lib/libc/sys/sctp_generic_recvmsg.2 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/sys/sctp_generic_sendmsg.2 b/lib/libc/sys/sctp_generic_sendmsg.2 index 1a2b12866d97..bf54e95473d5 100644 --- a/lib/libc/sys/sctp_generic_sendmsg.2 +++ b/lib/libc/sys/sctp_generic_sendmsg.2 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/sys/sctp_peeloff.2 b/lib/libc/sys/sctp_peeloff.2 index 40a026d8139d..9964586c9e9e 100644 --- a/lib/libc/sys/sctp_peeloff.2 +++ b/lib/libc/sys/sctp_peeloff.2 @@ -9,11 +9,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. 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. .\" diff --git a/lib/libc/sys/setfib.2 b/lib/libc/sys/setfib.2 index bf23c7a97792..d759109fa39e 100644 --- a/lib/libc/sys/setfib.2 +++ b/lib/libc/sys/setfib.2 @@ -64,10 +64,13 @@ with where .Em N is an integer. -However, this maximum is capped at 16 due to the implementation storing -the fib number in a 4-bit field in +This maximum is capped at 65536 due to the implementation storing +the fib number in a 16-bit field in the .Xr mbuf 9 -flags. +packet header, however it is not suggested that one use such a large number +as memory is allocated for every FIB regardless of whether it is used, and +there are places where all FIBs are iterated over. +.Pp The default fib of the process will be applied to all protocol families that support multiple fibs, and ignored by those that do not. The default fib for a process may be overridden for a socket with the use diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2 index e161bf2000bf..d975ef931653 100644 --- a/lib/libc/sys/sigaction.2 +++ b/lib/libc/sys/sigaction.2 @@ -28,7 +28,7 @@ .\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94 .\" $FreeBSD$ .\" -.Dd September 27, 2012 +.Dd June 8, 2013 .Dt SIGACTION 2 .Os .Sh NAME @@ -346,13 +346,19 @@ Any attempt to do so will be silently ignored. The following functions are either reentrant or not interruptible by signals and are async-signal safe. Therefore applications may -invoke them, without restriction, from signal-catching functions: +invoke them, without restriction, from signal-catching functions +or from a child process after calling +.Xr fork 2 +in a multi-threaded process: .Pp Base Interfaces: .Pp +.Fn _Exit , .Fn _exit , +.Fn accept , .Fn access , .Fn alarm , +.Fn bind , .Fn cfgetispeed , .Fn cfgetospeed , .Fn cfsetispeed , @@ -361,41 +367,76 @@ Base Interfaces: .Fn chmod , .Fn chown , .Fn close , +.Fn connect , .Fn creat , .Fn dup , .Fn dup2 , +.Fn execl , .Fn execle , +.Fn execv , .Fn execve , +.Fn faccessat , +.Fn fchdir , +.Fn fchmod , +.Fn fchmodat , +.Fn fchown , +.Fn fchownat , .Fn fcntl , .Fn fork , -.Fn fpathconf , .Fn fstat , +.Fn fstatat , .Fn fsync , +.Fn ftruncate , .Fn getegid , .Fn geteuid , .Fn getgid , .Fn getgroups , +.Fn getpeername , .Fn getpgrp , .Fn getpid , .Fn getppid , +.Fn getsockname , +.Fn getsockopt , .Fn getuid , .Fn kill , .Fn link , +.Fn linkat , +.Fn listen , .Fn lseek , +.Fn lstat , .Fn mkdir , +.Fn mkdirat , .Fn mkfifo , +.Fn mkfifoat , +.Fn mknod , +.Fn mknodat , .Fn open , -.Fn pathconf , +.Fn openat , .Fn pause , .Fn pipe , +.Fn poll , +.Fn pselect , +.Fn pthread_sigmask , .Fn raise , .Fn read , +.Fn readlink , +.Fn readlinkat , +.Fn recv , +.Fn recvfrom , +.Fn recvmsg , .Fn rename , +.Fn renameat , .Fn rmdir , +.Fn select , +.Fn send , +.Fn sendmsg , +.Fn sendto , .Fn setgid , .Fn setpgid , .Fn setsid , +.Fn setsockopt , .Fn setuid , +.Fn shutdown , .Fn sigaction , .Fn sigaddset , .Fn sigdelset , @@ -407,8 +448,12 @@ Base Interfaces: .Fn sigprocmask , .Fn sigsuspend , .Fn sleep , +.Fn sockatmark , +.Fn socket , +.Fn socketpair , .Fn stat , -.Fn sysconf , +.Fn symlink , +.Fn symlinkat , .Fn tcdrain , .Fn tcflow , .Fn tcflush , @@ -422,16 +467,22 @@ Base Interfaces: .Fn umask , .Fn uname , .Fn unlink , +.Fn unlinkat , .Fn utime , .Fn wait , .Fn waitpid , .Fn write . .Pp +X/Open Systems Interfaces: +.Pp +.Fn sigpause , +.Fn sigset , +.Fn utimes . +.Pp Realtime Interfaces: .Pp .Fn aio_error , .Fn clock_gettime , -.Fn sigpause , .Fn timer_getoverrun , .Fn aio_return , .Fn fdatasync , @@ -439,27 +490,98 @@ Realtime Interfaces: .Fn timer_gettime , .Fn aio_suspend , .Fn sem_post , -.Fn sigset , .Fn timer_settime . .Pp -.Tn ANSI C -Interfaces: +Base Interfaces not specified as async-signal safe by +.Tn POSIX : .Pp -.Fn strcpy , +.Fn fpathconf , +.Fn pathconf , +.Fn sysconf . +.Pp +Base Interfaces not specified as async-signal safe by +.Tn POSIX , +but planned to be: +.Pp +.Fn ffs , +.Fn htonl , +.Fn htons , +.Fn memccpy , +.Fn memchr , +.Fn memcmp , +.Fn memcpy , +.Fn memmove , +.Fn memset , +.Fn ntohl , +.Fn ntohs , +.Fn stpcpy , +.Fn stpncpy , .Fn strcat , -.Fn strncpy , +.Fn strchr , +.Fn strcmp , +.Fn strcpy , +.Fn strcspn , +.Fn strlen , .Fn strncat , -and perhaps some others. +.Fn strncmp , +.Fn strncpy , +.Fn strnlen , +.Fn strpbrk , +.Fn strrchr , +.Fn strspn , +.Fn strstr , +.Fn strtok_r , +.Fn wcpcpy , +.Fn wcpncpy , +.Fn wcscat , +.Fn wcschr , +.Fn wcscmp , +.Fn wcscpy , +.Fn wcscspn , +.Fn wcslen , +.Fn wcsncat , +.Fn wcsncmp , +.Fn wcsncpy , +.Fn wcsnlen , +.Fn wcspbrk , +.Fn wcsrchr , +.Fn wcsspn , +.Fn wcsstr , +.Fn wcstok , +.Fn wmemchr , +.Fn wmemcmp , +.Fn wmemcpy , +.Fn wmemmove , +.Fn wmemset . .Pp Extension Interfaces: .Pp -.Fn strlcpy , +.Fn accept4 , +.Fn bindat , +.Fn closefrom , +.Fn connectat , +.Fn eaccess , +.Fn ffsl , +.Fn ffsll , +.Fn flock , +.Fn fls , +.Fn flsl , +.Fn flsll , +.Fn futimesat , +.Fn pipe2 , .Fn strlcat . +.Fn strlcpy , +.Fn strsep . +.Pp +In addition, reading or writing +.Va errno +is async-signal safe. .Pp All functions not in the above lists are considered to be unsafe with respect to signals. That is to say, the behaviour of such -functions when called from a signal handler is undefined. +functions is undefined when they are called from a signal handler +that interrupted an unsafe function. In general though, signal handlers should do little more than set a flag; most other actions are not safe. .Pp diff --git a/lib/libc/sys/sigreturn.2 b/lib/libc/sys/sigreturn.2 index 02d75a83b6ed..13d76f68d48b 100644 --- a/lib/libc/sys/sigreturn.2 +++ b/lib/libc/sys/sigreturn.2 @@ -56,10 +56,6 @@ Execution resumes at the specified pc. This system call is used by the trampoline code and .Xr longjmp 3 when returning from a signal to the previously executing program. -.Sh NOTES -This system call is not available in -.Bx 4.2 -hence it should not be used if backward compatibility is needed. .Sh RETURN VALUES If successful, the system call does not return. Otherwise, a value of -1 is returned and diff --git a/lib/libc/sys/sigsuspend.2 b/lib/libc/sys/sigsuspend.2 index 3a67b53374d4..0ffc11dc4f3e 100644 --- a/lib/libc/sys/sigsuspend.2 +++ b/lib/libc/sys/sigsuspend.2 @@ -28,7 +28,7 @@ .\" @(#)sigsuspend.2 8.2 (Berkeley) 5/16/95 .\" $FreeBSD$ .\" -.Dd May 16, 1995 +.Dd August 16, 2013 .Dt SIGSUSPEND 2 .Os .Sh NAME @@ -70,9 +70,13 @@ always terminates by being interrupted, returning -1 with set to .Er EINTR . .Sh SEE ALSO +.Xr pselect 2 , .Xr sigaction 2 , .Xr sigpending 2 , .Xr sigprocmask 2 , +.Xr sigtimedwait 2 , +.Xr sigwait 2 , +.Xr sigwaitinfo 2 , .Xr sigsetops 3 .Sh STANDARDS The |