diff options
Diffstat (limited to 'lib/libc')
287 files changed, 5508 insertions, 1661 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 5653220..b6d3f9f 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -44,13 +44,11 @@ CFLAGS+=${CANCELPOINTS_CFLAGS} # # Link with static libcompiler_rt.a. # -DPADD+= ${LIBCOMPILER_RT} LDFLAGS+= -nodefaultlibs -LDADD+= -lcompiler_rt +LIBADD+= compiler_rt .if ${MK_SSP} != "no" -DPADD+= ${LIBSSP_NONSHARED} -LDADD+= -lssp_nonshared +LIBADD+= ssp_nonshared .endif # Extras that live in either libc.a or libc_nonshared.a @@ -81,7 +79,8 @@ NOASM= .include "${LIBC_SRCTOP}/net/Makefile.inc" .include "${LIBC_SRCTOP}/nls/Makefile.inc" .include "${LIBC_SRCTOP}/posix1e/Makefile.inc" -.if ${LIBC_ARCH} != "amd64" && \ +.if ${LIBC_ARCH} != "aarch64" && \ + ${LIBC_ARCH} != "amd64" && \ ${LIBC_ARCH} != "powerpc64" && \ ${LIBC_ARCH} != "sparc64" && \ ${MACHINE_ARCH:Mmipsn32*} == "" && \ @@ -151,14 +150,16 @@ KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ libkern: libkern.gen libkern.${LIBC_ARCH} libkern.gen: ${KQSRCS} ${KSRCS} - cp -fp ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern + ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern libkern.${LIBC_ARCH}:: ${KMSRCS} .if defined(KMSRCS) && !empty(KMSRCS) - cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} + ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} .endif -.include <bsd.arch.inc.mk> +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include <bsd.lib.mk> diff --git a/lib/libc/Makefile.amd64 b/lib/libc/Makefile.amd64 deleted file mode 100644 index dd0f5b0..0000000 --- a/lib/libc/Makefile.amd64 +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ - -.if ${MK_TESTS} != "no" -SUBDIR+= tests -.endif - diff --git a/lib/libc/Makefile.i386 b/lib/libc/Makefile.i386 deleted file mode 100644 index dd0f5b0..0000000 --- a/lib/libc/Makefile.i386 +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ - -.if ${MK_TESTS} != "no" -SUBDIR+= tests -.endif - diff --git a/lib/libc/aarch64/Makefile.inc b/lib/libc/aarch64/Makefile.inc new file mode 100644 index 0000000..5f17200 --- /dev/null +++ b/lib/libc/aarch64/Makefile.inc @@ -0,0 +1,9 @@ +# $FreeBSD$ +# +# Machine dependent definitions for the arm 64-bit architecture. +# + +# Long double is quad precision +GDTOASRCS+=strtorQ.c +MDSRCS+=machdep_ldisQ.c +SYM_MAPS+=${LIBC_SRCTOP}/aarch64/Symbol.map diff --git a/lib/libc/aarch64/SYS.h b/lib/libc/aarch64/SYS.h new file mode 100644 index 0000000..e0be59d --- /dev/null +++ b/lib/libc/aarch64/SYS.h @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/syscall.h> +#include <machine/asm.h> + +#define _SYSCALL(name) \ + mov x8, SYS_ ## name; \ + svc 0 + +#define SYSCALL(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + ret; \ +END(__sys_##name) + +#define PSEUDO(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + b.cs cerror; \ + ret; \ +END(__sys_##name) + +#define RSYSCALL(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + b.cs cerror; \ + ret; \ +END(__sys_##name) diff --git a/lib/libc/aarch64/Symbol.map b/lib/libc/aarch64/Symbol.map new file mode 100644 index 0000000..a0b33da --- /dev/null +++ b/lib/libc/aarch64/Symbol.map @@ -0,0 +1,30 @@ +/* + * $FreeBSD$ + */ + +/* + * This only needs to contain symbols that are not listed in + * symbol maps from other parts of libc (i.e., not found in + * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). + */ +FBSD_1.0 { + /* PSEUDO syscalls */ + _exit; + + _setjmp; + _longjmp; + fabs; + setjmp; + longjmp; + sigsetjmp; + siglongjmp; + vfork; + brk; + sbrk; +}; + +FBSDprivate_1.0 { + _set_tp; + curbrk; + minbrk; +}; diff --git a/lib/libc/aarch64/_fpmath.h b/lib/libc/aarch64/_fpmath.h new file mode 100644 index 0000000..71d0a71 --- /dev/null +++ b/lib/libc/aarch64/_fpmath.h @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG> + * Copyright (2) 2014 The FreeBSD Foundation + * 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$ + */ + +union IEEEl2bits { + long double e; + struct { + unsigned long manl :64; + unsigned long manh :48; + unsigned int exp :15; + unsigned int sign :1; + } bits; + /* TODO andrew: Check the packing here */ + struct { + unsigned long manl :64; + unsigned long manh :48; + unsigned int expsign :16; + } xbits; +}; + +#define LDBL_NBIT 0 +#define LDBL_IMPLICIT_NBIT +#define mask_nbit_l(u) ((void)0) + +#define LDBL_MANH_SIZE 48 +#define LDBL_MANL_SIZE 64 + +#define LDBL_TO_ARRAY32(u, a) do { \ + (a)[0] = (uint32_t)(u).bits.manl; \ + (a)[1] = (uint32_t)((u).bits.manl >> 32); \ + (a)[2] = (uint32_t)(u).bits.manh; \ + (a)[3] = (uint32_t)((u).bits.manh >> 32); \ +} while(0) diff --git a/lib/libc/aarch64/arith.h b/lib/libc/aarch64/arith.h new file mode 100644 index 0000000..ecb1a33 --- /dev/null +++ b/lib/libc/aarch64/arith.h @@ -0,0 +1,19 @@ +/* + * MD header for contrib/gdtoa + * + * $FreeBSD$ + */ + +/* + * NOTE: The definitions in this file must be correct or strtod(3) and + * floating point formats in printf(3) will break! The file can be + * generated by running contrib/gdtoa/arithchk.c on the target + * architecture. See contrib/gdtoa/gdtoaimp.h for details. + */ + +#define IEEE_8087 +#define Arith_Kind_ASL 1 +#define Long int +#define Intcast (int)(long) +#define Double_Align +#define X64_bit_pointers diff --git a/lib/libc/aarch64/gd_qnan.h b/lib/libc/aarch64/gd_qnan.h new file mode 100644 index 0000000..27e8d58 --- /dev/null +++ b/lib/libc/aarch64/gd_qnan.h @@ -0,0 +1,21 @@ +/* + * MD header for contrib/gdtoa + * + * This file can be generated by compiling and running contrib/gdtoa/qnan.c + * on the target architecture after arith.h has been generated. + * + * $FreeBSD$ + */ + +#define f_QNAN 0x7fc00000 +#define d_QNAN0 0x0 +#define d_QNAN1 0x7ff80000 +#define ld_QNAN0 0x0 +#define ld_QNAN1 0x0 +#define ld_QNAN2 0x0 +#define ld_QNAN3 0x7fff8000 +#define ldus_QNAN0 0x0 +#define ldus_QNAN1 0x0 +#define ldus_QNAN2 0x0 +#define ldus_QNAN3 0x0 +#define ldus_QNAN4 0x0 diff --git a/lib/libc/aarch64/gen/Makefile.inc b/lib/libc/aarch64/gen/Makefile.inc new file mode 100644 index 0000000..c4f7c80 --- /dev/null +++ b/lib/libc/aarch64/gen/Makefile.inc @@ -0,0 +1,10 @@ +# $FreeBSD$ + +SRCS+= fabs.S \ + flt_rounds.c \ + ldexp.c \ + _setjmp.S \ + _set_tp.c \ + setjmp.S \ + sigsetjmp.S \ + trivial-getcontextx.c diff --git a/lib/libc/posix1e/acl_size.c b/lib/libc/aarch64/gen/_set_tp.c index 27ad651..a587b2e 100644 --- a/lib/libc/posix1e/acl_size.c +++ b/lib/libc/aarch64/gen/_set_tp.c @@ -1,5 +1,5 @@ -/* - * Copyright (c) 2001-2002 Chris D. Faulhaber +/*- + * Copyright (c) 2014 Andrew Turner * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * 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 AUTHOR OR CONTRIBUTORS BE LIABLE + * 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) @@ -27,17 +27,16 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <string.h> #include <sys/types.h> -#include "namespace.h" -#include <sys/acl.h> -#include "un-namespace.h" -#include <errno.h> +#include <machine/sysarch.h> -ssize_t -acl_size(acl_t acl) +#include <stdlib.h> + +void +_set_tp(void *tp) { - errno = ENOSYS; - return (-1); + asm volatile("msr tpidr_el0, %0" : : "r"(tp)); } diff --git a/lib/libc/aarch64/gen/_setjmp.S b/lib/libc/aarch64/gen/_setjmp.S new file mode 100644 index 0000000..504423b --- /dev/null +++ b/lib/libc/aarch64/gen/_setjmp.S @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by Andrew Turner + * under sponsorship from the FreeBSD Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include <machine/setjmp.h> + +ENTRY(_setjmp) + /* Store the magic value and stack pointer */ + ldr x8, .Lmagic + mov x9, sp + stp x8, x9, [x0], #16 + + /* Store the general purpose registers and lr */ + stp x19, x20, [x0], #16 + stp x21, x22, [x0], #16 + stp x23, x24, [x0], #16 + stp x25, x26, [x0], #16 + stp x27, x28, [x0], #16 + stp x29, lr, [x0], #16 + +#ifndef _STANDALONE + /* Store the vfp registers */ + stp d8, d9, [x0], #16 + stp d10, d11, [x0], #16 + stp d12, d13, [x0], #16 + stp d14, d15, [x0] +#endif + + /* Return value */ + mov x0, #0 + ret +.Lmagic: + .align 3 + .quad _JB_MAGIC__SETJMP +END(_setjmp) + +ENTRY(_longjmp) + /* Check the magic value */ + ldr x8, [x0], #8 + ldr x9, .Lmagic + cmp x8, x9 + b.ne botch + + /* Restore the stack pointer */ + ldr x8, [x0], #8 + mov sp, x8 + + /* Restore the general purpose registers and lr */ + ldp x19, x20, [x0], #16 + ldp x21, x22, [x0], #16 + ldp x23, x24, [x0], #16 + ldp x25, x26, [x0], #16 + ldp x27, x28, [x0], #16 + ldp x29, lr, [x0], #16 + +#ifndef _STANDALONE + /* Restore the vfp registers */ + ldp d8, d9, [x0], #16 + ldp d10, d11, [x0], #16 + ldp d12, d13, [x0], #16 + ldp d14, d15, [x0] +#endif + + /* Load the return value */ + mov x0, x1 + ret + +botch: +#ifdef _STANDALONE + b botch +#else + bl _C_LABEL(longjmperror) + bl _C_LABEL(abort) +#endif +END(_longjmp) diff --git a/lib/libc/aarch64/gen/fabs.S b/lib/libc/aarch64/gen/fabs.S new file mode 100644 index 0000000..2f5fd06 --- /dev/null +++ b/lib/libc/aarch64/gen/fabs.S @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2015 The FreeBSD Foundation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +ENTRY(fabs) + fabs d0, d0 + ret +END(fabs) diff --git a/lib/libc/powerpc/sys/__vdso_gettc.c b/lib/libc/aarch64/gen/flt_rounds.c index b99bbc4..6f8eeeb 100644 --- a/lib/libc/powerpc/sys/__vdso_gettc.c +++ b/lib/libc/aarch64/gen/flt_rounds.c @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org> + * Copyright (c) 2012 Ian Lepore <freebsd@damnhippie.dyndns.org> + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,22 +28,22 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> -#include <sys/time.h> -#include <sys/vdso.h> -#include <errno.h> -#pragma weak __vdso_gettc -u_int -__vdso_gettc(const struct vdso_timehands *th) -{ +#include <fenv.h> +#include <float.h> - return (0); -} +static int map[] = { + 1, /* round to nearest */ + 2, /* round to positive infinity */ + 3, /* round to negative infinity */ + 0 /* round to zero */ +}; -#pragma weak __vdso_gettimekeep int -__vdso_gettimekeep(struct vdso_timekeep **tk) +__flt_rounds(void) { + uint64_t fpcr; - return (ENOSYS); + asm volatile("mrs %0, fpcr" : "=r" (fpcr)); + return map[(fpcr >> 22) & 3]; } diff --git a/lib/libc/aarch64/gen/setjmp.S b/lib/libc/aarch64/gen/setjmp.S new file mode 100644 index 0000000..80a9484 --- /dev/null +++ b/lib/libc/aarch64/gen/setjmp.S @@ -0,0 +1,123 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by Andrew Turner + * under sponsorship from the FreeBSD Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include <machine/setjmp.h> + +ENTRY(setjmp) + sub sp, sp, #16 + stp x0, lr, [sp] + + /* Store the signal mask */ + add x2, x0, #(_JB_SIGMASK * 8) /* oset */ + mov x1, #0 /* set */ + mov x0, #1 /* SIG_BLOCK */ + bl sigprocmask + + ldp x0, lr, [sp] + add sp, sp, #16 + + /* Store the magic value and stack pointer */ + ldr x8, .Lmagic + mov x9, sp + stp x8, x9, [x0], #16 + + /* Store the general purpose registers and lr */ + stp x19, x20, [x0], #16 + stp x21, x22, [x0], #16 + stp x23, x24, [x0], #16 + stp x25, x26, [x0], #16 + stp x27, x28, [x0], #16 + stp x29, lr, [x0], #16 + + /* Store the vfp registers */ + stp d8, d9, [x0], #16 + stp d10, d11, [x0], #16 + stp d12, d13, [x0], #16 + stp d14, d15, [x0] + + /* Return value */ + mov x0, #0 + ret +.Lmagic: + .align 3 + .quad _JB_MAGIC_SETJMP +END(setjmp) + +ENTRY(longjmp) + sub sp, sp, #32 + stp x0, lr, [sp] + str x1, [sp, #16] + + /* Restore the signal mask */ + mov x1, #0 /* oset */ + add x1, x0, #(_JB_SIGMASK * 8) /* set */ + mov x0, #3 /* SIG_BLOCK */ + bl sigprocmask + + ldr x1, [sp, #16] + ldp x0, lr, [sp] + add sp, sp, #32 + + /* Check the magic value */ + ldr x8, [x0], #8 + ldr x9, .Lmagic + cmp x8, x9 + b.ne botch + + /* Restore the stack pointer */ + ldr x8, [x0], #8 + mov sp, x8 + + /* Restore the general purpose registers and lr */ + ldp x19, x20, [x0], #16 + ldp x21, x22, [x0], #16 + ldp x23, x24, [x0], #16 + ldp x25, x26, [x0], #16 + ldp x27, x28, [x0], #16 + ldp x29, lr, [x0], #16 + + /* Restore the vfp registers */ + ldp d8, d9, [x0], #16 + ldp d10, d11, [x0], #16 + ldp d12, d13, [x0], #16 + ldp d14, d15, [x0] + + /* Load the return value */ + mov x0, x1 + ret + +botch: + bl _C_LABEL(longjmperror) + bl _C_LABEL(abort) +END(longjmp) diff --git a/lib/libc/aarch64/gen/sigsetjmp.S b/lib/libc/aarch64/gen/sigsetjmp.S new file mode 100644 index 0000000..8a13c9f --- /dev/null +++ b/lib/libc/aarch64/gen/sigsetjmp.S @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include <machine/setjmp.h> + +ENTRY(sigsetjmp) + cmp x1, #0 + b.eq _C_LABEL(_setjmp) + b _C_LABEL(setjmp) +END(sigsetjmp) + +ENTRY(siglongjmp) + /* Load the _setjmp magic */ + ldr x2, .Lmagic + ldr x3, [x0] + + /* Check the magic */ + cmp x2, x3 + b.eq _C_LABEL(_longjmp) + b _C_LABEL(longjmp) +.Lmagic: + .align 3 + .quad _JB_MAGIC__SETJMP +END(siglongjmp) diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc new file mode 100644 index 0000000..cb56f73 --- /dev/null +++ b/lib/libc/aarch64/sys/Makefile.inc @@ -0,0 +1,25 @@ +# $FreeBSD$ + +SRCS+= trivial-vdso_tc.c + +#MDASM= ptrace.S +MDASM= brk.S \ + cerror.S \ + pipe.S \ + sbrk.S \ + shmat.S \ + sigreturn.S \ + syscall.S \ + vfork.S + +# Don't generate default code for these syscalls: +NOASM= break.o \ + exit.o \ + getlogin.o \ + openbsd_poll.o \ + sstk.o \ + vfork.o \ + yield.o + +PSEUDO= _exit.o \ + _getlogin.o diff --git a/lib/libc/aarch64/sys/brk.S b/lib/libc/aarch64/sys/brk.S new file mode 100644 index 0000000..09167b6 --- /dev/null +++ b/lib/libc/aarch64/sys/brk.S @@ -0,0 +1,93 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include "SYS.h" + + .data + .align 3 + .globl _C_LABEL(minbrk) + .type _C_LABEL(minbrk),#object +_C_LABEL(minbrk): + .quad _C_LABEL(_end) + + .text +/* + * int brk(const void *addr); + */ +ENTRY(_brk) + WEAK_REFERENCE(_brk, brk) + + /* Load the address of minbrk */ +#ifdef __PIC__ + adrp x2, :got:minbrk + ldr x3, [x2, #:got_lo12:minbrk] +#else + ldr x3, .Lminbrk +#endif + + /* Get the minimum allowable brk address */ + ldr x2, [x3] + + /* Validate the address */ + cmp x0, x2 + b.ge 1f + /* Invalid, set it to the minimum */ + mov x0, x2 + + /* Backup the new address */ +1: mov x4, x0 + + /* Update for this value, will overwrite x0 and x1 */ + _SYSCALL(break) + b.cs cerror + +#ifdef __PIC__ + adrp x2, :got:curbrk + ldr x3, [x2, #:got_lo12:curbrk] +#else + ldr x3, .Lcurbrk +#endif + + /* Store the new curbrk value */ + str x4, [x3] + + /* Return success */ + mov x0, #0 + ret + +#ifndef __PIC__ +.Lcurbrk: + .quad _C_LABEL(curbrk) +.Lminbrk: + .quad _C_LABEL(minbrk) +#endif +END(_brk) diff --git a/lib/libc/aarch64/sys/cerror.S b/lib/libc/aarch64/sys/cerror.S new file mode 100644 index 0000000..26c61bc --- /dev/null +++ b/lib/libc/aarch64/sys/cerror.S @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +ENTRY(cerror) + sub sp, sp, #16 + stp x0, lr, [sp] + bl _C_LABEL(__error) + ldp x1, lr, [sp] + str x1, [x0] + movn x0, #0 + movn x1, #0 + add sp, sp, #16 + ret +END(cerror) diff --git a/lib/libc/aarch64/sys/pipe.S b/lib/libc/aarch64/sys/pipe.S new file mode 100644 index 0000000..6b1cf24 --- /dev/null +++ b/lib/libc/aarch64/sys/pipe.S @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include "SYS.h" + +ENTRY(__sys_pipe) + WEAK_REFERENCE(__sys_pipe, pipe) + + /* Backup the pointer passed to us */ + mov x2, x0 + + /* Make the syscall */ + _SYSCALL(pipe) + b.cs cerror + + /* Store the result */ + str w0, [x2, #0] + str w1, [x2, #4] + + /* Return */ + mov x0, #0 + ret +END(__sys_pipe) diff --git a/lib/libc/aarch64/sys/sbrk.S b/lib/libc/aarch64/sys/sbrk.S new file mode 100644 index 0000000..db9d7e1 --- /dev/null +++ b/lib/libc/aarch64/sys/sbrk.S @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include "SYS.h" + + .data + .align 3 + .global _C_LABEL(curbrk) + .type _C_LABEL(curbrk),#object +_C_LABEL(curbrk): + .quad _C_LABEL(_end) + + .text +/* + * void *sbrk(intptr_t incr); + */ +ENTRY(_sbrk) + WEAK_REFERENCE(_sbrk, sbrk) + + /* Load the address of curbrk */ +#ifdef __PIC__ + adrp x2, :got:curbrk + ldr x3, [x2, #:got_lo12:curbrk] +#else + ldr x3, .Lcurbrk +#endif + + /* Get the current brk address */ + ldr x2, [x3] + + /* Calculate the new value */ + add x0, x2, x0 + mov x4, x0 + + /* Update for this value, will overwrite x0 and x1 */ + _SYSCALL(break) + b.cs cerror + + /* Load the old value to return */ + ldr x0, [x3] + + /* Store the new curbrk value */ + str x4, [x3] + + ret +#ifndef __PIC__ +.Lcurbrk: + .quad _C_LABEL(curbrk) +#endif +END(_sbrk) diff --git a/lib/libc/mips/sys/__vdso_gettc.c b/lib/libc/aarch64/sys/shmat.S index b99bbc4..c0fb34f 100644 --- a/lib/libc/mips/sys/__vdso_gettc.c +++ b/lib/libc/aarch64/sys/shmat.S @@ -1,5 +1,9 @@ /*- - * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org> + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,26 +27,9 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> +#include <machine/asm.h> __FBSDID("$FreeBSD$"); -#include <sys/types.h> -#include <sys/time.h> -#include <sys/vdso.h> -#include <errno.h> - -#pragma weak __vdso_gettc -u_int -__vdso_gettc(const struct vdso_timehands *th) -{ - - return (0); -} - -#pragma weak __vdso_gettimekeep -int -__vdso_gettimekeep(struct vdso_timekeep **tk) -{ +#include "SYS.h" - return (ENOSYS); -} +RSYSCALL(shmat) diff --git a/lib/libc/aarch64/sys/sigreturn.S b/lib/libc/aarch64/sys/sigreturn.S new file mode 100644 index 0000000..21ec1e4 --- /dev/null +++ b/lib/libc/aarch64/sys/sigreturn.S @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include "SYS.h" + +RSYSCALL(sigreturn) diff --git a/lib/libc/aarch64/sys/syscall.S b/lib/libc/aarch64/sys/syscall.S new file mode 100644 index 0000000..6314835 --- /dev/null +++ b/lib/libc/aarch64/sys/syscall.S @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$"); + +#include "SYS.h" + +RSYSCALL(syscall) diff --git a/lib/libc/powerpc64/sys/__vdso_gettc.c b/lib/libc/aarch64/sys/vfork.S index b99bbc4..daecd1f 100644 --- a/lib/libc/powerpc64/sys/__vdso_gettc.c +++ b/lib/libc/aarch64/sys/vfork.S @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org> + * Copyright (c) 2014 Andrew Turner + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -21,28 +22,21 @@ * 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> +#include <machine/asm.h> __FBSDID("$FreeBSD$"); +#include "SYS.h" -#include <sys/types.h> -#include <sys/time.h> -#include <sys/vdso.h> -#include <errno.h> - -#pragma weak __vdso_gettc -u_int -__vdso_gettc(const struct vdso_timehands *th) -{ - - return (0); -} - -#pragma weak __vdso_gettimekeep -int -__vdso_gettimekeep(struct vdso_timekeep **tk) -{ - - return (ENOSYS); -} +ENTRY(__sys_vfork) + WEAK_REFERENCE(__sys_vfork, vfork) + WEAK_REFERENCE(__sys_vfork, _vfork) + mov x2, lr + _SYSCALL(vfork) + b.cs cerror + sub x1, x1, #1 + and x0, x0, x1 + mov lr, x2 + ret +END(__sys_vfork) diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc index 8e0d614..46ea955 100644 --- a/lib/libc/amd64/sys/Makefile.inc +++ b/lib/libc/amd64/sys/Makefile.inc @@ -11,6 +11,3 @@ MDASM= vfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \ NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o PSEUDO= _getlogin.o _exit.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif diff --git a/lib/libc/arm/SYS.h b/lib/libc/arm/SYS.h index ed1a045..3254c45 100644 --- a/lib/libc/arm/SYS.h +++ b/lib/libc/arm/SYS.h @@ -62,6 +62,7 @@ #define _SYSCALL(x) \ _SYSCALL_NOERROR(x); \ + it cs; \ bcs PIC_SYM(CERROR, PLT) #define SYSCALL(x) \ @@ -72,6 +73,7 @@ .weak _C_LABEL(__CONCAT(_,x)); \ .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \ SYSTRAP(x); \ + it cs; \ bcs PIC_SYM(CERROR, PLT); \ RET diff --git a/lib/libc/arm/aeabi/Makefile.inc b/lib/libc/arm/aeabi/Makefile.inc index b204a53..fa0ec8e 100644 --- a/lib/libc/arm/aeabi/Makefile.inc +++ b/lib/libc/arm/aeabi/Makefile.inc @@ -20,7 +20,7 @@ SRCS+= aeabi_vfp_double.S \ # libc. This causes issues when other parts of libc call these functions. # We work around this by including these functions in libc but mark them as # hidden so users of libc will not pick up these versions. -.PATH: ${LIBC_SRCTOP}/../../contrib/compiler-rt/lib/arm +.PATH: ${LIBC_SRCTOP}/../../contrib/compiler-rt/lib/builtins/arm SRCS+= aeabi_memcmp.S \ aeabi_memcpy.S \ diff --git a/lib/libc/arm/aeabi/aeabi_vfp_double.S b/lib/libc/arm/aeabi/aeabi_vfp_double.S index 62100d2..aae49f8 100644 --- a/lib/libc/arm/aeabi/aeabi_vfp_double.S +++ b/lib/libc/arm/aeabi/aeabi_vfp_double.S @@ -66,6 +66,7 @@ AEABI_ENTRY(dcmpeq) LOAD_DREG(d1, r2, r3) vcmp.f64 d0, d1 vmrs APSR_nzcv, fpscr + ite ne movne r0, #0 moveq r0, #1 RET @@ -77,8 +78,9 @@ AEABI_ENTRY(dcmplt) LOAD_DREG(d1, r2, r3) vcmp.f64 d0, d1 vmrs APSR_nzcv, fpscr + ite cs movcs r0, #0 - movlt r0, #1 + movcc r0, #1 RET AEABI_END(dcmplt) @@ -88,6 +90,7 @@ AEABI_ENTRY(dcmple) LOAD_DREG(d1, r2, r3) vcmp.f64 d0, d1 vmrs APSR_nzcv, fpscr + ite hi movhi r0, #0 movls r0, #1 RET @@ -99,6 +102,7 @@ AEABI_ENTRY(dcmpge) LOAD_DREG(d1, r2, r3) vcmp.f64 d0, d1 vmrs APSR_nzcv, fpscr + ite lt movlt r0, #0 movge r0, #1 RET @@ -110,6 +114,7 @@ AEABI_ENTRY(dcmpgt) LOAD_DREG(d1, r2, r3) vcmp.f64 d0, d1 vmrs APSR_nzcv, fpscr + ite le movle r0, #0 movgt r0, #1 RET @@ -121,6 +126,7 @@ AEABI_ENTRY(dcmpun) LOAD_DREG(d1, r2, r3) vcmp.f64 d0, d1 vmrs APSR_nzcv, fpscr + ite vc movvc r0, #0 movvs r0, #1 RET diff --git a/lib/libc/arm/aeabi/aeabi_vfp_float.S b/lib/libc/arm/aeabi/aeabi_vfp_float.S index c9a9a7e..7de8daf 100644 --- a/lib/libc/arm/aeabi/aeabi_vfp_float.S +++ b/lib/libc/arm/aeabi/aeabi_vfp_float.S @@ -62,6 +62,7 @@ AEABI_ENTRY(fcmpeq) LOAD_SREGS(s0, s1, r0, r1) vcmp.f32 s0, s1 vmrs APSR_nzcv, fpscr + ite ne movne r0, #0 moveq r0, #1 RET @@ -72,8 +73,9 @@ AEABI_ENTRY(fcmplt) LOAD_SREGS(s0, s1, r0, r1) vcmp.f32 s0, s1 vmrs APSR_nzcv, fpscr + ite cs movcs r0, #0 - movlt r0, #1 + movcc r0, #1 RET AEABI_END(fcmplt) @@ -82,6 +84,7 @@ AEABI_ENTRY(fcmple) LOAD_SREGS(s0, s1, r0, r1) vcmp.f32 s0, s1 vmrs APSR_nzcv, fpscr + ite hi movhi r0, #0 movls r0, #1 RET @@ -92,6 +95,7 @@ AEABI_ENTRY(fcmpge) LOAD_SREGS(s0, s1, r0, r1) vcmp.f32 s0, s1 vmrs APSR_nzcv, fpscr + ite lt movlt r0, #0 movge r0, #1 RET @@ -102,6 +106,7 @@ AEABI_ENTRY(fcmpgt) LOAD_SREGS(s0, s1, r0, r1) vcmp.f32 s0, s1 vmrs APSR_nzcv, fpscr + ite le movle r0, #0 movgt r0, #1 RET @@ -112,6 +117,7 @@ AEABI_ENTRY(fcmpun) LOAD_SREGS(s0, s1, r0, r1) vcmp.f32 s0, s1 vmrs APSR_nzcv, fpscr + ite vc movvc r0, #0 movvs r0, #1 RET diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc index 8efde09..c0f5392 100644 --- a/lib/libc/arm/gen/Makefile.inc +++ b/lib/libc/arm/gen/Makefile.inc @@ -2,9 +2,10 @@ # $FreeBSD$ SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \ - getcontextx.c infinity.c ldexp.c makecontext.c \ + infinity.c ldexp.c makecontext.c \ __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \ - arm_initfini.c + arm_initfini.c \ + trivial-getcontextx.c .if ${MACHINE_ARCH} == "armv6hf" SRCS+= fpgetmask_vfp.c fpgetround_vfp.c fpgetsticky_vfp.c fpsetmask_vfp.c \ diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S index 387f8a9..3de9d99 100644 --- a/lib/libc/arm/gen/_setjmp.S +++ b/lib/libc/arm/gen/_setjmp.S @@ -85,7 +85,13 @@ ENTRY(_setjmp) add r0, r0, #(_JB_REG_R4 * 4) /* Store integer registers */ +#ifndef __thumb__ stmia r0, {r4-r14} +#else + stmia r0, {r4-r12} + str r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)] + str r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)] +#endif mov r0, #0x00000000 RET @@ -120,15 +126,24 @@ ENTRY(_longjmp) add r0, r0, #(_JB_REG_R4 * 4) /* Restore integer registers */ +#ifndef __thumb__ ldmia r0, {r4-r14} +#else + ldmia r0, {r4-r12} + ldr r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)] + ldr r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)] +#endif /* Validate sp and r14 */ teq sp, #0 + it ne teqne r14, #0 + it eq beq botch /* Set return value */ movs r0, r1 + it eq moveq r0, #0x00000001 RET @@ -137,7 +152,7 @@ botch: #if !defined(_STANDALONE) bl PIC_SYM(_C_LABEL(longjmperror), PLT) bl PIC_SYM(_C_LABEL(abort), PLT) - b . - 8 /* Cannot get here */ +1: b 1b /* Cannot get here */ #else b . #endif diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S index ad4ba38..6269563 100644 --- a/lib/libc/arm/gen/setjmp.S +++ b/lib/libc/arm/gen/setjmp.S @@ -90,7 +90,13 @@ ENTRY(setjmp) /* Store integer registers */ add r0, r0, #(_JB_REG_R4 * 4) +#ifndef __thumb__ stmia r0, {r4-r14} +#else + stmia r0, {r4-r12} + str r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)] + str r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)] +#endif mov r0, #0x00000000 RET @@ -133,15 +139,24 @@ ENTRY(__longjmp) add r0, r0, #(_JB_REG_R4 * 4) /* Restore integer registers */ +#ifndef __thumb__ ldmia r0, {r4-r14} +#else + ldmia r0, {r4-r12} + ldr r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)] + ldr r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)] +#endif /* Validate sp and r14 */ teq sp, #0 + it ne teqne r14, #0 + it eq beq .Lbotch /* Set return value */ movs r0, r1 + it eq moveq r0, #0x00000001 RET @@ -149,5 +164,5 @@ ENTRY(__longjmp) .Lbotch: bl PIC_SYM(_C_LABEL(longjmperror), PLT) bl PIC_SYM(_C_LABEL(abort), PLT) - b . - 8 /* Cannot get here */ +1: b 1b /* Cannot get here */ END(__longjmp) diff --git a/lib/libc/arm/string/ffs.S b/lib/libc/arm/string/ffs.S index d3684ed..4567f6c 100644 --- a/lib/libc/arm/string/ffs.S +++ b/lib/libc/arm/string/ffs.S @@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$"); +.syntax unified + /* * ffs - find first set bit, this algorithm isolates the first set * bit, then multiplies the number by 0x0450fbaf which leaves the top @@ -60,7 +62,7 @@ ENTRY(ffs) rsbne r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */ /* now lookup in table indexed on top 6 bits of r0 */ - ldrneb r0, [ r2, r0, lsr #26 ] + ldrbne r0, [ r2, r0, lsr #26 ] RET .text; diff --git a/lib/libc/arm/string/memcmp.S b/lib/libc/arm/string/memcmp.S index 63a00ef..6fd8130 100644 --- a/lib/libc/arm/string/memcmp.S +++ b/lib/libc/arm/string/memcmp.S @@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$"); +.syntax unified + ENTRY(memcmp) mov ip, r0 #if defined(_KERNEL) && !defined(_STANDALONE) @@ -76,7 +78,7 @@ ENTRY(memcmp) /* Are both addresses aligned the same way? */ cmp r2, #0x00 - eornes r3, ip, r1 + eorsne r3, ip, r1 RETeq /* len == 0, or same addresses! */ tst r3, #0x03 subne r2, r2, #0x01 diff --git a/lib/libc/arm/string/memcpy_arm.S b/lib/libc/arm/string/memcpy_arm.S index eff1eb0..56fb703 100644 --- a/lib/libc/arm/string/memcpy_arm.S +++ b/lib/libc/arm/string/memcpy_arm.S @@ -31,6 +31,9 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); + +.syntax unified + /* * This is one fun bit of code ... * Some easy listening music is suggested while trying to understand this @@ -91,8 +94,8 @@ ENTRY(memcpy) bge .Lmemcpy_loop32 cmn r2, #0x10 - ldmgeia r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmgeia r0!, {r3, r4, r12, lr} + ldmiage r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmiage r0!, {r3, r4, r12, lr} subge r2, r2, #0x10 ldmia sp!, {r4} /* return r4 */ @@ -101,9 +104,9 @@ ENTRY(memcpy) /* blat 12 bytes at a time */ .Lmemcpy_loop12: - ldmgeia r1!, {r3, r12, lr} - stmgeia r0!, {r3, r12, lr} - subges r2, r2, #0x0c + ldmiage r1!, {r3, r12, lr} + stmiage r0!, {r3, r12, lr} + subsge r2, r2, #0x0c bge .Lmemcpy_loop12 .Lmemcpy_l12: @@ -113,26 +116,26 @@ ENTRY(memcpy) subs r2, r2, #4 ldrlt r3, [r1], #4 strlt r3, [r0], #4 - ldmgeia r1!, {r3, r12} - stmgeia r0!, {r3, r12} + ldmiage r1!, {r3, r12} + stmiage r0!, {r3, r12} subge r2, r2, #4 .Lmemcpy_l4: /* less than 4 bytes to go */ adds r2, r2, #4 #ifdef __APCS_26_ - ldmeqia sp!, {r0, pc}^ /* done */ + ldmiaeq sp!, {r0, pc}^ /* done */ #else - ldmeqia sp!, {r0, pc} /* done */ + ldmiaeq sp!, {r0, pc} /* done */ #endif /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 ldmia sp!, {r0, pc} /* erg - unaligned destination */ @@ -143,10 +146,10 @@ ENTRY(memcpy) /* align destination with byte copies */ ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 subs r2, r2, r12 blt .Lmemcpy_l4 /* less the 4 bytes */ diff --git a/lib/libc/arm/string/memcpy_xscale.S b/lib/libc/arm/string/memcpy_xscale.S index 1f48cd9..a451de4 100644 --- a/lib/libc/arm/string/memcpy_xscale.S +++ b/lib/libc/arm/string/memcpy_xscale.S @@ -38,6 +38,8 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +.syntax unified + /* LINTSTUB: Func: void *memcpy(void *dst, const void *src, size_t len) */ ENTRY(memcpy) pld [r1] @@ -52,12 +54,12 @@ ENTRY(memcpy) ldrb ip, [r1], #0x01 sub r2, r2, #0x01 strb ip, [r3], #0x01 - ldrleb ip, [r1], #0x01 + ldrble ip, [r1], #0x01 suble r2, r2, #0x01 - strleb ip, [r3], #0x01 - ldrltb ip, [r1], #0x01 + strble ip, [r3], #0x01 + ldrblt ip, [r1], #0x01 sublt r2, r2, #0x01 - strltb ip, [r3], #0x01 + strblt ip, [r3], #0x01 /* Destination buffer is now word aligned */ .Lmemcpy_wordaligned: @@ -134,7 +136,7 @@ ENTRY(memcpy) .Lmemcpy_w_lessthan128: adds r2, r2, #0x80 /* Adjust for extra sub */ - ldmeqfd sp!, {r4-r9} + ldmfdeq sp!, {r4-r9} bxeq lr /* Return now if done */ subs r2, r2, #0x20 blt .Lmemcpy_w_lessthan32 @@ -159,7 +161,7 @@ ENTRY(memcpy) .Lmemcpy_w_lessthan32: adds r2, r2, #0x20 /* Adjust for extra sub */ - ldmeqfd sp!, {r4-r9} + ldmfdeq sp!, {r4-r9} bxeq lr /* Return now if done */ and r4, r2, #0x18 @@ -195,11 +197,11 @@ ENTRY(memcpy) addlt r2, r2, #0x04 ldrb ip, [r1], #0x01 cmp r2, #0x02 - ldrgeb r2, [r1], #0x01 + ldrbge r2, [r1], #0x01 strb ip, [r3], #0x01 - ldrgtb ip, [r1] - strgeb r2, [r3], #0x01 - strgtb ip, [r3] + ldrbgt ip, [r1] + strbge r2, [r3], #0x01 + strbgt ip, [r3] bx lr @@ -253,7 +255,7 @@ ENTRY(memcpy) bge .Lmemcpy_bad1_loop16 adds r2, r2, #0x10 - ldmeqfd sp!, {r4-r7} + ldmfdeq sp!, {r4-r7} bxeq lr /* Return now if done */ subs r2, r2, #0x04 sublt r1, r1, #0x03 @@ -314,7 +316,7 @@ ENTRY(memcpy) bge .Lmemcpy_bad2_loop16 adds r2, r2, #0x10 - ldmeqfd sp!, {r4-r7} + ldmfdeq sp!, {r4-r7} bxeq lr /* Return now if done */ subs r2, r2, #0x04 sublt r1, r1, #0x02 @@ -375,7 +377,7 @@ ENTRY(memcpy) bge .Lmemcpy_bad3_loop16 adds r2, r2, #0x10 - ldmeqfd sp!, {r4-r7} + ldmfdeq sp!, {r4-r7} bxeq lr /* Return now if done */ subs r2, r2, #0x04 sublt r1, r1, #0x01 @@ -404,11 +406,11 @@ ENTRY(memcpy) bxeq lr ldrb ip, [r1], #0x01 cmp r2, #0x02 - ldrgeb r2, [r1], #0x01 + ldrbge r2, [r1], #0x01 strb ip, [r3], #0x01 - ldrgtb ip, [r1] - strgeb r2, [r3], #0x01 - strgtb ip, [r3] + ldrbgt ip, [r1] + strbge r2, [r3], #0x01 + strbgt ip, [r3] bx lr @@ -440,7 +442,7 @@ ENTRY(memcpy) ldrb ip, [r1], #0x01 1: subs r2, r2, #0x01 strb ip, [r3], #0x01 - ldrneb ip, [r1], #0x01 + ldrbne ip, [r1], #0x01 bne 1b bx lr diff --git a/lib/libc/arm/string/memmove.S b/lib/libc/arm/string/memmove.S index 75a2744..94e5474 100644 --- a/lib/libc/arm/string/memmove.S +++ b/lib/libc/arm/string/memmove.S @@ -32,6 +32,8 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +.syntax unified + #ifndef _BCOPY /* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */ ENTRY(memmove) @@ -86,8 +88,8 @@ ENTRY(bcopy) bge .Lmemmove_floop32 cmn r2, #0x10 - ldmgeia r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmgeia r0!, {r3, r4, r12, lr} + ldmiage r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmiage r0!, {r3, r4, r12, lr} subge r2, r2, #0x10 ldmia sp!, {r4} /* return r4 */ @@ -96,9 +98,9 @@ ENTRY(bcopy) /* blat 12 bytes at a time */ .Lmemmove_floop12: - ldmgeia r1!, {r3, r12, lr} - stmgeia r0!, {r3, r12, lr} - subges r2, r2, #0x0c + ldmiage r1!, {r3, r12, lr} + stmiage r0!, {r3, r12, lr} + subsge r2, r2, #0x0c bge .Lmemmove_floop12 .Lmemmove_fl12: @@ -108,23 +110,23 @@ ENTRY(bcopy) subs r2, r2, #4 ldrlt r3, [r1], #4 strlt r3, [r0], #4 - ldmgeia r1!, {r3, r12} - stmgeia r0!, {r3, r12} + ldmiage r1!, {r3, r12} + stmiage r0!, {r3, r12} subge r2, r2, #4 .Lmemmove_fl4: /* less than 4 bytes to go */ adds r2, r2, #4 - ldmeqia sp!, {r0, pc} /* done */ + ldmiaeq sp!, {r0, pc} /* done */ /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 ldmia sp!, {r0, pc} /* erg - unaligned destination */ @@ -135,10 +137,10 @@ ENTRY(bcopy) /* align destination with byte copies */ ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrgeb r3, [r1], #1 - strgeb r3, [r0], #1 - ldrgtb r3, [r1], #1 - strgtb r3, [r0], #1 + ldrbge r3, [r1], #1 + strbge r3, [r0], #1 + ldrbgt r3, [r1], #1 + strbgt r3, [r0], #1 subs r2, r2, r12 blt .Lmemmove_fl4 /* less the 4 bytes */ @@ -353,12 +355,12 @@ ENTRY(bcopy) .Lmemmove_bl32: cmn r2, #0x10 - ldmgedb r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmgedb r0!, {r3, r4, r12, lr} + ldmdbge r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmdbge r0!, {r3, r4, r12, lr} subge r2, r2, #0x10 adds r2, r2, #0x14 - ldmgedb r1!, {r3, r12, lr} /* blat a remaining 12 bytes */ - stmgedb r0!, {r3, r12, lr} + ldmdbge r1!, {r3, r12, lr} /* blat a remaining 12 bytes */ + stmdbge r0!, {r3, r12, lr} subge r2, r2, #0x0c ldmia sp!, {r4, lr} @@ -368,8 +370,8 @@ ENTRY(bcopy) subs r2, r2, #4 ldrlt r3, [r1, #-4]! strlt r3, [r0, #-4]! - ldmgedb r1!, {r3, r12} - stmgedb r0!, {r3, r12} + ldmdbge r1!, {r3, r12} + stmdbge r0!, {r3, r12} subge r2, r2, #4 .Lmemmove_bl4: @@ -381,10 +383,10 @@ ENTRY(bcopy) cmp r2, #2 ldrb r3, [r1, #-1]! strb r3, [r0, #-1]! - ldrgeb r3, [r1, #-1]! - strgeb r3, [r0, #-1]! - ldrgtb r3, [r1, #-1]! - strgtb r3, [r0, #-1]! + ldrbge r3, [r1, #-1]! + strbge r3, [r0, #-1]! + ldrbgt r3, [r1, #-1]! + strbgt r3, [r0, #-1]! RET /* erg - unaligned destination */ @@ -394,10 +396,10 @@ ENTRY(bcopy) /* align destination with byte copies */ ldrb r3, [r1, #-1]! strb r3, [r0, #-1]! - ldrgeb r3, [r1, #-1]! - strgeb r3, [r0, #-1]! - ldrgtb r3, [r1, #-1]! - strgtb r3, [r0, #-1]! + ldrbge r3, [r1, #-1]! + strbge r3, [r0, #-1]! + ldrbgt r3, [r1, #-1]! + strbgt r3, [r0, #-1]! subs r2, r2, r12 blt .Lmemmove_bl4 /* less than 4 bytes to go */ ands r12, r1, #3 diff --git a/lib/libc/arm/string/memset.S b/lib/libc/arm/string/memset.S index 458f8f7..66af33e 100644 --- a/lib/libc/arm/string/memset.S +++ b/lib/libc/arm/string/memset.S @@ -69,6 +69,8 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +.syntax unified + /* * memset: Sets a block of memory to the specified value * @@ -125,39 +127,39 @@ ENTRY(memset) .Lmemset_loop128: subs r1, r1, #0x80 #ifdef _ARM_ARCH_5E - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 #else - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} #endif bgt .Lmemset_loop128 RETeq /* Zero length so just exit */ @@ -168,15 +170,15 @@ ENTRY(memset) .Lmemset_loop32: subs r1, r1, #0x20 #ifdef _ARM_ARCH_5E - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 #else - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} #endif bgt .Lmemset_loop32 RETeq /* Zero length so just exit */ @@ -185,11 +187,11 @@ ENTRY(memset) /* Deal with 16 bytes or more */ #ifdef _ARM_ARCH_5E - strged r2, [ip], #0x08 - strged r2, [ip], #0x08 + strdge r2, [ip], #0x08 + strdge r2, [ip], #0x08 #else - stmgeia ip!, {r2-r3} - stmgeia ip!, {r2-r3} + stmiage ip!, {r2-r3} + stmiage ip!, {r2-r3} #endif RETeq /* Zero length so just exit */ @@ -212,17 +214,17 @@ ENTRY(memset) #endif strb r3, [ip], #0x01 /* Set 1 byte */ - strgeb r3, [ip], #0x01 /* Set another byte */ - strgtb r3, [ip] /* and a third */ + strbge r3, [ip], #0x01 /* Set another byte */ + strbgt r3, [ip] /* and a third */ RET /* Exit */ .Lmemset_wordunaligned: rsb r2, r2, #0x004 strb r3, [ip], #0x01 /* Set 1 byte */ cmp r2, #0x02 - strgeb r3, [ip], #0x01 /* Set another byte */ + strbge r3, [ip], #0x01 /* Set another byte */ sub r1, r1, r2 - strgtb r3, [ip], #0x01 /* and a third */ + strbgt r3, [ip], #0x01 /* and a third */ cmp r1, #0x04 /* More than 4 bytes left? */ bge .Lmemset_wordaligned /* Yup */ @@ -231,8 +233,8 @@ ENTRY(memset) RETeq /* Zero length so exit */ strb r3, [ip], #0x01 /* Set 1 byte */ cmp r1, #0x02 - strgeb r3, [ip], #0x01 /* Set another byte */ - strgtb r3, [ip] /* and a third */ + strbge r3, [ip], #0x01 /* Set another byte */ + strbgt r3, [ip] /* and a third */ RET /* Exit */ #ifdef _BZERO END(bzero) diff --git a/lib/libc/arm/string/strlen.S b/lib/libc/arm/string/strlen.S index 3d7726f..7447710 100644 --- a/lib/libc/arm/string/strlen.S +++ b/lib/libc/arm/string/strlen.S @@ -27,6 +27,8 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +.syntax unified + ENTRY(strlen) mov r1, #0 /* Check that the pointer is aligned on 32 bits. */ @@ -53,23 +55,23 @@ ENTRY(strlen) addne r1, r1, #1 .Ldo_3: #ifndef __ARMEB__ - andnes r3, r2, #0x0000ff00 + andsne r3, r2, #0x0000ff00 #else - andnes r3, r2, #0x00ff0000 + andsne r3, r2, #0x00ff0000 #endif addne r1, r1, #1 .Ldo_2: #ifndef __ARMEB__ - andnes r3, r2, #0x00ff0000 + andsne r3, r2, #0x00ff0000 #else - andnes r3, r2, #0x0000ff00 + andsne r3, r2, #0x0000ff00 #endif addne r1, r1, #1 .Ldo_1: #ifndef __ARMEB__ - andnes r3, r2, #0xff000000 + andsne r3, r2, #0xff000000 #else - andnes r3, r2, #0x000000ff + andsne r3, r2, #0x000000ff #endif addne r1, r1, #1 bne .Loop diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc index 069aad3..60c2dc3 100644 --- a/lib/libc/arm/sys/Makefile.inc +++ b/lib/libc/arm/sys/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= trivial-vdso_tc.c MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S @@ -8,6 +8,3 @@ MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscal NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o PSEUDO= _exit.o _getlogin.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif diff --git a/lib/libc/arm/sys/brk.S b/lib/libc/arm/sys/brk.S index f3d8d87..e5f8336 100644 --- a/lib/libc/arm/sys/brk.S +++ b/lib/libc/arm/sys/brk.S @@ -53,16 +53,10 @@ _C_LABEL(minbrk): * Change the data segment size */ ENTRY(_brk) -#ifdef PIC /* Setup the GOT */ - ldr r3, .Lgot - add r3, pc, r3 -.L1: - ldr r1, .Lminbrk - ldr r1, [r3, r1] -#else - ldr r1, .Lminbrk -#endif + GOT_INIT(r3, .Lgot, .L1) + GOT_GET(r1, r3, .Lminbrk) + /* Get the minimum allowable brk address */ ldr r1, [r1] @@ -71,6 +65,7 @@ ENTRY(_brk) * if the address is below minbrk. */ cmp r0, r1 + it lt movlt r0, r1 mov r2, r0 SYSTRAP(break) @@ -90,10 +85,7 @@ ENTRY(_brk) RET .align 2 -#ifdef PIC -.Lgot: - .word _GLOBAL_OFFSET_TABLE_ - (.L1+4) -#endif + GOT_INITSYM(.Lgot, .L1) .Lminbrk: .word PIC_SYM(_C_LABEL(minbrk), GOT) .Lcurbrk: diff --git a/lib/libc/arm/sys/sbrk.S b/lib/libc/arm/sys/sbrk.S index 7d22aa7..5cd9a03 100644 --- a/lib/libc/arm/sys/sbrk.S +++ b/lib/libc/arm/sys/sbrk.S @@ -52,16 +52,10 @@ CURBRK: * Change the data segment size */ ENTRY(_sbrk) -#ifdef PIC /* Setup the GOT */ - ldr r3, .Lgot - add r3, pc, r3 -.L1: - ldr r2, .Lcurbrk - ldr r2, [r3, r2] -#else - ldr r2, .Lcurbrk -#endif + GOT_INIT(r3, .Lgot, .L1) + GOT_GET(r2, r3, .Lcurbrk) + /* Get the current brk address */ ldr r1, [r2] @@ -80,10 +74,7 @@ ENTRY(_sbrk) RET .align 0 -#ifdef PIC -.Lgot: - .word _GLOBAL_OFFSET_TABLE_ - (.L1+4) -#endif + GOT_INITSYM(.Lgot, .L1) .Lcurbrk: .word PIC_SYM(CURBRK, GOT) END(_sbrk) diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c index fc3be06..4545482 100644 --- a/lib/libc/compat-43/creat.c +++ b/lib/libc/compat-43/creat.c @@ -36,11 +36,18 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <fcntl.h> #include "un-namespace.h" +#include "libc_private.h" +__weak_reference(__creat, creat); +__weak_reference(__creat, _creat); + +#pragma weak creat int __creat(const char *path, mode_t mode) { - return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); + + return (((int (*)(int, const char *, int, ...)) + __libc_interposing[INTERPOS_openat])(AT_FDCWD, path, O_WRONLY | + O_CREAT | O_TRUNC, mode)); } -__weak_reference(__creat, creat); -__weak_reference(__creat, _creat); + diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index af80929..e6da5fe 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -808,7 +808,7 @@ __expand_table(HTAB *hashp) hashp->DSIZE = dirsize << 1; } if ((hashp->dir[new_segnum] = - (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) + calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) return (-1); hashp->exsegs++; hashp->nsegs++; @@ -877,7 +877,7 @@ alloc_segs(HTAB *hashp, int nsegs) int save_errno; if ((hashp->dir = - (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { + calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { save_errno = errno; (void)hdestroy(hashp); errno = save_errno; @@ -887,8 +887,7 @@ alloc_segs(HTAB *hashp, int nsegs) if (nsegs == 0) return (0); /* Allocate segments */ - if ((store = (SEGMENT)calloc(nsegs << hashp->SSHIFT, - sizeof(SEGMENT))) == NULL) { + if ((store = calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { save_errno = errno; (void)hdestroy(hashp); errno = save_errno; diff --git a/lib/libc/db/man/dbm.3 b/lib/libc/db/man/dbm.3 index fabce8a..eedf804 100644 --- a/lib/libc/db/man/dbm.3 +++ b/lib/libc/db/man/dbm.3 @@ -15,7 +15,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 16, 2006 +.Dd February 19, 2015 .Dt DBM 3 .Os .Sh NAME @@ -174,9 +174,7 @@ deletes the entry for The .Fn dbm_delete function -normally returns zero but returns 1 if there was no entry with -.Fa key -in the database or returns -1 and sets +normally returns zero or returns -1 and sets .Va errno if there were any errors. .Pp diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index f64caf0..2232b79 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -5,6 +5,7 @@ .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen SRCS+= __getosreldate.c \ + __pthread_mutex_init_calloc_cb_stub.c \ __xuname.c \ _once_stub.c \ _pthread_stubs.c \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 77413d6..ee4d619 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -487,6 +487,7 @@ FBSDprivate_1.0 { _rtld_atfork_post; _rtld_error; /* for private use */ _rtld_get_stack_prot; + _rtld_is_dlopened; _rtld_thread_init; /* for private use */ __elf_phdr_match_addr; _err; @@ -532,6 +533,8 @@ FBSDprivate_1.0 { _libc_sem_post_compat; _libc_sem_getvalue_compat; + __libc_tcdrain; + __elf_aux_vector; __pthread_map_stacks_exec; __fillcontextx; diff --git a/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c b/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c new file mode 100644 index 0000000..1c566ec --- /dev/null +++ b/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 <pthread.h> +#include "libc_private.h" + +int +_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex, + void *(calloc_cb)(size_t, size_t)) +{ + + return (0); +} diff --git a/lib/libc/gen/_once_stub.c b/lib/libc/gen/_once_stub.c index d2acc29..c45565a 100644 --- a/lib/libc/gen/_once_stub.c +++ b/lib/libc/gen/_once_stub.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009 Advanced Computing Technologies LLC + * Copyright (c) 2009 Hudson River Trading LLC * Written by: John H. Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c index 47bbfeb..3decf8a 100644 --- a/lib/libc/gen/_spinlock_stub.c +++ b/lib/libc/gen/_spinlock_stub.c @@ -33,51 +33,48 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include "spinlock.h" +#include "libc_private.h" long _atomic_lock_stub(volatile long *); void _spinlock_stub(spinlock_t *); void _spinunlock_stub(spinlock_t *); void _spinlock_debug_stub(spinlock_t *, char *, int); -/* - * Declare weak definitions in case the application is not linked - * with libpthread. - */ __weak_reference(_atomic_lock_stub, _atomic_lock); -__weak_reference(_spinlock_stub, _spinlock); -__weak_reference(_spinunlock_stub, _spinunlock); -__weak_reference(_spinlock_debug_stub, _spinlock_debug); -/* - * This function is a stub for the _atomic_lock function in libpthread. - */ long _atomic_lock_stub(volatile long *lck __unused) { return (0L); } +__weak_reference(_spinlock, _spinlock_debug); +#pragma weak _spinlock +void +_spinlock(spinlock_t *lck) +{ -/* - * This function is a stub for the spinlock function in libpthread. - */ + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock]) + (lck); + +} + +#pragma weak _spinunlock void -_spinlock_stub(spinlock_t *lck __unused) +_spinunlock(spinlock_t *lck) { + + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock]) + (lck); + } -/* - * This function is a stub for the spinunlock function in libpthread. - */ void -_spinunlock_stub(spinlock_t *lck __unused) +__libc_spinlock_stub(spinlock_t *lck __unused) { } -/* - * This function is a stub for the debug spinlock function in libpthread. - */ void -_spinlock_debug_stub(spinlock_t *lck __unused, char *fname __unused, int lineno __unused) +__libc_spinunlock_stub(spinlock_t *lck __unused) { } diff --git a/lib/libc/gen/cap_rights_get.3 b/lib/libc/gen/cap_rights_get.3 index f74d1f7a..a665465 100644 --- a/lib/libc/gen/cap_rights_get.3 +++ b/lib/libc/gen/cap_rights_get.3 @@ -100,10 +100,10 @@ argument points at an invalid address. .El .Sh SEE ALSO .Xr cap_rights_limit 2 , -.Xr cap_rights_init 3 , .Xr errno 2 , .Xr open 2 , .Xr assert 3 , +.Xr cap_rights_init 3 , .Xr err 3 , .Xr memcmp 3 , .Xr memset 3 , diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3 index 1e864f8..f0d0f4b 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 28, 2014 +.Dd May 6, 2015 .Dt DIRECTORY 3 .Os .Sh NAME @@ -263,8 +263,25 @@ function appeared in function appeared in .Fx 10.0 . .Sh BUGS -The invalidation of +The behaviour of .Fn telldir -tokens when calling +and +.Fn seekdir +is likely to be wrong if there are parallel unlinks happening +and the directory is larger than one page. +There is code to ensure that a .Fn seekdir -is non-standard. +to the location given by a +.Fn telldir +immediately before the last +.Fn readdir +will always set the correct location to return the same value as that last +.Fn readdir +performed. +This is enough for some applications which want to "push back the last entry read" E.g. Samba. +Seeks back to any other location, +other than the beginning of the directory, +may result in unexpected behaviour if deletes are present. +It is hoped that this situation will be resolved with changes to +.Fn getdirentries +and the VFS. diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c index bd15a47..8780573 100644 --- a/lib/libc/gen/disklabel.c +++ b/lib/libc/gen/disklabel.c @@ -85,10 +85,13 @@ getdiskbyname(const char *name) cq++, cp++; *cq = '\0'; - if (cgetstr(buf, "ty", &cq) > 0 && strcmp(cq, "removable") == 0) - dp->d_flags |= D_REMOVABLE; - else if (cq && strcmp(cq, "simulated") == 0) - dp->d_flags |= D_RAMDISK; + if (cgetstr(buf, "ty", &cq) > 0) { + if (strcmp(cq, "removable") == 0) + dp->d_flags |= D_REMOVABLE; + else if (cq && strcmp(cq, "simulated") == 0) + dp->d_flags |= D_RAMDISK; + free(cq); + } if (cgetcap(buf, "sf", ':') != NULL) dp->d_flags |= D_BADSECT; @@ -100,9 +103,10 @@ getdiskbyname(const char *name) getnumdflt(dp->d_nsectors, "ns", 0); getnumdflt(dp->d_ncylinders, "nc", 0); - if (cgetstr(buf, "dt", &cq) > 0) + if (cgetstr(buf, "dt", &cq) > 0) { dp->d_type = gettype(cq, dktypenames); - else + free(cq); + } else getnumdflt(dp->d_type, "dt", 0); getnumdflt(dp->d_secpercyl, "sc", dp->d_nsectors * dp->d_ntracks); getnumdflt(dp->d_secperunit, "su", dp->d_secpercyl * dp->d_ncylinders); @@ -140,8 +144,11 @@ getdiskbyname(const char *name) pp->p_frag = 8; } getnumdflt(pp->p_fstype, ptype, 0); - if (pp->p_fstype == 0 && cgetstr(buf, ptype, &cq) > 0) - pp->p_fstype = gettype(cq, fstypenames); + if (pp->p_fstype == 0) + if (cgetstr(buf, ptype, &cq) >= 0) { + pp->p_fstype = gettype(cq, fstypenames); + free(cq); + } max = p; } } diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index ad24bb4..7d28797 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -149,10 +149,8 @@ static void dl_init_phdr_info(void) { Elf_Auxinfo *auxp; - size_t phent; unsigned int i; - phent = 0; for (auxp = __elf_aux_vector; auxp->a_type != AT_NULL; auxp++) { switch (auxp->a_type) { case AT_BASE: @@ -165,9 +163,6 @@ dl_init_phdr_info(void) phdr_info.dlpi_phdr = (const Elf_Phdr *)auxp->a_un.a_ptr; break; - case AT_PHENT: - phent = auxp->a_un.a_val; - break; case AT_PHNUM: phdr_info.dlpi_phnum = (Elf_Half)auxp->a_un.a_val; break; @@ -233,3 +228,10 @@ _rtld_get_stack_prot(void) return (PROT_EXEC | PROT_READ | PROT_WRITE); } +#pragma weak _rtld_is_dlopened +int +_rtld_is_dlopened(void *arg) +{ + + return (0); +} diff --git a/lib/libc/gen/dlopen.3 b/lib/libc/gen/dlopen.3 index 089e631..1963528 100644 --- a/lib/libc/gen/dlopen.3 +++ b/lib/libc/gen/dlopen.3 @@ -32,7 +32,7 @@ .\" @(#) dlopen.3 1.6 90/01/31 SMI .\" $FreeBSD$ .\" -.Dd December 21, 2011 +.Dd February 14, 2015 .Dt DLOPEN 3 .Os .Sh NAME @@ -236,7 +236,7 @@ as follows, in the given order: The referencing object itself (or the object from which the call to .Fn dlsym is made), if that object was linked using the -.Fl Wsymbolic +.Fl Bsymbolic option to .Xr ld 1 . .It diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 6a77abd..c21ceb3 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -181,7 +181,7 @@ fstabscan(void) if (cp != NULL) _fs_fstab.fs_passno = atoi(cp); } - strcpy(subline, _fs_fstab.fs_mntops); + (void)strlcpy(subline, _fs_fstab.fs_mntops, sizeof(subline)); p = subline; for (typexx = 0, cp = strsep(&p, ","); cp; cp = strsep(&p, ",")) { diff --git a/lib/libc/gen/ftok.3 b/lib/libc/gen/ftok.3 index 98f8bad..b819dbd 100644 --- a/lib/libc/gen/ftok.3 +++ b/lib/libc/gen/ftok.3 @@ -64,9 +64,9 @@ function will return -1 if .Fa path does not exist or if it cannot be accessed by the calling process. .Sh SEE ALSO +.Xr msgget 2 , .Xr semget 2 , -.Xr shmget 2 , -.Xr msgget 2 +.Xr shmget 2 .Sh HISTORY The .Fn ftok diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 7635fbc..1ca8334 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -905,12 +905,13 @@ fts_stat(FTS *sp, FTSENT *p, int follow, int dfd) if (ISSET(FTS_LOGICAL) || follow) { if (fstatat(dfd, path, sbp, 0)) { saved_errno = errno; - if (!fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) { - errno = 0; - return (FTS_SLNONE); + if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) { + p->fts_errno = saved_errno; + goto err; } - p->fts_errno = saved_errno; - goto err; + errno = 0; + if (S_ISLNK(sbp->st_mode)) + return (FTS_SLNONE); } } else if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) { p->fts_errno = errno; diff --git a/lib/libc/gen/ftw.3 b/lib/libc/gen/ftw.3 index ba8859b..df8abab 100644 --- a/lib/libc/gen/ftw.3 +++ b/lib/libc/gen/ftw.3 @@ -87,8 +87,9 @@ A directory which cannot be read. The directory will not be descended into. .It Dv FTW_DP A directory being visited in post-order -.Fn ( nftw -only). +.Po Fn nftw +only +.Pc . .It Dv FTW_NS A file for which no .Xr stat 2 @@ -100,8 +101,9 @@ structure are undefined. A symbolic link. .It Dv FTW_SLN A symbolic link with a non-existent target -.Fn ( nftw -only). +.Po Fn nftw +only +.Pc . .El .Pp The diff --git a/lib/libc/gen/getcap.3 b/lib/libc/gen/getcap.3 index 73826ae..c3a9ce8 100644 --- a/lib/libc/gen/getcap.3 +++ b/lib/libc/gen/getcap.3 @@ -137,9 +137,10 @@ It must be called before the call. If a sequential access is being performed (see below), it must be called before the first sequential access call -.Fn ( cgetfirst +.Po Fn cgetfirst or -.Fn cgetnext ) , +.Fn cgetnext +.Pc , or be directly preceded by a .Fn cgetclose call. diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index f9480c3..1f4d7e9 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -896,7 +896,7 @@ files_group(void *retval, void *mdata, va_list ap) break; pos = ftello(st->fp); } - if (!stayopen && st->fp != NULL) { + if (st->fp != NULL && !stayopen) { fclose(st->fp); st->fp = NULL; } @@ -1173,8 +1173,10 @@ nis_group(void *retval, void *mdata, va_list ap) * terminator, alignment padding, and one (char *) * pointer for the member list terminator. */ - if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *)) + if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *)) { + free(result); goto erange; + } memcpy(buffer, result, resultlen); buffer[resultlen] = '\0'; free(result); @@ -1450,7 +1452,7 @@ docompat: pos = ftello(st->fp); } fin: - if (!stayopen && st->fp != NULL) { + if (st->fp != NULL && !stayopen) { fclose(st->fp); st->fp = NULL; } diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index f729cdf..09a6247 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -815,7 +815,7 @@ files_passwd(void *retval, void *mdata, va_list ap) size_t bufsize, namesize; uid_t uid; uint32_t store; - int rv, stayopen, *errnop; + int rv, stayopen = 0, *errnop; name = NULL; uid = (uid_t)-1; @@ -921,7 +921,7 @@ files_passwd(void *retval, void *mdata, va_list ap) errnop); } while (how == nss_lt_all && !(rv & NS_TERMINATE)); fin: - if (!stayopen && st->db != NULL) { + if (st->db != NULL && !stayopen) { (void)st->db->close(st->db); st->db = NULL; } @@ -1392,8 +1392,10 @@ nis_passwd(void *retval, void *mdata, va_list ap) continue; } } - if (resultlen >= bufsize) + if (resultlen >= bufsize) { + free(result); goto erange; + } memcpy(buffer, result, resultlen); buffer[resultlen] = '\0'; free(result); @@ -1940,7 +1942,7 @@ docompat: break; } fin: - if (!stayopen && st->db != NULL) { + if (st->db != NULL && !stayopen) { (void)st->db->close(st->db); st->db = NULL; } diff --git a/lib/libc/gen/getutxent.3 b/lib/libc/gen/getutxent.3 index 120f4a0..85c37b1 100644 --- a/lib/libc/gen/getutxent.3 +++ b/lib/libc/gen/getutxent.3 @@ -475,4 +475,4 @@ They replaced the .In utmp.h interface. .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3 index 9c39b78..b04c8f4 100644 --- a/lib/libc/gen/nice.3 +++ b/lib/libc/gen/nice.3 @@ -28,7 +28,7 @@ .\" @(#)nice.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd February 28, 2015 .Dt NICE 3 .Os .Sh NAME @@ -48,20 +48,48 @@ This interface is obsoleted by .Pp The .Fn nice -function obtains the scheduling priority of the process -from the system and sets it to the priority value specified in -.Fa incr . +function adds +.Fa incr +to the scheduling priority of the process. The priority is a value in the range -20 to 20. The default priority is 0; lower priorities cause more favorable scheduling. Only the super-user may lower priorities. .Pp Children inherit the priority of their parent processes via .Xr fork 2 . +.Sh RETURN VALUES +Upon successful completion, +.Fn nice +returns 0, and +.Va errno +is unchanged. +Otherwise, \-1 is returned, the process' nice value is not changed, and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn nice +function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The +.Fa incr +argument is negative and the caller does not have appropriate privileges. +.El .Sh SEE ALSO .Xr nice 1 , .Xr fork 2 , .Xr setpriority 2 , .Xr renice 8 +.Sh STANDARDS +The +.Fn nice +function conforms to +.St -p1003.1-2008 +except for the return value. +This implementation returns 0 upon successful completion but +the standard requires returning the new nice value, +which could be \-1. .Sh HISTORY A .Fn nice diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c index e8375e8..ba9524b 100644 --- a/lib/libc/gen/nice.c +++ b/lib/libc/gen/nice.c @@ -43,14 +43,20 @@ __FBSDID("$FreeBSD$"); * Backwards compatible nice. */ int -nice(incr) - int incr; +nice(int incr) { - int prio; + int saverrno, prio; + saverrno = errno; errno = 0; prio = getpriority(PRIO_PROCESS, 0); - if (prio == -1 && errno) + if (prio == -1 && errno != 0) return (-1); - return (setpriority(PRIO_PROCESS, 0, prio + incr)); + if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) { + if (errno == EACCES) + errno = EPERM; + return (-1); + } + errno = saverrno; + return (0); } diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index bdadd55..ec878c5 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -47,7 +47,10 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +/* There is no a.out support on arm64 */ +#ifndef __aarch64__ #define _NLIST_DO_AOUT +#endif #define _NLIST_DO_ELF #ifdef _NLIST_DO_ELF diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c index 51706cf..ef48c1c 100644 --- a/lib/libc/gen/pause.c +++ b/lib/libc/gen/pause.c @@ -33,10 +33,10 @@ static char sccsid[] = "@(#)pause.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "namespace.h" #include <signal.h> #include <unistd.h> -#include "un-namespace.h" + +#include "libc_private.h" /* * Backwards compatible pause. @@ -46,9 +46,10 @@ __pause(void) { sigset_t oset; - if (_sigprocmask(SIG_BLOCK, NULL, &oset) == -1) + if (sigprocmask(SIG_BLOCK, NULL, &oset) == -1) return (-1); - return (_sigsuspend(&oset)); + return (sigsuspend(&oset)); } + __weak_reference(__pause, pause); __weak_reference(__pause, _pause); diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3 index dd5bd2b..2c9131b 100644 --- a/lib/libc/gen/posix_spawn.3 +++ b/lib/libc/gen/posix_spawn.3 @@ -413,6 +413,10 @@ including trying to close a descriptor that is not open. .Xr execve 2 , .Xr fcntl 2 , .Xr open 2 , +.Xr sched_setparam 2 , +.Xr sched_setscheduler 2 , +.Xr setpgid 2 , +.Xr vfork 2 , .Xr posix_spawn_file_actions_addclose 3 , .Xr posix_spawn_file_actions_adddup2 3 , .Xr posix_spawn_file_actions_addopen 3 , @@ -431,11 +435,7 @@ including trying to close a descriptor that is not open. .Xr posix_spawnattr_setschedparam 3 , .Xr posix_spawnattr_setschedpolicy 3 , .Xr posix_spawnattr_setsigdefault 3 , -.Xr posix_spawnattr_setsigmask 3 , -.Xr sched_setparam 2 , -.Xr sched_setscheduler 2 , -.Xr setpgid 2 , -.Xr vfork 2 +.Xr posix_spawnattr_setsigmask 3 .Sh STANDARDS The .Fn posix_spawn @@ -457,4 +457,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3 index b28f396..0b57999b 100644 --- a/lib/libc/gen/posix_spawn_file_actions_addopen.3 +++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3 @@ -200,4 +200,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn_file_actions_init.3 b/lib/libc/gen/posix_spawn_file_actions_init.3 index eda2a1d..380eed7 100644 --- a/lib/libc/gen/posix_spawn_file_actions_init.3 +++ b/lib/libc/gen/posix_spawn_file_actions_init.3 @@ -101,4 +101,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getflags.3 b/lib/libc/gen/posix_spawnattr_getflags.3 index b5995ce..2571f4a 100644 --- a/lib/libc/gen/posix_spawnattr_getflags.3 +++ b/lib/libc/gen/posix_spawnattr_getflags.3 @@ -108,4 +108,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getpgroup.3 b/lib/libc/gen/posix_spawnattr_getpgroup.3 index 91b3e5c..cfc1b54 100644 --- a/lib/libc/gen/posix_spawnattr_getpgroup.3 +++ b/lib/libc/gen/posix_spawnattr_getpgroup.3 @@ -93,4 +93,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getschedparam.3 b/lib/libc/gen/posix_spawnattr_getschedparam.3 index a137200..5eef96e 100644 --- a/lib/libc/gen/posix_spawnattr_getschedparam.3 +++ b/lib/libc/gen/posix_spawnattr_getschedparam.3 @@ -97,4 +97,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getschedpolicy.3 b/lib/libc/gen/posix_spawnattr_getschedpolicy.3 index 3e79d4b..5276de5 100644 --- a/lib/libc/gen/posix_spawnattr_getschedpolicy.3 +++ b/lib/libc/gen/posix_spawnattr_getschedpolicy.3 @@ -95,4 +95,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getsigdefault.3 b/lib/libc/gen/posix_spawnattr_getsigdefault.3 index 8878332..a81c714 100644 --- a/lib/libc/gen/posix_spawnattr_getsigdefault.3 +++ b/lib/libc/gen/posix_spawnattr_getsigdefault.3 @@ -95,4 +95,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getsigmask.3 b/lib/libc/gen/posix_spawnattr_getsigmask.3 index 4f9c014..be15d9d 100644 --- a/lib/libc/gen/posix_spawnattr_getsigmask.3 +++ b/lib/libc/gen/posix_spawnattr_getsigmask.3 @@ -95,4 +95,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_init.3 b/lib/libc/gen/posix_spawnattr_init.3 index 388fe5a..b4ec52c 100644 --- a/lib/libc/gen/posix_spawnattr_init.3 +++ b/lib/libc/gen/posix_spawnattr_init.3 @@ -120,4 +120,4 @@ and functions first appeared in .Fx 8.0 . .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c index b3d0aae..994fea5 100644 --- a/lib/libc/gen/raise.c +++ b/lib/libc/gen/raise.c @@ -36,11 +36,17 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <unistd.h> +#include "libc_private.h" + __weak_reference(__raise, raise); __weak_reference(__raise, _raise); int __raise(int s) { - return(kill(getpid(), s)); + long id; + + if (__sys_thr_self(&id) == -1) + return (-1); + return (__sys_thr_kill(id, s)); } diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index 69f59d1..c6f5d3f 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -54,19 +54,25 @@ _readdir_unlocked(dirp, skip) int skip; { struct dirent *dp; + long initial_seek; + long initial_loc = 0; for (;;) { if (dirp->dd_loc >= dirp->dd_size) { if (dirp->dd_flags & __DTF_READALL) return (NULL); + initial_loc = dirp->dd_loc; + dirp->dd_flags &= ~__DTF_SKIPREAD; dirp->dd_loc = 0; } if (dirp->dd_loc == 0 && !(dirp->dd_flags & (__DTF_READALL | __DTF_SKIPREAD))) { + initial_seek = dirp->dd_seek; dirp->dd_size = _getdirentries(dirp->dd_fd, dirp->dd_buf, dirp->dd_len, &dirp->dd_seek); if (dirp->dd_size <= 0) return (NULL); + _fixtelldir(dirp, initial_seek, initial_loc); } dirp->dd_flags &= ~__DTF_SKIPREAD; dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c index 193f4b0..e157cd6 100644 --- a/lib/libc/gen/rewinddir.c +++ b/lib/libc/gen/rewinddir.c @@ -51,6 +51,7 @@ rewinddir(dirp) if (__isthreaded) _pthread_mutex_lock(&dirp->dd_lock); + dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */ if (dirp->dd_flags & __DTF_READALL) _filldir(dirp, false); else { diff --git a/lib/libc/gen/scandir.3 b/lib/libc/gen/scandir.3 index eaba754..aa8dea0 100644 --- a/lib/libc/gen/scandir.3 +++ b/lib/libc/gen/scandir.3 @@ -92,7 +92,7 @@ by freeing each pointer in the array and then the array itself. .Pp The .Fn scandir_b -function behaves in the same way as +function behaves in the same way as .Fn scandir , but takes blocks as arguments instead of function pointers and calls .Fn qsort_b @@ -106,8 +106,8 @@ cannot allocate enough memory to hold all the data structures. .Xr directory 3 , .Xr malloc 3 , .Xr qsort 3 , -.Xr dir 5 , -.Xr strcoll 3 +.Xr strcoll 3 , +.Xr dir 5 .Sh HISTORY The .Fn scandir diff --git a/lib/libc/gen/sem_new.c b/lib/libc/gen/sem_new.c index 3ee0272..c5dc7e7 100644 --- a/lib/libc/gen/sem_new.c +++ b/lib/libc/gen/sem_new.c @@ -439,8 +439,10 @@ _sem_post(sem_t *sem) do { count = sem->_kern._count; - if (USEM_COUNT(count) + 1 > SEM_VALUE_MAX) - return (EOVERFLOW); + if (USEM_COUNT(count) + 1 > SEM_VALUE_MAX) { + errno = EOVERFLOW; + return (-1); + } } while (!atomic_cmpset_rel_int(&sem->_kern._count, count, count + 1)); if (count & USEM_HAS_WAITERS) usem_wake(&sem->_kern); diff --git a/lib/libc/gen/sem_post.3 b/lib/libc/gen/sem_post.3 index 485d2fc..dea8eb6 100644 --- a/lib/libc/gen/sem_post.3 +++ b/lib/libc/gen/sem_post.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 15, 2000 +.Dd January 28, 2015 .Dt SEM_POST 3 .Os .Sh NAME @@ -65,6 +65,9 @@ The .Fa sem argument points to an invalid semaphore. +.It Bq Er EOVERFLOW +The semaphore value would exceed +.Dv SEM_VALUE_MAX . .El .Sh SEE ALSO .Xr sem_getvalue 3 , diff --git a/lib/libc/gen/setmode.3 b/lib/libc/gen/setmode.3 index 5cab44a..684c2e1 100644 --- a/lib/libc/gen/setmode.3 +++ b/lib/libc/gen/setmode.3 @@ -28,7 +28,7 @@ .\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd April 28, 1995 +.Dd February 22, 2015 .Dt SETMODE 3 .Os .Sh NAME @@ -99,7 +99,20 @@ The function may fail and set errno for any of the errors specified for the library routine -.Xr malloc 3 . +.Xr malloc 3 +or +.Xr strtol 3 . +In addition, +.Fn setmode +will fail and set +.Va errno +to: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa mode +argument does not represent a valid mode. +.El .Sh SEE ALSO .Xr chmod 1 , .Xr stat 2 , diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 3966fd0..815cf14 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -39,8 +39,11 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <sys/types.h> #include <sys/stat.h> +#include <sys/sysctl.h> #include <ctype.h> +#include <errno.h> +#include <limits.h> #include <signal.h> #include <stddef.h> #include <stdlib.h> @@ -66,7 +69,8 @@ typedef struct bitcmd { #define CMD2_OBITS 0x08 #define CMD2_UBITS 0x10 -static BITCMD *addcmd(BITCMD *, int, int, int, u_int); +static mode_t getumask(void); +static BITCMD *addcmd(BITCMD *, mode_t, mode_t, mode_t, mode_t); static void compress_mode(BITCMD *); #ifdef SETMODE_DEBUG static void dumpmode(BITCMD *); @@ -151,45 +155,37 @@ common: if (set->cmd2 & CMD2_CLR) { BITCMD *newset; \ setlen += SET_LEN_INCR; \ newset = realloc(saveset, sizeof(BITCMD) * setlen); \ - if (!newset) { \ - if (saveset) \ - free(saveset); \ - saveset = NULL; \ - return (NULL); \ - } \ + if (newset == NULL) \ + goto out; \ set = newset + (set - saveset); \ saveset = newset; \ endset = newset + (setlen - 2); \ } \ - set = addcmd(set, (a), (b), (c), (d)) + set = addcmd(set, (mode_t)(a), (mode_t)(b), (mode_t)(c), (d)) #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) void * setmode(const char *p) { - int perm, who; + int serrno; char op, *ep; BITCMD *set, *saveset, *endset; - sigset_t sigset, sigoset; - mode_t mask; - int equalopdone=0, permXbits, setlen; + mode_t mask, perm, permXbits, who; long perml; + int equalopdone; + int setlen; - if (!*p) + if (!*p) { + errno = EINVAL; return (NULL); + } /* * Get a copy of the mask for the permissions that are mask relative. - * Flip the bits, we want what's not set. Since it's possible that - * the caller is opening files inside a signal handler, protect them - * as best we can. + * Flip the bits, we want what's not set. */ - sigfillset(&sigset); - (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset); - (void)umask(mask = umask(0)); - mask = ~mask; - (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL); + mask = ~getumask(); setlen = SET_LEN + 2; @@ -203,10 +199,17 @@ setmode(const char *p) * or illegal bits. */ if (isdigit((unsigned char)*p)) { + errno = 0; perml = strtol(p, &ep, 8); - if (*ep || perml < 0 || perml & ~(STANDARD_BITS|S_ISTXT)) { - free(saveset); - return (NULL); + if (*ep) { + errno = EINVAL; + goto out; + } + if (errno == ERANGE && (perml == LONG_MAX || perml == LONG_MIN)) + goto out; + if (perml & ~(STANDARD_BITS|S_ISTXT)) { + errno = EINVAL; + goto out; } perm = (mode_t)perml; ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask); @@ -218,6 +221,7 @@ setmode(const char *p) * Build list of structures to set/clear/copy bits as described by * each clause of the symbolic mode. */ + equalopdone = 0; for (;;) { /* First, find out which bits might be modified. */ for (who = 0;; ++p) { @@ -240,8 +244,8 @@ setmode(const char *p) } getop: if ((op = *p++) != '+' && op != '-' && op != '=') { - free(saveset); - return (NULL); + errno = EINVAL; + goto out; } if (op == '=') equalopdone = 0; @@ -330,10 +334,44 @@ apply: if (!*p) dumpmode(saveset); #endif return (saveset); +out: + serrno = errno; + free(saveset); + errno = serrno; + return NULL; +} + +static mode_t +getumask(void) +{ + sigset_t sigset, sigoset; + size_t len; + mode_t mask; + u_short smask; + + /* + * First try requesting the umask without temporarily modifying it. + * Note that this does not work if the sysctl + * security.bsd.unprivileged_proc_debug is set to 0. + */ + len = sizeof(smask); + if (sysctl((int[4]){ CTL_KERN, KERN_PROC, KERN_PROC_UMASK, getpid() }, + 4, &smask, &len, NULL, 0) == 0) + return (smask); + + /* + * Since it's possible that the caller is opening files inside a signal + * handler, protect them as best we can. + */ + sigfillset(&sigset); + (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset); + (void)umask(mask = umask(0)); + (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL); + return (mask); } static BITCMD * -addcmd(BITCMD *set, int op, int who, int oparg, u_int mask) +addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask) { switch (op) { case '=': diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c index cd705fb..9dff328 100644 --- a/lib/libc/gen/setproctitle.c +++ b/lib/libc/gen/setproctitle.c @@ -42,9 +42,10 @@ __FBSDID("$FreeBSD$"); * 1: old_ps_strings at the very top of the stack. * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack. * 3: ps_strings at the very top of the stack. - * This attempts to support a kernel built in the #2 and #3 era. - */ - + * We only support a kernel providing #3 style ps_strings. + * + * For historical purposes, a definition of the old ps_strings structure + * and location is preserved below: struct old_ps_strings { char *old_ps_argvstr; int old_ps_nargvstr; @@ -53,6 +54,7 @@ struct old_ps_strings { }; #define OLD_PS_STRINGS ((struct old_ps_strings *) \ (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings))) + */ #include <stdarg.h> @@ -136,41 +138,38 @@ setproctitle(const char *fmt, ...) ps_strings = (struct ps_strings *)ul_ps_strings; } - /* PS_STRINGS points to zeroed memory on a style #2 kernel */ - if (ps_strings->ps_argvstr) { - /* style #3 */ - if (oargc == -1) { - /* Record our original args */ - oargc = ps_strings->ps_nargvstr; - oargv = ps_strings->ps_argvstr; - for (i = len = 0; i < oargc; i++) { - /* - * The program may have scribbled into its - * argv array, e.g., to remove some arguments. - * If that has happened, break out before - * trying to call strlen on a NULL pointer. - */ - if (oargv[i] == NULL) { - oargc = i; - break; - } - snprintf(obuf + len, SPT_BUFSIZE - len, "%s%s", - len ? " " : "", oargv[i]); - if (len) - len++; - len += strlen(oargv[i]); - if (len >= SPT_BUFSIZE) - break; + /* + * PS_STRINGS points to zeroed memory on a style #2 kernel. + * Should not happen. + */ + if (ps_strings->ps_argvstr == NULL) + return; + + /* style #3 */ + if (oargc == -1) { + /* Record our original args */ + oargc = ps_strings->ps_nargvstr; + oargv = ps_strings->ps_argvstr; + for (i = len = 0; i < oargc; i++) { + /* + * The program may have scribbled into its + * argv array, e.g., to remove some arguments. + * If that has happened, break out before + * trying to call strlen on a NULL pointer. + */ + if (oargv[i] == NULL) { + oargc = i; + break; } + snprintf(obuf + len, SPT_BUFSIZE - len, "%s%s", + len != 0 ? " " : "", oargv[i]); + if (len != 0) + len++; + len += strlen(oargv[i]); + if (len >= SPT_BUFSIZE) + break; } - ps_strings->ps_nargvstr = nargc; - ps_strings->ps_argvstr = nargvp; - } else { - /* style #2 - we can only restore our first arg :-( */ - if (*obuf == '\0') - strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr, - SPT_BUFSIZE - 1); - OLD_PS_STRINGS->old_ps_nargvstr = 1; - OLD_PS_STRINGS->old_ps_argvstr = nargvp[0]; } + ps_strings->ps_nargvstr = nargc; + ps_strings->ps_argvstr = nargvp; } diff --git a/lib/libc/gen/sleep.3 b/lib/libc/gen/sleep.3 index ecfa237..00e8f8d 100644 --- a/lib/libc/gen/sleep.3 +++ b/lib/libc/gen/sleep.3 @@ -33,7 +33,7 @@ .Os .Sh NAME .Nm sleep -.Nd suspend process execution for an interval measured in seconds +.Nd suspend thread execution for an interval measured in seconds .Sh LIBRARY .Lb libc .Sh SYNOPSIS @@ -43,11 +43,11 @@ .Sh DESCRIPTION The .Fn sleep -function suspends execution of the calling process until either +function suspends execution of the calling thread until either .Fa seconds -seconds have elapsed or a signal is delivered to the process and its +seconds have elapsed or a signal is delivered to the thread and its action is to invoke a signal-catching function or to terminate the -process. +thread or process. System activity may lengthen the sleep by an indeterminate amount. .Pp This function is implemented using diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index b807c2d..6bb4ecd 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" + unsigned int __sleep(unsigned int seconds) { @@ -55,12 +57,14 @@ __sleep(unsigned int seconds) time_to_sleep.tv_sec = seconds; time_to_sleep.tv_nsec = 0; - if (_nanosleep(&time_to_sleep, &time_remaining) != -1) + if (((int (*)(const struct timespec *, struct timespec *)) + __libc_interposing[INTERPOS_nanosleep])( + &time_to_sleep, &time_remaining) != -1) return (0); if (errno != EINTR) return (seconds); /* best guess */ return (time_remaining.tv_sec + - (time_remaining.tv_nsec != 0)); /* round up */ + (time_remaining.tv_nsec != 0)); /* round up */ } __weak_reference(__sleep, sleep); diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c index a09a8e7..236af17 100644 --- a/lib/libc/gen/stringlist.c +++ b/lib/libc/gen/stringlist.c @@ -10,8 +10,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. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 3a5cafe..003f24d 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -261,26 +261,45 @@ vsyslog(int pri, const char *fmt, va_list ap) connectlog(); /* - * If the send() failed, there are two likely scenarios: + * If the send() fails, there are two likely scenarios: * 1) syslogd was restarted * 2) /var/run/log is out of socket buffer space, which * in most cases means local DoS. - * We attempt to reconnect to /var/run/log[priv] to take care of - * case #1 and keep send()ing data to cover case #2 - * to give syslogd a chance to empty its socket buffer. + * If the error does not indicate a full buffer, we address + * case #1 by attempting to reconnect to /var/run/log[priv] + * and resending the message once. * - * If we are working with a priveleged socket, then take - * only one attempt, because we don't want to freeze a + * If we are working with a privileged socket, the retry + * attempts end there, because we don't want to freeze a * critical application like su(1) or sshd(8). * + * Otherwise, we address case #2 by repeatedly retrying the + * send() to give syslogd a chance to empty its socket buffer. */ if (send(LogFile, tbuf, cnt, 0) < 0) { if (errno != ENOBUFS) { + /* + * Scenario 1: syslogd was restarted + * reconnect and resend once + */ disconnectlog(); connectlog(); + if (send(LogFile, tbuf, cnt, 0) >= 0) { + THREAD_UNLOCK(); + return; + } + /* + * if the resend failed, fall through to + * possible scenario 2 + */ } - do { + while (errno == ENOBUFS) { + /* + * Scenario 2: out of socket buffer space + * possible DoS, fail fast on a privileged + * socket + */ if (status == CONNPRIV) break; _usleep(1); @@ -288,7 +307,7 @@ vsyslog(int pri, const char *fmt, va_list ap) THREAD_UNLOCK(); return; } - } while (errno == ENOBUFS); + } } else { THREAD_UNLOCK(); return; @@ -350,7 +369,7 @@ connectlog(void) SyslogAddr.sun_family = AF_UNIX; /* - * First try priveleged socket. If no success, + * First try privileged socket. If no success, * then try default socket. */ (void)strncpy(SyslogAddr.sun_path, _PATH_LOG_PRIV, diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c index d72b500..19cd6ee 100644 --- a/lib/libc/gen/telldir.c +++ b/lib/libc/gen/telldir.c @@ -101,9 +101,22 @@ _seekdir(dirp, loc) return; if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek) return; + + /* If it's within the same chunk of data, don't bother reloading. */ + if (lp->loc_seek == dirp->dd_seek) { + /* + * If we go back to 0 don't make the next readdir + * trigger a call to getdirentries(). + */ + if (lp->loc_loc == 0) + dirp->dd_flags |= __DTF_SKIPREAD; + dirp->dd_loc = lp->loc_loc; + return; + } (void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET); dirp->dd_seek = lp->loc_seek; dirp->dd_loc = 0; + dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */ while (dirp->dd_loc < lp->loc_loc) { dp = _readdir_unlocked(dirp, 0); if (dp == NULL) @@ -112,6 +125,30 @@ _seekdir(dirp, loc) } /* + * After readdir returns the last entry in a block, a call to telldir + * returns a location that is after the end of that last entry. + * However, that location doesn't refer to a valid directory entry. + * Ideally, the call to telldir would return a location that refers to + * the first entry in the next block. That location is not known + * until the next block is read, so readdir calls this function after + * fetching a new block to fix any such telldir locations. + */ +void +_fixtelldir(DIR *dirp, long oldseek, long oldloc) +{ + struct ddloc *lp; + + lp = LIST_FIRST(&dirp->dd_td->td_locq); + if (lp != NULL) { + if (lp->loc_loc == oldloc && + lp->loc_seek == oldseek) { + lp->loc_seek = dirp->dd_seek; + lp->loc_loc = dirp->dd_loc; + } + } +} + +/* * Reclaim memory for telldir cookies which weren't used. */ void diff --git a/lib/libc/gen/telldir.h b/lib/libc/gen/telldir.h index 04989bb..bccabb1 100644 --- a/lib/libc/gen/telldir.h +++ b/lib/libc/gen/telldir.h @@ -64,5 +64,6 @@ bool _filldir(DIR *, bool); struct dirent *_readdir_unlocked(DIR *, int); void _reclaim_telldir(DIR *); void _seekdir(DIR *, long); +void _fixtelldir(DIR *dirp, long oldseek, long oldloc); #endif diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c index 7e9f169..f8b7354 100644 --- a/lib/libc/gen/termios.c +++ b/lib/libc/gen/termios.c @@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" + int tcgetattr(int fd, struct termios *t) { @@ -208,13 +210,23 @@ tcsendbreak(int fd, int len __unused) } int -__tcdrain(int fd) +__libc_tcdrain(int fd) { + return (_ioctl(fd, TIOCDRAIN, 0)); } -__weak_reference(__tcdrain, tcdrain); -__weak_reference(__tcdrain, _tcdrain); +#pragma weak tcdrain +int +tcdrain(int fd) +{ + + return (((int (*)(int)) + __libc_interposing[INTERPOS_tcdrain])(fd)); +} + +__weak_reference(__libc_tcdrain, __tcdrain); +__weak_reference(__libc_tcdrain, _tcdrain); int tcflush(int fd, int which) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 5219418..58ebb55 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -65,13 +65,14 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); #if defined(__amd64__) #define TLS_TCB_ALIGN 16 #elif defined(__powerpc__) || defined(__i386__) || defined(__arm__) || \ - defined(__sparc64__) || defined(__mips__) + defined(__sparc64__) || defined(__mips__) || defined(__aarch64__) #define TLS_TCB_ALIGN sizeof(void *) #else #error TLS_TCB_ALIGN undefined for target architecture #endif -#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) +#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) || \ + defined(__aarch64__) #define TLS_VARIANT_I #endif #if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) diff --git a/lib/libc/arm/gen/getcontextx.c b/lib/libc/gen/trivial-getcontextx.c index 54f8513..54f8513 100644 --- a/lib/libc/arm/gen/getcontextx.c +++ b/lib/libc/gen/trivial-getcontextx.c diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index a21b77f..02aa158 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -65,7 +65,7 @@ ttyname_r(int fd, char *buf, size_t len) /* Must be a terminal. */ if (!isatty(fd)) - return (ENOTTY); + return (errno); /* Must have enough room */ if (len <= sizeof(_PATH_DEV)) return (ERANGE); @@ -73,7 +73,7 @@ ttyname_r(int fd, char *buf, size_t len) strcpy(buf, _PATH_DEV); used = strlen(buf); if (fdevname_r(fd, buf + used, len - used) == NULL) - return (ENOTTY); + return (errno == EINVAL ? ERANGE : errno); return (0); } diff --git a/lib/libc/gen/ulimit.c b/lib/libc/gen/ulimit.c index e1bc020..2c090c0 100644 --- a/lib/libc/gen/ulimit.c +++ b/lib/libc/gen/ulimit.c @@ -40,7 +40,7 @@ ulimit(int cmd, ...) { struct rlimit limit; va_list ap; - long arg; + rlim_t arg; if (cmd == UL_GETFSIZE) { if (getrlimit(RLIMIT_FSIZE, &limit) == -1) @@ -53,14 +53,16 @@ ulimit(int cmd, ...) va_start(ap, cmd); arg = va_arg(ap, long); va_end(ap); - limit.rlim_max = limit.rlim_cur = (rlim_t)arg * 512; + if (arg < 0) + arg = LONG_MAX; + if (arg > RLIM_INFINITY / 512) + arg = RLIM_INFINITY / 512; + limit.rlim_max = limit.rlim_cur = arg * 512; /* The setrlimit() function sets errno to EPERM if needed. */ if (setrlimit(RLIMIT_FSIZE, &limit) == -1) return (-1); - if (arg * 512 > LONG_MAX) - return (LONG_MAX); - return (arg); + return ((long)arg); } else { errno = EINVAL; return (-1); diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 7d6559b..7c35f6c 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" + int __usleep(useconds_t useconds) { @@ -45,7 +47,8 @@ __usleep(useconds_t useconds) time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; time_to_sleep.tv_sec = useconds / 1000000; - return (_nanosleep(&time_to_sleep, NULL)); + return (((int (*)(const struct timespec *, struct timespec *)) + __libc_interposing[INTERPOS_nanosleep])(&time_to_sleep, NULL)); } __weak_reference(__usleep, usleep); diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c index 2169b9d..46a3fdd 100644 --- a/lib/libc/gen/wait.c +++ b/lib/libc/gen/wait.c @@ -40,10 +40,14 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include "un-namespace.h" +#include "libc_private.h" + pid_t __wait(int *istat) { - return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0)); + + return (((pid_t (*)(pid_t, int *, int, struct rusage *)) + __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, 0, NULL)); } __weak_reference(__wait, wait); diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c index 6098773..965effe 100644 --- a/lib/libc/gen/wait3.c +++ b/lib/libc/gen/wait3.c @@ -40,11 +40,14 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include "un-namespace.h" +#include "libc_private.h" + pid_t -wait3(istat, options, rup) - int *istat; - int options; - struct rusage *rup; +__wait3(int *istat, int options, struct rusage *rup) { - return (_wait4(WAIT_ANY, istat, options, rup)); + + return (((pid_t (*)(pid_t, int *, int, struct rusage *)) + __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, options, rup)); } + +__weak_reference(__wait3, wait3); diff --git a/lib/libc/gen/waitid.c b/lib/libc/gen/waitid.c index 795b208..17a2dd6 100644 --- a/lib/libc/gen/waitid.c +++ b/lib/libc/gen/waitid.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <errno.h> #include "un-namespace.h" +#include "libc_private.h" int __waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags) @@ -44,7 +45,9 @@ __waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags) int status; pid_t ret; - ret = _wait6(idtype, id, &status, flags, NULL, info); + ret = ((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *, + siginfo_t *))__libc_interposing[INTERPOS_wait6])(idtype, id, + &status, flags, NULL, info); /* * According to SUSv4, waitid() shall not return a PID when a diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c index b001837..5177591 100644 --- a/lib/libc/gen/waitpid.c +++ b/lib/libc/gen/waitpid.c @@ -40,10 +40,14 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include "un-namespace.h" +#include "libc_private.h" + pid_t __waitpid(pid_t pid, int *istat, int options) { - return (_wait4(pid, istat, options, (struct rusage *)0)); + + return (((pid_t (*)(pid_t, int *, int, struct rusage *)) + __libc_interposing[INTERPOS_wait4])(pid, istat, options, NULL)); } __weak_reference(__waitpid, waitpid); diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c index 377caff..c7f4b1d 100644 --- a/lib/libc/gen/wordexp.c +++ b/lib/libc/gen/wordexp.c @@ -118,8 +118,10 @@ we_askshell(const char *words, wordexp_t *we, int flags) char *nstrings; /* Temporary for realloc() */ char **nwv; /* Temporary for realloc() */ sigset_t newsigblock, oldsigblock; + const char *ifs; serrno = errno; + ifs = getenv("IFS"); if (pipe2(pdes, O_CLOEXEC) < 0) return (WRDE_NOSPACE); /* XXX */ @@ -145,7 +147,8 @@ we_askshell(const char *words, wordexp_t *we, int flags) _fcntl(pdes[1], F_SETFD, 0)) < 0) _exit(1); execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u", - "-c", "eval \"$1\";eval \"wordexp $2\"", "", + "-c", "IFS=$1;eval \"$2\";eval \"wordexp $3\"", "", + ifs != NULL ? ifs : " \t\n", flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words, (char *)NULL); _exit(1); diff --git a/lib/libc/i386/sys/Makefile.inc b/lib/libc/i386/sys/Makefile.inc index b56183c..ebaa462 100644 --- a/lib/libc/i386/sys/Makefile.inc +++ b/lib/libc/i386/sys/Makefile.inc @@ -15,9 +15,6 @@ MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \ NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o PSEUDO= _getlogin.o _exit.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif MAN+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2 MAN+= i386_set_watch.3 diff --git a/lib/libc/iconv/__iconv.c b/lib/libc/iconv/__iconv.c index c9bee3f..85170b7 100644 --- a/lib/libc/iconv/__iconv.c +++ b/lib/libc/iconv/__iconv.c @@ -31,7 +31,7 @@ #include "iconv-internal.h" size_t -__iconv(iconv_t a, const char **b, size_t *c, char **d, +__iconv(iconv_t a, char **b, size_t *c, char **d, size_t *e, __uint32_t f, size_t *g) { return __bsd___iconv(a, b, c, d, e, f, g); diff --git a/lib/libc/iconv/bsd_iconv.c b/lib/libc/iconv/bsd_iconv.c index f764886..e032a5b 100644 --- a/lib/libc/iconv/bsd_iconv.c +++ b/lib/libc/iconv/bsd_iconv.c @@ -120,7 +120,7 @@ __bsd_iconv_close(iconv_t handle) } size_t -__bsd_iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout) +__bsd_iconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout) { size_t ret; int err; @@ -141,7 +141,7 @@ __bsd_iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *s } size_t -__bsd___iconv(iconv_t handle, const char **in, size_t *szin, char **out, +__bsd___iconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout, uint32_t flags, size_t *invalids) { size_t ret; diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c index 5c8bf49..5994063 100644 --- a/lib/libc/iconv/citrus_iconv.c +++ b/lib/libc/iconv/citrus_iconv.c @@ -278,7 +278,9 @@ _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv, struct _citrus_iconv *cv = NULL; struct _citrus_iconv_shared *ci = NULL; char realdst[PATH_MAX], realsrc[PATH_MAX]; +#ifdef _PATH_ICONV char buf[PATH_MAX], path[PATH_MAX]; +#endif int ret; init_cache(); @@ -290,10 +292,16 @@ _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv, dst = nl_langinfo(CODESET); /* resolve codeset name aliases */ +#ifdef _PATH_ICONV + snprintf(path, sizeof(path), "%s/%s", _PATH_ICONV, _CITRUS_ICONV_ALIAS); strlcpy(realsrc, _lookup_alias(path, src, buf, (size_t)PATH_MAX, _LOOKUP_CASE_IGNORE), (size_t)PATH_MAX); strlcpy(realdst, _lookup_alias(path, dst, buf, (size_t)PATH_MAX, _LOOKUP_CASE_IGNORE), (size_t)PATH_MAX); +#else + strlcpy(realsrc, src, (size_t)PATH_MAX); + strlcpy(realdst, dst, (size_t)PATH_MAX); +#endif /* sanity check */ if (strchr(realsrc, '/') != NULL || strchr(realdst, '/')) diff --git a/lib/libc/iconv/citrus_iconv.h b/lib/libc/iconv/citrus_iconv.h index ac14ac3..99604e9 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, - const char * __restrict * __restrict in, size_t * __restrict inbytes, + 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 12d2fa3..5392da1 100644 --- a/lib/libc/iconv/citrus_iconv_local.h +++ b/lib/libc/iconv/citrus_iconv_local.h @@ -46,7 +46,7 @@ static void _citrus_##_m_##_iconv_uninit_shared \ (struct _citrus_iconv_shared *); \ static int _citrus_##_m_##_iconv_convert \ (struct _citrus_iconv * __restrict, \ - const char * __restrict * __restrict, \ + char * __restrict * __restrict, \ size_t * __restrict, \ char * __restrict * __restrict, \ size_t * __restrict outbytes, \ @@ -75,7 +75,7 @@ typedef void (*_citrus_iconv_uninit_shared_t) (struct _citrus_iconv_shared *); typedef int (*_citrus_iconv_convert_t) (struct _citrus_iconv * __restrict, - const char *__restrict* __restrict, size_t * __restrict, + 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_none.c b/lib/libc/iconv/citrus_none.c index 4f9b254..9ec4bd3 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, const char **s, size_t n, + _csid_t *csid, _index_t *idx, 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, const char ** __restrict s, size_t n, + _wc_t * __restrict pwc, 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_prop.c b/lib/libc/iconv/citrus_prop.c index 28318de..642e423 100644 --- a/lib/libc/iconv/citrus_prop.c +++ b/lib/libc/iconv/citrus_prop.c @@ -293,8 +293,10 @@ done: } _memstream_ungetc(ms, ch); errnum = _citrus_prop_read_character_common(ms, &ch); - if (errnum != 0) + if (errnum != 0) { + free(s); return (errnum); + } s[n] = ch; ++n, --m; } diff --git a/lib/libc/iconv/citrus_stdenc.h b/lib/libc/iconv/citrus_stdenc.h index 28fa29d..50f4dff 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, - const char ** __restrict s, size_t n, void * __restrict ps, + 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 7b627a0..141abff 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, \ - const char ** __restrict, size_t, \ + 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, \ - const char ** __restrict, size_t, \ + char ** __restrict, size_t, \ void * __restrict, size_t * __restrict, \ struct iconv_hooks *); \ static int _citrus_##_e_##_stdenc_wctomb \ @@ -106,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, - const char ** __restrict, size_t, + char ** __restrict, size_t, void * __restrict, size_t * __restrict, struct iconv_hooks *); typedef int (*_citrus_stdenc_cstomb_t) @@ -116,7 +116,7 @@ typedef int (*_citrus_stdenc_cstomb_t) typedef int (*_citrus_stdenc_mbtowc_t) (struct _citrus_stdenc * __restrict, _citrus_wc_t * __restrict, - const char ** __restrict, size_t, + 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 21bc5cc..9a05fa7 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, - const char ** __restrict s, size_t n, void * __restrict ps, + 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, const char ** __restrict s, size_t n, + _citrus_wc_t * __restrict wc, char ** __restrict s, size_t n, void * __restrict ps, size_t * __restrict nresult, struct iconv_hooks *hooks) { diff --git a/lib/libc/iconv/iconv-internal.h b/lib/libc/iconv/iconv-internal.h index 9a6b3d9..9937f09 100644 --- a/lib/libc/iconv/iconv-internal.h +++ b/lib/libc/iconv/iconv-internal.h @@ -29,11 +29,11 @@ /* * Interal prototypes for our back-end functions. */ -size_t __bsd___iconv(iconv_t, const char **, size_t *, char **, +size_t __bsd___iconv(iconv_t, char **, size_t *, char **, size_t *, __uint32_t, size_t *); void __bsd___iconv_free_list(char **, size_t); int __bsd___iconv_get_list(char ***, size_t *, __iconv_bool); -size_t __bsd_iconv(iconv_t, const char ** __restrict, +size_t __bsd_iconv(iconv_t, char ** __restrict, size_t * __restrict, char ** __restrict, size_t * __restrict); const char *__bsd_iconv_canonicalize(const char *); diff --git a/lib/libc/iconv/iconv.3 b/lib/libc/iconv/iconv.3 index 6692c47..1a4f8c3 100644 --- a/lib/libc/iconv/iconv.3 +++ b/lib/libc/iconv/iconv.3 @@ -48,7 +48,7 @@ .Ft size_t .Fn iconv "iconv_t cd" "char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft" .Ft size_t -.Fn __iconv "iconv_t cd" "const char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft" "uint32_t flags" "size_t invalids" +.Fn __iconv "iconv_t cd" "char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft" "uint32_t flags" "size_t * invalids" .Sh DESCRIPTION The .Fn iconv_open @@ -176,8 +176,8 @@ may be .Dv NULL . In this case, the shift sequence for the destination switching to the initial state is discarded. -.Pp .El +.Pp The .Fn __iconv function works just like diff --git a/lib/libc/iconv/iconv.c b/lib/libc/iconv/iconv.c index d13c1df..4bd9620 100644 --- a/lib/libc/iconv/iconv.c +++ b/lib/libc/iconv/iconv.c @@ -31,7 +31,7 @@ #include "iconv-internal.h" size_t -iconv(iconv_t a, const char ** __restrict b, +iconv(iconv_t a, char ** __restrict b, size_t * __restrict c, char ** __restrict d, size_t * __restrict e) { diff --git a/lib/libc/iconv/iconv_compat.c b/lib/libc/iconv/iconv_compat.c index dea968f..ded2499 100644 --- a/lib/libc/iconv/iconv_compat.c +++ b/lib/libc/iconv/iconv_compat.c @@ -37,7 +37,7 @@ #include "iconv-internal.h" size_t -__iconv_compat(iconv_t a, const char ** b, size_t * c, char ** d, +__iconv_compat(iconv_t a, char ** b, size_t * c, char ** d, size_t * e, __uint32_t f, size_t *g) { return __bsd___iconv(a, b, c, d, e, f, g); @@ -56,7 +56,7 @@ __iconv_get_list_compat(char ***a, size_t *b, __iconv_bool c) } size_t -iconv_compat(iconv_t a, const char ** __restrict b, +iconv_compat(iconv_t a, char ** __restrict b, size_t * __restrict c, char ** __restrict d, size_t * __restrict e) { diff --git a/lib/libc/iconv/iconvlist.3 b/lib/libc/iconv/iconvlist.3 index bef609b..b1a6e05 100644 --- a/lib/libc/iconv/iconvlist.3 +++ b/lib/libc/iconv/iconvlist.3 @@ -78,9 +78,9 @@ If an error occurs, will be NULL when calling .Fn do_one . .Sh SEE ALSO -.Xr iconv 3 , +.Xr __iconv_free_list 3 , .Xr __iconv_get_list 3 , -.Xr __iconv_free_list 3 +.Xr iconv 3 .Sh STANDARDS The .Nm diff --git a/lib/libc/include/compat.h b/lib/libc/include/compat.h index 7694540..b20fac5 100644 --- a/lib/libc/include/compat.h +++ b/lib/libc/include/compat.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009 Advanced Computing Technologies LLC + * Copyright (c) 2009 Hudson River Trading LLC * Written by: John H. Baldwin <jhb@FreeBSD.org> * All rights reserved. * @@ -44,5 +44,12 @@ __sym_compat(shmctl, freebsd7_shmctl, FBSD_1.0); #undef __sym_compat +#define __weak_reference(sym,alias) \ + .weak alias;.equ alias,sym + +__weak_reference(__sys_fcntl,__fcntl_compat) + +#undef __weak_reference + #endif /* __LIBC_COMPAT_H__ */ diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 40a5f72..a670d63 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -95,6 +95,9 @@ do { \ _SPINUNLOCK(&__stdio_thread_lock); \ } while (0) +void __libc_spinlock_stub(struct _spinlock *); +void __libc_spinunlock_stub(struct _spinlock *); + /* * Indexes into the pthread jump table. * @@ -173,6 +176,57 @@ typedef pthread_func_t pthread_func_entry_t[2]; extern pthread_func_entry_t __thr_jtable[]; +void __set_error_selector(int *(*arg)(void)); +int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex, + void *(calloc_cb)(__size_t, __size_t)); + +typedef int (*interpos_func_t)(void); +interpos_func_t *__libc_interposing_slot(int interposno); +extern interpos_func_t __libc_interposing[] __hidden; + +enum { + INTERPOS_accept, + INTERPOS_accept4, + INTERPOS_aio_suspend, + INTERPOS_close, + INTERPOS_connect, + INTERPOS_fcntl, + INTERPOS_fsync, + INTERPOS_fork, + INTERPOS_msync, + INTERPOS_nanosleep, + INTERPOS_openat, + INTERPOS_poll, + INTERPOS_pselect, + INTERPOS_recvfrom, + INTERPOS_recvmsg, + INTERPOS_select, + INTERPOS_sendmsg, + INTERPOS_sendto, + INTERPOS_setcontext, + INTERPOS_sigaction, + INTERPOS_sigprocmask, + INTERPOS_sigsuspend, + INTERPOS_sigwait, + INTERPOS_sigtimedwait, + INTERPOS_sigwaitinfo, + INTERPOS_swapcontext, + INTERPOS_system, + INTERPOS_tcdrain, + INTERPOS_read, + INTERPOS_readv, + INTERPOS_wait4, + INTERPOS_write, + INTERPOS_writev, + INTERPOS__pthread_mutex_init_calloc_cb, + INTERPOS_spinlock, + INTERPOS_spinunlock, + INTERPOS_kevent, + INTERPOS_wait6, + INTERPOS_ppoll, + INTERPOS_MAX +}; + /* * yplib internal interfaces */ @@ -215,6 +269,8 @@ void _malloc_thread_cleanup(void); void _malloc_prefork(void); void _malloc_postfork(void); +void _malloc_first_thread(void); + /* * Function to clean up streams, called from abort() and exit(). */ @@ -222,35 +278,96 @@ extern void (*__cleanup)(void) __hidden; /* * Get kern.osreldate to detect ABI revisions. Explicitly - * ignores value of $OSVERSION and caches result. Prototypes - * for the wrapped "new" pad-less syscalls are here for now. + * ignores value of $OSVERSION and caches result. */ -extern int __getosreldate(void); +int __getosreldate(void); #include <sys/_types.h> -/* Without pad */ -extern __off_t __sys_lseek(int, __off_t, int); -extern int __sys_ftruncate(int, __off_t); -extern int __sys_truncate(const char *, __off_t); -extern __ssize_t __sys_pread(int, void *, __size_t, __off_t); -extern __ssize_t __sys_pwrite(int, const void *, __size_t, __off_t); -extern void * __sys_mmap(void *, __size_t, int, int, int, __off_t); - -/* With pad */ -extern __off_t __sys_freebsd6_lseek(int, int, __off_t, int); -extern int __sys_freebsd6_ftruncate(int, int, __off_t); -extern int __sys_freebsd6_truncate(const char *, int, __off_t); -extern __ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t); -extern __ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t); -extern void * __sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t); - -/* Without back-compat translation */ -extern int __sys_fcntl(int, int, ...); +#include <sys/_sigset.h> +struct aiocb; +struct fd_set; +struct iovec; +struct kevent; +struct msghdr; +struct pollfd; +struct rusage; +struct sigaction; +struct sockaddr; struct timespec; struct timeval; struct timezone; -int __sys_gettimeofday(struct timeval *, struct timezone *); -int __sys_clock_gettime(__clockid_t, struct timespec *ts); +struct __siginfo; +struct __ucontext; +struct __wrusage; +enum idtype; +int __sys_aio_suspend(const struct aiocb * const[], int, + const struct timespec *); +int __sys_accept(int, struct sockaddr *, __socklen_t *); +int __sys_accept4(int, struct sockaddr *, __socklen_t *, int); +int __sys_clock_gettime(__clockid_t, struct timespec *ts); +int __sys_close(int); +int __sys_connect(int, const struct sockaddr *, __socklen_t); +int __sys_fcntl(int, int, ...); +int __sys_fsync(int); +__pid_t __sys_fork(void); +int __sys_ftruncate(int, __off_t); +int __sys_gettimeofday(struct timeval *, struct timezone *); +int __sys_kevent(int, const struct kevent *, int, struct kevent *, + int, const struct timespec *); +__off_t __sys_lseek(int, __off_t, int); +void *__sys_mmap(void *, __size_t, int, int, int, __off_t); +int __sys_msync(void *, __size_t, int); +int __sys_nanosleep(const struct timespec *, struct timespec *); +int __sys_open(const char *, int, ...); +int __sys_openat(int, const char *, int, ...); +int __sys_pselect(int, struct fd_set *, struct fd_set *, + struct fd_set *, const struct timespec *, + const __sigset_t *); +int __sys_poll(struct pollfd *, unsigned, int); +int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *, + const __sigset_t *); +__ssize_t __sys_pread(int, void *, __size_t, __off_t); +__ssize_t __sys_pwrite(int, const void *, __size_t, __off_t); +__ssize_t __sys_read(int, void *, __size_t); +__ssize_t __sys_readv(int, const struct iovec *, int); +__ssize_t __sys_recv(int, void *, __size_t, int); +__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *, + __socklen_t *); +__ssize_t __sys_recvmsg(int, struct msghdr *, int); +int __sys_select(int, struct fd_set *, struct fd_set *, + struct fd_set *, struct timeval *); +__ssize_t __sys_sendmsg(int, const struct msghdr *, int); +__ssize_t __sys_sendto(int, const void *, __size_t, int, + const struct sockaddr *, __socklen_t); +int __sys_setcontext(const struct __ucontext *); +int __sys_sigaction(int, const struct sigaction *, + struct sigaction *); +int __sys_sigprocmask(int, const __sigset_t *, __sigset_t *); +int __sys_sigsuspend(const __sigset_t *); +int __sys_sigtimedwait(const __sigset_t *, struct __siginfo *, + const struct timespec *); +int __sys_sigwait(const __sigset_t *, int *); +int __sys_sigwaitinfo(const __sigset_t *, struct __siginfo *); +int __sys_swapcontext(struct __ucontext *, + const struct __ucontext *); +int __sys_thr_kill(long, int); +int __sys_thr_self(long *); +int __sys_truncate(const char *, __off_t); +__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *); +__pid_t __sys_wait6(enum idtype, __id_t, int *, int, + struct __wrusage *, struct __siginfo *); +__ssize_t __sys_write(int, const void *, __size_t); +__ssize_t __sys_writev(int, const struct iovec *, int); + +int __libc_sigwait(const __sigset_t * __restrict, + int * restrict sig); +int __libc_system(const char *); +int __libc_tcdrain(int); +int __fcntl_compat(int fd, int cmd, ...); + +int __sys_futimens(int fd, const struct timespec *times) __hidden; +int __sys_utimensat(int fd, const char *path, + const struct timespec *times, int flag) __hidden; /* execve() with PATH processing to implement posix_spawnp() */ int _execvpe(const char *, char * const *, char * const *); diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h index 0ea553b..d6e7ce0 100644 --- a/lib/libc/locale/cXXrtomb_iconv.h +++ b/lib/libc/locale/cXXrtomb_iconv.h @@ -57,8 +57,7 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps, { _ConversionState *cs; struct _citrus_iconv *handle; - const char *src; - char *dst; + char *src, *dst; size_t srcleft, dstleft, invlen; int err; diff --git a/lib/libc/locale/digittoint.3 b/lib/libc/locale/digittoint.3 index 4a7f2e2..6670abe 100644 --- a/lib/libc/locale/digittoint.3 +++ b/lib/libc/locale/digittoint.3 @@ -64,5 +64,5 @@ the function will return 0. .Sh SEE ALSO .Xr ctype 3 , .Xr isdigit 3 , -.Xr isxdigit 3, +.Xr isxdigit 3 , .Xr xlocale 3 diff --git a/lib/libc/locale/duplocale.3 b/lib/libc/locale/duplocale.3 index f2e8215..bc0c4bc 100644 --- a/lib/libc/locale/duplocale.3 +++ b/lib/libc/locale/duplocale.3 @@ -36,7 +36,7 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In xlocale.h +.In locale.h .Ft locale_t .Fn duplocale "locale_t locale" .Sh DESCRIPTION diff --git a/lib/libc/locale/freelocale.3 b/lib/libc/locale/freelocale.3 index 86f4809..0df80e7 100644 --- a/lib/libc/locale/freelocale.3 +++ b/lib/libc/locale/freelocale.3 @@ -38,7 +38,7 @@ or .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In xlocale.h +.In locale.h .Ft int .Fn freelocale "locale_t locale" .Sh DESCRIPTION diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h index ac85a5a..9eb6f68 100644 --- a/lib/libc/locale/mbrtocXX_iconv.h +++ b/lib/libc/locale/mbrtocXX_iconv.h @@ -99,8 +99,7 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n, /* Convert as few characters to the dst buffer as possible. */ for (i = 0; ; i++) { - const char *src; - char *dst; + char *src, *dst; size_t srcleft, dstleft, invlen; int err; diff --git a/lib/libc/locale/newlocale.3 b/lib/libc/locale/newlocale.3 index a639c37..c7414be 100644 --- a/lib/libc/locale/newlocale.3 +++ b/lib/libc/locale/newlocale.3 @@ -35,7 +35,7 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In xlocale +.In locale.h .Ft locale_t .Fn newlocale "int mask" "const char * locale" "locale_t base" .Sh DESCRIPTION diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c index 75adffa..cacfd73 100644 --- a/lib/libc/locale/none.c +++ b/lib/libc/locale/none.c @@ -209,7 +209,7 @@ struct xlocale_ctype __xlocale_global_ctype = { 256 /* __mb_sb_limit */ }; -const struct xlocale_ctype __xlocale_C_ctype = { +struct xlocale_ctype __xlocale_C_ctype = { {{0}, "C"}, (_RuneLocale*)&_DefaultRuneLocale, _none_mbrtowc, diff --git a/lib/libc/locale/querylocale.3 b/lib/libc/locale/querylocale.3 index f90d626..d1bb688 100644 --- a/lib/libc/locale/querylocale.3 +++ b/lib/libc/locale/querylocale.3 @@ -36,7 +36,7 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In xlocale.h +.In locale.h .Ft const char * .Fn querylocale "int mask" "locale_t locale" .Sh DESCRIPTION diff --git a/lib/libc/locale/uselocale.3 b/lib/libc/locale/uselocale.3 index df29a62..96d0008 100644 --- a/lib/libc/locale/uselocale.3 +++ b/lib/libc/locale/uselocale.3 @@ -36,7 +36,7 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In xlocale.h +.In locale.h .Ft locale_t .Fn uselocale "locale_t locale" .Sh DESCRIPTION diff --git a/lib/libc/locale/xlocale.3 b/lib/libc/locale/xlocale.3 index d467a10..da217c6 100644 --- a/lib/libc/locale/xlocale.3 +++ b/lib/libc/locale/xlocale.3 @@ -71,7 +71,7 @@ function. .Xr localeconv 3 , .Xr newlocale 3 , .Xr querylocale 3 , -.Xr uselocale 3 , +.Xr uselocale 3 .Sh CONVENIENCE FUNCTIONS The xlocale API includes a number of .Fa _l diff --git a/lib/libc/mips/gen/Makefile.inc b/lib/libc/mips/gen/Makefile.inc index 9d9cc7a..a186fda 100644 --- a/lib/libc/mips/gen/Makefile.inc +++ b/lib/libc/mips/gen/Makefile.inc @@ -6,5 +6,6 @@ SRCS+= infinity.c fabs.c ldexp.c # SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ # fpsetround.c fpsetsticky.c -SRCS+= _ctx_start.S _set_tp.c _setjmp.S getcontextx.c makecontext.c \ - setjmp.S signalcontext.c sigsetjmp.S +SRCS+= _ctx_start.S _set_tp.c _setjmp.S makecontext.c \ + setjmp.S signalcontext.c sigsetjmp.S \ + trivial-getcontextx.c diff --git a/lib/libc/mips/gen/_setjmp.S b/lib/libc/mips/gen/_setjmp.S index 3918407..0f7a75a 100644 --- a/lib/libc/mips/gen/_setjmp.S +++ b/lib/libc/mips/gen/_setjmp.S @@ -61,9 +61,16 @@ __FBSDID("$FreeBSD$"); LEAF(_setjmp) REG_PROLOGUE - REG_LI v0, _JB_MAGIC__SETJMP + REG_LI v0, _JB_MAGIC__SETJMP # sigcontext magic number REG_S v0, (_JB_MAGIC * SZREG)(a0) REG_S ra, (_JB_REG_RA * SZREG)(a0) + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * Registers s0..s7 are callee-saved. + * The sp register is callee-saved. + * The fp (or s8) register is callee-saved. + * The gp register is callee-saved (for n32/n64). + */ REG_S s0, (_JB_REG_S0 * SZREG)(a0) REG_S s1, (_JB_REG_S1 * SZREG)(a0) REG_S s2, (_JB_REG_S2 * SZREG)(a0) @@ -72,11 +79,41 @@ LEAF(_setjmp) REG_S s5, (_JB_REG_S5 * SZREG)(a0) REG_S s6, (_JB_REG_S6 * SZREG)(a0) REG_S s7, (_JB_REG_S7 * SZREG)(a0) + REG_S sp, (_JB_REG_SP * SZREG)(a0) REG_S s8, (_JB_REG_S8 * SZREG)(a0) #if defined(__mips_n32) || defined(__mips_n64) REG_S gp, (_JB_REG_GP * SZREG)(a0) # newabi gp is callee-saved #endif - REG_S sp, (_JB_REG_SP * SZREG)(a0) + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved. + * In N64, FP registers F24 .. F31 are callee-saved. + * In O32, FP registers F20 .. F23 are callee-saved. + */ +#ifndef SOFTFLOAT + cfc1 v0, $31 # too bad can't check if FP used +#if defined(__mips_n64) || defined(__mips_n32) + FP_S $f30, (_JB_FPREG_F30 * SZREG)(a0) + FP_S $f28, (_JB_FPREG_F28 * SZREG)(a0) + FP_S $f26, (_JB_FPREG_F26 * SZREG)(a0) + FP_S $f24, (_JB_FPREG_F24 * SZREG)(a0) +#endif +#if defined(__mips_n32) || defined(__mips_o32) || defined(__mips_o64) + FP_S $f22, (_JB_FPREG_F22 * SZREG)(a0) + FP_S $f20, (_JB_FPREG_F20 * SZREG)(a0) +#endif +#if defined(__mips_o32) || defined(__mips_o64) + FP_S $f21, (_JB_FPREG_F21 * SZREG)(a0) + FP_S $f23, (_JB_FPREG_F23 * SZREG)(a0) +#endif +#if defined(__mips_n64) + FP_S $f25, (_JB_FPREG_F25 * SZREG)(a0) + FP_S $f27, (_JB_FPREG_F27 * SZREG)(a0) + FP_S $f29, (_JB_FPREG_F29 * SZREG)(a0) + FP_S $f31, (_JB_FPREG_F31 * SZREG)(a0) +#endif + INT_S v0, (_JB_FPREG_FCSR * SZREG)(a0) +#endif /* ! SOFTFLOAT */ REG_EPILOGUE j ra @@ -94,6 +131,13 @@ LEAF(_longjmp) REG_LI t0, _JB_MAGIC__SETJMP bne v0, t0, botch # jump if error PTR_ADDU sp, sp, CALLFRAME_SIZ # does not matter, sanity + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * Registers s0..s7 are callee-saved. + * The sp register is callee-saved. + * The fp (or s8) register is callee-saved. + * The gp register is callee-saved (for n32/n64). + */ REG_L s0, (_JB_REG_S0 * SZREG)(a0) REG_L s1, (_JB_REG_S1 * SZREG)(a0) REG_L s2, (_JB_REG_S2 * SZREG)(a0) @@ -102,11 +146,42 @@ LEAF(_longjmp) REG_L s5, (_JB_REG_S5 * SZREG)(a0) REG_L s6, (_JB_REG_S6 * SZREG)(a0) REG_L s7, (_JB_REG_S7 * SZREG)(a0) + REG_L sp, (_JB_REG_SP * SZREG)(a0) + REG_L s8, (_JB_REG_S8 * SZREG)(a0) #if defined(__mips_n32) || defined(__mips_n64) REG_L gp, (_JB_REG_GP * SZREG)(a0) #endif - REG_L sp, (_JB_REG_SP * SZREG)(a0) - REG_L s8, (_JB_REG_S8 * SZREG)(a0) +#ifndef SOFTFLOAT + # get fpu status + INT_L v0, (_JB_FPREG_FCSR * SZREG)(a0) + ctc1 v0, $31 + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved. + * In N64, FP registers F24 .. F31 are callee-saved. + * In O32, FP registers F20 .. F23 are callee-saved. + */ +#if defined(__mips_n64) || defined(__mips_n32) + FP_L $f30, (_JB_FPREG_F30 * SZREG)(a0) + FP_L $f28, (_JB_FPREG_F28 * SZREG)(a0) + FP_L $f26, (_JB_FPREG_F26 * SZREG)(a0) + FP_L $f24, (_JB_FPREG_F24 * SZREG)(a0) +#endif +#if defined(__mips_n32) || defined(__mips_o32) || defined(__mips_o64) + FP_L $f22, (_JB_FPREG_F22 * SZREG)(a0) + FP_L $f20, (_JB_FPREG_F20 * SZREG)(a0) +#endif +#if defined(__mips_o32) || defined(__mips_o64) + FP_L $f21, (_JB_FPREG_F21 * SZREG)(a0) + FP_L $f23, (_JB_FPREG_F23 * SZREG)(a0) +#endif +#if defined(__mips_n64) + FP_L $f25, (_JB_FPREG_F25 * SZREG)(a0) + FP_L $f27, (_JB_FPREG_F27 * SZREG)(a0) + FP_L $f29, (_JB_FPREG_F29 * SZREG)(a0) + FP_L $f31, (_JB_FPREG_F31 * SZREG)(a0) +#endif +#endif /* ! SOFTFLOAT */ REG_EPILOGUE move v0, a1 # get return value in 1st arg diff --git a/lib/libc/mips/gen/getcontextx.c b/lib/libc/mips/gen/getcontextx.c deleted file mode 100644 index 54f8513..0000000 --- a/lib/libc/mips/gen/getcontextx.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/ucontext.h> -#include <errno.h> -#include <stdlib.h> - -int -__getcontextx_size(void) -{ - - return (sizeof(ucontext_t)); -} - -int -__fillcontextx2(char *ctx) -{ - - return (0); -} - -int -__fillcontextx(char *ctx) -{ - ucontext_t *ucp; - - ucp = (ucontext_t *)ctx; - return (getcontext(ucp)); -} - -__weak_reference(__getcontextx, getcontextx); - -ucontext_t * -__getcontextx(void) -{ - char *ctx; - int error; - - ctx = malloc(__getcontextx_size()); - if (ctx == NULL) - return (NULL); - if (__fillcontextx(ctx) == -1) { - error = errno; - free(ctx); - errno = error; - return (NULL); - } - return ((ucontext_t *)ctx); -} diff --git a/lib/libc/mips/gen/setjmp.S b/lib/libc/mips/gen/setjmp.S index deeb892..9c9e8b8 100644 --- a/lib/libc/mips/gen/setjmp.S +++ b/lib/libc/mips/gen/setjmp.S @@ -86,6 +86,13 @@ NESTED(setjmp, SETJMP_FRAME_SIZE, ra) REG_LI v0, _JB_MAGIC_SETJMP REG_S v0, (_JB_MAGIC * SZREG)(a0) REG_S ra, (_JB_REG_RA * SZREG)(a0) + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * Registers s0..s7 are callee-saved. + * The sp register is callee-saved. + * The fp (or s8) register is callee-saved. + * The gp register is callee-saved (for n32/n64). + */ REG_S s0, (_JB_REG_S0 * SZREG)(a0) REG_S s1, (_JB_REG_S1 * SZREG)(a0) REG_S s2, (_JB_REG_S2 * SZREG)(a0) @@ -99,6 +106,36 @@ NESTED(setjmp, SETJMP_FRAME_SIZE, ra) #if defined(__mips_n32) || defined(__mips_n64) REG_S gp, (_JB_REG_GP * SZREG)(a0) #endif +#ifndef SOFTFLOAT + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved. + * In N64, FP registers F24 .. F31 are callee-saved. + * In O32, FP registers F20 .. F23 are callee-saved. + */ + cfc1 v0, $31 + INT_S v0, (_JB_FPREG_FCSR * SZREG)(a0) +#if defined(__mips_o32) || defined(__mips_o64) || defined(__mips_n32) + FP_S $f20, (_JB_FPREG_F20 * SZREG)(a0) + FP_S $f22, (_JB_FPREG_F22 * SZREG)(a0) +#endif +#if defined(__mips_o32) || defined(__mips_o64) + FP_S $f21, (_JB_FPREG_F21 * SZREG)(a0) + FP_S $f23, (_JB_FPREG_F23 * SZREG)(a0) +#endif +#if defined(__mips_n32) || defined(__mips_n64) + FP_S $f24, (_JB_FPREG_F24 * SZREG)(a0) + FP_S $f26, (_JB_FPREG_F26 * SZREG)(a0) + FP_S $f28, (_JB_FPREG_F28 * SZREG)(a0) + FP_S $f30, (_JB_FPREG_F30 * SZREG)(a0) +#endif +#if defined(__mips_n64) + FP_S $f25, (_JB_FPREG_F25 * SZREG)(a0) + FP_S $f27, (_JB_FPREG_F27 * SZREG)(a0) + FP_S $f29, (_JB_FPREG_F29 * SZREG)(a0) + FP_S $f31, (_JB_FPREG_F31 * SZREG)(a0) +#endif +#endif /* ! SOFTFLOAT */ move v0, zero jr ra @@ -133,6 +170,13 @@ NESTED(longjmp, LONGJMP_FRAME_SIZE, ra) REG_L a1, (CALLFRAME_SIZ + SZREG)(sp) # restore return value REG_L ra, (_JB_REG_RA * SZREG)(a0) + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * Registers s0..s7 are callee-saved. + * The sp register is callee-saved. + * The fp (or s8) register is callee-saved. + * The gp register is callee-saved (for n32/n64). + */ REG_L s0, (_JB_REG_S0 * SZREG)(a0) REG_L s1, (_JB_REG_S1 * SZREG)(a0) REG_L s2, (_JB_REG_S2 * SZREG)(a0) @@ -146,6 +190,36 @@ NESTED(longjmp, LONGJMP_FRAME_SIZE, ra) #if defined(__mips_n32) || defined(__mips_n64) REG_L gp, (_JB_REG_GP * SZREG)(a0) #endif +#ifndef SOFTFLOAT + /* + * From "MIPSpro N32 ABI Handbook", Table 2-1: + * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved. + * In N64, FP registers F23 .. F31 are callee-saved. + * In O32, FP registers F20 .. F23 are callee-saved. + */ + INT_L v0, (_JB_FPREG_FCSR * SZREG)(a0) + ctc1 v0, $31 +#if defined(__mips_n64) || defined(__mips_n32) + FP_L $f30, (_JB_FPREG_F30 * SZREG)(a0) + FP_L $f28, (_JB_FPREG_F28 * SZREG)(a0) + FP_L $f26, (_JB_FPREG_F26 * SZREG)(a0) + FP_L $f24, (_JB_FPREG_F24 * SZREG)(a0) +#endif +#if defined(__mips_n32) || defined(__mips_o32) || defined(__mips_o64) + FP_L $f22, (_JB_FPREG_F22 * SZREG)(a0) + FP_L $f20, (_JB_FPREG_F20 * SZREG)(a0) +#endif +#if defined(__mips_o32) || defined(__mips_o64) + FP_L $f21, (_JB_FPREG_F21 * SZREG)(a0) + FP_L $f23, (_JB_FPREG_F23 * SZREG)(a0) +#endif +#if defined(__mips_n64) + FP_L $f25, (_JB_FPREG_F25 * SZREG)(a0) + FP_L $f27, (_JB_FPREG_F27 * SZREG)(a0) + FP_L $f29, (_JB_FPREG_F29 * SZREG)(a0) + FP_L $f31, (_JB_FPREG_F31 * SZREG)(a0) +#endif +#endif /* ! SOFTFLOAT */ move v0, a1 j ra diff --git a/lib/libc/mips/gen/sigsetjmp.S b/lib/libc/mips/gen/sigsetjmp.S index 7705c29..41c47f2 100644 --- a/lib/libc/mips/gen/sigsetjmp.S +++ b/lib/libc/mips/gen/sigsetjmp.S @@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$"); LEAF(sigsetjmp) PIC_PROLOGUE(sigsetjmp) - bne a1, 0x0, 1f # do saving of signal mask? + bne a1, zero, 1f # do saving of signal mask? PIC_TAILCALL(_setjmp) 1: PIC_TAILCALL(setjmp) diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc index c754f36..460e69b 100644 --- a/lib/libc/mips/sys/Makefile.inc +++ b/lib/libc/mips/sys/Makefile.inc @@ -1,15 +1,11 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= trivial-vdso_tc.c MDASM= Ovfork.S brk.S cerror.S exect.S \ fork.S pipe.S ptrace.S sbrk.S syscall.S # Don't generate default code for these syscalls: -NOASM= break.o exit.o ftruncate.o getlogin.o lseek.o mmap.o \ - openbsd_poll.o pread.o pwrite.o sstk.o truncate.o vfork.o yield.o +NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o PSEUDO= _exit.o _getlogin.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map index 2eddc47..01d3bcb 100644 --- a/lib/libc/net/Symbol.map +++ b/lib/libc/net/Symbol.map @@ -124,6 +124,7 @@ FBSD_1.0 { in6addr_nodelocal_allnodes; in6addr_linklocal_allnodes; sctp_getaddrlen; + sctp_getassocid; sctp_bindx; sctp_connectx; sctp_peeloff; diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c index 4335030..8a9c59e 100644 --- a/lib/libc/net/base64.c +++ b/lib/libc/net/base64.c @@ -193,12 +193,10 @@ b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { */ int -b64_pton(src, target, targsize) - char const *src; - u_char *target; - size_t targsize; +b64_pton(const char *src, u_char *target, size_t targsize) { int tarindex, state, ch; + u_char nextbyte; char *pos; state = 0; @@ -226,22 +224,28 @@ b64_pton(src, target, targsize) break; case 1: if (target) { - if ((size_t)tarindex + 1 >= targsize) + if ((size_t)tarindex >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 4; - target[tarindex+1] = ((pos - Base64) & 0x0f) - << 4 ; + nextbyte = ((pos - Base64) & 0x0f) << 4; + if ((size_t)tarindex + 1 < targsize) + target[tarindex + 1] = nextbyte; + else if (nextbyte) + return (-1); } tarindex++; state = 2; break; case 2: if (target) { - if ((size_t)tarindex + 1 >= targsize) + if ((size_t)tarindex >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 2; - target[tarindex+1] = ((pos - Base64) & 0x03) - << 6; + nextbyte = ((pos - Base64) & 0x03) << 6; + if ((size_t)tarindex + 1 < targsize) + target[tarindex + 1] = nextbyte; + else if (nextbyte) + return (-1); } tarindex++; state = 3; @@ -299,7 +303,8 @@ b64_pton(src, target, targsize) * zeros. If we don't check them, they become a * subliminal channel. */ - if (target && target[tarindex] != 0) + if (target && (size_t)tarindex < targsize && + target[tarindex] != 0) return (-1); } } else { diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c index d9ed76c..bb3077f 100644 --- a/lib/libc/net/eui64.c +++ b/lib/libc/net/eui64.c @@ -132,6 +132,7 @@ eui64_line(const char *l, struct eui64 *e, char *hostname, size_t len) goto bad; } + free(linehead); return (0); bad: diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index 5d03aab..570fc2e 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -237,8 +237,8 @@ pointer in each .Li addrinfo structure until a null pointer is encountered. The three members -.Fa ai_family, -.Fa ai_socktype, +.Fa ai_family , +.Fa ai_socktype , and .Fa ai_protocol in each returned diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index c50374e..17c9b65 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$"); #include <ifaddrs.h> #include <sys/queue.h> #ifdef INET6 -#include <net/if_var.h> #include <sys/sysctl.h> #include <sys/ioctl.h> #include <netinet6/in6_var.h> diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3 index ff3f774..b0b17bb 100644 --- a/lib/libc/net/getifaddrs.3 +++ b/lib/libc/net/getifaddrs.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 21, 2013 +.Dd November 25, 2014 .Dt GETIFADDRS 3 .Os .Sh NAME @@ -110,19 +110,17 @@ if one exists, otherwise it is NULL. .Pp The .Li ifa_data -field references address family specific data. -For -.Dv AF_LINK -addresses it contains a pointer to the +field references address family specific data +in a pointer to the .Fa struct if_data (as defined in include file -.In net/if.h ) -which contains various interface attributes and statistics. -For all other address families, it contains a pointer to the -.Fa struct ifa_data -(as defined in include file -.In net/if.h ) -which contains per-address interface statistics. +.In net/if.h ) . +For +.Dv AF_LINK +addresses, +it contains various interface attributes and statistics. +For all other address families, +it contains per-address interface statistics. .Pp The data returned by .Fn getifaddrs diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c index a467758..2f0c51d 100644 --- a/lib/libc/net/ip6opt.c +++ b/lib/libc/net/ip6opt.c @@ -419,7 +419,7 @@ inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, * The option data length must have a value between 0 and 255, * inclusive, and is the length of the option data that follows. */ - if (len < 0 || len > 255) + if (len > 255 || len < 0 ) return(-1); /* diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 97880a2..89effe6 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -94,7 +94,6 @@ __FBSDID("$FreeBSD$"); #include <netinet/in.h> #ifdef INET6 #include <net/if.h> -#include <net/if_var.h> #include <sys/sysctl.h> #include <sys/ioctl.h> #include <netinet6/in6_var.h> /* XXX */ diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c index c23315c..4de1df3 100644 --- a/lib/libc/net/nsdispatch.c +++ b/lib/libc/net/nsdispatch.c @@ -132,14 +132,17 @@ static void *nss_cache_cycle_prevention_func = NULL; #endif /* - * When this is set to 1, nsdispatch won't use nsswitch.conf - * but will consult the 'defaults' source list only. - * NOTE: nested fallbacks (when nsdispatch calls fallback functions, - * which in turn calls nsdispatch, which should call fallback - * function) are not supported + * We keep track of nsdispatch() nesting depth in dispatch_depth. When a + * fallback method is invoked from nsdispatch(), we temporarily set + * fallback_depth to the current dispatch depth plus one. Subsequent + * calls at that exact depth will run in fallback mode (restricted to the + * same source as the call that was handled by the fallback method), while + * calls below that depth will be handled normally, allowing fallback + * methods to perform arbitrary lookups. */ struct fb_state { - int fb_dispatch; + int dispatch_depth; + int fallback_depth; }; static void fb_endstate(void *); NSS_TLS_HANDLING(fb); @@ -613,6 +616,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, void *mdata; int isthreaded, serrno, i, result, srclistsize; struct fb_state *st; + int saved_depth; #ifdef NS_CACHING nss_cache_data cache_data; @@ -644,7 +648,8 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, result = NS_UNAVAIL; goto fin; } - if (st->fb_dispatch == 0) { + ++st->dispatch_depth; + if (st->dispatch_depth > st->fallback_depth) { dbt = vector_search(&database, _nsmap, _nsmapsize, sizeof(*_nsmap), string_compare); fb_method = nss_method_lookup(NSSRC_FALLBACK, database, @@ -713,12 +718,13 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, break; } else { if (fb_method != NULL) { - st->fb_dispatch = 1; + saved_depth = st->fallback_depth; + st->fallback_depth = st->dispatch_depth + 1; va_start(ap, defaults); result = fb_method(retval, (void *)srclist[i].name, ap); va_end(ap); - st->fb_dispatch = 0; + st->fallback_depth = saved_depth; } else nss_log(LOG_DEBUG, "%s, %s, %s, not found, " "and no fallback provided", @@ -750,6 +756,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, if (isthreaded) (void)_pthread_rwlock_unlock(&nss_lock); + --st->dispatch_depth; fin: errno = serrno; return (result); diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c index f71d478..6a584ca 100644 --- a/lib/libc/net/recv.c +++ b/lib/libc/net/recv.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> +#include "libc_private.h" #include <stddef.h> @@ -48,5 +49,8 @@ recv(s, buf, len, flags) * 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)); + return (((ssize_t (*)(int, void *, size_t, int, + struct sockaddr *, socklen_t *)) + __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags, + NULL, NULL)); } diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3 index e3ced9c..945797d 100644 --- a/lib/libc/net/sctp_recvmsg.3 +++ b/lib/libc/net/sctp_recvmsg.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 13, 2007 +.Dd April 23, 2015 .Dt SCTP_RECVMSG 3 .Os .Sh NAME @@ -98,13 +98,13 @@ receive buffer, then the argument will .Em not have the -.Dv MSG_EOF +.Dv MSG_EOR flag applied. If the message is a complete message then the .Fa flags argument will have -.Dv MSG_EOF +.Dv MSG_EOR set. Locally detected errors are indicated by a return value of -1 with @@ -282,12 +282,12 @@ This typically means that the socket is not connected and is a one-to-one style socket. .El .Sh SEE ALSO +.Xr getsockopt 2 , .Xr recv 2 , .Xr select 2 , +.Xr setsockopt 2 , .Xr socket 2 , .Xr write 2 , -.Xr getsockopt 2 , -.Xr setsockopt 2 , .Xr sctp_send 3 , .Xr sctp_sendmsg 3 , .Xr sendmsg 3 , diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3 index 37b0b71..9c7f833 100644 --- a/lib/libc/net/sctp_send.3 +++ b/lib/libc/net/sctp_send.3 @@ -337,7 +337,7 @@ is not connected and is a one-to-one style socket. .Xr select 2 , .Xr sendmsg 2 , .Xr socket 2 , -.Xr write 2 +.Xr write 2 , .Xr sctp_connectx 3 , .Xr sctp_recvmsg 3 , .Xr sctp_sendmsg 3 , diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 91527c3..f07aa43 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -383,6 +383,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size) case SCTP_PR_ASSOC_STATUS: ((struct sctp_prstatus *)arg)->sprstat_assoc_id = id; break; + case SCTP_MAX_CWND: + ((struct sctp_assoc_value *)arg)->assoc_id = id; + break; default: break; } @@ -597,6 +600,7 @@ sctp_sendmsg(int s, msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + msg.msg_flags = 0; cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; @@ -663,6 +667,7 @@ sctp_send(int sd, const void *data, size_t len, msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + msg.msg_flags = 0; cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; @@ -820,7 +825,6 @@ sctp_recvmsg(int s, errno = EINVAL; return (-1); } - msg.msg_flags = 0; iov.iov_base = dbuf; iov.iov_len = len; msg.msg_name = (caddr_t)from; @@ -832,6 +836,7 @@ sctp_recvmsg(int s, msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); + msg.msg_flags = 0; sz = recvmsg(s, &msg, *msg_flags); *msg_flags = msg.msg_flags; if (sz <= 0) { @@ -886,7 +891,7 @@ sctp_recvv(int sd, struct sctp_rcvinfo *rcvinfo; struct sctp_nxtinfo *nxtinfo; - if (((info != NULL) && (infolen == NULL)) | + if (((info != NULL) && (infolen == NULL)) || ((info == NULL) && (infolen != NULL) && (*infolen != 0)) || ((info != NULL) && (infotype == NULL))) { errno = EINVAL; @@ -905,6 +910,7 @@ sctp_recvv(int sd, msg.msg_iovlen = iovlen; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); + msg.msg_flags = 0; ret = recvmsg(sd, &msg, *flags); *flags = msg.msg_flags; if ((ret > 0) && diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c index 93cdfda..c44f4b9 100644 --- a/lib/libc/net/send.c +++ b/lib/libc/net/send.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> +#include "libc_private.h" #include <stddef.h> @@ -48,5 +49,8 @@ send(s, msg, len, flags) * 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)); + return (((ssize_t (*)(int, const void *, size_t, int, + const struct sockaddr *, socklen_t)) + __libc_interposing[INTERPOS_sendto])(s, msg, len, flags, + NULL, 0)); } diff --git a/lib/libc/nls/catopen.3 b/lib/libc/nls/catopen.3 index 7a16ee5..7744b0b 100644 --- a/lib/libc/nls/catopen.3 +++ b/lib/libc/nls/catopen.3 @@ -94,7 +94,7 @@ An empty string is substituted for undefined values. Path names templates defined in .Ev NLSPATH are separated by colons -.No ( Sq \&: ) . +.Pq Sq \&: . A leading or two adjacent colons is equivalent to specifying %N. .Pp diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index 2859916..0cba460 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); np->name = strdup(n); \ np->path = NULL; \ np->catd = NLERR; \ + np->refcount = 0; \ np->lang = (l == NULL) ? NULL : \ strdup(l); \ np->caterrno = e; \ diff --git a/lib/libc/posix1e/acl_calc_mask.c b/lib/libc/posix1e/acl_calc_mask.c index a2d1527..56215b9 100644 --- a/lib/libc/posix1e/acl_calc_mask.c +++ b/lib/libc/posix1e/acl_calc_mask.c @@ -104,6 +104,7 @@ acl_calc_mask(acl_t *acl_p) /* if no mask exists, check acl_cnt... */ if (acl_int_new->acl_cnt == ACL_MAX_ENTRIES) { errno = ENOMEM; + acl_free(acl_new); return (-1); } /* ...and add the mask entry */ diff --git a/lib/libc/posix1e/acl_set_flagset_np.3 b/lib/libc/posix1e/acl_set_flagset_np.3 index 2230c48..685680d 100644 --- a/lib/libc/posix1e/acl_set_flagset_np.3 +++ b/lib/libc/posix1e/acl_set_flagset_np.3 @@ -64,9 +64,9 @@ ACL is already branded as POSIX.1e. .Sh SEE ALSO .Xr acl 3 , .Xr acl_add_flag_np 3 , -.Xr acl_get_brand_np 3 , .Xr acl_clear_flags_np 3 , .Xr acl_delete_flag_np 3 , +.Xr acl_get_brand_np 3 , .Xr acl_get_flagset_np 3 , .Xr posix1e 3 .Sh STANDARDS diff --git a/lib/libc/posix1e/acl_strip.c b/lib/libc/posix1e/acl_strip.c index ae37b38..85dfb47 100644 --- a/lib/libc/posix1e/acl_strip.c +++ b/lib/libc/posix1e/acl_strip.c @@ -82,8 +82,10 @@ _posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) have_mask_entry = 0; acl_new = acl_init(ACL_MAX_ENTRIES); - if (acl_new == NULL) + if (acl_new == NULL) { + acl_free(acl_old); return (NULL); + } tag = ACL_UNDEFINED_TAG; /* only save the default user/group/other entries */ @@ -94,16 +96,16 @@ _posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) assert(_entry_brand(entry) == ACL_BRAND_POSIX); if (acl_get_tag_type(entry, &tag) == -1) - return (NULL); + goto fail; switch(tag) { case ACL_USER_OBJ: case ACL_GROUP_OBJ: case ACL_OTHER: if (acl_get_tag_type(entry, &tag) == -1) - return (NULL); + goto fail; if (acl_get_permset(entry, &perm) == -1) - return (NULL); + goto fail; if (acl_create_entry(&acl_new, &entry_new) == -1) return (NULL); if (acl_set_tag_type(entry_new, tag) == -1) @@ -120,6 +122,10 @@ _posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) default: break; } +fail: + acl_free(acl_new); + acl_free(acl_old); + return (NULL); } assert(_acl_brand(acl_new) == ACL_BRAND_POSIX); diff --git a/lib/libc/powerpc/Makefile.inc b/lib/libc/powerpc/Makefile.inc index f378780..42982671 100644 --- a/lib/libc/powerpc/Makefile.inc +++ b/lib/libc/powerpc/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= trivial-vdso_tc.c # Long double is 64-bits MDSRCS+=machdep_ldisd.c diff --git a/lib/libc/powerpc/gen/Makefile.inc b/lib/libc/powerpc/gen/Makefile.inc index 81c6a69..2a00ba3 100644 --- a/lib/libc/powerpc/gen/Makefile.inc +++ b/lib/libc/powerpc/gen/Makefile.inc @@ -1,9 +1,11 @@ # $FreeBSD$ SRCS += _ctx_start.S eabi.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \ - fpgetsticky.c fpsetmask.c fpsetround.c getcontextx.c \ + fpgetsticky.c fpsetmask.c fpsetround.c \ infinity.c ldexp.c makecontext.c _setjmp.S \ setjmp.S sigsetjmp.S signalcontext.c syncicache.c \ - _set_tp.c + _set_tp.c \ + trivial-getcontextx.c + diff --git a/lib/libc/powerpc/gen/_set_tp.c b/lib/libc/powerpc/gen/_set_tp.c index 5a89698..aa1150a 100644 --- a/lib/libc/powerpc/gen/_set_tp.c +++ b/lib/libc/powerpc/gen/_set_tp.c @@ -29,7 +29,6 @@ void _set_tp(void *tpval) { - register void *tp __asm__("r2"); - __asm __volatile("mr %0,%1" : "=r"(tp) : "r"((char*)tpval + 0x7008)); + __asm __volatile("mr 2,%0" :: "r"((char*)tpval + 0x7008)); } diff --git a/lib/libc/powerpc/gen/_setjmp.S b/lib/libc/powerpc/gen/_setjmp.S index e28386c..663a8b6 100644 --- a/lib/libc/powerpc/gen/_setjmp.S +++ b/lib/libc/powerpc/gen/_setjmp.S @@ -56,12 +56,54 @@ ENTRY(_setjmp) mr %r10,%r1 mr %r9,%r2 stmw %r9,20(%r3) + + /* FPRs */ + stfd %f14,112+0*8(%r3) + stfd %f15,112+1*8(%r3) + stfd %f16,112+2*8(%r3) + stfd %f17,112+3*8(%r3) + stfd %f18,112+4*8(%r3) + stfd %f19,112+5*8(%r3) + stfd %f20,112+6*8(%r3) + stfd %f21,112+7*8(%r3) + stfd %f22,112+8*8(%r3) + stfd %f23,112+9*8(%r3) + stfd %f24,112+10*8(%r3) + stfd %f25,112+11*8(%r3) + stfd %f26,112+12*8(%r3) + stfd %f27,112+13*8(%r3) + stfd %f28,112+14*8(%r3) + stfd %f29,112+15*8(%r3) + stfd %f30,112+16*8(%r3) + stfd %f31,112+17*8(%r3) + li %r3,0 blr END(_setjmp) ENTRY(_longjmp) lmw %r9,20(%r3) + + /* FPRs */ + lfd %f14,112+0*8(%r3) + lfd %f15,112+1*8(%r3) + lfd %f16,112+2*8(%r3) + lfd %f17,112+3*8(%r3) + lfd %f18,112+4*8(%r3) + lfd %f19,112+5*8(%r3) + lfd %f20,112+6*8(%r3) + lfd %f21,112+7*8(%r3) + lfd %f22,112+8*8(%r3) + lfd %f23,112+9*8(%r3) + lfd %f24,112+10*8(%r3) + lfd %f25,112+11*8(%r3) + lfd %f26,112+12*8(%r3) + lfd %f27,112+13*8(%r3) + lfd %f28,112+14*8(%r3) + lfd %f29,112+15*8(%r3) + lfd %f30,112+16*8(%r3) + lfd %f31,112+17*8(%r3) + mtlr %r11 mtcr %r12 mr %r1,%r10 diff --git a/lib/libc/powerpc/gen/getcontextx.c b/lib/libc/powerpc/gen/getcontextx.c deleted file mode 100644 index 54f8513..0000000 --- a/lib/libc/powerpc/gen/getcontextx.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/ucontext.h> -#include <errno.h> -#include <stdlib.h> - -int -__getcontextx_size(void) -{ - - return (sizeof(ucontext_t)); -} - -int -__fillcontextx2(char *ctx) -{ - - return (0); -} - -int -__fillcontextx(char *ctx) -{ - ucontext_t *ucp; - - ucp = (ucontext_t *)ctx; - return (getcontext(ucp)); -} - -__weak_reference(__getcontextx, getcontextx); - -ucontext_t * -__getcontextx(void) -{ - char *ctx; - int error; - - ctx = malloc(__getcontextx_size()); - if (ctx == NULL) - return (NULL); - if (__fillcontextx(ctx) == -1) { - error = errno; - free(ctx); - errno = error; - return (NULL); - } - return ((ucontext_t *)ctx); -} diff --git a/lib/libc/powerpc/gen/setjmp.S b/lib/libc/powerpc/gen/setjmp.S index 9325fc2..ef7cb7e 100644 --- a/lib/libc/powerpc/gen/setjmp.S +++ b/lib/libc/powerpc/gen/setjmp.S @@ -66,6 +66,27 @@ ENTRY(setjmp) mr %r10,%r1 /* r10 <- stackptr */ mr %r9,%r2 /* r9 <- global ptr */ stmw %r9,20(%r6) + + /* FPRs */ + stfd %f14,112+0*8(%r6) + stfd %f15,112+1*8(%r6) + stfd %f16,112+2*8(%r6) + stfd %f17,112+3*8(%r6) + stfd %f18,112+4*8(%r6) + stfd %f19,112+5*8(%r6) + stfd %f20,112+6*8(%r6) + stfd %f21,112+7*8(%r6) + stfd %f22,112+8*8(%r6) + stfd %f23,112+9*8(%r6) + stfd %f24,112+10*8(%r6) + stfd %f25,112+11*8(%r6) + stfd %f26,112+12*8(%r6) + stfd %f27,112+13*8(%r6) + stfd %f28,112+14*8(%r6) + stfd %f29,112+15*8(%r6) + stfd %f30,112+16*8(%r6) + stfd %f31,112+17*8(%r6) + li %r3,0 /* return (0) */ blr END(setjmp) @@ -73,6 +94,27 @@ END(setjmp) WEAK_REFERENCE(CNAME(__longjmp), longjmp) ENTRY(__longjmp) lmw %r9,20(%r3) /* restore regs */ + + /* FPRs */ + lfd %f14,112+0*8(%r3) + lfd %f15,112+1*8(%r3) + lfd %f16,112+2*8(%r3) + lfd %f17,112+3*8(%r3) + lfd %f18,112+4*8(%r3) + lfd %f19,112+5*8(%r3) + lfd %f20,112+6*8(%r3) + lfd %f21,112+7*8(%r3) + lfd %f22,112+8*8(%r3) + lfd %f23,112+9*8(%r3) + lfd %f24,112+10*8(%r3) + lfd %f25,112+11*8(%r3) + lfd %f26,112+12*8(%r3) + lfd %f27,112+13*8(%r3) + lfd %f28,112+14*8(%r3) + lfd %f29,112+15*8(%r3) + lfd %f30,112+16*8(%r3) + lfd %f31,112+17*8(%r3) + mr %r6,%r4 /* save val param */ mtlr %r11 /* r11 -> link reg */ mtcr %r12 /* r12 -> condition reg */ diff --git a/lib/libc/powerpc/gen/sigsetjmp.S b/lib/libc/powerpc/gen/sigsetjmp.S index c67afc6..9c75f4f 100644 --- a/lib/libc/powerpc/gen/sigsetjmp.S +++ b/lib/libc/powerpc/gen/sigsetjmp.S @@ -71,12 +71,54 @@ ENTRY(sigsetjmp) mr %r10,%r1 mr %r9,%r2 stmw %r9,20(%r6) + + /* FPRs */ + stfd %f14,112+0*8(%r6) + stfd %f15,112+1*8(%r6) + stfd %f16,112+2*8(%r6) + stfd %f17,112+3*8(%r6) + stfd %f18,112+4*8(%r6) + stfd %f19,112+5*8(%r6) + stfd %f20,112+6*8(%r6) + stfd %f21,112+7*8(%r6) + stfd %f22,112+8*8(%r6) + stfd %f23,112+9*8(%r6) + stfd %f24,112+10*8(%r6) + stfd %f25,112+11*8(%r6) + stfd %f26,112+12*8(%r6) + stfd %f27,112+13*8(%r6) + stfd %f28,112+14*8(%r6) + stfd %f29,112+15*8(%r6) + stfd %f30,112+16*8(%r6) + stfd %f31,112+17*8(%r6) + li %r3,0 blr END(sigsetjmp) ENTRY(siglongjmp) lmw %r9,20(%r3) + + /* FPRs */ + lfd %f14,112+0*8(%r3) + lfd %f15,112+1*8(%r3) + lfd %f16,112+2*8(%r3) + lfd %f17,112+3*8(%r3) + lfd %f18,112+4*8(%r3) + lfd %f19,112+5*8(%r3) + lfd %f20,112+6*8(%r3) + lfd %f21,112+7*8(%r3) + lfd %f22,112+8*8(%r3) + lfd %f23,112+9*8(%r3) + lfd %f24,112+10*8(%r3) + lfd %f25,112+11*8(%r3) + lfd %f26,112+12*8(%r3) + lfd %f27,112+13*8(%r3) + lfd %f28,112+14*8(%r3) + lfd %f29,112+15*8(%r3) + lfd %f30,112+16*8(%r3) + lfd %f31,112+17*8(%r3) + lwz %r7,0(%r3) mr %r6,%r4 mtlr %r11 diff --git a/lib/libc/powerpc/sys/Makefile.inc b/lib/libc/powerpc/sys/Makefile.inc index ad98ba1..98ec888 100644 --- a/lib/libc/powerpc/sys/Makefile.inc +++ b/lib/libc/powerpc/sys/Makefile.inc @@ -6,6 +6,3 @@ MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o PSEUDO= _getlogin.o _exit.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif diff --git a/lib/libc/powerpc64/Makefile.inc b/lib/libc/powerpc64/Makefile.inc index 2a080f6..8e9bcc5 100644 --- a/lib/libc/powerpc64/Makefile.inc +++ b/lib/libc/powerpc64/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c +SRCS+= trivial-vdso_tc.c # Long double is 64-bits MDSRCS+=machdep_ldisd.c diff --git a/lib/libc/powerpc64/gen/Makefile.inc b/lib/libc/powerpc64/gen/Makefile.inc index 79a2746..864fb9e 100644 --- a/lib/libc/powerpc64/gen/Makefile.inc +++ b/lib/libc/powerpc64/gen/Makefile.inc @@ -1,9 +1,10 @@ # $FreeBSD$ SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \ - fpgetsticky.c fpsetmask.c fpsetround.c getcontextx.c \ + fpgetsticky.c fpsetmask.c fpsetround.c \ infinity.c ldexp.c makecontext.c _setjmp.S \ setjmp.S sigsetjmp.S signalcontext.c syncicache.c \ - _set_tp.c + _set_tp.c \ + trivial-getcontextx.c diff --git a/lib/libc/powerpc64/gen/_set_tp.c b/lib/libc/powerpc64/gen/_set_tp.c index 9adb6a5..32137e5 100644 --- a/lib/libc/powerpc64/gen/_set_tp.c +++ b/lib/libc/powerpc64/gen/_set_tp.c @@ -29,7 +29,6 @@ void _set_tp(void *tpval) { - register void *tp __asm__("r13"); - __asm __volatile("mr %0,%1" : "=r"(tp) : "r"((char*)tpval + 0x7010)); + __asm __volatile("mr 13,%0" :: "r"((char*)tpval + 0x7010)); } diff --git a/lib/libc/powerpc64/gen/_setjmp.S b/lib/libc/powerpc64/gen/_setjmp.S index 207c4f7..f7689ae 100644 --- a/lib/libc/powerpc64/gen/_setjmp.S +++ b/lib/libc/powerpc64/gen/_setjmp.S @@ -56,23 +56,41 @@ ENTRY(_setjmp) mr %r10,%r1 mr %r9,%r2 std %r9,40 + 0*8(%r3) + stfd %f14,40 + 23*8(%r3) std %r10,40 + 1*8(%r3) + stfd %f15,40 + 24*8(%r3) std %r11,40 + 2*8(%r3) + stfd %f16,40 + 25*8(%r3) std %r12,40 + 3*8(%r3) + stfd %f17,40 + 26*8(%r3) std %r13,40 + 4*8(%r3) + stfd %f18,40 + 27*8(%r3) std %r14,40 + 5*8(%r3) + stfd %f19,40 + 28*8(%r3) std %r15,40 + 6*8(%r3) + stfd %f20,40 + 29*8(%r3) std %r16,40 + 7*8(%r3) + stfd %f21,40 + 30*8(%r3) std %r17,40 + 8*8(%r3) + stfd %f22,40 + 31*8(%r3) std %r18,40 + 9*8(%r3) + stfd %f23,40 + 32*8(%r3) std %r19,40 + 10*8(%r3) + stfd %f24,40 + 33*8(%r3) std %r20,40 + 11*8(%r3) + stfd %f25,40 + 34*8(%r3) std %r21,40 + 12*8(%r3) + stfd %f26,40 + 35*8(%r3) std %r22,40 + 13*8(%r3) + stfd %f27,40 + 36*8(%r3) std %r23,40 + 14*8(%r3) + stfd %f28,40 + 37*8(%r3) std %r24,40 + 15*8(%r3) + stfd %f29,40 + 38*8(%r3) std %r25,40 + 16*8(%r3) + stfd %f30,40 + 39*8(%r3) std %r26,40 + 17*8(%r3) + stfd %f31,40 + 40*8(%r3) std %r27,40 + 18*8(%r3) std %r28,40 + 19*8(%r3) std %r29,40 + 20*8(%r3) @@ -84,23 +102,41 @@ END(_setjmp) ENTRY(_longjmp) ld %r9,40 + 0*8(%r3) + lfd %f14,40 + 23*8(%r3) ld %r10,40 + 1*8(%r3) + lfd %f15,40 + 24*8(%r3) ld %r11,40 + 2*8(%r3) + lfd %f16,40 + 25*8(%r3) ld %r12,40 + 3*8(%r3) + lfd %f17,40 + 26*8(%r3) ld %r14,40 + 5*8(%r3) + lfd %f18,40 + 27*8(%r3) ld %r15,40 + 6*8(%r3) + lfd %f19,40 + 28*8(%r3) ld %r16,40 + 7*8(%r3) + lfd %f20,40 + 29*8(%r3) ld %r17,40 + 8*8(%r3) + lfd %f21,40 + 30*8(%r3) ld %r18,40 + 9*8(%r3) + lfd %f22,40 + 31*8(%r3) ld %r19,40 + 10*8(%r3) + lfd %f23,40 + 32*8(%r3) ld %r20,40 + 11*8(%r3) + lfd %f24,40 + 33*8(%r3) ld %r21,40 + 12*8(%r3) + lfd %f25,40 + 34*8(%r3) ld %r22,40 + 13*8(%r3) + lfd %f26,40 + 35*8(%r3) ld %r23,40 + 14*8(%r3) + lfd %f27,40 + 36*8(%r3) ld %r24,40 + 15*8(%r3) + lfd %f28,40 + 37*8(%r3) ld %r25,40 + 16*8(%r3) + lfd %f29,40 + 38*8(%r3) ld %r26,40 + 17*8(%r3) + lfd %f30,40 + 39*8(%r3) ld %r27,40 + 18*8(%r3) + lfd %f31,40 + 40*8(%r3) ld %r28,40 + 19*8(%r3) ld %r29,40 + 20*8(%r3) ld %r30,40 + 21*8(%r3) diff --git a/lib/libc/powerpc64/gen/getcontextx.c b/lib/libc/powerpc64/gen/getcontextx.c deleted file mode 100644 index 54f8513..0000000 --- a/lib/libc/powerpc64/gen/getcontextx.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/ucontext.h> -#include <errno.h> -#include <stdlib.h> - -int -__getcontextx_size(void) -{ - - return (sizeof(ucontext_t)); -} - -int -__fillcontextx2(char *ctx) -{ - - return (0); -} - -int -__fillcontextx(char *ctx) -{ - ucontext_t *ucp; - - ucp = (ucontext_t *)ctx; - return (getcontext(ucp)); -} - -__weak_reference(__getcontextx, getcontextx); - -ucontext_t * -__getcontextx(void) -{ - char *ctx; - int error; - - ctx = malloc(__getcontextx_size()); - if (ctx == NULL) - return (NULL); - if (__fillcontextx(ctx) == -1) { - error = errno; - free(ctx); - errno = error; - return (NULL); - } - return ((ucontext_t *)ctx); -} diff --git a/lib/libc/powerpc64/gen/setjmp.S b/lib/libc/powerpc64/gen/setjmp.S index 1495466..5eb395e 100644 --- a/lib/libc/powerpc64/gen/setjmp.S +++ b/lib/libc/powerpc64/gen/setjmp.S @@ -67,29 +67,49 @@ ENTRY(setjmp) mr %r9,%r2 /* r9 <- global ptr */ std %r9,40 + 0*8(%r6) + stfd %f14,40 + 23*8(%r6) std %r10,40 + 1*8(%r6) + stfd %f15,40 + 24*8(%r6) std %r11,40 + 2*8(%r6) + stfd %f16,40 + 25*8(%r6) std %r12,40 + 3*8(%r6) + stfd %f17,40 + 26*8(%r6) std %r13,40 + 4*8(%r6) + stfd %f18,40 + 27*8(%r6) std %r14,40 + 5*8(%r6) + stfd %f19,40 + 28*8(%r6) std %r15,40 + 6*8(%r6) + stfd %f20,40 + 29*8(%r6) std %r16,40 + 7*8(%r6) + stfd %f21,40 + 30*8(%r6) std %r17,40 + 8*8(%r6) + stfd %f22,40 + 31*8(%r6) std %r18,40 + 9*8(%r6) + stfd %f23,40 + 32*8(%r6) std %r19,40 + 10*8(%r6) + stfd %f24,40 + 33*8(%r6) std %r20,40 + 11*8(%r6) + stfd %f25,40 + 34*8(%r6) std %r21,40 + 12*8(%r6) + stfd %f26,40 + 35*8(%r6) std %r22,40 + 13*8(%r6) + stfd %f27,40 + 36*8(%r6) std %r23,40 + 14*8(%r6) + stfd %f28,40 + 37*8(%r6) std %r24,40 + 15*8(%r6) + stfd %f29,40 + 38*8(%r6) std %r25,40 + 16*8(%r6) + stfd %f30,40 + 39*8(%r6) std %r26,40 + 17*8(%r6) + stfd %f31,40 + 40*8(%r6) std %r27,40 + 18*8(%r6) std %r28,40 + 19*8(%r6) std %r29,40 + 20*8(%r6) std %r30,40 + 21*8(%r6) std %r31,40 + 22*8(%r6) + /* XXX Altivec regs */ + li %r3,0 /* return (0) */ blr END(setjmp) @@ -97,23 +117,41 @@ END(setjmp) WEAK_REFERENCE(__longjmp, longjmp) ENTRY(__longjmp) ld %r9,40 + 0*8(%r3) + lfd %f14,40 + 23*8(%r3) ld %r10,40 + 1*8(%r3) + lfd %f15,40 + 24*8(%r3) ld %r11,40 + 2*8(%r3) + lfd %f16,40 + 25*8(%r3) ld %r12,40 + 3*8(%r3) + lfd %f17,40 + 26*8(%r3) ld %r14,40 + 5*8(%r3) + lfd %f18,40 + 27*8(%r3) ld %r15,40 + 6*8(%r3) + lfd %f19,40 + 28*8(%r3) ld %r16,40 + 7*8(%r3) + lfd %f20,40 + 29*8(%r3) ld %r17,40 + 8*8(%r3) + lfd %f21,40 + 30*8(%r3) ld %r18,40 + 9*8(%r3) + lfd %f22,40 + 31*8(%r3) ld %r19,40 + 10*8(%r3) + lfd %f23,40 + 32*8(%r3) ld %r20,40 + 11*8(%r3) + lfd %f24,40 + 33*8(%r3) ld %r21,40 + 12*8(%r3) + lfd %f25,40 + 34*8(%r3) ld %r22,40 + 13*8(%r3) + lfd %f26,40 + 35*8(%r3) ld %r23,40 + 14*8(%r3) + lfd %f27,40 + 36*8(%r3) ld %r24,40 + 15*8(%r3) + lfd %f28,40 + 37*8(%r3) ld %r25,40 + 16*8(%r3) + lfd %f29,40 + 38*8(%r3) ld %r26,40 + 17*8(%r3) + lfd %f30,40 + 39*8(%r3) ld %r27,40 + 18*8(%r3) + lfd %f31,40 + 40*8(%r3) ld %r28,40 + 19*8(%r3) ld %r29,40 + 20*8(%r3) ld %r30,40 + 21*8(%r3) diff --git a/lib/libc/powerpc64/gen/sigsetjmp.S b/lib/libc/powerpc64/gen/sigsetjmp.S index 5cfd684..c0648a6 100644 --- a/lib/libc/powerpc64/gen/sigsetjmp.S +++ b/lib/libc/powerpc64/gen/sigsetjmp.S @@ -72,23 +72,41 @@ ENTRY(sigsetjmp) mr %r9,%r2 std %r9,40 + 0*8(%r6) + stfd %f14,40 + 23*8(%r6) std %r10,40 + 1*8(%r6) + stfd %f15,40 + 24*8(%r6) std %r11,40 + 2*8(%r6) + stfd %f16,40 + 25*8(%r6) std %r12,40 + 3*8(%r6) + stfd %f17,40 + 26*8(%r6) std %r13,40 + 4*8(%r6) + stfd %f18,40 + 27*8(%r6) std %r14,40 + 5*8(%r6) + stfd %f19,40 + 28*8(%r6) std %r15,40 + 6*8(%r6) + stfd %f20,40 + 29*8(%r6) std %r16,40 + 7*8(%r6) + stfd %f21,40 + 30*8(%r6) std %r17,40 + 8*8(%r6) + stfd %f22,40 + 31*8(%r6) std %r18,40 + 9*8(%r6) + stfd %f23,40 + 32*8(%r6) std %r19,40 + 10*8(%r6) + stfd %f24,40 + 33*8(%r6) std %r20,40 + 11*8(%r6) + stfd %f25,40 + 34*8(%r6) std %r21,40 + 12*8(%r6) + stfd %f26,40 + 35*8(%r6) std %r22,40 + 13*8(%r6) + stfd %f27,40 + 36*8(%r6) std %r23,40 + 14*8(%r6) + stfd %f28,40 + 37*8(%r6) std %r24,40 + 15*8(%r6) + stfd %f29,40 + 38*8(%r6) std %r25,40 + 16*8(%r6) + stfd %f30,40 + 39*8(%r6) std %r26,40 + 17*8(%r6) + stfd %f31,40 + 40*8(%r6) std %r27,40 + 18*8(%r6) std %r28,40 + 19*8(%r6) std %r29,40 + 20*8(%r6) @@ -101,23 +119,41 @@ END(sigsetjmp) ENTRY(siglongjmp) ld %r9,40 + 0*8(%r3) + lfd %f14,40 + 23*8(%r3) ld %r10,40 + 1*8(%r3) + lfd %f15,40 + 24*8(%r3) ld %r11,40 + 2*8(%r3) + lfd %f16,40 + 25*8(%r3) ld %r12,40 + 3*8(%r3) + lfd %f17,40 + 26*8(%r3) ld %r14,40 + 5*8(%r3) + lfd %f18,40 + 27*8(%r3) ld %r15,40 + 6*8(%r3) + lfd %f19,40 + 28*8(%r3) ld %r16,40 + 7*8(%r3) + lfd %f20,40 + 29*8(%r3) ld %r17,40 + 8*8(%r3) + lfd %f21,40 + 30*8(%r3) ld %r18,40 + 9*8(%r3) + lfd %f22,40 + 31*8(%r3) ld %r19,40 + 10*8(%r3) + lfd %f23,40 + 32*8(%r3) ld %r20,40 + 11*8(%r3) + lfd %f24,40 + 33*8(%r3) ld %r21,40 + 12*8(%r3) + lfd %f25,40 + 34*8(%r3) ld %r22,40 + 13*8(%r3) + lfd %f26,40 + 35*8(%r3) ld %r23,40 + 14*8(%r3) + lfd %f27,40 + 36*8(%r3) ld %r24,40 + 15*8(%r3) + lfd %f28,40 + 37*8(%r3) ld %r25,40 + 16*8(%r3) + lfd %f29,40 + 38*8(%r3) ld %r26,40 + 17*8(%r3) + lfd %f30,40 + 39*8(%r3) ld %r27,40 + 18*8(%r3) + lfd %f31,40 + 40*8(%r3) ld %r28,40 + 19*8(%r3) ld %r29,40 + 20*8(%r3) ld %r30,40 + 21*8(%r3) diff --git a/lib/libc/powerpc64/sys/Makefile.inc b/lib/libc/powerpc64/sys/Makefile.inc index ad98ba1..98ec888 100644 --- a/lib/libc/powerpc64/sys/Makefile.inc +++ b/lib/libc/powerpc64/sys/Makefile.inc @@ -6,6 +6,3 @@ MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o PSEUDO= _getlogin.o _exit.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 589bb9d..436370d 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -157,7 +157,7 @@ matcher(struct re_guts *g, int i; struct match mv; struct match *m = &mv; - const char *dp; + const char *dp = NULL; const sopno gf = g->firststate+1; /* +1 for OEND */ const sopno gl = g->laststate; const char *start; @@ -244,7 +244,7 @@ matcher(struct re_guts *g, ZAPSTATE(&m->mbs); /* Adjust start according to moffset, to speed things up */ - if (g->moffset > -1) + if (dp != NULL && g->moffset > -1) start = ((dp - g->moffset) < start) ? start : dp - g->moffset; SP("mloop", m->st, *start); diff --git a/lib/libc/regex/re_format.7 b/lib/libc/regex/re_format.7 index 05b1494..b3f9561 100644 --- a/lib/libc/regex/re_format.7 +++ b/lib/libc/regex/re_format.7 @@ -314,10 +314,10 @@ compatible with but not specified by .St -p1003.2 , and should be used with caution in software intended to be portable to other systems. -The additional word delimiters +The additional word delimiters .Ql \e< and -.Ql \e> +.Ql \e> are provided to ease compatibility with traditional .Xr svr4 4 systems but are not portable and should be avoided. @@ -392,10 +392,12 @@ and .Ql ?\& are ordinary characters, and their functionality can be expressed using bounds -.No ( Ql {1,} +.Po +.Ql {1,} or .Ql {0,1} -respectively). +respectively +.Pc . Also note that .Ql x+ in modern REs is equivalent to diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index a01bb95..2f2d827 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -192,6 +192,7 @@ regcomp(regex_t * __restrict preg, struct parse *p = &pa; int i; size_t len; + size_t maxlen; #ifdef REDEBUG # define GOODFLAGS(f) (f) #else @@ -213,7 +214,23 @@ regcomp(regex_t * __restrict preg, g = (struct re_guts *)malloc(sizeof(struct re_guts)); if (g == NULL) return(REG_ESPACE); + /* + * Limit the pattern space to avoid a 32-bit overflow on buffer + * extension. Also avoid any signed overflow in case of conversion + * so make the real limit based on a 31-bit overflow. + * + * Likely not applicable on 64-bit systems but handle the case + * generically (who are we to stop people from using ~715MB+ + * patterns?). + */ + maxlen = ((size_t)-1 >> 1) / sizeof(sop) * 2 / 3; + if (len >= maxlen) { + free((char *)g); + return(REG_ESPACE); + } p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ + assert(p->ssize >= len); + p->strip = (sop *)malloc(p->ssize * sizeof(sop)); p->slen = 0; if (p->strip == NULL) { @@ -1405,8 +1422,8 @@ static void findmust(struct parse *p, struct re_guts *g) { sop *scan; - sop *start; - sop *newstart; + sop *start = NULL; + sop *newstart = NULL; sopno newlen; sop s; char *cp; @@ -1709,15 +1726,17 @@ computematchjumps(struct parse *p, struct re_guts *g) if (p->error != 0) return; - pmatches = (int*) malloc(g->mlen * sizeof(unsigned int)); + pmatches = (int*) malloc(g->mlen * sizeof(int)); if (pmatches == NULL) { g->matchjump = NULL; return; } - g->matchjump = (int*) malloc(g->mlen * sizeof(unsigned int)); - if (g->matchjump == NULL) /* Not a fatal error */ + g->matchjump = (int*) malloc(g->mlen * sizeof(int)); + if (g->matchjump == NULL) { /* Not a fatal error */ + free(pmatches); return; + } /* Set maximum possible jump for each character in the pattern */ for (mindex = 0; mindex < g->mlen; mindex++) diff --git a/lib/libc/regex/regex.3 b/lib/libc/regex/regex.3 index ea1ba25..6df2f09 100644 --- a/lib/libc/regex/regex.3 +++ b/lib/libc/regex/regex.3 @@ -420,10 +420,12 @@ it should have been the result from the most recent using that .Ft regex_t . The -.Fn ( regerror +.Po +.Fn regerror may be able to supply a more detailed message using information from the -.Ft regex_t . ) +.Ft regex_t . +.Pc The .Fn regerror function diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index 5feab88..cebbaf9 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -327,7 +327,7 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) struct sockaddr *sa; sigset_t mask; sigset_t newmask; - socklen_t inlen, salen; + socklen_t salen; ssize_t recvlen = 0; int kin_len, n, rpc_lock_value; u_int32_t xid; @@ -520,7 +520,6 @@ get_reply: goto call_again_same_xid; } } - inlen = (socklen_t)recvlen; /* * now decode and validate the response diff --git a/lib/libc/rpc/crypt_client.c b/lib/libc/rpc/crypt_client.c index 4e5c793..5290021 100644 --- a/lib/libc/rpc/crypt_client.c +++ b/lib/libc/rpc/crypt_client.c @@ -64,6 +64,7 @@ _des_crypt_call(buf, len, dparms) } if (nconf == NULL) { warnx("getnetconfig: %s", nc_sperror()); + endnetconfig(localhandle); return(DESERR_HWERROR); } clnt = clnt_tp_create(NULL, CRYPT_PROG, CRYPT_VERS, nconf); diff --git a/lib/libc/rpc/rpc.3 b/lib/libc/rpc/rpc.3 index 4fa3e2c..988b5f1 100644 --- a/lib/libc/rpc/rpc.3 +++ b/lib/libc/rpc/rpc.3 @@ -504,7 +504,6 @@ pages on which they are described: .Sh SEE ALSO .Xr getnetconfig 3 , .Xr getnetpath 3 , -.Xr rpcbind 3 , .Xr rpc_clnt_auth 3 , .Xr rpc_clnt_calls 3 , .Xr rpc_clnt_create 3 , @@ -513,5 +512,6 @@ pages on which they are described: .Xr rpc_svc_err 3 , .Xr rpc_svc_reg 3 , .Xr rpc_xdr 3 , +.Xr rpcbind 3 , .Xr xdr 3 , .Xr netconfig 5 diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c index d7702f5..febc597 100644 --- a/lib/libc/rpc/rpc_soc.c +++ b/lib/libc/rpc/rpc_soc.c @@ -462,12 +462,10 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) u_int recvsz; { struct netbuf *svcaddr; - struct netconfig *nconf; CLIENT *cl; int len; cl = NULL; - nconf = NULL; svcaddr = NULL; if ((raddr->sun_len == 0) || ((svcaddr = malloc(sizeof(struct netbuf))) == NULL ) || diff --git a/lib/libc/rpc/rpc_svc_reg.3 b/lib/libc/rpc/rpc_svc_reg.3 index aed2ba1..81a749a 100644 --- a/lib/libc/rpc/rpc_svc_reg.3 +++ b/lib/libc/rpc/rpc_svc_reg.3 @@ -176,8 +176,8 @@ Service implementors usually do not need this routine. .Sh SEE ALSO .Xr select 2 , .Xr rpc 3 , -.Xr rpcbind 3 , .Xr rpc_svc_calls 3 , .Xr rpc_svc_create 3 , .Xr rpc_svc_err 3 , +.Xr rpcbind 3 , .Xr rpcbind 8 diff --git a/lib/libc/rpc/rpcbind.3 b/lib/libc/rpc/rpcbind.3 index 0b716ca..3bf8be9 100644 --- a/lib/libc/rpc/rpcbind.3 +++ b/lib/libc/rpc/rpcbind.3 @@ -25,7 +25,7 @@ .Ft bool_t .Fn rpcb_gettime "const char *host" "time_t * timep" .Ft "enum clnt_stat" -.Fn rpcb_rmtcall "const struct netconfig *netconf" "const char *host" "const rpcprog_t prognum, const rpcvers_t versnum" "const rpcproc_t procnum, const xdrproc_t inproc" "const caddr_t in" "const xdrproc_t outproc" "const caddr_t out" "const struct timeval tout, const struct netbuf *svcaddr" +.Fn rpcb_rmtcall "const struct netconfig *netconf" "const char *host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const rpcproc_t procnum" "const xdrproc_t inproc" "const caddr_t in" "const xdrproc_t outproc" "const caddr_t out" "const struct timeval tout" "const struct netbuf *svcaddr" .Ft bool_t .Fn rpcb_set "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" "const struct netbuf *svcaddr" .Ft bool_t diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c index f830425..aa45396 100644 --- a/lib/libc/rpc/svc_vc.c +++ b/lib/libc/rpc/svc_vc.c @@ -128,7 +128,7 @@ svc_vc_create(fd, sendsize, recvsize) u_int sendsize; u_int recvsize; { - SVCXPRT *xprt; + SVCXPRT *xprt = NULL; struct cf_rendezvous *r = NULL; struct __rpc_sockinfo si; struct sockaddr_storage sslocal; diff --git a/lib/libc/sparc64/Makefile.inc b/lib/libc/sparc64/Makefile.inc index af23ae4..74fb7cd 100644 --- a/lib/libc/sparc64/Makefile.inc +++ b/lib/libc/sparc64/Makefile.inc @@ -5,7 +5,7 @@ .include "fpu/Makefile.inc" -SRCS+= __vdso_gettc.c +SRCS+= trivial-vdso_tc.c # Long double is quad precision GDTOASRCS+=strtorQ.c diff --git a/lib/libc/sparc64/gen/Makefile.inc b/lib/libc/sparc64/gen/Makefile.inc index d3fbfe4..5442a33 100644 --- a/lib/libc/sparc64/gen/Makefile.inc +++ b/lib/libc/sparc64/gen/Makefile.inc @@ -2,5 +2,6 @@ SRCS+= _ctx_start.S _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpgetmask.c \ fpgetround.c fpgetsticky.c fpsetmask.c fpsetround.c \ - getcontextx.c infinity.c ldexp.c makecontext.c \ - signalcontext.c setjmp.S sigsetjmp.S _set_tp.c + infinity.c ldexp.c makecontext.c \ + signalcontext.c setjmp.S sigsetjmp.S _set_tp.c \ + trivial-getcontextx.c diff --git a/lib/libc/sparc64/gen/getcontextx.c b/lib/libc/sparc64/gen/getcontextx.c deleted file mode 100644 index 54f8513..0000000 --- a/lib/libc/sparc64/gen/getcontextx.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/ucontext.h> -#include <errno.h> -#include <stdlib.h> - -int -__getcontextx_size(void) -{ - - return (sizeof(ucontext_t)); -} - -int -__fillcontextx2(char *ctx) -{ - - return (0); -} - -int -__fillcontextx(char *ctx) -{ - ucontext_t *ucp; - - ucp = (ucontext_t *)ctx; - return (getcontext(ucp)); -} - -__weak_reference(__getcontextx, getcontextx); - -ucontext_t * -__getcontextx(void) -{ - char *ctx; - int error; - - ctx = malloc(__getcontextx_size()); - if (ctx == NULL) - return (NULL); - if (__fillcontextx(ctx) == -1) { - error = errno; - free(ctx); - errno = error; - return (NULL); - } - return ((ucontext_t *)ctx); -} diff --git a/lib/libc/sparc64/sys/Makefile.inc b/lib/libc/sparc64/sys/Makefile.inc index 031af19..a62aac2 100644 --- a/lib/libc/sparc64/sys/Makefile.inc +++ b/lib/libc/sparc64/sys/Makefile.inc @@ -12,12 +12,9 @@ SRCS+= __sparc_sigtramp_setup.c \ CFLAGS+= -I${LIBC_SRCTOP}/sparc64/fpu -MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S sigaction.S +MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S sigaction1.S # Don't generate default code for these syscalls: NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o PSEUDO= _getlogin.o _exit.o -.if ${MK_SYSCALL_COMPAT} != "no" -PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o -.endif diff --git a/lib/libc/sparc64/sys/__vdso_gettc.c b/lib/libc/sparc64/sys/__vdso_gettc.c deleted file mode 100644 index b99bbc4..0000000 --- a/lib/libc/sparc64/sys/__vdso_gettc.c +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/time.h> -#include <sys/vdso.h> -#include <errno.h> - -#pragma weak __vdso_gettc -u_int -__vdso_gettc(const struct vdso_timehands *th) -{ - - return (0); -} - -#pragma weak __vdso_gettimekeep -int -__vdso_gettimekeep(struct vdso_timekeep **tk) -{ - - return (ENOSYS); -} diff --git a/lib/libc/sparc64/sys/sigaction.S b/lib/libc/sparc64/sys/sigaction1.S index 7d32f97..219a238 100644 --- a/lib/libc/sparc64/sys/sigaction.S +++ b/lib/libc/sparc64/sys/sigaction1.S @@ -29,7 +29,8 @@ __FBSDID("$FreeBSD$"); #include "SYS.h" -_SYSENTRY(sigaction) + WEAK_REFERENCE(__sys_sigaction, _sigaction) +ENTRY(__sys_sigaction) PIC_PROLOGUE(%o3, %o4) SET(sigcode_installed, %o4, %o3) lduw [%o3], %o4 @@ -44,6 +45,6 @@ _SYSENTRY(sigaction) 1: _SYSCALL(sigaction) retl nop -_SYSEND(sigaction) +END(__sys_sigaction) .comm sigcode_installed, 4, 4 diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c index ef9b45b..123167a 100644 --- a/lib/libc/stdio/fflush.c +++ b/lib/libc/stdio/fflush.c @@ -124,11 +124,13 @@ __sflush(FILE *fp) t = _swrite(fp, (char *)p, n); if (t <= 0) { /* Reset _p and _w. */ - if (p > fp->_p) /* Some was written. */ + if (p > fp->_p) { + /* Some was written. */ memmove(fp->_p, p, n); - fp->_p += n; - if ((fp->_flags & (__SLBF | __SNBF)) == 0) - fp->_w -= n; + fp->_p += n; + if ((fp->_flags & (__SLBF | __SNBF)) == 0) + fp->_w -= n; + } fp->_flags |= __SERR; return (EOF); } diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c index b7552a4..9eed6d7 100644 --- a/lib/libc/stdio/flags.c +++ b/lib/libc/stdio/flags.c @@ -97,6 +97,10 @@ __sflags(const char *mode, int *optr) /* set close-on-exec */ o |= O_CLOEXEC; break; + case 'v': + /* verify */ + o |= O_VERIFY; + break; default: known = 0; break; diff --git a/lib/libc/stdio/open_memstream.3 b/lib/libc/stdio/open_memstream.3 index 117dcb2..e01952b 100644 --- a/lib/libc/stdio/open_memstream.3 +++ b/lib/libc/stdio/open_memstream.3 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2013 Advanced Computing Technologies LLC +.\" Copyright (c) 2013 Hudson River Trading LLC .\" Written by: John H. Baldwin <jhb@FreeBSD.org> .\" All rights reserved. .\" diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c index aa50822..baa71e4 100644 --- a/lib/libc/stdio/open_memstream.c +++ b/lib/libc/stdio/open_memstream.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Advanced Computing Technologies LLC + * Copyright (c) 2013 Hudson River Trading LLC * Written by: John H. Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c index cf2968a..299e3d8 100644 --- a/lib/libc/stdio/open_wmemstream.c +++ b/lib/libc/stdio/open_wmemstream.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Advanced Computing Technologies LLC + * Copyright (c) 2013 Hudson River Trading LLC * Written by: John H. Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/lib/libc/stdio/xprintf_float.c b/lib/libc/stdio/xprintf_float.c index b719aac..ad17eb2 100644 --- a/lib/libc/stdio/xprintf_float.c +++ b/lib/libc/stdio/xprintf_float.c @@ -168,7 +168,6 @@ __printf_render_float(struct __printf_io *io, const struct printf_info *pi, cons int realsz; /* field size expanded by dprec, sign, etc */ int dprec; /* a copy of prec if [diouxX], 0 otherwise */ char ox[2]; /* space for 0x; ox[1] is either x, X, or \0 */ - int prsize; /* max size of printed field */ int ret; /* return value accumulator */ char *decimal_point; /* locale specific decimal point */ int n2; /* XXX: for PRINTANDPAD */ @@ -344,8 +343,6 @@ here: if (ox[1]) realsz += 2; - prsize = pi->width > realsz ? pi->width : realsz; - /* right-adjusting blank padding */ if (pi->pad != '0' && pi->left == 0) ret += __printf_pad(io, pi->width - realsz, 0); diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index 57205a7..7cee03a 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -10,7 +10,8 @@ MISRCS+=_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \ insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c \ merge.c mergesort_b.c ptsname.c qsort.c qsort_r.c quick_exit.c \ radixsort.c rand.c \ - random.c reallocf.c realpath.c remque.c strfmon.c strtoimax.c \ + random.c reallocarray.c reallocf.c realpath.c remque.c strfmon.c \ + strtoimax.c \ strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \ strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c @@ -25,7 +26,7 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 \ hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \ lsearch.3 memory.3 ptsname.3 qsort.3 \ quick_exit.3 \ - radixsort.3 rand.3 random.3 reallocf.3 \ + radixsort.3 rand.3 random.3 reallocarray.3 reallocf.3 \ realpath.3 strfmon.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 \ tsearch.3 diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map index 8355f9a..782023e 100644 --- a/lib/libc/stdlib/Symbol.map +++ b/lib/libc/stdlib/Symbol.map @@ -113,9 +113,11 @@ FBSD_1.4 { hcreate_r; hdestroy_r; hsearch_r; + reallocarray; }; FBSDprivate_1.0 { __system; _system; + __libc_system; }; diff --git a/lib/libc/stdlib/atexit.3 b/lib/libc/stdlib/atexit.3 index 68f4e8f..3cdc59f 100644 --- a/lib/libc/stdlib/atexit.3 +++ b/lib/libc/stdlib/atexit.3 @@ -88,12 +88,12 @@ The existing list of functions is unmodified. .It Bq Er ENOSYS The .Fn atexit_b -function was called by a program that did not supply a +function was called by a program that did not supply a .Fn _Block_copy implementation. .El .Sh SEE ALSO -.Xr at_quick_exit 3 +.Xr at_quick_exit 3 , .Xr exit 3 .Sh STANDARDS The diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3 index 07ce0d7..7d657c9 100644 --- a/lib/libc/stdlib/exit.3 +++ b/lib/libc/stdlib/exit.3 @@ -117,8 +117,8 @@ never return. .Sh SEE ALSO .Xr _exit 2 , .Xr wait 2 , -.Xr atexit 3 , .Xr at_quick_exit 3 , +.Xr atexit 3 , .Xr intro 3 , .Xr quick_exit 3 , .Xr sysexits 3 , diff --git a/lib/libc/stdlib/jemalloc/Symbol.map b/lib/libc/stdlib/jemalloc/Symbol.map index 35a5dad..132664a 100644 --- a/lib/libc/stdlib/jemalloc/Symbol.map +++ b/lib/libc/stdlib/jemalloc/Symbol.map @@ -55,4 +55,5 @@ FBSDprivate_1.0 { _malloc_thread_cleanup; _malloc_prefork; _malloc_postfork; + _malloc_first_thread; }; diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index 93e22cd..e97ea92 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -41,47 +41,55 @@ typedef int cmp_t(void *, const void *, const void *); typedef int cmp_t(const void *, const void *); #endif static inline char *med3(char *, char *, char *, cmp_t *, void *); -static inline void swapfunc(char *, char *, int, int); +static inline void swapfunc(char *, char *, int, int, int); -#define min(a, b) (a) < (b) ? a : b +#define MIN(a, b) ((a) < (b) ? a : b) /* * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". */ -#define swapcode(TYPE, parmi, parmj, n) { \ - long i = (n) / sizeof (TYPE); \ - TYPE *pi = (TYPE *) (parmi); \ - TYPE *pj = (TYPE *) (parmj); \ +#define swapcode(TYPE, parmi, parmj, n) { \ + long i = (n) / sizeof (TYPE); \ + TYPE *pi = (TYPE *) (parmi); \ + TYPE *pj = (TYPE *) (parmj); \ do { \ TYPE t = *pi; \ *pi++ = *pj; \ *pj++ = t; \ - } while (--i > 0); \ + } while (--i > 0); \ } -#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ - es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; +#define SWAPINIT(TYPE, a, es) swaptype_ ## TYPE = \ + ((char *)a - (char *)0) % sizeof(TYPE) || \ + es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1; static inline void -swapfunc(a, b, n, swaptype) +swapfunc(a, b, n, swaptype_long, swaptype_int) char *a, *b; - int n, swaptype; + int n, swaptype_long, swaptype_int; { - if(swaptype <= 1) + if (swaptype_long <= 1) swapcode(long, a, b, n) + else if (swaptype_int <= 1) + swapcode(int, a, b, n) else swapcode(char, a, b, n) } -#define swap(a, b) \ - if (swaptype == 0) { \ +#define swap(a, b) \ + if (swaptype_long == 0) { \ long t = *(long *)(a); \ *(long *)(a) = *(long *)(b); \ *(long *)(b) = t; \ + } else if (swaptype_int == 0) { \ + int t = *(int *)(a); \ + *(int *)(a) = *(int *)(b); \ + *(int *)(b) = t; \ } else \ - swapfunc(a, b, es, swaptype) + swapfunc(a, b, es, swaptype_long, swaptype_int) -#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) +#define vecswap(a, b, n) \ + if ((n) > 0) swapfunc(a, b, n, swaptype_long, swaptype_int) #ifdef I_AM_QSORT_R #define CMP(t, x, y) (cmp((t), (x), (y))) @@ -98,14 +106,14 @@ __unused { return CMP(thunk, a, b) < 0 ? (CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a )) - :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c )); + :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c )); } #ifdef I_AM_QSORT_R void qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp) #else -#define thunk NULL +#define thunk NULL void qsort(void *a, size_t n, size_t es, cmp_t *cmp) #endif @@ -113,9 +121,10 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp) char *pa, *pb, *pc, *pd, *pl, *pm, *pn; size_t d, r; int cmp_result; - int swaptype, swap_cnt; + int swaptype_long, swaptype_int, swap_cnt; -loop: SWAPINIT(a, es); +loop: SWAPINIT(long, a, es); + SWAPINIT(int, a, es); swap_cnt = 0; if (n < 7) { for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) @@ -175,9 +184,9 @@ loop: SWAPINIT(a, es); } pn = (char *)a + n * es; - r = min(pa - (char *)a, pb - pa); + r = MIN(pa - (char *)a, pb - pa); vecswap(a, pb - r, r); - r = min(pd - pc, pn - pd - es); + r = MIN(pd - pc, pn - pd - es); vecswap(pb, pn - r, r); if ((r = pb - pa) > es) #ifdef I_AM_QSORT_R diff --git a/lib/libc/stdlib/quick_exit.3 b/lib/libc/stdlib/quick_exit.3 index f2ea379..7bbd2f3 100644 --- a/lib/libc/stdlib/quick_exit.3 +++ b/lib/libc/stdlib/quick_exit.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 7, 2011 +.Dd December 13, 2014 .Dt QUICK_EXIT 3 .Os .Sh NAME @@ -35,7 +35,7 @@ .Sh SYNOPSIS .In stdlib.h .Ft _Noreturn void -.Fn quick_exit "void" +.Fn quick_exit "int status" .Sh DESCRIPTION The .Fn quick_exit diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3 index dc8e961..254be0a 100644 --- a/lib/libc/stdlib/random.3 +++ b/lib/libc/stdlib/random.3 @@ -54,9 +54,8 @@ .Fn setstate "char *state" .Sh DESCRIPTION .Bf -symbolic -The functions described in this manual page are not cryptographically -secure. -Cryptographic applications should use +The functions described in this manual page are not secure. +Applications which require unpredictable random numbers should use .Xr arc4random 3 instead. .Ef diff --git a/lib/libc/stdlib/reallocarray.3 b/lib/libc/stdlib/reallocarray.3 new file mode 100644 index 0000000..8e714f4 --- /dev/null +++ b/lib/libc/stdlib/reallocarray.3 @@ -0,0 +1,142 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd May 1, 2015 +.Dt REALLOCARRAY 3 +.Os +.Sh NAME +.Nm reallocarray +.Nd memory reallocation function +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void * +.Fn reallocarray "void *ptr" "size_t nmemb" "size_t size" +.Sh DESCRIPTION +The +.Fn reallocarray +function is similar to the +.Fn realloc +function +except it operates on +.Fa nmemb +members of size +.Fa size +and checks for integer overflow in the calculation +.Fa nmemb +* +.Fa size . +.Sh RETURN VALUES +The +.Fn reallocarray +function returns a pointer to the allocated space; otherwise, a +.Dv NULL +pointer is returned and +.Va errno +is set to +.Er ENOMEM . +.Sh EXAMPLES +Consider +.Fn reallocarray +when there is multiplication in the +.Fa size +argument of +.Fn malloc +or +.Fn realloc . +For example, avoid this common idiom as it may lead to integer overflow: +.Bd -literal -offset indent +if ((p = malloc(num * size)) == NULL) + err(1, "malloc"); +.Ed +.Pp +A drop-in replacement is the +.Ox +extension +.Fn reallocarray : +.Bd -literal -offset indent +if ((p = reallocarray(NULL, num, size)) == NULL) + err(1, "reallocarray"); +.Ed +.Pp +When using +.Fn realloc , +be careful to avoid the following idiom: +.Bd -literal -offset indent +size += 50; +if ((p = realloc(p, size)) == NULL) + return (NULL); +.Ed +.Pp +Do not adjust the variable describing how much memory has been allocated +until the allocation has been successful. +This can cause aberrant program behavior if the incorrect size value is used. +In most cases, the above sample will also result in a leak of memory. +As stated earlier, a return value of +.Dv NULL +indicates that the old object still remains allocated. +Better code looks like this: +.Bd -literal -offset indent +newsize = size + 50; +if ((newp = realloc(p, newsize)) == NULL) { + free(p); + p = NULL; + size = 0; + return (NULL); +} +p = newp; +size = newsize; +.Ed +.Pp +As with +.Fn malloc , +it is important to ensure the new size value will not overflow; +i.e. avoid allocations like the following: +.Bd -literal -offset indent +if ((newp = realloc(p, num * size)) == NULL) { + ... +.Ed +.Pp +Instead, use +.Fn reallocarray : +.Bd -literal -offset indent +if ((newp = reallocarray(p, num, size)) == NULL) { + ... +.Ed +.Sh SEE ALSO +.Xr realloc 3 +.Sh HISTORY +The +.Fn reallocarray +function first appeared in +.Ox 5.6 +and +.Fx 11.0 . diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c new file mode 100644 index 0000000..e1e9b7c --- /dev/null +++ b/lib/libc/stdlib/reallocarray.c @@ -0,0 +1,42 @@ +/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */ +/* + * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <errno.h> +#include <stdint.h> +#include <stdlib.h> + +/* + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW + */ +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) + +void * +reallocarray(void *optr, size_t nmemb, size_t size) +{ + + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && + nmemb > 0 && SIZE_MAX / nmemb < size) { + errno = ENOMEM; + return (NULL); + } + return (realloc(optr, size * nmemb)); +} diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index e018e6f..bd9ea5a 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -46,8 +46,17 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" +#pragma weak system int -__system(const char *command) +system(const char *command) +{ + + return (((int (*)(const char *)) + __libc_interposing[INTERPOS_system])(command)); +} + +int +__libc_system(const char *command) { pid_t pid, savedpid; int pstat; @@ -95,5 +104,5 @@ __system(const char *command) return(pid == -1 ? -1 : pstat); } -__weak_reference(__system, system); -__weak_reference(__system, _system); +__weak_reference(__libc_system, __system); +__weak_reference(__libc_system, _system); diff --git a/lib/libc/stdlib/tdelete.c b/lib/libc/stdlib/tdelete.c index c83afb8..bef187e 100644 --- a/lib/libc/stdlib/tdelete.c +++ b/lib/libc/stdlib/tdelete.c @@ -14,7 +14,7 @@ #include <sys/cdefs.h> #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); +__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $"); #endif /* LIBC_SCCS and not lint */ #endif __FBSDID("$FreeBSD$"); @@ -25,9 +25,9 @@ __FBSDID("$FreeBSD$"); /* - * delete node with given key + * find a node with given key * - * vkey: key to be deleted + * vkey: key to be found * vrootp: address of the root of the tree * compar: function to carry out node comparisons */ @@ -65,7 +65,8 @@ tdelete(const void * __restrict vkey, void ** __restrict vrootp, q->rlink = (*rootp)->rlink; } } - free(*rootp); /* D4: Free node */ + if (p != *rootp) + free(*rootp); /* D4: Free node */ *rootp = q; /* link parent to new node */ return p; } diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c index 2d13be7..f5ed6c6 100644 --- a/lib/libc/string/strlcat.c +++ b/lib/libc/string/strlcat.c @@ -1,7 +1,7 @@ -/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */ +/* $OpenBSD: strlcat.c,v 1.15 2015/03/02 21:41:08 millert Exp $ */ /* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -23,36 +23,36 @@ __FBSDID("$FreeBSD$"); #include <string.h> /* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. + * Appends src to string dst of size dsize (unlike strncat, dsize is the + * full size of dst, not space left). At most dsize-1 characters + * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). + * Returns strlen(src) + MIN(dsize, strlen(initial dst)). + * If retval >= dsize, truncation occurred. */ size_t -strlcat(char * __restrict dst, const char * __restrict src, size_t siz) +strlcat(char * __restrict dst, const char * __restrict src, size_t dsize) { - char *d = dst; - const char *s = src; - size_t n = siz; + const char *odst = dst; + const char *osrc = src; + size_t n = dsize; size_t dlen; - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; + /* Find the end of dst and adjust bytes left but don't go past end. */ + while (n-- != 0 && *dst != '\0') + dst++; + dlen = dst - odst; + n = dsize - dlen; - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; + if (n-- == 0) + return(dlen + strlen(src)); + while (*src != '\0') { + if (n != 0) { + *dst++ = *src; n--; } - s++; + src++; } - *d = '\0'; + *dst = '\0'; - return(dlen + (s - src)); /* count does not include NUL */ + return(dlen + (src - osrc)); /* count does not include NUL */ } diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c index 451b6df..019d231 100644 --- a/lib/libc/string/strlcpy.c +++ b/lib/libc/string/strlcpy.c @@ -1,7 +1,7 @@ -/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ +/* $OpenBSD: strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $ */ /* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -23,32 +23,31 @@ __FBSDID("$FreeBSD$"); #include <string.h> /* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. + * Copy string src to buffer dst of size dsize. At most dsize-1 + * chars will be copied. Always NUL terminates (unless dsize == 0). + * Returns strlen(src); if retval >= dsize, truncation occurred. */ size_t -strlcpy(char * __restrict dst, const char * __restrict src, size_t siz) +strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize) { - char *d = dst; - const char *s = src; - size_t n = siz; + const char *osrc = src; + size_t nleft = dsize; - /* Copy as many bytes as will fit */ - if (n != 0) { - while (--n != 0) { - if ((*d++ = *s++) == '\0') + /* Copy as many bytes as will fit. */ + if (nleft != 0) { + while (--nleft != 0) { + if ((*dst++ = *src++) == '\0') break; } } - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) + /* Not enough room in dst, add NUL and traverse rest of src. */ + if (nleft == 0) { + if (dsize != 0) + *dst = '\0'; /* NUL-terminate dst */ + while (*src++) ; } - return(s - src - 1); /* count does not include NUL */ + return(src - osrc - 1); /* count does not include NUL */ } diff --git a/lib/libc/string/strspn.3 b/lib/libc/string/strspn.3 index 542b190..4a8e3f4 100644 --- a/lib/libc/string/strspn.3 +++ b/lib/libc/string/strspn.3 @@ -71,7 +71,7 @@ spans the initial part of the null-terminated string .Fa s as long as the characters from .Fa s -.Sy do not +.Sy do not occur in the null-terminated string .Fa charset .Po it spans the diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index c14b351..5162563 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -20,17 +20,62 @@ NOASM+= clock_gettime.o gettimeofday.o PSEUDO+= _clock_gettime.o _gettimeofday.o # Sources common to both syscall interfaces: -SRCS+= stack_protector.c stack_protector_compat.c __error.c -.if ${MK_SYSCALL_COMPAT} != "no" -SYSCALL_COMPAT_SRCS= fcntl.c ftruncate.c lseek.c mmap.c pread.c \ - pwrite.c truncate.c -SRCS+= ${SYSCALL_COMPAT_SRCS} -NOASM+= ${SYSCALL_COMPAT_SRCS:S/.c/.o/} -PSEUDO+= _fcntl.o +SRCS+= \ + stack_protector.c \ + stack_protector_compat.c \ + __error.c \ + interposing_table.c + +SRCS+= futimens.c utimensat.c +NOASM+= futimens.o utimensat.o +PSEUDO+= _futimens.o _utimensat.o + +INTERPOSED = \ + accept \ + accept4 \ + aio_suspend \ + close \ + connect \ + fcntl \ + fsync \ + fork \ + kevent \ + msync \ + nanosleep \ + open \ + openat \ + poll \ + ppoll \ + pselect \ + read \ + readv \ + recvfrom \ + recvmsg \ + select \ + sendmsg \ + sendto \ + setcontext \ + sigprocmask \ + sigsuspend \ + sigtimedwait \ + sigwait \ + sigwaitinfo \ + swapcontext \ + wait4 \ + wait6 \ + write \ + writev + +.if ${MACHINE_CPUARCH} == "sparc64" +SRCS+= sigaction.c +NOASM+= sigaction.o +.else +INTERPOSED+= sigaction .endif -SRCS+= sigwait.c -NOASM+= sigwait.o -PSEUDO+= _sigwait.o + +SRCS+= ${INTERPOSED:S/$/.c/} +NOASM+= ${INTERPOSED:S/$/.o/} +PSEUDO+= ${INTERPOSED:C/^.*$/_&.o/} # Add machine dependent asm sources: SRCS+=${MDASM} @@ -266,6 +311,7 @@ MAN+= sctp_generic_recvmsg.2 \ umask.2 \ undelete.2 \ unlink.2 \ + utimensat.2 \ utimes.2 \ utrace.2 \ uuidgen.2 \ @@ -398,6 +444,7 @@ MLINKS+=timer_settime.2 timer_getoverrun.2 \ timer_settime.2 timer_gettime.2 MLINKS+=truncate.2 ftruncate.2 MLINKS+=unlink.2 unlinkat.2 +MLINKS+=utimensat.2 futimens.2 MLINKS+=utimes.2 futimes.2 \ utimes.2 futimesat.2 \ utimes.2 lutimes.2 diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 448bcce..194aa5b 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -245,7 +245,6 @@ FBSD_1.0 { setaudit; setaudit_addr; setauid; - setcontext; setegid; seteuid; setgid; @@ -286,7 +285,6 @@ FBSD_1.0 { __stack_chk_guard; stat; statfs; - swapcontext; swapoff; swapon; symlink; @@ -351,7 +349,6 @@ FBSD_1.1 { mkfifoat; mknodat; msgctl; - openat; readlinkat; renameat; setfib; @@ -400,7 +397,9 @@ FBSD_1.3 { }; FBSD_1.4 { + futimens; ppoll; + utimensat; }; FBSDprivate_1.0 { @@ -1048,7 +1047,9 @@ FBSDprivate_1.0 { __sys_write; _writev; __sys_writev; - __error_unthreaded; + __set_error_selector; nlm_syscall; gssd_syscall; + __libc_interposing_slot; + __libc_sigwait; }; diff --git a/lib/libc/sys/__error.c b/lib/libc/sys/__error.c index c3f59f8..28cc31d 100644 --- a/lib/libc/sys/__error.c +++ b/lib/libc/sys/__error.c @@ -32,14 +32,25 @@ __FBSDID("$FreeBSD$"); extern int errno; -/* - * Declare a weak reference in case the application is not linked - * with libpthread. - */ -__weak_reference(__error_unthreaded, __error); +static int * +__error_unthreaded(void) +{ + + return (&errno); +} + +static int *(*__error_selector)(void) = __error_unthreaded; + +void +__set_error_selector(int *(*arg)(void)) +{ + + __error_selector = arg; +} int * -__error_unthreaded(void) +__error(void) { - return(&errno); + + return (__error_selector()); } diff --git a/lib/libc/sys/accept.c b/lib/libc/sys/accept.c new file mode 100644 index 0000000..38e32f2 --- /dev/null +++ b/lib/libc/sys/accept.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_accept, __accept); + +#pragma weak accept +int +accept(int s, struct sockaddr *addr, socklen_t *addrlen) +{ + + return (((int (*)(int, struct sockaddr *, socklen_t *)) + __libc_interposing[INTERPOS_accept])(s, addr, addrlen)); +} diff --git a/lib/libc/sys/accept4.c b/lib/libc/sys/accept4.c new file mode 100644 index 0000000..2907b04 --- /dev/null +++ b/lib/libc/sys/accept4.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_accept4, __accept4); + +#pragma weak accept4 +int +accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) +{ + + return (((int (*)(int, struct sockaddr *, socklen_t *, int)) + __libc_interposing[INTERPOS_accept4])(s, addr, addrlen, flags)); +} diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2 index 46bf948..c70e7a2 100644 --- a/lib/libc/sys/access.2 +++ b/lib/libc/sys/access.2 @@ -136,7 +136,7 @@ and .Fn access , .Fn eaccess , or -.Fn faccessat +.Fn faccessat will fail if: .Bl -tag -width Er .It Bq Er EINVAL diff --git a/lib/libc/sys/aio_suspend.c b/lib/libc/sys/aio_suspend.c new file mode 100644 index 0000000..020edf8 --- /dev/null +++ b/lib/libc/sys/aio_suspend.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/aio.h> +#include "libc_private.h" + +__weak_reference(__sys_aio_suspend, __aio_suspend); + +#pragma weak aio_suspend +int +aio_suspend(const struct aiocb * const iocbs[], int niocb, + const struct timespec *timeout) +{ + + return (((int (*)(const struct aiocb * const[], int, + const struct timespec *)) + __libc_interposing[INTERPOS_aio_suspend])(iocbs, niocb, timeout)); +} diff --git a/lib/libc/sys/cap_ioctls_limit.2 b/lib/libc/sys/cap_ioctls_limit.2 index 2d1eef9..39f117f 100644 --- a/lib/libc/sys/cap_ioctls_limit.2 +++ b/lib/libc/sys/cap_ioctls_limit.2 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 27, 2014 +.Dd March 6, 2015 .Dt CAP_IOCTLS_LIMIT 2 .Os .Sh NAME @@ -61,6 +61,8 @@ argument specifies the number of elements in the array. There can be up to .Va 256 elements in the array. +Including an element that has been previously revoked will generate an error. +After a successful call only those listed in the array may be used. .Pp The list of allowed ioctl commands for a given file descriptor can be obtained with the @@ -92,7 +94,7 @@ system call was never called for this file descriptor), the .Fn cap_ioctls_get system call will return .Dv CAP_IOCTLS_ALL -and won't modify the buffer pointed to by the +and will not modify the buffer pointed to by the .Fa cmds argument. .Sh RETURN VALUES diff --git a/lib/libc/sys/close.c b/lib/libc/sys/close.c new file mode 100644 index 0000000..02e74c6 --- /dev/null +++ b/lib/libc/sys/close.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/fcntl.h> +#include "libc_private.h" + +__weak_reference(__sys_close, __close); + +#pragma weak close +int +close(int fd) +{ + + return (((int (*)(int))__libc_interposing[INTERPOS_close])(fd)); +} diff --git a/lib/libc/sys/closefrom.2 b/lib/libc/sys/closefrom.2 index ffaa001..a0b5fc2 100644 --- a/lib/libc/sys/closefrom.2 +++ b/lib/libc/sys/closefrom.2 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2009 Advanced Computing Technologies LLC +.\" Copyright (c) 2009 Hudson River Trading LLC .\" Written by: John H. Baldwin <jhb@FreeBSD.org> .\" All rights reserved. .\" diff --git a/lib/libc/sys/connect.c b/lib/libc/sys/connect.c new file mode 100644 index 0000000..7969142 --- /dev/null +++ b/lib/libc/sys/connect.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_connect, __connect); + +#pragma weak connect +int +connect(int s, const struct sockaddr *addr, socklen_t addrlen) +{ + + return (((int (*)(int, const struct sockaddr *, socklen_t)) + __libc_interposing[INTERPOS_connect])(s, addr, addrlen)); +} diff --git a/lib/libc/sys/cpuset.2 b/lib/libc/sys/cpuset.2 index 0c32b42..8349566 100644 --- a/lib/libc/sys/cpuset.2 +++ b/lib/libc/sys/cpuset.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2014 +.Dd January 8, 2015 .Dt CPUSET 2 .Os .Sh NAME @@ -101,6 +101,7 @@ argument may have the following values: .It Dv CPU_WHICH_JAIL Ta "id is jid (jail id)" .It Dv CPU_WHICH_CPUSET Ta "id is a cpusetid_t (cpuset id)" .It Dv CPU_WHICH_IRQ Ta "id is an irq number" +.It Dv CPU_WHICH_DOMAIN Ta "id is a NUMA domain" .El .Pp An diff --git a/lib/libc/sys/fcntl.c b/lib/libc/sys/fcntl.c index 480cc40..e85574a 100644 --- a/lib/libc/sys/fcntl.c +++ b/lib/libc/sys/fcntl.c @@ -3,6 +3,12 @@ * Authors: Doug Rabson <dfr@rabson.org> * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org> * + * Copyright (c) 2014-2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,56 +40,17 @@ __FBSDID("$FreeBSD$"); #include <sys/syscall.h> #include "libc_private.h" -__weak_reference(__fcntl_compat, fcntl); - +#pragma weak fcntl int -__fcntl_compat(int fd, int cmd, ...) +fcntl(int fd, int cmd, ...) { va_list args; long arg; - struct __oflock ofl; - struct flock *flp; - int res; va_start(args, cmd); arg = va_arg(args, long); va_end(args); - if (__getosreldate() >= 800028) { - return (__sys_fcntl(fd, cmd, arg)); - } else { - if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW) { - /* - * Convert new-style struct flock (which - * includes l_sysid) to old-style. - */ - flp = (struct flock *) (uintptr_t) arg; - ofl.l_start = flp->l_start; - ofl.l_len = flp->l_len; - ofl.l_pid = flp->l_pid; - ofl.l_type = flp->l_type; - ofl.l_whence = flp->l_whence; - - switch (cmd) { - case F_GETLK: - res = __sys_fcntl(fd, F_OGETLK, &ofl); - if (res >= 0) { - flp->l_start = ofl.l_start; - flp->l_len = ofl.l_len; - flp->l_pid = ofl.l_pid; - flp->l_type = ofl.l_type; - flp->l_whence = ofl.l_whence; - flp->l_sysid = 0; - } - return (res); - - case F_SETLK: - return (__sys_fcntl(fd, F_OSETLK, &ofl)); - - case F_SETLKW: - return (__sys_fcntl(fd, F_OSETLKW, &ofl)); - } - } - return (__sys_fcntl(fd, cmd, arg)); - } + return (((int (*)(int, int, ...)) + __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg)); } diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index 1ad2052f..4fda74d 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 May 31, 2013 +.Dd May 1, 2015 .Dt FORK 2 .Os .Sh NAME @@ -53,7 +53,10 @@ The child process has a unique process ID. The child process has a different parent process ID (i.e., the process ID of the parent process). .It -The child process has its own copy of the parent's descriptors. +The child process has its own copy of the parent's descriptors, +except for descriptors returned by +.Xr kqueue 2 , +which are not inherited from the parent process. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an diff --git a/lib/libc/sys/fork.c b/lib/libc/sys/fork.c new file mode 100644 index 0000000..695540a --- /dev/null +++ b/lib/libc/sys/fork.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <unistd.h> +#include "libc_private.h" + +__weak_reference(__sys_fork, __fork); + +#pragma weak fork +pid_t +fork(void) +{ + + return (((pid_t (*)(void))__libc_interposing[INTERPOS_fork])()); +} diff --git a/lib/libc/sys/fsync.c b/lib/libc/sys/fsync.c new file mode 100644 index 0000000..3fff428 --- /dev/null +++ b/lib/libc/sys/fsync.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/fcntl.h> +#include "libc_private.h" + +__weak_reference(__sys_fsync, __fsync); + +int +fsync(int fd) +{ + + return (((int (*)(int))__libc_interposing[INTERPOS_fsync])(fd)); +} diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c deleted file mode 100644 index 78b5a36..0000000 --- a/lib/libc/sys/ftruncate.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -int -ftruncate(fd, length) - int fd; - off_t length; -{ - - if (__getosreldate() >= 700051) - return(__sys_ftruncate(fd, length)); - else - return(__sys_freebsd6_ftruncate(fd, 0, length)); -} diff --git a/lib/libc/sys/futimens.c b/lib/libc/sys/futimens.c new file mode 100644 index 0000000..2014cc5 --- /dev/null +++ b/lib/libc/sys/futimens.c @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2015 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/stat.h> + +#include <errno.h> +#include <fcntl.h> +#include <time.h> +#include "un-namespace.h" + +#include "libc_private.h" + +int +futimens(int fd, const struct timespec times[2]) +{ + struct timeval now, tv[2], *tvp; + struct stat sb; + + if (__getosreldate() >= 1100056) + return (__sys_futimens(fd, times)); + + if (times == NULL || (times[0].tv_nsec == UTIME_NOW && + times[1].tv_nsec == UTIME_NOW)) + tvp = NULL; + else if (times[0].tv_nsec == UTIME_OMIT && + times[1].tv_nsec == UTIME_OMIT) + return (0); + else { + if ((times[0].tv_nsec < 0 || times[0].tv_nsec > 999999999) && + times[0].tv_nsec != UTIME_NOW && + times[0].tv_nsec != UTIME_OMIT) { + errno = EINVAL; + return (-1); + } + if ((times[1].tv_nsec < 0 || times[1].tv_nsec > 999999999) && + times[1].tv_nsec != UTIME_NOW && + times[1].tv_nsec != UTIME_OMIT) { + errno = EINVAL; + return (-1); + } + tv[0].tv_sec = times[0].tv_sec; + tv[0].tv_usec = times[0].tv_nsec / 1000; + tv[1].tv_sec = times[1].tv_sec; + tv[1].tv_usec = times[1].tv_nsec / 1000; + tvp = tv; + if (times[0].tv_nsec == UTIME_OMIT || + times[1].tv_nsec == UTIME_OMIT) { + if (_fstat(fd, &sb) == -1) + return (-1); + if (times[0].tv_nsec == UTIME_OMIT) { + tv[0].tv_sec = sb.st_atim.tv_sec; + tv[0].tv_usec = sb.st_atim.tv_nsec / 1000; + } + if (times[1].tv_nsec == UTIME_OMIT) { + tv[1].tv_sec = sb.st_mtim.tv_sec; + tv[1].tv_usec = sb.st_mtim.tv_nsec / 1000; + } + } + if (times[0].tv_nsec == UTIME_NOW || + times[1].tv_nsec == UTIME_NOW) { + if (gettimeofday(&now, NULL) == -1) + return (-1); + if (times[0].tv_nsec == UTIME_NOW) + tv[0] = now; + if (times[1].tv_nsec == UTIME_NOW) + tv[1] = now; + } + } + return (futimes(fd, tvp)); +} diff --git a/lib/libc/sys/getdirentries.2 b/lib/libc/sys/getdirentries.2 index 3fe1632..ab60ed2 100644 --- a/lib/libc/sys/getdirentries.2 +++ b/lib/libc/sys/getdirentries.2 @@ -134,8 +134,9 @@ The current position pointer should only be set to a value returned by .Xr lseek 2 , a value returned in the location pointed to by .Fa basep -.Fn ( getdirentries -only) +.Po Fn getdirentries +only +.Pc or zero. .Sh RETURN VALUES If successful, the number of bytes actually transferred is returned. diff --git a/lib/libc/sys/getrlimit.2 b/lib/libc/sys/getrlimit.2 index 1f84bfb..5fdd58b 100644 --- a/lib/libc/sys/getrlimit.2 +++ b/lib/libc/sys/getrlimit.2 @@ -194,8 +194,8 @@ raised the maximum limit value, and the caller is not the super-user. .Xr csh 1 , .Xr quota 1 , .Xr quotactl 2 , -.Xr sigaltstack 2 , .Xr sigaction 2 , +.Xr sigaltstack 2 , .Xr sysctl 3 , .Xr ulimit 3 .Sh HISTORY diff --git a/lib/libc/sys/interposing_table.c b/lib/libc/sys/interposing_table.c new file mode 100644 index 0000000..08dfbb1 --- /dev/null +++ b/lib/libc/sys/interposing_table.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include "libc_private.h" + +#define SLOT(a, b) \ + [INTERPOS_##a] = (interpos_func_t)b +interpos_func_t __libc_interposing[INTERPOS_MAX] = { + SLOT(accept, __sys_accept), + SLOT(accept4, __sys_accept4), + SLOT(aio_suspend, __sys_aio_suspend), + SLOT(close, __sys_close), + SLOT(connect, __sys_connect), + SLOT(fcntl, __sys_fcntl), + SLOT(fsync, __sys_fsync), + SLOT(fork, __sys_fork), + SLOT(msync, __sys_msync), + SLOT(nanosleep, __sys_nanosleep), + SLOT(openat, __sys_openat), + SLOT(poll, __sys_poll), + SLOT(pselect, __sys_pselect), + SLOT(read, __sys_read), + SLOT(readv, __sys_readv), + SLOT(recvfrom, __sys_recvfrom), + SLOT(recvmsg, __sys_recvmsg), + SLOT(select, __sys_select), + SLOT(sendmsg, __sys_sendmsg), + SLOT(sendto, __sys_sendto), + SLOT(setcontext, __sys_setcontext), + SLOT(sigaction, __sys_sigaction), + SLOT(sigprocmask, __sys_sigprocmask), + SLOT(sigsuspend, __sys_sigsuspend), + SLOT(sigwait, __libc_sigwait), + SLOT(sigtimedwait, __sys_sigtimedwait), + SLOT(sigwaitinfo, __sys_sigwaitinfo), + SLOT(swapcontext, __sys_swapcontext), + SLOT(system, __libc_system), + SLOT(tcdrain, __libc_tcdrain), + SLOT(wait4, __sys_wait4), + SLOT(write, __sys_write), + SLOT(writev, __sys_writev), + SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub), + SLOT(spinlock, __libc_spinlock_stub), + SLOT(spinunlock, __libc_spinunlock_stub), + SLOT(kevent, __sys_kevent), + SLOT(wait6, __sys_wait6), + SLOT(ppoll, __sys_ppoll), +}; +#undef SLOT + +interpos_func_t * +__libc_interposing_slot(int interposno) +{ + + return (&__libc_interposing[interposno]); +} diff --git a/lib/libc/sys/kevent.c b/lib/libc/sys/kevent.c new file mode 100644 index 0000000..5f84ef8 --- /dev/null +++ b/lib/libc/sys/kevent.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/event.h> +#include <sys/time.h> +#include "libc_private.h" + +__weak_reference(__sys_kevent, __kevent); + +#pragma weak kevent +int +kevent(int kq, const struct kevent *changelist, int nchanges, + struct kevent *eventlist, int nevents, const struct timespec *timeout) +{ + + return (((int (*)(int, const struct kevent *, int, + struct kevent *, int, const struct timespec *)) + __libc_interposing[INTERPOS_kevent])(kq, changelist, nchanges, + eventlist, nevents, timeout)); +} diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index 9a7cc23..c5e8caf 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 18, 2014 +.Dd March 29, 2015 .Dt KQUEUE 2 .Os .Sh NAME @@ -41,7 +41,7 @@ .Fn kqueue "void" .Ft int .Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout" -.Fn EV_SET "&kev" ident filter flags fflags data udata +.Fn EV_SET "kev" ident filter flags fflags data udata .Sh DESCRIPTION The .Fn kqueue @@ -162,56 +162,56 @@ struct kevent { The fields of .Fa struct kevent are: -.Bl -tag -width XXXfilter -.It ident +.Bl -tag -width "Fa filter" +.It Fa ident Value used to identify this event. The exact interpretation is determined by the attached filter, but often is a file descriptor. -.It filter +.It Fa filter Identifies the kernel filter used to process this event. The pre-defined system filters are described below. -.It flags +.It Fa flags Actions to perform on the event. -.It fflags +.It Fa fflags Filter-specific flags. -.It data +.It Fa data Filter-specific data value. -.It udata +.It Fa udata Opaque user-defined value passed through the kernel unchanged. .El .Pp The .Va flags field can contain the following values: -.Bl -tag -width XXXEV_ONESHOT -.It EV_ADD +.Bl -tag -width EV_DISPATCH +.It Dv EV_ADD Adds the event to the kqueue. Re-adding an existing event will modify the parameters of the original event, and not result in a duplicate entry. Adding an event automatically enables it, unless overridden by the EV_DISABLE flag. -.It EV_ENABLE +.It Dv EV_ENABLE Permit .Fn kevent to return the event if it is triggered. -.It EV_DISABLE +.It Dv EV_DISABLE Disable the event so .Fn kevent will not return it. The filter itself is not disabled. -.It EV_DISPATCH +.It Dv EV_DISPATCH Disable the event source immediately after delivery of an event. See .Dv EV_DISABLE above. -.It EV_DELETE +.It Dv EV_DELETE Removes the event from the kqueue. Events which are attached to file descriptors are automatically deleted on the last close of the descriptor. -.It EV_RECEIPT +.It Dv EV_RECEIPT This flag is useful for making bulk changes to a kqueue without draining any pending events. When passed as input, it forces @@ -220,20 +220,20 @@ to always be returned. When a filter is successfully added the .Va data field will be zero. -.It EV_ONESHOT +.It Dv EV_ONESHOT Causes the event to return only the first occurrence of the filter being triggered. After the user retrieves the event from the kqueue, it is deleted. -.It EV_CLEAR +.It Dv EV_CLEAR After the event is retrieved by the user, its state is reset. This is useful for filters which report state transitions instead of the current state. Note that some filters may automatically set this flag internally. -.It EV_EOF +.It Dv EV_EOF Filters may set this flag to indicate filter-specific EOF condition. -.It EV_ERROR +.It Dv EV_ERROR See .Sx RETURN VALUES below. @@ -245,8 +245,8 @@ Arguments may be passed to and from the filter via the and .Va data fields in the kevent structure. -.Bl -tag -width EVFILT_PROCDESC -.It EVFILT_READ +.Bl -tag -width "Dv EVFILT_PROCDESC" +.It Dv EVFILT_READ Takes a descriptor as the identifier, and returns whenever there is data available to read. The behavior of the filter is slightly different depending @@ -265,7 +265,7 @@ subject to the value of the socket buffer. This may be overridden with a per-filter low water mark at the time the filter is added by setting the -NOTE_LOWAT +.Dv NOTE_LOWAT flag in .Va fflags , and specifying the new low water mark in @@ -275,7 +275,9 @@ On return, contains the number of bytes of protocol data available to read. .Pp If the read direction of the socket has shutdown, then the filter -also sets EV_EOF in +also sets +.Dv EV_EOF +in .Va flags , and returns the socket error (if any) in .Va fflags . @@ -291,9 +293,13 @@ Returns when the there is data to read; .Va data contains the number of bytes available. .Pp -When the last writer disconnects, the filter will set EV_EOF in +When the last writer disconnects, the filter will set +.Dv EV_EOF +in .Va flags . -This may be cleared by passing in EV_CLEAR, at which point the +This may be cleared by passing in +.Dv EV_CLEAR , +at which point the filter will resume waiting for data to become available before returning. .It "BPF devices" @@ -304,7 +310,7 @@ enabled and there is any data to read; .Va data contains the number of bytes available. .El -.It EVFILT_WRITE +.It Dv EVFILT_WRITE Takes a descriptor as the identifier, and returns whenever it is possible to write to the descriptor. For sockets, pipes @@ -312,23 +318,30 @@ and fifos, .Va data will contain the amount of space remaining in the write buffer. The filter will set EV_EOF when the reader disconnects, and for -the fifo case, this may be cleared by use of EV_CLEAR. +the fifo case, this may be cleared by use of +.Dv EV_CLEAR . Note that this filter is not supported for vnodes or BPF devices. .Pp For sockets, the low water mark and socket error handling is -identical to the EVFILT_READ case. -.It EVFILT_AIO +identical to the +.Dv EVFILT_READ +case. +.It Dv EVFILT_AIO The sigevent portion of the AIO request is filled in, with .Va sigev_notify_kqueue containing the descriptor of the kqueue that the event should be attached to, .Va sigev_notify_kevent_flags -containing the kevent flags which should be EV_ONESHOT, EV_CLEAR or -EV_DISPATCH, +containing the kevent flags which should be +.Dv EV_ONESHOT , +.Dv EV_CLEAR +or +.Dv EV_DISPATCH , .Va sigev_value containing the udata value, and .Va sigev_notify -set to SIGEV_KEVENT. +set to +.Dv SIGEV_KEVENT . When the .Fn aio_* system call is made, the event will be registered @@ -339,29 +352,30 @@ argument set to the returned by the .Fn aio_* system call. -The filter returns under the same conditions as aio_error. -.It EVFILT_VNODE +The filter returns under the same conditions as +.Fn aio_error . +.It Dv EVFILT_VNODE Takes a file descriptor as the identifier and the events to watch for in .Va fflags , and returns when one or more of the requested events occurs on the descriptor. The events to monitor are: -.Bl -tag -width XXNOTE_RENAME -.It NOTE_DELETE +.Bl -tag -width "Dv NOTE_RENAME" +.It Dv NOTE_DELETE The .Fn unlink system call was called on the file referenced by the descriptor. -.It NOTE_WRITE +.It Dv NOTE_WRITE A write occurred on the file referenced by the descriptor. -.It NOTE_EXTEND +.It Dv NOTE_EXTEND The file referenced by the descriptor was extended. -.It NOTE_ATTRIB +.It Dv NOTE_ATTRIB The file referenced by the descriptor had its attributes changed. -.It NOTE_LINK +.It Dv NOTE_LINK The link count on the file changed. -.It NOTE_RENAME +.It Dv NOTE_RENAME The file referenced by the descriptor was renamed. -.It NOTE_REVOKE +.It Dv NOTE_REVOKE Access to the file was revoked via .Xr revoke 2 or the underlying file system was unmounted. @@ -370,26 +384,26 @@ or the underlying file system was unmounted. On return, .Va fflags contains the events which triggered the filter. -.It EVFILT_PROC +.It Dv EVFILT_PROC Takes the process ID to monitor as the identifier and the events to watch for in .Va fflags , and returns when the process performs one or more of the requested events. If a process can normally see another process, it can attach an event to it. The events to monitor are: -.Bl -tag -width XXNOTE_TRACKERR -.It NOTE_EXIT +.Bl -tag -width "Dv NOTE_TRACKERR" +.It Dv NOTE_EXIT The process has exited. The exit status will be stored in .Va data . -.It NOTE_FORK +.It Dv NOTE_FORK The process has called .Fn fork . -.It NOTE_EXEC +.It Dv NOTE_EXEC The process has executed a new process via .Xr execve 2 or a similar call. -.It NOTE_TRACK +.It Dv NOTE_TRACK Follow a process across .Fn fork calls. @@ -397,22 +411,28 @@ The parent process registers a new kevent to monitor the child process using the same .Va fflags as the original event. -The child process will signal an event with NOTE_CHILD set in +The child process will signal an event with +.Dv NOTE_CHILD +set in .Va fflags and the parent PID in .Va data . .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 +it will signal an event with +.Dv NOTE_TRACKERR +set in .Va fflags , -and the child process will not signal a NOTE_CHILD event. +and the child process will not signal a +.Dv NOTE_CHILD +event. .El .Pp On return, .Va fflags contains the events which triggered the filter. -.It EVFILT_PROCDESC +.It Dv EVFILT_PROCDESC Takes the process descriptor created by .Xr pdfork 2 to monitor as the identifier and the events to watch for in @@ -420,8 +440,8 @@ to monitor as the identifier and the events to watch for in and returns when the associated process performs one or more of the requested events. The events to monitor are: -.Bl -tag -width XXNOTE_EXIT -.It NOTE_EXIT +.Bl -tag -width "Dv NOTE_EXIT" +.It Dv NOTE_EXIT The process has exited. The exit status will be stored in .Va data . @@ -430,7 +450,7 @@ The exit status will be stored in On return, .Va fflags contains the events which triggered the filter. -.It EVFILT_SIGNAL +.It Dv EVFILT_SIGNAL Takes the signal number to monitor as the identifier and returns when the given signal is delivered to the process. This coexists with the @@ -440,7 +460,9 @@ and facilities, and has a lower precedence. The filter will record all attempts to deliver a signal to a process, even if the signal has -been marked as SIG_IGN, except for the +been marked as +.Dv SIG_IGN , +except for the .Dv SIGCHLD signal, which, if ignored, won't be recorded by the filter. Event notification happens after normal @@ -448,14 +470,18 @@ signal delivery processing. .Va data returns the number of times the signal has occurred since the last call to .Fn kevent . -This filter automatically sets the EV_CLEAR flag internally. -.It EVFILT_TIMER +This filter automatically sets the +.Dv EV_CLEAR +flag internally. +.It Dv EVFILT_TIMER Establishes an arbitrary timer identified by .Va ident . When adding a timer, .Va data specifies the timeout period. -The timer will be periodic unless EV_ONESHOT is specified. +The timer will be periodic unless +.Dv EV_ONESHOT +is specified. On return, .Va data contains the number of times the timeout has expired since the last call to @@ -465,7 +491,7 @@ There is a system wide limit on the number of timers which is controlled by the .Va kern.kq_calloutmax sysctl. -.Bl -tag -width XXNOTE_USECONDS +.Bl -tag -width "Dv NOTE_USECONDS" .It Dv NOTE_SECONDS .Va data is in seconds. @@ -493,7 +519,7 @@ user level code. The lower 24 bits of the .Va fflags may be used for user defined flags and manipulated using the following: -.Bl -tag -width XXNOTE_FFLAGSMASK +.Bl -tag -width "Dv NOTE_FFLAGSMASK" .It Dv NOTE_FFNOP Ignore the input .Va fflags . @@ -515,7 +541,7 @@ User defined flag mask for .El .Pp A user event is triggered for output with the following: -.Bl -tag -width XXNOTE_FFLAGSMASK +.Bl -tag -width "Dv NOTE_FFLAGSMASK" .It Dv NOTE_TRIGGER Cause the event to be triggered. .El @@ -524,6 +550,16 @@ On return, .Va fflags contains the users defined flags in the lower 24 bits. .El +.Sh CANCELLATION BEHAVIOUR +If +.Fa nevents +is non-zero, i.e. the function is potentially blocking, the call +is a cancellation point. +Otherwise, i.e. if +.Fa nevents +is zero, the call is not cancellable. +Cancellation can only occur before any changes are made to the kqueue, +or when the call was blocked and no changes to the queue were requested. .Sh RETURN VALUES The .Fn kqueue @@ -594,6 +630,8 @@ The specified descriptor is invalid. .It Bq Er EINTR A signal was delivered before the timeout expired and before any events were placed on the kqueue for return. +.It Bq Er EINTR +A cancellation request was delivered to the thread, but not yet handled. .It Bq Er EINVAL The specified time limit or filter is invalid. .It Bq Er ENOENT @@ -608,6 +646,14 @@ sysctl. .It Bq Er ESRCH The specified process to attach to does not exist. .El +.Pp +When +.Fn kevent +call fails with +.Er EINTR +error, all changes in the +.Fa changelist +have been applied. .Sh SEE ALSO .Xr aio_error 2 , .Xr aio_read 2 , @@ -617,6 +663,7 @@ The specified process to attach to does not exist. .Xr select 2 , .Xr sigaction 2 , .Xr write 2 , +.Xr pthread_setcancelstate 3 , .Xr signal 3 .Sh HISTORY The diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c deleted file mode 100644 index a086be1..0000000 --- a/lib/libc/sys/lseek.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lseek.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -off_t -lseek(fd, offset, whence) - int fd; - off_t offset; - int whence; -{ - - if (__getosreldate() >= 700051) - return(__sys_lseek(fd, offset, whence)); - else - return(__sys_freebsd6_lseek(fd, 0, offset, whence)); -} diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 7380a7f..c818342 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 September 17, 2014 +.Dd February 18, 2015 .Dt MMAP 2 .Os .Sh NAME @@ -160,7 +160,7 @@ is specified, must be a multiple of the pagesize. If .Dv MAP_EXCL -is not specified, a successfull +is not specified, a successful .Dv MAP_FIXED request replaces any previous mappings for the process' pages in the range from @@ -225,7 +225,7 @@ it. You can test file fragmentation by observing the KB/t (kilobytes per transfer) results from an .Dq Li iostat 1 -while reading a large file sequentially, e.g.\& using +while reading a large file sequentially, e.g.,\& using .Dq Li dd if=filename of=/dev/null bs=32k . .Pp The @@ -448,17 +448,3 @@ was specified and insufficient memory was available. .Xr munmap 2 , .Xr getpagesize 3 , .Xr getpagesizes 3 -.Sh BUGS -The -.Fa len -argument -is limited to the maximum file size or available userland address -space. -Files may not be able to be made more than 1TB large on 32 bit systems -due to file systems restrictions and bugs, but address space is far more -restrictive. -Larger files may be possible on 64 bit systems. -.Pp -The previous documented limit of 2GB was a documentation bug. -That limit has not existed since -.Fx 2.2 . diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c deleted file mode 100644 index 0fa03ba..0000000 --- a/lib/libc/sys/mmap.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -void * -mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - - if (__getosreldate() >= 700051) { - return (__sys_mmap(addr, len, prot, flags, fd, offset)); - } else { - return (__sys_freebsd6_mmap(addr, len, prot, flags, fd, 0, - offset)); - } -} diff --git a/lib/libc/sys/mount.2 b/lib/libc/sys/mount.2 index 57ad428..881d830 100644 --- a/lib/libc/sys/mount.2 +++ b/lib/libc/sys/mount.2 @@ -28,7 +28,7 @@ .\" @(#)mount.2 8.3 (Berkeley) 5/24/95 .\" $FreeBSD$ .\" -.Dd January 26, 2010 +.Dd April 13, 2015 .Dt MOUNT 2 .Os .Sh NAME @@ -86,7 +86,7 @@ containing .Fa niov elements. The following options are required by all file systems: -.Bl -item -offset indent -compact +.Bl -column fstype -offset indent .It .Li fstype Ta file system type name (e.g., Dq Li procfs ) .It @@ -351,11 +351,6 @@ The argument points outside the process's allocated address space. .El -.Pp -A -.Em ufs -mount can also fail if the maximum number of file systems are currently -mounted. .Sh SEE ALSO .Xr lsvfs 1 , .Xr mksnap_ffs 8 , diff --git a/lib/libc/sys/msync.c b/lib/libc/sys/msync.c new file mode 100644 index 0000000..3c6879f --- /dev/null +++ b/lib/libc/sys/msync.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/fcntl.h> +#include "libc_private.h" + +__weak_reference(__sys_msync, __msync); + +#pragma weak msync +int +msync(void *addr, size_t len, int flags) +{ + + return (((int (*)(void *, size_t, int)) + __libc_interposing[INTERPOS_msync])(addr, len, flags)); +} diff --git a/lib/libc/sys/nanosleep.c b/lib/libc/sys/nanosleep.c new file mode 100644 index 0000000..412b05e --- /dev/null +++ b/lib/libc/sys/nanosleep.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <time.h> +#include "libc_private.h" + +__weak_reference(__sys_nanosleep, __nanosleep); + +#pragma weak nanosleep +int +nanosleep(const struct timespec *rqtp, struct timespec *rmtp) +{ + + return (((int (*)(const struct timespec *, struct timespec *)) + __libc_interposing[INTERPOS_nanosleep])(rqtp, rmtp)); +} diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index 41a6c64..acd376c 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd February 7, 2013 +.Dd April 2, 2015 .Dt OPEN 2 .Os .Sh NAME @@ -115,8 +115,8 @@ O_DIRECT eliminate or reduce cache effects O_FSYNC synchronous writes O_SYNC synchronous writes O_NOFOLLOW do not follow symlinks -O_NOCTTY don't assign controlling terminal -O_TTY_INIT restore default terminal attributes +O_NOCTTY ignored +O_TTY_INIT ignored O_DIRECTORY error if file is not a directory O_CLOEXEC set FD_CLOEXEC upon open .Ed diff --git a/lib/libc/sys/open.c b/lib/libc/sys/open.c new file mode 100644 index 0000000..e0273c6 --- /dev/null +++ b/lib/libc/sys/open.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/fcntl.h> +#include <stdarg.h> +#include "libc_private.h" + +__weak_reference(__sys_open, __open); + +#pragma weak open +int +open(const char *path, int flags, ...) +{ + va_list ap; + int mode; + + if ((flags & O_CREAT) != 0) { + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } else { + mode = 0; + } + return (((int (*)(int, const char *, int, ...)) + __libc_interposing[INTERPOS_openat])(AT_FDCWD, path, flags, mode)); +} diff --git a/lib/libc/sys/openat.c b/lib/libc/sys/openat.c new file mode 100644 index 0000000..1bd12ea --- /dev/null +++ b/lib/libc/sys/openat.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/fcntl.h> +#include <stdarg.h> +#include "libc_private.h" + +__weak_reference(__sys_openat, __openat); +__sym_compat(openat, __impl_openat, FBSD_1.1); +__weak_reference(openat, __impl_openat); +__sym_default(openat, openat, FBSD_1.2); + +#pragma weak openat +int +openat(int fd, const char *path, int flags, ...) +{ + va_list ap; + int mode; + + if ((flags & O_CREAT) != 0) { + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } else { + mode = 0; + } + return (((int (*)(int, const char *, int, ...)) + __libc_interposing[INTERPOS_openat])(fd, path, flags, mode)); +} diff --git a/lib/libc/sys/poll.2 b/lib/libc/sys/poll.2 index a1c7ada..dbd641f 100644 --- a/lib/libc/sys/poll.2 +++ b/lib/libc/sys/poll.2 @@ -148,8 +148,8 @@ is zero, then will return without blocking. .Pp The -.Fn ppoll -system call, unlike +.Fn ppoll +system call, unlike .Fn poll , is used to safely wait until either a set of file descriptors becomes ready or until a signal is caught. @@ -174,13 +174,12 @@ used by A null pointer may be passed to indicate that .Fn ppoll should wait indefinitely. -Finally, +Finally, .Fa newsigmask specifies a signal mask which is set while waiting for input. -When +When .Fn ppoll returns, the original signal mask is restored. -.Pp .Bd -literal struct timespec { time_t tv_sec; /* seconds */ @@ -247,11 +246,11 @@ The specified time limit is invalid. One of its components is negative or too la .Xr write 2 .Sh STANDARDS The -.Fn poll +.Fn poll function conforms to .St -p1003.1-2001 . The -.Fn ppoll +.Fn ppoll is not specified by POSIX. .Sh HISTORY The @@ -262,8 +261,8 @@ This manual page and the core of the implementation was taken from .Nx . The .Fn ppoll -function first appeared in -.Fx 11.0 +function first appeared in +.Fx 11.0 .Sh BUGS The distinction between some of the fields in the .Fa events diff --git a/lib/libc/sys/poll.c b/lib/libc/sys/poll.c new file mode 100644 index 0000000..43c17d2 --- /dev/null +++ b/lib/libc/sys/poll.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/poll.h> +#include "libc_private.h" + +__weak_reference(__sys_poll, __poll); + +#pragma weak poll +int +poll(struct pollfd pfd[], nfds_t nfds, int timeout) +{ + + return (((int (*)(struct pollfd *, nfds_t, int)) + __libc_interposing[INTERPOS_poll])(pfd, nfds, timeout)); +} diff --git a/lib/libc/sys/posix_openpt.2 b/lib/libc/sys/posix_openpt.2 index 916e75a..b7e345c 100644 --- a/lib/libc/sys/posix_openpt.2 +++ b/lib/libc/sys/posix_openpt.2 @@ -110,8 +110,8 @@ is not valid. Out of pseudo-terminal resources. .El .Sh SEE ALSO -.Xr pts 4 , .Xr ptsname 3 , +.Xr pts 4 , .Xr tty 4 .Sh STANDARDS The @@ -137,4 +137,4 @@ is included for compatibility; in opening a terminal does not cause it to become a process's controlling terminal. .Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org +.An \&Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/sys/ppoll.c b/lib/libc/sys/ppoll.c new file mode 100644 index 0000000..f62fd19 --- /dev/null +++ b/lib/libc/sys/ppoll.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/poll.h> +#include "libc_private.h" + +__weak_reference(__sys_ppoll, __ppoll); + +#pragma weak ppoll +int +ppoll(struct pollfd pfd[], nfds_t nfds, const struct timespec *__restrict + timeout, const sigset_t *__restrict newsigmask) +{ + + return (((int (*)(struct pollfd *, nfds_t, const struct timespec *, + const sigset_t *)) __libc_interposing[INTERPOS_ppoll])(pfd, nfds, + timeout, newsigmask)); +} diff --git a/lib/libc/sys/pread.c b/lib/libc/sys/pread.c deleted file mode 100644 index 7566566..0000000 --- a/lib/libc/sys/pread.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -pread(fd, buf, nbyte, offset) - int fd; - void *buf; - size_t nbyte; - off_t offset; -{ - - if (__getosreldate() >= 700051) - return (__sys_pread(fd, buf, nbyte, offset)); - else - return (__sys_freebsd6_pread(fd, buf, nbyte, 0, offset)); -} diff --git a/lib/libc/sys/procctl.2 b/lib/libc/sys/procctl.2 index 6ad0590..76a3cef 100644 --- a/lib/libc/sys/procctl.2 +++ b/lib/libc/sys/procctl.2 @@ -1,7 +1,11 @@ -.\" Copyright (c) 2013 Advanced Computing Technologies LLC +.\" Copyright (c) 2013 Hudson River Trading LLC .\" Written by: John H. Baldwin <jhb@FreeBSD.org> .\" All rights reserved. .\" +.\" Copyright (c) 2014 The FreeBSD Foundation +.\" Portions of this documentation were written by Konstantin Belousov +.\" under sponsorship from the FreeBSD Foundation. +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -25,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 19, 2013 +.Dd December 29, 2014 .Dt PROCCTL 2 .Os .Sh NAME @@ -67,7 +71,7 @@ The control request to perform is specified by the .Fa cmd argument. The following commands are supported: -.Bl -tag -width "Dv PROC_SPROTECT" +.Bl -tag -width "Dv PROC_REAP_GETPIDS" .It Dv PROC_SPROTECT Set process protection state. This is used to mark a process as protected from being killed if the system @@ -95,7 +99,237 @@ When used with mark all future child processes of each selected process as protected. Future child processes will also mark all of their future child processes. .El +.It Dv PROC_REAP_ACQUIRE +Acquires the reaper status for the current process. +The status means that children orphaned by the reaper's descendants +that were forked after the acquisition of the status are reparented to the +reaper. +After the system initialization, +.Xr init 8 +is the default reaper. +.It Dv PROC_REAP_RELEASE +Releases the reaper state for the current process. +The reaper of the current process becomes the new reaper of the +current process's descendants. +.It Dv PROC_REAP_STATUS +Provides the information about the reaper of the specified process, +or the process itself when it is a reaper. +The +.Fa data +argument must point to a +.Vt procctl_reaper_status +structure which is filled in by the syscall on successful return. +.Bd -literal +struct procctl_reaper_status { + u_int rs_flags; + u_int rs_children; + u_int rs_descendants; + pid_t rs_reaper; + pid_t rs_pid; +}; +.Ed +The +.Fa rs_flags +may have the following flags returned: +.Bl -tag -width "Dv REAPER_STATUS_REALINIT" +.It Dv REAPER_STATUS_OWNED +The specified process has acquired the reaper status and has not +released it. +When the flag is returned, the specified process +.Fa id , +pid, identifies the reaper, otherwise the +.Fa rs_reaper +field of the structure is set to the pid of the reaper +for the specified process id. +.It Dv REAPER_STATUS_REALINIT +The specified process is the root of the reaper tree, i.e. +.Xr init 8 . +.El +.Pp +The +.Fa rs_children +field returns the number of children of the reaper. +The +.Fa rs_descendants +field returns the total number of descendants of the reaper(s), +not counting descendants of the reaper in the subtree. +The +.Fa rs_reaper +field returns the reaper pid. +The +.Fa rs_pid +returns the pid of one reaper child if there are any descendants. +.It Dv PROC_REAP_GETPIDS +Queries the list of descendants of the reaper of the specified process. +The request takes a pointer to a +.Vt procctl_reaper_pids +structure in the +.Fa data +parameter. +.Bd -literal +struct procctl_reaper_pids { + u_int rp_count; + struct procctl_reaper_pidinfo *rp_pids; +}; +.Ed +When called, the +.Fa rp_pids +field must point to an array of +.Vt procctl_reaper_pidinfo +structures, to be filled in on return, +and the +.Fa rp_count +field must specify the size of the array, +into which no more than +.Fa rp_count +elements will be filled in by the kernel. +.Pp +The +.Vt "struct procctl_reaper_pidinfo" +structure provides some information about one of the reaper's descendants. +Note that for a descendant that is not a child, it may be incorrectly +identified because of a race in which the original child process exited +and the exited process's pid was reused for an unrelated process. +.Bd -literal +struct procctl_reaper_pidinfo { + pid_t pi_pid; + pid_t pi_subtree; + u_int pi_flags; +}; +.Ed +The +.Fa pi_pid +field is the process id of the descendant. +The +.Fa pi_subtree +field provides the pid of the child of the reaper, which is the (grand-)parent +of the process. +The +.Fa pi_flags +field returns the following flags, further describing the descendant: +.Bl -tag -width "Dv REAPER_PIDINFO_VALID" +.It Dv REAPER_PIDINFO_VALID +Set to indicate that the +.Vt procctl_reaper_pidinfo +structure was filled in by the kernel. +Zero-filling the +.Fa rp_pids +array and testing the +.Dv REAPER_PIDINFO_VALID +flag allows the caller to detect the end +of the returned array. +.It Dv REAPER_PIDINFO_CHILD +The +.Fa pi_pid +field identifies the direct child of the reaper. +.El +.It Dv PROC_REAP_KILL +Request to deliver a signal to some subset of the descendants of the reaper. +The +.Fa data +parameter must point to a +.Vt procctl_reaper_kill +structure, which is used both for parameters and status return. +.Bd -literal +struct procctl_reaper_kill { + int rk_sig; + u_int rk_flags; + pid_t rk_subtree; + u_int rk_killed; + pid_t rk_fpid; +}; +.Ed +The +.Fa rk_sig +field specifies the signal to be delivered. +Zero is not a valid signal number, unlike +.Xr kill 2 . +The +.Fa rk_flags +field further directs the operation. +It is or-ed from the following flags: +.Bl -tag -width "Dv REAPER_KILL_CHILDREN" +.It Dv REAPER_KILL_CHILDREN +Deliver the specified signal only to direct children of the reaper. +.It Dv REAPER_KILL_SUBTREE +Deliver the specified signal only to descendants that were forked by +the direct child with pid specified in the +.Fa rk_subtree +field. +.El +If neither the +.Dv REAPER_KILL_CHILDREN +nor the +.Dv REAPER_KILL_SUBTREE +flags are specified, all current descendants of the reaper are signalled. +.Pp +If a signal was delivered to any process, the return value from the request +is zero. +In this case, the +.Fa rk_killed +field identifies the number of processes signalled. +The +.Fa rk_fpid +field is set to the pid of the first process for which signal +delivery failed, e.g. due to the permission problems. +If no such process exist, the +.Fa rk_fpid +field is set to -1. +.It Dv PROC_TRACE_CTL +Enable or disable tracing of the specified process(es), according to the +value of the integer argument. +Tracing includes attachment to the process using +.Xr ptrace 2 +and +.Xr ktrace 2 , +debugging sysctls, +.Xr hwpmc 4 , +.Xr dtrace 1 +and core dumping. +Possible values for the +.Fa data +argument are: +.Bl -tag -width "Dv PROC_TRACE_CTL_DISABLE_EXEC" +.It Dv PROC_TRACE_CTL_ENABLE +Enable tracing, after it was disabled by +.Dv PROC_TRACE_CTL_DISABLE . +Only allowed for self. +.It Dv PROC_TRACE_CTL_DISABLE +Disable tracing for the specified process. +Tracing is re-enabled when the process changes the executing +program with +.Xr execve 2 +syscall. +A child inherits the trace settings from the parent on +.Xr fork 2 . +.It Dv PROC_TRACE_CTL_DISABLE_EXEC +Same as +.Dv PROC_TRACE_CTL_DISABLE , +but the setting persist for the process even after +.Xr execve 2 . +.El +.It Dv PROC_TRACE_STATUS +Returns the current tracing status for the specified process in +the integer variable pointed to by +.Fa data . +If tracing is disabled, +.Fa data +is set to -1. +If tracing is enabled, but no debugger is attached by +.Xr ptrace 2 +syscall, +.Fa data +is set to 0. +If a debugger is attached, +.Fa data +is set to the pid of the debugger process. .El +.Sh NOTES +Disabling tracing on a process should not be considered a security +feature, as it is bypassable both by the kernel and privileged processes, +and via other system mechanisms. +As such, it should not be relied on to reliably protect cryptographic +keying material or other confidential data. .Sh RETURN VALUES If an error occurs, a value of -1 is returned and .Va errno @@ -109,7 +343,7 @@ will fail if: .It Bq Er EFAULT The .Fa arg -points outside the process's allocated address space. +parameter points outside the process's allocated address space. .It Bq Er EINVAL The .Fa cmd @@ -132,11 +366,71 @@ An invalid operation or flag was passed in for a .Dv PROC_SPROTECT command. +.It Bq Er EPERM +The +.Fa idtype +argument is not equal to +.Dv P_PID , +or +.Fa id +is not equal to the pid of the calling process, for +.Dv PROC_REAP_ACQUIRE +or +.Dv PROC_REAP_RELEASE +requests. +.It Bq Er EINVAL +Invalid or undefined flags were passed to a +.Dv PROC_REAP_KILL +request. +.It Bq Er EINVAL +An invalid or zero signal number was requested for a +.Dv PROC_REAP_KILL +request. +.It Bq Er EINVAL +The +.Dv PROC_REAP_RELEASE +request was issued by the +.Xr init 8 +process. +.It Bq Er EBUSY +The +.Dv PROC_REAP_ACQUIRE +request was issued by a process that had already acquired reaper status +and has not yet released it. +.It Bq Er EBUSY +The +.Dv PROC_TRACE_CTL +request was issued for a process already being traced. +.It Bq Er EPERM +The +.Dv PROC_TRACE_CTL +request to re-enable tracing of the process ( +.Dv PROC_TRACE_CTL_ENABLE ) , +or to disable persistence of the +.Dv PROC_TRACE_CTL_DISABLE +on +.Xr execve 2 +was issued for a non-current process. +.It Bq Er EINVAL +The value of the integer +.Fa data +parameter for the +.Dv PROC_TRACE_CTL +request is invalid. .El .Sh SEE ALSO -.Xr ptrace 2 +.Xr dtrace 1 , +.Xr kill 2 , +.Xr ktrace 2 , +.Xr ptrace 2 , +.Xr wait 2 , +.Xr hwpmc 4 , +.Xr init 8 .Sh HISTORY The .Fn procctl function appeared in .Fx 10.0 . +The reaper facility is based on a similar feature of Linux and +DragonflyBSD, and first appeared in +.Fx 10.2 . diff --git a/lib/libc/sys/pselect.c b/lib/libc/sys/pselect.c new file mode 100644 index 0000000..a623a7d --- /dev/null +++ b/lib/libc/sys/pselect.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/select.h> +#include "libc_private.h" + +__weak_reference(__sys_pselect, __pselect); + +#pragma weak pselect +int +pselect(int n, fd_set *rs, fd_set *ws, fd_set *es, const struct timespec *t, + const sigset_t *s) +{ + + return (((int (*)(int, fd_set *, fd_set *, fd_set *, + const struct timespec *, const sigset_t *)) + __libc_interposing[INTERPOS_pselect])(n, rs, ws, es, t, s)); +} diff --git a/lib/libc/sys/pwrite.c b/lib/libc/sys/pwrite.c deleted file mode 100644 index d17ed29..0000000 --- a/lib/libc/sys/pwrite.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -pwrite(fd, buf, nbyte, offset) - int fd; - const void *buf; - size_t nbyte; - off_t offset; -{ - if (__getosreldate() >= 700051) - return (__sys_pwrite(fd, buf, nbyte, offset)); - else - return (__sys_freebsd6_pwrite(fd, buf, nbyte, 0, offset)); -} diff --git a/lib/libc/sys/read.c b/lib/libc/sys/read.c new file mode 100644 index 0000000..ab30189 --- /dev/null +++ b/lib/libc/sys/read.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <unistd.h> +#include "libc_private.h" + +__weak_reference(__sys_read, __read); + +#pragma weak read +ssize_t +read(int fd, void *buf, size_t nbytes) +{ + + return (((ssize_t (*)(int, void *, size_t)) + __libc_interposing[INTERPOS_read])(fd, buf, nbytes)); +} diff --git a/lib/libc/sys/readv.c b/lib/libc/sys/readv.c new file mode 100644 index 0000000..8c82040 --- /dev/null +++ b/lib/libc/sys/readv.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <unistd.h> +#include "libc_private.h" + +__weak_reference(__sys_readv, __readv); + +#pragma weak readv +ssize_t +readv(int fd, const struct iovec *iov, int iovcnt) +{ + + return (((ssize_t (*)(int, const struct iovec *, int)) + __libc_interposing[INTERPOS_readv])(fd, iov, iovcnt)); +} diff --git a/lib/libc/sys/recvfrom.c b/lib/libc/sys/recvfrom.c new file mode 100644 index 0000000..aa6ef3f --- /dev/null +++ b/lib/libc/sys/recvfrom.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_recvfrom, __recvfrom); + +#pragma weak recvfrom +ssize_t +recvfrom(int s, void *buf, size_t len, int flags, + struct sockaddr * __restrict from, socklen_t * __restrict fromlen) +{ + + return (((ssize_t (*)(int, void *, size_t, int, + struct sockaddr *, socklen_t *)) + __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags, + from, fromlen)); +} diff --git a/lib/libc/sys/recvmsg.c b/lib/libc/sys/recvmsg.c new file mode 100644 index 0000000..282ede9 --- /dev/null +++ b/lib/libc/sys/recvmsg.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_recvmsg, __recvmsg); + +#pragma weak recvmsg +ssize_t +recvmsg(int s, struct msghdr *msg, int flags) +{ + + return (((int (*)(int, struct msghdr *, int)) + __libc_interposing[INTERPOS_recvmsg])(s, msg, flags)); +} diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2 index 57abdbb..482cbf6 100644 --- a/lib/libc/sys/revoke.2 +++ b/lib/libc/sys/revoke.2 @@ -97,8 +97,8 @@ operation on the named file. The caller is neither the owner of the file nor the super user. .El .Sh SEE ALSO -.Xr close 2 , -.Xr revoke 1 +.Xr revoke 1 , +.Xr close 2 .Sh HISTORY The .Fn revoke diff --git a/lib/libc/sys/sched_setscheduler.2 b/lib/libc/sys/sched_setscheduler.2 index 3e7c42b..b84c1a1 100644 --- a/lib/libc/sys/sched_setscheduler.2 +++ b/lib/libc/sys/sched_setscheduler.2 @@ -151,9 +151,9 @@ argument is invalid, or one or more of the parameters contained in is outside the valid range for the specified scheduling policy. .El .Sh SEE ALSO -.Xr sched_getparam 2 , .Xr sched_get_priority_max 2 , .Xr sched_get_priority_min 2 , +.Xr sched_getparam 2 , .Xr sched_rr_get_interval 2 , .Xr sched_setparam 2 , .Xr sched_yield 2 diff --git a/lib/libc/sys/select.c b/lib/libc/sys/select.c new file mode 100644 index 0000000..3990496 --- /dev/null +++ b/lib/libc/sys/select.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/select.h> +#include "libc_private.h" + +__weak_reference(__sys_select, __select); + +#pragma weak select +int +select(int n, fd_set *rs, fd_set *ws, fd_set *es, struct timeval *t) +{ + + return (((int (*)(int, fd_set *, fd_set *, fd_set *, struct timeval *)) + __libc_interposing[INTERPOS_select])(n, rs, ws, es, t)); +} diff --git a/lib/libc/sys/sendmsg.c b/lib/libc/sys/sendmsg.c new file mode 100644 index 0000000..7944643 --- /dev/null +++ b/lib/libc/sys/sendmsg.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_sendmsg, __sendmsg); + +#pragma weak sendmsg +ssize_t +sendmsg(int s, const struct msghdr *msg, int flags) +{ + + return (((int (*)(int, const struct msghdr *, int)) + __libc_interposing[INTERPOS_sendmsg])(s, msg, flags)); +} diff --git a/lib/libc/sys/sendto.c b/lib/libc/sys/sendto.c new file mode 100644 index 0000000..ecf98ee --- /dev/null +++ b/lib/libc/sys/sendto.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/socket.h> +#include "libc_private.h" + +__weak_reference(__sys_sendto, __sendto); + +#pragma weak sendto +ssize_t +sendto(int s, const void *msg, size_t len, int flags, + const struct sockaddr *to, socklen_t tolen) +{ + + return (((ssize_t (*)(int, const void *, size_t, int, + const struct sockaddr *, socklen_t)) + __libc_interposing[INTERPOS_sendto])(s, msg, len, flags, + to, tolen)); +} diff --git a/lib/libc/sys/setcontext.c b/lib/libc/sys/setcontext.c new file mode 100644 index 0000000..31b888f --- /dev/null +++ b/lib/libc/sys/setcontext.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <ucontext.h> +#include "libc_private.h" + +__weak_reference(__sys_setcontext, __setcontext); +__sym_compat(setcontext, __impl_setcontext, FBSD_1.0); +__weak_reference(setcontext, __impl_setcontext); +__sym_default(setcontext, setcontext, FBSD_1.2); + +#pragma weak setcontext +int +setcontext(const ucontext_t *uc) +{ + + return (((int (*)(const ucontext_t *)) + __libc_interposing[INTERPOS_setcontext])(uc)); +} diff --git a/lib/libc/sys/setresuid.2 b/lib/libc/sys/setresuid.2 index 08d07f3..602166f 100644 --- a/lib/libc/sys/setresuid.2 +++ b/lib/libc/sys/setresuid.2 @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 13, 2001 +.Dd February 7, 2015 .Dt SETRESUID 2 .Os .Sh NAME @@ -90,10 +90,5 @@ was invalid. .Xr setregid 2 , .Xr setreuid 2 , .Xr setuid 2 -.Sh STANDARDS -These system calls are not available on many platforms. -They exist in -.Fx -to support Linux binaries linked against GNU libc2. .Sh HISTORY These functions first appeared in HP-UX. diff --git a/lib/libc/sys/sigaction.c b/lib/libc/sys/sigaction.c new file mode 100644 index 0000000..7645538 --- /dev/null +++ b/lib/libc/sys/sigaction.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <signal.h> +#include "libc_private.h" + +__weak_reference(__sys_sigaction, __sigaction); + +#pragma weak sigaction +int +sigaction(int sig, const struct sigaction *act, struct sigaction *oact) +{ + + return (((int (*)(int, const struct sigaction *, struct sigaction *)) + __libc_interposing[INTERPOS_sigaction])(sig, act, oact)); +} diff --git a/lib/libc/sys/sigprocmask.c b/lib/libc/sys/sigprocmask.c new file mode 100644 index 0000000..40dba95 --- /dev/null +++ b/lib/libc/sys/sigprocmask.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <signal.h> +#include "libc_private.h" + +__weak_reference(__sys_sigprocmask, __sigprocmask); + +#pragma weak sigprocmask +int +sigprocmask(int how, const sigset_t *set, sigset_t *oset) +{ + + return (((int (*)(int, const sigset_t *, sigset_t *)) + __libc_interposing[INTERPOS_sigprocmask])(how, set, oset)); +} diff --git a/lib/libc/sys/sigsuspend.c b/lib/libc/sys/sigsuspend.c new file mode 100644 index 0000000..6e47368 --- /dev/null +++ b/lib/libc/sys/sigsuspend.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <signal.h> +#include "libc_private.h" + +__weak_reference(__sys_sigsuspend, __sigsuspend); + +#pragma weak sigsuspend +int +sigsuspend(const sigset_t *set) +{ + + return (((int (*)(const sigset_t *)) + __libc_interposing[INTERPOS_sigsuspend])(set)); +} diff --git a/lib/libc/sys/sigtimedwait.c b/lib/libc/sys/sigtimedwait.c new file mode 100644 index 0000000..4e06719 --- /dev/null +++ b/lib/libc/sys/sigtimedwait.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <signal.h> +#include "libc_private.h" + +__weak_reference(__sys_sigtimedwait, __sigtimedwait); + +#pragma weak sigtimedwait +int +sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info, + const struct timespec * __restrict t) +{ + + return (((int (*)(const sigset_t *, siginfo_t *, + const struct timespec *)) + __libc_interposing[INTERPOS_sigtimedwait])(set, info, t)); +} diff --git a/lib/libc/sys/sigwait.c b/lib/libc/sys/sigwait.c index 2fdffdd..b21cabd 100644 --- a/lib/libc/sys/sigwait.c +++ b/lib/libc/sys/sigwait.c @@ -28,13 +28,21 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <signal.h> +#include "libc_private.h" -int __sys_sigwait(const sigset_t * restrict, int * restrict); +__weak_reference(__libc_sigwait, __sigwait); -__weak_reference(__sigwait, sigwait); +#pragma weak sigwait +int +sigwait(const sigset_t *set, int *sig) +{ + + return (((int (*)(const sigset_t *, int *)) + __libc_interposing[INTERPOS_sigwait])(set, sig)); +} int -__sigwait(const sigset_t * restrict set, int * restrict sig) +__libc_sigwait(const sigset_t *set, int *sig) { int ret; diff --git a/lib/libc/sys/sigwaitinfo.2 b/lib/libc/sys/sigwaitinfo.2 index 9109759..b497592 100644 --- a/lib/libc/sys/sigwaitinfo.2 +++ b/lib/libc/sys/sigwaitinfo.2 @@ -172,8 +172,8 @@ system calls fail if: .Bl -tag -width Er .It Bq Er EINTR The wait was interrupted by an unblocked, caught signal. -.Pp .El +.Pp The .Fn sigtimedwait system call may also fail if: diff --git a/lib/libc/sys/sigwaitinfo.c b/lib/libc/sys/sigwaitinfo.c new file mode 100644 index 0000000..b9cdc79 --- /dev/null +++ b/lib/libc/sys/sigwaitinfo.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <signal.h> +#include "libc_private.h" + +__weak_reference(__sys_sigwaitinfo, __sigwaitinfo); + +#pragma weak sigwaitinfo +int +sigwaitinfo(const sigset_t * __restrict set, siginfo_t * __restrict info) +{ + + return (((int (*)(const sigset_t *, siginfo_t *)) + __libc_interposing[INTERPOS_sigwaitinfo])(set, info)); +} diff --git a/lib/libc/sys/socketpair.2 b/lib/libc/sys/socketpair.2 index d3a47eb..b15553a 100644 --- a/lib/libc/sys/socketpair.2 +++ b/lib/libc/sys/socketpair.2 @@ -28,7 +28,7 @@ .\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 11, 2013 +.Dd May 4, 2015 .Dt SOCKETPAIR 2 .Os .Sh NAME @@ -40,13 +40,13 @@ .In sys/types.h .In sys/socket.h .Ft int -.Fn socketpair "int fd" "int type" "int protocol" "int *sv" +.Fn socketpair "int domain" "int type" "int protocol" "int *sv" .Sh DESCRIPTION The .Fn socketpair system call creates an unnamed pair of connected sockets in -the specified domain -.Fa fd , +the specified communications +.Fa domain , of the specified .Fa type , and using the optionally specified diff --git a/lib/libc/gen/swapcontext.c b/lib/libc/sys/swapcontext.c index c34cb23..0a8125e 100644 --- a/lib/libc/gen/swapcontext.c +++ b/lib/libc/sys/swapcontext.c @@ -1,7 +1,11 @@ /* * Copyright (c) 2001 Daniel M. Eischen <deischen@freebsd.org> + * Copyright (c) 2014 The FreeBSD Foundation. * All rights reserved. * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -30,26 +34,20 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/signal.h> #include <sys/ucontext.h> - #include <errno.h> #include <stddef.h> +#include "libc_private.h" -__weak_reference(__swapcontext, swapcontext); +__weak_reference(__sys_swapcontext, __swapcontext); +__sym_compat(swapcontext, __impl_swapcontext, FBSD_1.0); +__weak_reference(swapcontext, __impl_swapcontext); +__sym_default(swapcontext, swapcontext, FBSD_1.2); +#pragma weak swapcontext int -__swapcontext(ucontext_t *oucp, const ucontext_t *ucp) +swapcontext(ucontext_t *oucp, const ucontext_t *ucp) { - int ret; - if ((oucp == NULL) || (ucp == NULL)) { - errno = EINVAL; - return (-1); - } - oucp->uc_flags &= ~UCF_SWAPPED; - ret = getcontext(oucp); - if ((ret == 0) && !(oucp->uc_flags & UCF_SWAPPED)) { - oucp->uc_flags |= UCF_SWAPPED; - ret = setcontext(ucp); - } - return (ret); + return (((int (*)(ucontext_t *, const ucontext_t *)) + __libc_interposing[INTERPOS_swapcontext])(oucp, ucp)); } diff --git a/lib/libc/arm/sys/__vdso_gettc.c b/lib/libc/sys/trivial-vdso_tc.c index b99bbc4..b99bbc4 100644 --- a/lib/libc/arm/sys/__vdso_gettc.c +++ b/lib/libc/sys/trivial-vdso_tc.c diff --git a/lib/libc/sys/truncate.2 b/lib/libc/sys/truncate.2 index f06c1eb..0734464 100644 --- a/lib/libc/sys/truncate.2 +++ b/lib/libc/sys/truncate.2 @@ -28,7 +28,7 @@ .\" @(#)truncate.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd December 13, 2006 +.Dd May 4, 2015 .Dt TRUNCATE 2 .Os .Sh NAME @@ -60,9 +60,18 @@ is lost. If the file was smaller than this size, it will be extended as if by writing bytes with the value zero. -With -.Fn ftruncate , -the file must be open for writing. +.Pp +The +.Fn ftruncate +system call causes the file or shared memory object backing the file descriptor +.Fa fd +to be truncated or extended to +.Fa length +bytes in size. +The file descriptor must be a valid file descriptor open for writing. +The file position pointer associated with the file descriptor +.Fa fd +will not be modified. .Sh RETURN VALUES .Rv -std If the file to be modified is not a directory or @@ -129,7 +138,7 @@ is not a valid descriptor. The .Fa fd argument -references a socket, not a file. +references a file descriptor that is not a regular file or shared memory object. .It Bq Er EINVAL The .Fa fd @@ -138,11 +147,14 @@ is not open for writing. .El .Sh SEE ALSO .Xr chflags 2 , -.Xr open 2 +.Xr open 2 , +.Xr shm_open 2 .Sh HISTORY The .Fn truncate -system call appeared in +and +.Fn ftruncate +system calls appeared in .Bx 4.2 . .Sh BUGS These calls should be generalized to allow ranges diff --git a/lib/libc/sys/truncate.c b/lib/libc/sys/truncate.c deleted file mode 100644 index 375c9d9..0000000 --- a/lib/libc/sys/truncate.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)truncate.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -int -truncate(path, length) - const char *path; - off_t length; -{ - - if (__getosreldate() >= 700051) - return(__sys_truncate(path, length)); - else - return(__sys_freebsd6_truncate(path, 0, length)); -} diff --git a/lib/libc/sys/utimensat.2 b/lib/libc/sys/utimensat.2 new file mode 100644 index 0000000..0f397c6 --- /dev/null +++ b/lib/libc/sys/utimensat.2 @@ -0,0 +1,292 @@ +.\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled Exp $ +.\" +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 2012, Jilles Tjoelker +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD$ +.\" +.Dd January 23, 2015 +.Dt UTIMENSAT 2 +.Os +.Sh NAME +.Nm futimens , +.Nm utimensat +.Nd set file access and modification times +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/stat.h +.Ft int +.Fn futimens "int fd" "const struct timespec times[2]" +.Ft int +.Fo utimensat +.Fa "int fd" +.Fa "const char *path" +.Fa "const struct timespec times[2]" +.Fa "int flag" +.Fc +.Sh DESCRIPTION +The access and modification times of the file named by +.Fa path +or referenced by +.Fa fd +are changed as specified by the argument +.Fa times . +The inode-change-time of the file is set to the current time. +.Pp +If +.Fa path +specifies a relative path, +it is relative to the current working directory if +.Fa fd +is +.Dv AT_FDCWD +and otherwise relative to the directory associated with the file descriptor +.Fa fd . +.Pp +The +.Va tv_nsec +field of a +.Vt timespec +structure +can be set to the special value +.Dv UTIME_NOW +to set the current time, or to +.Dv UTIME_OMIT +to leave the time unchanged. +In either case, the +.Va tv_sec +field is ignored. +.Pp +If +.Fa times +is +.No non- Ns Dv NULL , +it is assumed to point to an array of two timespec structures. +The access time is set to the value of the first element, and the +modification time is set to the value of the second element. +For file systems that support file birth (creation) times (such as +.Dv UFS2 ) , +the birth time will be set to the value of the second element +if the second element is older than the currently set birth time. +To set both a birth time and a modification time, +two calls are required; the first to set the birth time +and the second to set the (presumably newer) modification time. +Ideally a new system call will be added that allows the setting +of all three times at once. +If +.Fa times +is +.Dv NULL , +this is equivalent to passing +a pointer to an array of two timespec structures +with both +.Va tv_nsec +fields set to +.Dv UTIME_NOW . +.Pp +If both +.Va tv_nsec +fields are +.Dv UTIME_OMIT , +the timestamps remain unchanged and +no permissions are needed for the file itself, +although search permissions may be required for the path prefix. +The call may or may not succeed if the named file does not exist. +.Pp +If both +.Va tv_nsec +fields are +.Dv UTIME_NOW , +the caller must be the owner of the file, have permission to +write the file, or be the super-user. +.Pp +For all other values of the timestamps, +the caller must be the owner of the file or be the super-user. +.Pp +The values for the +.Fa flag +argument of the +.Fn utimensat +system call +are constructed by a bitwise-inclusive OR of flags from the following list, +defined in +.In fcntl.h : +.Bl -tag -width indent +.It Dv AT_SYMLINK_NOFOLLOW +If +.Fa path +names a symbolic link, the symbolic link's times are changed. +By default, +.Fn utimensat +changes the times of the file referenced by the symbolic link. +.El +.Sh RETURN VALUES +.Rv -std +.Sh COMPATIBILITY +If the running kernel does not support this system call, +a wrapper emulates it using +.Xr fstatat 2 , +.Xr futimesat 2 +and +.Xr lutimes 2 . +As a result, timestamps will be rounded down to the nearest microsecond, +.Dv UTIME_OMIT +is not atomic and +.Dv AT_SYMLINK_NOFOLLOW +is not available with a path relative to a file descriptor. +.Sh ERRORS +These system calls will fail if: +.Bl -tag -width Er +.It Bq Er EACCES +The +.Fa times +argument is +.Dv NULL , +or both +.Va tv_nsec +values are +.Dv UTIME_NOW , +and the effective user ID of the process does not +match the owner of the file, and is not the super-user, and write +access is denied. +.It Bq Er EFAULT +The +.Fa times +argument +points outside the process's allocated address space. +.It Bq Er EINVAL +The +.Va tv_usec +component of at least one of the values specified by the +.Fa times +argument has a value less than 0 or greater than 999999. +.It Bq Er EIO +An I/O error occurred while reading or writing the affected inode. +.It Bq Er EPERM +The +.Fa times +argument is not +.Dv NULL +nor are both +.Va tv_nsec +values +.Dv UTIME_NOW , +nor are both +.Va tv_nsec +values +.Dv UTIME_OMIT +and the calling process's effective user ID +does not match the owner of the file and is not the super-user. +.It Bq Er EPERM +The named file has its immutable or append-only flag set, see the +.Xr chflags 2 +manual page for more information. +.It Bq Er EROFS +The file system containing the file is mounted read-only. +.El +.Pp +The +.Fn futimens +system call +will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fd +argument +does not refer to a valid descriptor. +.El +.Pp +The +.Fn utimensat +system call +will fail if: +.Bl -tag -width Er +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EBADF +The +.Fa path +argument does not specify an absolute path and the +.Fa fd +argument is neither +.Dv AT_FDCWD +nor a valid file descriptor. +.It Bq Er EFAULT +The +.Fa path +argument +points outside the process's allocated address space. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded +.Dv NAME_MAX +characters, or an entire path name exceeded +.Dv PATH_MAX +characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er ENOTDIR +The +.Fa path +argument is not an absolute path and +.Fa fd +is neither +.Dv AT_FDCWD +nor a file descriptor associated with a directory. +.It Bq Er ENOTSUP +The running kernel does not support this system call and +.Dv AT_SYMLINK_NOFOLLOW +is used with a path relative to a file descriptor. +.El +.Sh SEE ALSO +.Xr chflags 2 , +.Xr stat 2 , +.Xr symlink 2 , +.Xr utimes 2 , +.Xr utime 3 , +.Xr symlink 7 +.Sh STANDARDS +The +.Fn futimens +and +.Fn utimensat +system calls are expected to conform to +.St -p1003.1-2008 . +.Sh HISTORY +The +.Fn futimens +and +.Fn utimensat +system calls appeared in +.Fx 11.0 . diff --git a/lib/libc/sys/utimensat.c b/lib/libc/sys/utimensat.c new file mode 100644 index 0000000..67d19cb --- /dev/null +++ b/lib/libc/sys/utimensat.c @@ -0,0 +1,109 @@ +/*- + * Copyright (c) 2015 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/stat.h> + +#include <errno.h> +#include <fcntl.h> +#include <time.h> +#include "un-namespace.h" + +#include "libc_private.h" + +int +utimensat(int fd, const char *path, const struct timespec times[2], int flag) +{ + struct timeval now, tv[2], *tvp; + struct stat sb; + + if (__getosreldate() >= 1100056) + return (__sys_utimensat(fd, path, times, flag)); + + if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) { + errno = EINVAL; + return (-1); + } + if (times == NULL || (times[0].tv_nsec == UTIME_NOW && + times[1].tv_nsec == UTIME_NOW)) + tvp = NULL; + else if (times[0].tv_nsec == UTIME_OMIT && + times[1].tv_nsec == UTIME_OMIT) + return (0); + else { + if ((times[0].tv_nsec < 0 || times[0].tv_nsec > 999999999) && + times[0].tv_nsec != UTIME_NOW && + times[0].tv_nsec != UTIME_OMIT) { + errno = EINVAL; + return (-1); + } + if ((times[1].tv_nsec < 0 || times[1].tv_nsec > 999999999) && + times[1].tv_nsec != UTIME_NOW && + times[1].tv_nsec != UTIME_OMIT) { + errno = EINVAL; + return (-1); + } + tv[0].tv_sec = times[0].tv_sec; + tv[0].tv_usec = times[0].tv_nsec / 1000; + tv[1].tv_sec = times[1].tv_sec; + tv[1].tv_usec = times[1].tv_nsec / 1000; + tvp = tv; + if (times[0].tv_nsec == UTIME_OMIT || + times[1].tv_nsec == UTIME_OMIT) { + if (fstatat(fd, path, &sb, flag) == -1) + return (-1); + if (times[0].tv_nsec == UTIME_OMIT) { + tv[0].tv_sec = sb.st_atim.tv_sec; + tv[0].tv_usec = sb.st_atim.tv_nsec / 1000; + } + if (times[1].tv_nsec == UTIME_OMIT) { + tv[1].tv_sec = sb.st_mtim.tv_sec; + tv[1].tv_usec = sb.st_mtim.tv_nsec / 1000; + } + } + if (times[0].tv_nsec == UTIME_NOW || + times[1].tv_nsec == UTIME_NOW) { + if (gettimeofday(&now, NULL) == -1) + return (-1); + if (times[0].tv_nsec == UTIME_NOW) + tv[0] = now; + if (times[1].tv_nsec == UTIME_NOW) + tv[1] = now; + } + } + if ((flag & AT_SYMLINK_NOFOLLOW) == 0) + return (futimesat(fd, path, tvp)); + else if ((flag & AT_SYMLINK_NOFOLLOW) != 0 && + (fd == AT_FDCWD || path[0] == '/')) + return (lutimes(path, tvp)); + else { + errno = ENOTSUP; + return (-1); + } +} diff --git a/lib/libc/sys/vfork.2 b/lib/libc/sys/vfork.2 index 1cfaa61..0518262 100644 --- a/lib/libc/sys/vfork.2 +++ b/lib/libc/sys/vfork.2 @@ -28,7 +28,7 @@ .\" @(#)vfork.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 13, 2009 +.Dd April 6, 2015 .Dt VFORK 2 .Os .Sh NAME @@ -100,8 +100,8 @@ since buffered data would then be flushed twice.) Same as for .Xr fork 2 . .Sh SEE ALSO -.Xr execve 2 , .Xr _exit 2 , +.Xr execve 2 , .Xr fork 2 , .Xr rfork 2 , .Xr sigaction 2 , @@ -111,7 +111,7 @@ Same as for The .Fn vfork system call appeared in -.Bx 2.9 . +.Bx 3 . .Sh BUGS To avoid a possible deadlock situation, processes that are children in the middle diff --git a/lib/libc/sys/wait4.c b/lib/libc/sys/wait4.c new file mode 100644 index 0000000..a5dbd0f --- /dev/null +++ b/lib/libc/sys/wait4.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/wait.h> +#include "libc_private.h" + +__weak_reference(__sys_wait4, __wait4); + +#pragma weak wait4 +pid_t +wait4(pid_t pid, int *status, int options, struct rusage *ru) +{ + + return (((pid_t (*)(pid_t, int *, int, struct rusage *)) + __libc_interposing[INTERPOS_wait4])(pid, status, options, ru)); +} diff --git a/lib/libc/sys/wait6.c b/lib/libc/sys/wait6.c new file mode 100644 index 0000000..d280a76 --- /dev/null +++ b/lib/libc/sys/wait6.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> +#include "libc_private.h" + +__weak_reference(__sys_wait6, __wait6); + +#pragma weak wait6 +pid_t +wait6(idtype_t idtype, id_t id, int *status, int options, struct __wrusage *ru, + siginfo_t *infop) +{ + + return (((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *, + siginfo_t *))__libc_interposing[INTERPOS_wait6])(idtype, id, + status, options, ru, infop)); +} diff --git a/lib/libc/sys/write.c b/lib/libc/sys/write.c new file mode 100644 index 0000000..ffb1aa5 --- /dev/null +++ b/lib/libc/sys/write.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <unistd.h> +#include "libc_private.h" + +__weak_reference(__sys_write, __write); + +#pragma weak write +ssize_t +write(int fd, const void *buf, size_t nbytes) +{ + + return (((ssize_t (*)(int, const void *, size_t)) + __libc_interposing[INTERPOS_write])(fd, buf, nbytes)); +} diff --git a/lib/libc/sys/writev.c b/lib/libc/sys/writev.c new file mode 100644 index 0000000..6be74b3 --- /dev/null +++ b/lib/libc/sys/writev.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/syscall.h> +#include <unistd.h> +#include "libc_private.h" + +__weak_reference(__sys_writev, __writev); + +#pragma weak writev +ssize_t +writev(int fd, const struct iovec *iov, int iovcnt) +{ + + return (((ssize_t (*)(int, const struct iovec *, int)) + __libc_interposing[INTERPOS_writev])(fd, iov, iovcnt)); +} diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index b743165..5f4e1ca 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -2,23 +2,26 @@ TESTSDIR= ${TESTSBASE}/lib/libc/c063 -#TODO: t_o_search, t_utimensat +#TODO: t_o_search -NETBSD_ATF_TESTS_C= t_faccessat -NETBSD_ATF_TESTS_C+= t_fchmodat -NETBSD_ATF_TESTS_C+= t_fchownat -NETBSD_ATF_TESTS_C+= t_fexecve -NETBSD_ATF_TESTS_C+= t_fstatat -NETBSD_ATF_TESTS_C+= t_linkat -NETBSD_ATF_TESTS_C+= t_mkdirat -NETBSD_ATF_TESTS_C+= t_mkfifoat -NETBSD_ATF_TESTS_C+= t_mknodat -NETBSD_ATF_TESTS_C+= t_openat -NETBSD_ATF_TESTS_C+= t_readlinkat -NETBSD_ATF_TESTS_C+= t_renameat -NETBSD_ATF_TESTS_C+= t_symlinkat -NETBSD_ATF_TESTS_C+= t_unlinkat +NETBSD_ATF_TESTS_C= faccessat +NETBSD_ATF_TESTS_C+= fchmodat +NETBSD_ATF_TESTS_C+= fchownat +NETBSD_ATF_TESTS_C+= fexecve +NETBSD_ATF_TESTS_C+= fstatat +NETBSD_ATF_TESTS_C+= linkat +NETBSD_ATF_TESTS_C+= mkdirat +NETBSD_ATF_TESTS_C+= mkfifoat +NETBSD_ATF_TESTS_C+= mknodat +NETBSD_ATF_TESTS_C+= openat +NETBSD_ATF_TESTS_C+= readlinkat +NETBSD_ATF_TESTS_C+= renameat +NETBSD_ATF_TESTS_C+= symlinkat +NETBSD_ATF_TESTS_C+= unlinkat +NETBSD_ATF_TESTS_C+= utimensat CFLAGS+= -D_INCOMPLETE_XOPEN_C063 +.include "../Makefile.netbsd-tests" + .include <bsd.test.mk> diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index 323a9f0..ed1d6ca 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -11,6 +11,7 @@ FILESDIR= ${TESTSDIR} FILES= README NETBSD_ATF_TESTS_SH+= db_test +ATF_TESTS_SH_SED_db_test= -e 's,/bin/csh,/bin/cat,g' .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile index df9d6d9..52fd569 100644 --- a/lib/libc/tests/hash/Makefile +++ b/lib/libc/tests/hash/Makefile @@ -1,8 +1,14 @@ # $FreeBSD$ +.include <src.opts.mk> + TESTSDIR= ${TESTSBASE}/lib/libc/hash -NETBSD_ATF_TESTS_C= sha2_test +NETBSD_ATF_TESTS_C= + +.if ${MK_OPENSSL} != "no" +NETBSD_ATF_TESTS_C+= sha2_test +.endif NETBSD_ATF_TESTS_SH= hash_test diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index cf767ce..7bc8660 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -26,7 +26,11 @@ PROGS+= h_getcwd PROGS+= h_memcpy PROGS+= h_memmove PROGS+= h_memset +# This testcase doesn't run properly when not compiled with -fsantize=bounds +# with clang, which is currently contingent on a compiler_rt update +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30500 PROGS+= h_raw +.endif PROGS+= h_read PROGS+= h_readlink PROGS+= h_snprintf diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index 89431bc..5e457fd 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -12,7 +12,9 @@ NETBSD_ATF_TESTS_C+= clock_gettime_test NETBSD_ATF_TESTS_C+= connect_test NETBSD_ATF_TESTS_C+= dup_test NETBSD_ATF_TESTS_C+= fsync_test +.if ${MACHINE} != "arm64" # ARM64TODO: Missing makecontext NETBSD_ATF_TESTS_C+= getcontext_test +.endif NETBSD_ATF_TESTS_C+= getgroups_test NETBSD_ATF_TESTS_C+= getitimer_test NETBSD_ATF_TESTS_C+= getlogin_test diff --git a/lib/libc/xdr/xdr_float.c b/lib/libc/xdr/xdr_float.c index 1135806..1d3bb61 100644 --- a/lib/libc/xdr/xdr_float.c +++ b/lib/libc/xdr/xdr_float.c @@ -64,7 +64,8 @@ __FBSDID("$FreeBSD$"); #if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \ defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \ defined(__arm__) || defined(__ppc__) || \ - defined(__arm26__) || defined(__sparc64__) || defined(__amd64__) + defined(__arm26__) || defined(__sparc64__) || defined(__amd64__) || \ + defined(__aarch64__) #include <machine/endian.h> #define IEEEFP #endif |