diff options
Diffstat (limited to 'lib/libc')
54 files changed, 2020 insertions, 92 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 9853d4b..906ace1 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -156,6 +156,10 @@ libkern.${LIBC_ARCH}:: ${KMSRCS} cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} .endif +.if ${MK_SYSCALL_COMPAT} != "no" +CFLAGS+=-DSYSCALL_COMPAT +.endif + .include <bsd.arch.inc.mk> .include <bsd.lib.mk> diff --git a/lib/libc/compat-43/Symbol.map b/lib/libc/compat-43/Symbol.map index bd49f99..2827705 100644 --- a/lib/libc/compat-43/Symbol.map +++ b/lib/libc/compat-43/Symbol.map @@ -28,4 +28,5 @@ FBSD_1.2 { FBSDprivate_1.0 { __creat; _creat; + __libc_creat; }; diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c index fc3be06..5ee4531 100644 --- a/lib/libc/compat-43/creat.c +++ b/lib/libc/compat-43/creat.c @@ -36,11 +36,23 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <fcntl.h> #include "un-namespace.h" +#include "libc_private.h" +__weak_reference(__libc_creat, __creat); +__weak_reference(__libc_creat, _creat); + +#pragma weak creat int -__creat(const char *path, mode_t mode) +creat(const char *path, mode_t mode) { - return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); + + return (((int (*)(const char *, mode_t)) + __libc_interposing[INTERPOS_creat])(path, mode)); +} + +int +__libc_creat(const char *path, mode_t mode) +{ + + return(__sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)); } -__weak_reference(__creat, creat); -__weak_reference(__creat, _creat); 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 bbfd9e8..e01a897 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -533,6 +533,15 @@ FBSDprivate_1.0 { _libc_sem_post_compat; _libc_sem_getvalue_compat; + __libc_pause; + __libc_raise; + __libc_sleep; + __libc_tcdrain; + __libc_usleep; + __libc_wait; + __libc_wait3; + __libc_waitpid; + __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/pause.c b/lib/libc/gen/pause.c index 51706cf..97fbb01 100644 --- a/lib/libc/gen/pause.c +++ b/lib/libc/gen/pause.c @@ -38,11 +38,13 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" + /* * Backwards compatible pause. */ int -__pause(void) +__libc_pause(void) { sigset_t oset; @@ -50,5 +52,15 @@ __pause(void) return (-1); return (_sigsuspend(&oset)); } -__weak_reference(__pause, pause); -__weak_reference(__pause, _pause); + +#pragma weak pause +int +pause(void) +{ + + return (((int (*)(void)) + __libc_interposing[INTERPOS_pause])()); +} + +__weak_reference(__libc_pause, __pause); +__weak_reference(__libc_pause, _pause); diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c index b3d0aae..d605639 100644 --- a/lib/libc/gen/raise.c +++ b/lib/libc/gen/raise.c @@ -36,11 +36,23 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <unistd.h> -__weak_reference(__raise, raise); -__weak_reference(__raise, _raise); +#include "libc_private.h" +__weak_reference(__libc_raise, __raise); +__weak_reference(__libc_raise, _raise); + +#pragma weak raise int -__raise(int s) +raise(int s) { - return(kill(getpid(), s)); + + return (((int (*)(int)) + __libc_interposing[INTERPOS_raise])(s)); +} + +int +__libc_raise(int s) +{ + + return (kill(getpid(), s)); } diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index b807c2d..f558e36 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -40,8 +40,19 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" + +#pragma weak sleep +unsigned int +sleep(unsigned int seconds) +{ + + return (((unsigned int (*)(unsigned int)) + __libc_interposing[INTERPOS_sleep])(seconds)); +} + unsigned int -__sleep(unsigned int seconds) +__libc_sleep(unsigned int seconds) { struct timespec time_to_sleep; struct timespec time_remaining; @@ -51,7 +62,7 @@ __sleep(unsigned int seconds) * the maximum value for a time_t is >= INT_MAX. */ if (seconds > INT_MAX) - return (seconds - INT_MAX + __sleep(INT_MAX)); + return (seconds - INT_MAX + __libc_sleep(INT_MAX)); time_to_sleep.tv_sec = seconds; time_to_sleep.tv_nsec = 0; @@ -63,5 +74,5 @@ __sleep(unsigned int seconds) (time_remaining.tv_nsec != 0)); /* round up */ } -__weak_reference(__sleep, sleep); -__weak_reference(__sleep, _sleep); +__weak_reference(__libc_sleep, __sleep); +__weak_reference(__libc_sleep, _sleep); 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/usleep.c b/lib/libc/gen/usleep.c index 7d6559b..1d58b98 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -38,8 +38,19 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" + +#pragma weak usleep +int +usleep(useconds_t useconds) +{ + + return (((int (*)(useconds_t)) + __libc_interposing[INTERPOS_usleep])(useconds)); +} + int -__usleep(useconds_t useconds) +__libc_usleep(useconds_t useconds) { struct timespec time_to_sleep; @@ -48,5 +59,5 @@ __usleep(useconds_t useconds) return (_nanosleep(&time_to_sleep, NULL)); } -__weak_reference(__usleep, usleep); -__weak_reference(__usleep, _usleep); +__weak_reference(__libc_usleep, __usleep); +__weak_reference(__libc_usleep, _usleep); diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c index 2169b9d..dc1351d 100644 --- a/lib/libc/gen/wait.c +++ b/lib/libc/gen/wait.c @@ -40,11 +40,23 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include "un-namespace.h" +#include "libc_private.h" + +#pragma weak wait pid_t -__wait(int *istat) +wait(int *istat) { - return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0)); + + return (((pid_t (*)(int *)) + __libc_interposing[INTERPOS_wait])(istat)); +} + +pid_t +__libc_wait(int *istat) +{ + + return (__sys_wait4(WAIT_ANY, istat, 0, NULL)); } -__weak_reference(__wait, wait); -__weak_reference(__wait, _wait); +__weak_reference(__libc_wait, __wait); +__weak_reference(__libc_wait, _wait); diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c index 6098773..2e116be 100644 --- a/lib/libc/gen/wait3.c +++ b/lib/libc/gen/wait3.c @@ -40,11 +40,22 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include "un-namespace.h" +#include "libc_private.h" + +#pragma weak wait3 +pid_t +wait3(int *istat, int options, struct rusage *rup) +{ + + return (((pid_t (*)(int *, int, struct rusage *)) + __libc_interposing[INTERPOS_wait3])(istat, options, rup)); +} + +__weak_reference(__libc_wait3, __wait3); + pid_t -wait3(istat, options, rup) - int *istat; - int options; - struct rusage *rup; +__libc_wait3(int *istat, int options, struct rusage *rup) { - return (_wait4(WAIT_ANY, istat, options, rup)); + + return (__sys_wait4(WAIT_ANY, istat, options, rup)); } diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c index b001837..27e920f 100644 --- a/lib/libc/gen/waitpid.c +++ b/lib/libc/gen/waitpid.c @@ -40,11 +40,23 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include "un-namespace.h" +#include "libc_private.h" + +#pragma weak waitpid pid_t -__waitpid(pid_t pid, int *istat, int options) +waitpid(pid_t pid, int *istat, int options) { - return (_wait4(pid, istat, options, (struct rusage *)0)); + + return (((pid_t (*)(pid_t, int *, int)) + __libc_interposing[INTERPOS_waitpid])(pid, istat, options)); +} + +pid_t +__libc_waitpid(pid_t pid, int *istat, int options) +{ + + return (__sys_wait4(pid, istat, options, NULL)); } -__weak_reference(__waitpid, waitpid); -__weak_reference(__waitpid, _waitpid); +__weak_reference(__libc_waitpid, __waitpid); +__weak_reference(__libc_waitpid, _waitpid); diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 40a5f72..adf342d 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -173,6 +173,61 @@ typedef pthread_func_t pthread_func_entry_t[2]; extern pthread_func_entry_t __thr_jtable[]; +extern int *(*__error_selector)(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[]; + +enum { + INTERPOS_accept, + INTERPOS_accept4, + INTERPOS_aio_suspend, + INTERPOS_close, + INTERPOS_connect, + INTERPOS_creat, + INTERPOS_fcntl, + INTERPOS_fsync, + INTERPOS_fork, + INTERPOS_msync, + INTERPOS_nanosleep, + INTERPOS_open, + INTERPOS_openat, + INTERPOS_poll, + INTERPOS_pselect, + INTERPOS_raise, + 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_sleep, + INTERPOS_tcdrain, + INTERPOS_usleep, + INTERPOS_pause, + INTERPOS_read, + INTERPOS_readv, + INTERPOS_wait, + INTERPOS_wait3, + INTERPOS_wait4, + INTERPOS_waitpid, + INTERPOS_write, + INTERPOS_writev, + INTERPOS__pthread_mutex_init_calloc_cb, + INTERPOS_MAX +}; + /* * yplib internal interfaces */ @@ -215,42 +270,107 @@ 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(). */ -extern void (*__cleanup)(void) __hidden; +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. */ -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); +#include <sys/_sigset.h> /* 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, ...); +__off_t __sys_freebsd6_lseek(int, int, __off_t, int); +int __sys_freebsd6_ftruncate(int, int, __off_t); +int __sys_freebsd6_truncate(const char *, int, __off_t); +__ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t); +__ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t); +void * __sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t); +struct aiocb; +struct fd_set; +struct iovec; +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; +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 *); +__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); +__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_truncate(const char *, __off_t); +__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *); +__ssize_t __sys_write(int, const void *, __size_t); +__ssize_t __sys_writev(int, const struct iovec *, int); + +int __libc_creat(const char *path, __mode_t mode); +int __libc_pause(void); +int __libc_raise(int); +int __libc_sigwait(const __sigset_t * __restrict, + int * restrict sig); +int __libc_system(const char *); +unsigned int __libc_sleep(unsigned int); +int __libc_tcdrain(int); +int __libc_usleep(__useconds_t); +__pid_t __libc_wait(int *); +__pid_t __libc_wait3(int *, int, struct rusage *); +__pid_t __libc_waitpid(__pid_t, int *, int); +int __fcntl_compat(int fd, int cmd, ...); /* execve() with PATH processing to implement posix_spawnp() */ int _execvpe(const char *, char * const *, char * const *); diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map index 8355f9a..39eab7d 100644 --- a/lib/libc/stdlib/Symbol.map +++ b/lib/libc/stdlib/Symbol.map @@ -118,4 +118,5 @@ FBSD_1.4 { FBSDprivate_1.0 { __system; _system; + __libc_system; }; 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/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/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index c14b351..0a3c13f 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -20,17 +20,61 @@ 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 +SRCS+= \ + stack_protector.c \ + stack_protector_compat.c \ + __error.c \ + interposing_table.c + .if ${MK_SYSCALL_COMPAT} != "no" -SYSCALL_COMPAT_SRCS= fcntl.c ftruncate.c lseek.c mmap.c pread.c \ - pwrite.c truncate.c +SYSCALL_COMPAT_SRCS= \ + 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 .endif -SRCS+= sigwait.c -NOASM+= sigwait.o -PSEUDO+= _sigwait.o + +INTERPOSED = \ + accept \ + accept4 \ + aio_suspend \ + close \ + connect \ + fcntl \ + fsync \ + fork \ + msync \ + nanosleep \ + open \ + openat \ + poll \ + pselect \ + read \ + readv \ + recvfrom \ + recvmsg \ + select \ + sendmsg \ + sendto \ + setcontext \ + sigaction \ + sigprocmask \ + sigsuspend \ + sigtimedwait \ + sigwait \ + sigwaitinfo \ + swapcontext \ + wait4 \ + write \ + writev + +SRCS+= ${INTERPOSED:S/$/.c/} +NOASM+= ${INTERPOSED:S/$/.o/} +PSEUDO+= ${INTERPOSED:C/^.*$/_&.o/} # Add machine dependent asm sources: SRCS+=${MDASM} diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 448bcce..7d82361 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; @@ -1049,6 +1046,9 @@ FBSDprivate_1.0 { _writev; __sys_writev; __error_unthreaded; + __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..329d124 100644 --- a/lib/libc/sys/__error.c +++ b/lib/libc/sys/__error.c @@ -32,14 +32,17 @@ __FBSDID("$FreeBSD$"); extern int errno; -/* - * Declare a weak reference in case the application is not linked - * with libpthread. - */ -__weak_reference(__error_unthreaded, __error); - int * __error_unthreaded(void) { return(&errno); } + +int *(*__error_selector)(void) = __error_unthreaded; + +int * +__error(void) +{ + + 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/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/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/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/fcntl.c b/lib/libc/sys/fcntl.c index 480cc40..4cb887b 100644 --- a/lib/libc/sys/fcntl.c +++ b/lib/libc/sys/fcntl.c @@ -34,7 +34,23 @@ __FBSDID("$FreeBSD$"); #include <sys/syscall.h> #include "libc_private.h" -__weak_reference(__fcntl_compat, fcntl); +#pragma weak fcntl +int +fcntl(int fd, int cmd, ...) +{ + va_list args; + long arg; + + va_start(args, cmd); + arg = va_arg(args, long); + va_end(args); + + return (((int (*)(int, int, ...)) + __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg)); +} + +#ifdef SYSCALL_COMPAT +__weak_reference(__fcntl_compat, __fcntl); int __fcntl_compat(int fd, int cmd, ...) @@ -87,3 +103,7 @@ __fcntl_compat(int fd, int cmd, ...) return (__sys_fcntl(fd, cmd, arg)); } } +#else +__weak_reference(__sys_fcntl, __fcntl_compat); +__weak_reference(__sys_fcntl, __fcntl); +#endif 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/interposing_table.c b/lib/libc/sys/interposing_table.c new file mode 100644 index 0000000..9987bf0 --- /dev/null +++ b/lib/libc/sys/interposing_table.c @@ -0,0 +1,93 @@ +/* + * 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(creat, __libc_creat), + SLOT(fcntl, __fcntl_compat), + SLOT(fsync, __sys_fsync), + SLOT(fork, __sys_fork), + SLOT(msync, __sys_msync), + SLOT(nanosleep, __sys_nanosleep), + SLOT(open, __sys_open), + SLOT(openat, __sys_openat), + SLOT(poll, __sys_poll), + SLOT(pselect, __sys_pselect), + SLOT(raise, __libc_raise), + 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(sleep, __libc_sleep), + SLOT(tcdrain, __libc_tcdrain), + SLOT(usleep, __libc_usleep), + SLOT(pause, __libc_pause), + SLOT(wait, __libc_wait), + SLOT(wait3, __libc_wait3), + SLOT(wait4, __sys_wait4), + SLOT(waitpid, __libc_waitpid), + SLOT(write, __sys_write), + SLOT(writev, __sys_writev), + SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub), +}; +#undef SLOT + +interpos_func_t * +__libc_interposing_slot(int interposno) +{ + + return (&__libc_interposing[interposno]); +} 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.c b/lib/libc/sys/open.c new file mode 100644 index 0000000..57c0324 --- /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 (*)(const char *, int, ...)) + __libc_interposing[INTERPOS_open])(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.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/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/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/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/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.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/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/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/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)); +} |