Fix known issues which blow up the process after dlopen("libthr.so")
(or loading a dso linked to libthr.so into process which was not linked against threading library). - Remove libthr interposers of the libc functions, including __error(). Instead, functions calls are indirected through the interposing table, similar to how pthread stubs in libc are already done. Libc by default points either to syscall trampolines or to existing libc implementations. On libthr load, libthr rewrites the pointers to the cancellable implementations already in libthr. The interposition table is separate from pthreads stubs indirection table to not pull pthreads stubs into static binaries. - Postpone the malloc(3) internal mutexes initialization until libthr is loaded. This avoids recursion between calloc(3) and static pthread_mutex_t initialization. - Reinstall signal handlers with wrapper on libthr load. The _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2) when libthr is statically referenced from the main binary. In the process, fix openat(2), swapcontext(2) and setcontext(2) interposing. The libc symbols were exported at different versions than libthr interposers. Export both libc and libthr versions from libc now, with default set to the higher version from libthr. Remove unused and disconnected swapcontext(3) userspace implementation from libc/gen. No objections from: deischen Tested by: pho, antoine (exp-run) (previous versions) Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
7ac15f4b4c
commit
8d1dfb4106
@ -49,6 +49,7 @@ bool malloc_mutex_init(malloc_mutex_t *mutex);
|
||||
void malloc_mutex_prefork(malloc_mutex_t *mutex);
|
||||
void malloc_mutex_postfork_parent(malloc_mutex_t *mutex);
|
||||
void malloc_mutex_postfork_child(malloc_mutex_t *mutex);
|
||||
bool malloc_mutex_first_thread(void);
|
||||
bool mutex_boot(void);
|
||||
|
||||
#endif /* JEMALLOC_H_EXTERNS */
|
||||
|
@ -2061,6 +2061,13 @@ jemalloc_postfork_child(void)
|
||||
ctl_postfork_child();
|
||||
}
|
||||
|
||||
void
|
||||
_malloc_first_thread(void)
|
||||
{
|
||||
|
||||
(void)malloc_mutex_first_thread();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* The following functions are used for TLS allocation/deallocation in static
|
||||
|
@ -67,15 +67,15 @@ pthread_create(pthread_t *__restrict thread,
|
||||
JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
|
||||
void *(calloc_cb)(size_t, size_t));
|
||||
|
||||
__weak_reference(_pthread_mutex_init_calloc_cb_stub,
|
||||
_pthread_mutex_init_calloc_cb);
|
||||
|
||||
#pragma weak _pthread_mutex_init_calloc_cb
|
||||
int
|
||||
_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
|
||||
_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
|
||||
void *(calloc_cb)(size_t, size_t))
|
||||
{
|
||||
|
||||
return (0);
|
||||
return (((int (*)(pthread_mutex_t *, void *(*)(size_t, size_t)))
|
||||
__libc_interposing[INTERPOS__pthread_mutex_init_calloc_cb])(
|
||||
mutex, calloc_cb));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -144,7 +144,7 @@ malloc_mutex_postfork_child(malloc_mutex_t *mutex)
|
||||
}
|
||||
|
||||
bool
|
||||
mutex_boot(void)
|
||||
malloc_mutex_first_thread(void)
|
||||
{
|
||||
|
||||
#ifdef JEMALLOC_MUTEX_INIT_CB
|
||||
@ -158,3 +158,14 @@ mutex_boot(void)
|
||||
#endif
|
||||
return (false);
|
||||
}
|
||||
|
||||
bool
|
||||
mutex_boot(void)
|
||||
{
|
||||
|
||||
#ifndef JEMALLOC_MUTEX_INIT_CB
|
||||
return (malloc_mutex_first_thread());
|
||||
#else
|
||||
return (false);
|
||||
#endif
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -28,4 +28,5 @@ FBSD_1.2 {
|
||||
FBSDprivate_1.0 {
|
||||
__creat;
|
||||
_creat;
|
||||
__libc_creat;
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
return (((int (*)(const char *, mode_t))
|
||||
__libc_interposing[INTERPOS_creat])(path, mode));
|
||||
}
|
||||
|
||||
int
|
||||
__creat(const char *path, mode_t mode)
|
||||
__libc_creat(const char *path, mode_t mode)
|
||||
{
|
||||
return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
|
||||
|
||||
return(__sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
|
||||
}
|
||||
__weak_reference(__creat, creat);
|
||||
__weak_reference(__creat, _creat);
|
||||
|
@ -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 \
|
||||
|
@ -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;
|
||||
|
45
lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
Normal file
45
lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
Normal file
@ -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);
|
||||
}
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
return (((int (*)(int))
|
||||
__libc_interposing[INTERPOS_raise])(s));
|
||||
}
|
||||
|
||||
int
|
||||
__raise(int s)
|
||||
__libc_raise(int s)
|
||||
{
|
||||
|
||||
return (kill(getpid(), s));
|
||||
}
|
||||
|
@ -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)
|
||||
sleep(unsigned int seconds)
|
||||
{
|
||||
|
||||
return (((unsigned int (*)(unsigned int))
|
||||
__libc_interposing[INTERPOS_sleep])(seconds));
|
||||
}
|
||||
|
||||
unsigned int
|
||||
__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);
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
usleep(useconds_t useconds)
|
||||
{
|
||||
|
||||
return (((int (*)(useconds_t))
|
||||
__libc_interposing[INTERPOS_usleep])(useconds));
|
||||
}
|
||||
|
||||
int
|
||||
__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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
__weak_reference(__wait, wait);
|
||||
__weak_reference(__wait, _wait);
|
||||
pid_t
|
||||
__libc_wait(int *istat)
|
||||
{
|
||||
|
||||
return (__sys_wait4(WAIT_ANY, istat, 0, NULL));
|
||||
}
|
||||
|
||||
__weak_reference(__libc_wait, __wait);
|
||||
__weak_reference(__libc_wait, _wait);
|
||||
|
@ -40,11 +40,22 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/resource.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
|
||||
#pragma weak wait3
|
||||
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 (*)(int *, int, struct rusage *))
|
||||
__libc_interposing[INTERPOS_wait3])(istat, options, rup));
|
||||
}
|
||||
|
||||
__weak_reference(__libc_wait3, __wait3);
|
||||
|
||||
pid_t
|
||||
__libc_wait3(int *istat, int options, struct rusage *rup)
|
||||
{
|
||||
|
||||
return (__sys_wait4(WAIT_ANY, istat, options, rup));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
__weak_reference(__waitpid, waitpid);
|
||||
__weak_reference(__waitpid, _waitpid);
|
||||
pid_t
|
||||
__libc_waitpid(pid_t pid, int *istat, int options)
|
||||
{
|
||||
|
||||
return (__sys_wait4(pid, istat, options, NULL));
|
||||
}
|
||||
|
||||
__weak_reference(__libc_waitpid, __waitpid);
|
||||
__weak_reference(__libc_waitpid, _waitpid);
|
||||
|
@ -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 *);
|
||||
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 *);
|
||||
|
@ -118,4 +118,5 @@ FBSD_1.4 {
|
||||
FBSDprivate_1.0 {
|
||||
__system;
|
||||
_system;
|
||||
__libc_system;
|
||||
};
|
||||
|
@ -55,4 +55,5 @@ FBSDprivate_1.0 {
|
||||
_malloc_thread_cleanup;
|
||||
_malloc_prefork;
|
||||
_malloc_postfork;
|
||||
_malloc_first_thread;
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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());
|
||||
}
|
||||
|
50
lib/libc/sys/accept.c
Normal file
50
lib/libc/sys/accept.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/accept4.c
Normal file
50
lib/libc/sys/accept4.c
Normal file
@ -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));
|
||||
}
|
51
lib/libc/sys/aio_suspend.c
Normal file
51
lib/libc/sys/aio_suspend.c
Normal file
@ -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));
|
||||
}
|
48
lib/libc/sys/close.c
Normal file
48
lib/libc/sys/close.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/connect.c
Normal file
50
lib/libc/sys/connect.c
Normal file
@ -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));
|
||||
}
|
@ -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
|
||||
|
48
lib/libc/sys/fork.c
Normal file
48
lib/libc/sys/fork.c
Normal file
@ -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])());
|
||||
}
|
47
lib/libc/sys/fsync.c
Normal file
47
lib/libc/sys/fsync.c
Normal file
@ -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));
|
||||
}
|
93
lib/libc/sys/interposing_table.c
Normal file
93
lib/libc/sys/interposing_table.c
Normal file
@ -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]);
|
||||
}
|
49
lib/libc/sys/msync.c
Normal file
49
lib/libc/sys/msync.c
Normal file
@ -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));
|
||||
}
|
49
lib/libc/sys/nanosleep.c
Normal file
49
lib/libc/sys/nanosleep.c
Normal file
@ -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));
|
||||
}
|
59
lib/libc/sys/open.c
Normal file
59
lib/libc/sys/open.c
Normal file
@ -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));
|
||||
}
|
62
lib/libc/sys/openat.c
Normal file
62
lib/libc/sys/openat.c
Normal file
@ -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));
|
||||
}
|
49
lib/libc/sys/poll.c
Normal file
49
lib/libc/sys/poll.c
Normal file
@ -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));
|
||||
}
|
51
lib/libc/sys/pselect.c
Normal file
51
lib/libc/sys/pselect.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/read.c
Normal file
50
lib/libc/sys/read.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/readv.c
Normal file
50
lib/libc/sys/readv.c
Normal file
@ -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));
|
||||
}
|
53
lib/libc/sys/recvfrom.c
Normal file
53
lib/libc/sys/recvfrom.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/recvmsg.c
Normal file
50
lib/libc/sys/recvmsg.c
Normal file
@ -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));
|
||||
}
|
49
lib/libc/sys/select.c
Normal file
49
lib/libc/sys/select.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/sendmsg.c
Normal file
50
lib/libc/sys/sendmsg.c
Normal file
@ -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));
|
||||
}
|
53
lib/libc/sys/sendto.c
Normal file
53
lib/libc/sys/sendto.c
Normal file
@ -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));
|
||||
}
|
52
lib/libc/sys/setcontext.c
Normal file
52
lib/libc/sys/setcontext.c
Normal file
@ -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));
|
||||
}
|
49
lib/libc/sys/sigaction.c
Normal file
49
lib/libc/sys/sigaction.c
Normal file
@ -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));
|
||||
}
|
49
lib/libc/sys/sigprocmask.c
Normal file
49
lib/libc/sys/sigprocmask.c
Normal file
@ -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));
|
||||
}
|
49
lib/libc/sys/sigsuspend.c
Normal file
49
lib/libc/sys/sigsuspend.c
Normal file
@ -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));
|
||||
}
|
51
lib/libc/sys/sigtimedwait.c
Normal file
51
lib/libc/sys/sigtimedwait.c
Normal file
@ -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));
|
||||
}
|
@ -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;
|
||||
|
||||
|
49
lib/libc/sys/sigwaitinfo.c
Normal file
49
lib/libc/sys/sigwaitinfo.c
Normal file
@ -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));
|
||||
}
|
@ -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));
|
||||
}
|
49
lib/libc/sys/wait4.c
Normal file
49
lib/libc/sys/wait4.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/write.c
Normal file
50
lib/libc/sys/write.c
Normal file
@ -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));
|
||||
}
|
50
lib/libc/sys/writev.c
Normal file
50
lib/libc/sys/writev.c
Normal file
@ -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));
|
||||
}
|
@ -40,7 +40,6 @@ MAN= libthr.3
|
||||
|
||||
# enable extra internal consistancy checks
|
||||
CFLAGS+=-D_PTHREADS_INVARIANTS
|
||||
#CFLAGS+=-g
|
||||
|
||||
PRECIOUSLIB=
|
||||
|
||||
|
@ -6,22 +6,6 @@
|
||||
* Use the same naming scheme as libc.
|
||||
*/
|
||||
FBSD_1.0 {
|
||||
__error;
|
||||
accept;
|
||||
aio_suspend;
|
||||
close;
|
||||
connect;
|
||||
creat;
|
||||
execve;
|
||||
fcntl;
|
||||
fork;
|
||||
fsync;
|
||||
msync;
|
||||
nanosleep;
|
||||
open;
|
||||
pause;
|
||||
poll;
|
||||
pselect;
|
||||
pthread_atfork;
|
||||
pthread_barrier_destroy;
|
||||
pthread_barrier_init;
|
||||
@ -139,30 +123,6 @@ FBSD_1.0 {
|
||||
pthread_testcancel;
|
||||
pthread_timedjoin_np;
|
||||
pthread_yield;
|
||||
raise;
|
||||
read;
|
||||
readv;
|
||||
recvfrom;
|
||||
recvmsg;
|
||||
select;
|
||||
sendmsg;
|
||||
sendto;
|
||||
sigaction;
|
||||
sigprocmask;
|
||||
sigsuspend;
|
||||
sigwait;
|
||||
sigwaitinfo;
|
||||
sigtimedwait;
|
||||
sleep;
|
||||
system;
|
||||
tcdrain;
|
||||
usleep;
|
||||
wait;
|
||||
wait3;
|
||||
wait4;
|
||||
waitpid;
|
||||
write;
|
||||
writev;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -170,28 +130,6 @@ FBSD_1.0 {
|
||||
* These are not part of our application ABI.
|
||||
*/
|
||||
FBSDprivate_1.0 {
|
||||
___creat;
|
||||
___pause;
|
||||
___pselect;
|
||||
___sigwait;
|
||||
___sleep;
|
||||
___system;
|
||||
___tcdrain;
|
||||
___usleep;
|
||||
___wait;
|
||||
___waitpid;
|
||||
__accept;
|
||||
__accept4;
|
||||
__aio_suspend;
|
||||
__close;
|
||||
__connect;
|
||||
__fcntl;
|
||||
__fsync;
|
||||
__msync;
|
||||
__nanosleep;
|
||||
__open;
|
||||
__openat;
|
||||
__poll;
|
||||
__pthread_cond_timedwait;
|
||||
__pthread_cond_wait;
|
||||
__pthread_cxa_finalize;
|
||||
@ -199,21 +137,6 @@ FBSDprivate_1.0 {
|
||||
__pthread_mutex_lock;
|
||||
__pthread_mutex_timedlock;
|
||||
__pthread_mutex_trylock;
|
||||
__read;
|
||||
__readv;
|
||||
__recvfrom;
|
||||
__recvmsg;
|
||||
__select;
|
||||
__sendmsg;
|
||||
__sendto;
|
||||
__sigsuspend;
|
||||
__sigtimedwait;
|
||||
__sigwaitinfo;
|
||||
__wait3;
|
||||
__wait4;
|
||||
__write;
|
||||
__writev;
|
||||
_fork;
|
||||
_pthread_atfork;
|
||||
_pthread_barrier_destroy;
|
||||
_pthread_barrier_init;
|
||||
@ -345,18 +268,6 @@ FBSDprivate_1.0 {
|
||||
_pthread_testcancel;
|
||||
_pthread_timedjoin_np;
|
||||
_pthread_yield;
|
||||
_raise;
|
||||
_setcontext;
|
||||
_sigaction;
|
||||
_sigprocmask;
|
||||
_sigsuspend;
|
||||
_sigtimedwait;
|
||||
_sigwait;
|
||||
_sigwaitinfo;
|
||||
_spinlock;
|
||||
_spinlock_debug;
|
||||
_spinunlock;
|
||||
_swapcontext;
|
||||
|
||||
/* Debugger needs these. */
|
||||
_libthr_debug;
|
||||
@ -404,12 +315,5 @@ FBSD_1.1 {
|
||||
};
|
||||
|
||||
FBSD_1.2 {
|
||||
openat;
|
||||
pthread_getthreadid_np;
|
||||
setcontext;
|
||||
swapcontext;
|
||||
};
|
||||
|
||||
FBSD_1.3 {
|
||||
accept4;
|
||||
};
|
||||
|
@ -42,8 +42,9 @@
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
__weak_reference(__error_threaded, __error);
|
||||
int *
|
||||
__error(void)
|
||||
__error_threaded(void)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <pthread_np.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "thr_private.h"
|
||||
|
||||
static int create_stack(struct pthread_attr *pattr);
|
||||
@ -66,8 +67,11 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr,
|
||||
/*
|
||||
* Tell libc and others now they need lock to protect their data.
|
||||
*/
|
||||
if (_thr_isthreaded() == 0 && _thr_setthreaded(1))
|
||||
if (_thr_isthreaded() == 0) {
|
||||
_malloc_first_thread();
|
||||
if (_thr_setthreaded(1))
|
||||
return (EAGAIN);
|
||||
}
|
||||
|
||||
curthread = _get_curthread();
|
||||
if ((new_thread = _thr_alloc(curthread)) == NULL)
|
||||
|
@ -128,12 +128,10 @@ __pthread_cxa_finalize(struct dl_phdr_info *phdr_info)
|
||||
_thr_sigact_unload(phdr_info);
|
||||
}
|
||||
|
||||
__weak_reference(_fork, fork);
|
||||
|
||||
pid_t _fork(void);
|
||||
__weak_reference(__thr_fork, _fork);
|
||||
|
||||
pid_t
|
||||
_fork(void)
|
||||
__thr_fork(void)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
struct pthread_atfork *af;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/link_elf.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/ttycom.h>
|
||||
@ -302,7 +303,7 @@ _thread_init_hack(void)
|
||||
void
|
||||
_libpthread_init(struct pthread *curthread)
|
||||
{
|
||||
int fd, first = 0;
|
||||
int fd, first, dlopened;
|
||||
|
||||
/* Check if this function has already been called: */
|
||||
if ((_thr_initial != NULL) && (curthread == NULL))
|
||||
@ -316,6 +317,7 @@ _libpthread_init(struct pthread *curthread)
|
||||
if (sizeof(jmp_table) != (sizeof(pthread_func_t) * PJT_MAX * 2))
|
||||
PANIC("Thread jump table not properly initialized");
|
||||
memcpy(__thr_jtable, jmp_table, sizeof(jmp_table));
|
||||
__thr_interpose_libc();
|
||||
|
||||
/*
|
||||
* Check for the special case of this process running as
|
||||
@ -349,7 +351,10 @@ _libpthread_init(struct pthread *curthread)
|
||||
if (curthread == NULL)
|
||||
PANIC("Can't allocate initial thread");
|
||||
init_main_thread(curthread);
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the thread to the thread list queue.
|
||||
*/
|
||||
@ -361,7 +366,8 @@ _libpthread_init(struct pthread *curthread)
|
||||
|
||||
if (first) {
|
||||
_thr_initial = curthread;
|
||||
_thr_signal_init();
|
||||
dlopened = _rtld_is_dlopened(&_thread_autoinit_dummy_decl) != 0;
|
||||
_thr_signal_init(dlopened);
|
||||
if (_thread_event_mask & TD_CREATE)
|
||||
_thr_report_creation(curthread, curthread);
|
||||
/*
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "thr_private.h"
|
||||
|
||||
static void pchar(int fd, char c);
|
||||
|
@ -763,7 +763,7 @@ void _thr_cancel_leave(struct pthread *, int) __hidden;
|
||||
void _thr_testcancel(struct pthread *) __hidden;
|
||||
void _thr_signal_block(struct pthread *) __hidden;
|
||||
void _thr_signal_unblock(struct pthread *) __hidden;
|
||||
void _thr_signal_init(void) __hidden;
|
||||
void _thr_signal_init(int) __hidden;
|
||||
void _thr_signal_deinit(void) __hidden;
|
||||
int _thr_send_sig(struct pthread *, int sig) __hidden;
|
||||
void _thr_list_init(void) __hidden;
|
||||
@ -839,7 +839,6 @@ int __sys_close(int);
|
||||
int __sys_fork(void);
|
||||
pid_t __sys_getpid(void);
|
||||
ssize_t __sys_read(int, void *, size_t);
|
||||
ssize_t __sys_write(int, const void *, size_t);
|
||||
void __sys_exit(int);
|
||||
#endif
|
||||
|
||||
@ -906,12 +905,31 @@ int _sleepq_remove(struct sleepqueue *, struct pthread *) __hidden;
|
||||
void _sleepq_drop(struct sleepqueue *,
|
||||
void (*cb)(struct pthread *, void *arg), void *) __hidden;
|
||||
|
||||
int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
|
||||
void *(calloc_cb)(size_t, size_t));
|
||||
|
||||
struct dl_phdr_info;
|
||||
void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
|
||||
void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
|
||||
void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
|
||||
void _thr_stack_fix_protection(struct pthread *thrd);
|
||||
|
||||
int *__error_threaded(void);
|
||||
void __thr_interpose_libc(void) __hidden;
|
||||
pid_t __thr_fork(void);
|
||||
int __thr_pause(void) __hidden;
|
||||
int __thr_raise(int sig);
|
||||
int __thr_setcontext(const ucontext_t *ucp);
|
||||
int __thr_sigaction(int sig, const struct sigaction *act,
|
||||
struct sigaction *oact) __hidden;
|
||||
int __thr_sigprocmask(int how, const sigset_t *set, sigset_t *oset);
|
||||
int __thr_sigsuspend(const sigset_t * set);
|
||||
int __thr_sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
const struct timespec * timeout);
|
||||
int __thr_sigwait(const sigset_t *set, int *sig);
|
||||
int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info);
|
||||
int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_THR_PRIVATE_H */
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "thr_private.h"
|
||||
|
||||
/* #define DEBUG_SIGNAL */
|
||||
@ -54,24 +55,23 @@ struct usigaction {
|
||||
|
||||
static struct usigaction _thr_sigact[_SIG_MAXSIG];
|
||||
|
||||
static inline struct usigaction *
|
||||
__libc_sigaction_slot(int signo)
|
||||
{
|
||||
|
||||
return (&_thr_sigact[signo - 1]);
|
||||
}
|
||||
|
||||
static void thr_sighandler(int, siginfo_t *, void *);
|
||||
static void handle_signal(struct sigaction *, int, siginfo_t *, ucontext_t *);
|
||||
static void check_deferred_signal(struct pthread *);
|
||||
static void check_suspend(struct pthread *);
|
||||
static void check_cancel(struct pthread *curthread, ucontext_t *ucp);
|
||||
|
||||
int ___pause(void);
|
||||
int _raise(int);
|
||||
int __sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
const struct timespec * timeout);
|
||||
int _sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
const struct timespec * timeout);
|
||||
int __sigwaitinfo(const sigset_t *set, siginfo_t *info);
|
||||
int _sigwaitinfo(const sigset_t *set, siginfo_t *info);
|
||||
int ___sigwait(const sigset_t *set, int *sig);
|
||||
int _sigwait(const sigset_t *set, int *sig);
|
||||
int __sigsuspend(const sigset_t *sigmask);
|
||||
int _sigaction(int, const struct sigaction *, struct sigaction *);
|
||||
int _setcontext(const ucontext_t *);
|
||||
int _swapcontext(ucontext_t *, const ucontext_t *);
|
||||
|
||||
@ -143,8 +143,8 @@ sigcancel_handler(int sig __unused,
|
||||
errno = err;
|
||||
}
|
||||
|
||||
typedef void (*ohandler)(int sig, int code,
|
||||
struct sigcontext *scp, char *addr, __sighandler_t *catcher);
|
||||
typedef void (*ohandler)(int sig, int code, struct sigcontext *scp,
|
||||
char *addr, __sighandler_t *catcher);
|
||||
|
||||
/*
|
||||
* The signal handler wrapper is entered with all signal masked.
|
||||
@ -152,15 +152,19 @@ typedef void (*ohandler)(int sig, int code,
|
||||
static void
|
||||
thr_sighandler(int sig, siginfo_t *info, void *_ucp)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
ucontext_t *ucp = _ucp;
|
||||
struct pthread *curthread;
|
||||
ucontext_t *ucp;
|
||||
struct sigaction act;
|
||||
struct usigaction *usa;
|
||||
int err;
|
||||
|
||||
err = errno;
|
||||
_thr_rwl_rdlock(&_thr_sigact[sig-1].lock);
|
||||
act = _thr_sigact[sig-1].sigact;
|
||||
_thr_rwl_unlock(&_thr_sigact[sig-1].lock);
|
||||
curthread = _get_curthread();
|
||||
ucp = _ucp;
|
||||
usa = __libc_sigaction_slot(sig);
|
||||
_thr_rwl_rdlock(&usa->lock);
|
||||
act = usa->sigact;
|
||||
_thr_rwl_unlock(&usa->lock);
|
||||
errno = err;
|
||||
curthread->deferred_run = 0;
|
||||
|
||||
@ -234,12 +238,12 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp)
|
||||
* so after setjmps() returns once more, the user code may need to
|
||||
* re-set cancel_enable flag by calling pthread_setcancelstate().
|
||||
*/
|
||||
if ((actp->sa_flags & SA_SIGINFO) != 0)
|
||||
(*(sigfunc))(sig, info, ucp);
|
||||
else {
|
||||
((ohandler)(*sigfunc))(
|
||||
sig, info->si_code, (struct sigcontext *)ucp,
|
||||
info->si_addr, (__sighandler_t *)sigfunc);
|
||||
if ((actp->sa_flags & SA_SIGINFO) != 0) {
|
||||
sigfunc(sig, info, ucp);
|
||||
} else {
|
||||
((ohandler)sigfunc)(sig, info->si_code,
|
||||
(struct sigcontext *)ucp, info->si_addr,
|
||||
(__sighandler_t *)sigfunc);
|
||||
}
|
||||
err = errno;
|
||||
|
||||
@ -395,9 +399,34 @@ check_suspend(struct pthread *curthread)
|
||||
}
|
||||
|
||||
void
|
||||
_thr_signal_init(void)
|
||||
_thr_signal_init(int dlopened)
|
||||
{
|
||||
struct sigaction act;
|
||||
struct sigaction act, nact, oact;
|
||||
struct usigaction *usa;
|
||||
sigset_t oldset;
|
||||
int sig, error;
|
||||
|
||||
if (dlopened) {
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_maskset, &oldset);
|
||||
for (sig = 1; sig <= _SIG_MAXSIG; sig++) {
|
||||
if (sig == SIGCANCEL)
|
||||
continue;
|
||||
error = __sys_sigaction(sig, NULL, &oact);
|
||||
if (error == -1 || oact.sa_handler == SIG_DFL ||
|
||||
oact.sa_handler == SIG_IGN)
|
||||
continue;
|
||||
usa = __libc_sigaction_slot(sig);
|
||||
usa->sigact = oact;
|
||||
nact = oact;
|
||||
remove_thr_signals(&usa->sigact.sa_mask);
|
||||
nact.sa_flags &= ~SA_NODEFER;
|
||||
nact.sa_flags |= SA_SIGINFO;
|
||||
nact.sa_sigaction = thr_sighandler;
|
||||
nact.sa_mask = _thr_maskset;
|
||||
(void)__sys_sigaction(sig, &nact, NULL);
|
||||
}
|
||||
__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
}
|
||||
|
||||
/* Install SIGCANCEL handler. */
|
||||
SIGFILLSET(act.sa_mask);
|
||||
@ -418,18 +447,20 @@ _thr_sigact_unload(struct dl_phdr_info *phdr_info)
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct urwlock *rwlp;
|
||||
struct sigaction *actp;
|
||||
struct usigaction *usa;
|
||||
struct sigaction kact;
|
||||
void (*handler)(int);
|
||||
int sig;
|
||||
|
||||
_thr_signal_block(curthread);
|
||||
for (sig = 1; sig <= _SIG_MAXSIG; sig++) {
|
||||
actp = &_thr_sigact[sig-1].sigact;
|
||||
usa = __libc_sigaction_slot(sig);
|
||||
actp = &usa->sigact;
|
||||
retry:
|
||||
handler = actp->sa_handler;
|
||||
if (handler != SIG_DFL && handler != SIG_IGN &&
|
||||
__elf_phdr_match_addr(phdr_info, handler)) {
|
||||
rwlp = &_thr_sigact[sig-1].lock;
|
||||
rwlp = &usa->lock;
|
||||
_thr_rwl_wrlock(rwlp);
|
||||
if (handler != actp->sa_handler) {
|
||||
_thr_rwl_unlock(rwlp);
|
||||
@ -455,7 +486,7 @@ _thr_signal_prefork(void)
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= _SIG_MAXSIG; ++i)
|
||||
_thr_rwl_rdlock(&_thr_sigact[i-1].lock);
|
||||
_thr_rwl_rdlock(&__libc_sigaction_slot(i)->lock);
|
||||
}
|
||||
|
||||
void
|
||||
@ -464,7 +495,7 @@ _thr_signal_postfork(void)
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= _SIG_MAXSIG; ++i)
|
||||
_thr_rwl_unlock(&_thr_sigact[i-1].lock);
|
||||
_thr_rwl_unlock(&__libc_sigaction_slot(i)->lock);
|
||||
}
|
||||
|
||||
void
|
||||
@ -472,8 +503,10 @@ _thr_signal_postfork_child(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= _SIG_MAXSIG; ++i)
|
||||
bzero(&_thr_sigact[i-1].lock, sizeof(struct urwlock));
|
||||
for (i = 1; i <= _SIG_MAXSIG; ++i) {
|
||||
bzero(&__libc_sigaction_slot(i) -> lock,
|
||||
sizeof(struct urwlock));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -481,84 +514,81 @@ _thr_signal_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
__weak_reference(___pause, pause);
|
||||
|
||||
int
|
||||
___pause(void)
|
||||
__thr_pause(void)
|
||||
{
|
||||
sigset_t oset;
|
||||
|
||||
if (_sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
|
||||
return (-1);
|
||||
return (__sigsuspend(&oset));
|
||||
return (__thr_sigsuspend(&oset));
|
||||
}
|
||||
|
||||
__weak_reference(_raise, raise);
|
||||
|
||||
int
|
||||
_raise(int sig)
|
||||
__thr_raise(int sig)
|
||||
{
|
||||
return _thr_send_sig(_get_curthread(), sig);
|
||||
|
||||
return (_thr_send_sig(_get_curthread(), sig));
|
||||
}
|
||||
|
||||
__weak_reference(_sigaction, sigaction);
|
||||
|
||||
int
|
||||
_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
|
||||
__thr_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
|
||||
{
|
||||
struct sigaction newact, oldact, oldact2;
|
||||
sigset_t oldset;
|
||||
int ret = 0, err = 0;
|
||||
struct usigaction *usa;
|
||||
int ret, err;
|
||||
|
||||
if (!_SIG_VALID(sig) || sig == SIGCANCEL) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (act)
|
||||
newact = *act;
|
||||
ret = 0;
|
||||
err = 0;
|
||||
usa = __libc_sigaction_slot(sig);
|
||||
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_maskset, &oldset);
|
||||
_thr_rwl_wrlock(&_thr_sigact[sig-1].lock);
|
||||
_thr_rwl_wrlock(&usa->lock);
|
||||
|
||||
if (act != NULL) {
|
||||
oldact2 = _thr_sigact[sig-1].sigact;
|
||||
oldact2 = usa->sigact;
|
||||
newact = *act;
|
||||
|
||||
/*
|
||||
* if a new sig handler is SIG_DFL or SIG_IGN,
|
||||
* don't remove old handler from _thr_sigact[],
|
||||
* don't remove old handler from __libc_sigact[],
|
||||
* so deferred signals still can use the handlers,
|
||||
* multiple threads invoking sigaction itself is
|
||||
* a race condition, so it is not a problem.
|
||||
*/
|
||||
if (newact.sa_handler != SIG_DFL &&
|
||||
newact.sa_handler != SIG_IGN) {
|
||||
_thr_sigact[sig-1].sigact = newact;
|
||||
remove_thr_signals(
|
||||
&_thr_sigact[sig-1].sigact.sa_mask);
|
||||
usa->sigact = newact;
|
||||
remove_thr_signals(&usa->sigact.sa_mask);
|
||||
newact.sa_flags &= ~SA_NODEFER;
|
||||
newact.sa_flags |= SA_SIGINFO;
|
||||
newact.sa_sigaction = thr_sighandler;
|
||||
newact.sa_mask = _thr_maskset; /* mask all signals */
|
||||
}
|
||||
if ((ret = __sys_sigaction(sig, &newact, &oldact))) {
|
||||
ret = __sys_sigaction(sig, &newact, &oldact);
|
||||
if (ret == -1) {
|
||||
err = errno;
|
||||
_thr_sigact[sig-1].sigact = oldact2;
|
||||
usa->sigact = oldact2;
|
||||
}
|
||||
} else if (oact != NULL) {
|
||||
ret = __sys_sigaction(sig, NULL, &oldact);
|
||||
err = errno;
|
||||
}
|
||||
|
||||
if (oldact.sa_handler != SIG_DFL &&
|
||||
oldact.sa_handler != SIG_IGN) {
|
||||
if (oldact.sa_handler != SIG_DFL && oldact.sa_handler != SIG_IGN) {
|
||||
if (act != NULL)
|
||||
oldact = oldact2;
|
||||
else if (oact != NULL)
|
||||
oldact = _thr_sigact[sig-1].sigact;
|
||||
oldact = usa->sigact;
|
||||
}
|
||||
|
||||
_thr_rwl_unlock(&_thr_sigact[sig-1].lock);
|
||||
_thr_rwl_unlock(&usa->lock);
|
||||
__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
|
||||
if (ret == 0) {
|
||||
@ -570,10 +600,8 @@ _sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(_sigprocmask, sigprocmask);
|
||||
|
||||
int
|
||||
_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
|
||||
__thr_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
|
||||
{
|
||||
const sigset_t *p = set;
|
||||
sigset_t newset;
|
||||
@ -598,8 +626,6 @@ _pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
|
||||
return (0);
|
||||
}
|
||||
|
||||
__weak_reference(__sigsuspend, sigsuspend);
|
||||
|
||||
int
|
||||
_sigsuspend(const sigset_t * set)
|
||||
{
|
||||
@ -609,7 +635,7 @@ _sigsuspend(const sigset_t * set)
|
||||
}
|
||||
|
||||
int
|
||||
__sigsuspend(const sigset_t * set)
|
||||
__thr_sigsuspend(const sigset_t * set)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
sigset_t newset;
|
||||
@ -633,10 +659,6 @@ __sigsuspend(const sigset_t * set)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___sigwait, sigwait);
|
||||
__weak_reference(__sigtimedwait, sigtimedwait);
|
||||
__weak_reference(__sigwaitinfo, sigwaitinfo);
|
||||
|
||||
int
|
||||
_sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
const struct timespec * timeout)
|
||||
@ -653,7 +675,7 @@ _sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
* it is not canceled.
|
||||
*/
|
||||
int
|
||||
__sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
__thr_sigtimedwait(const sigset_t *set, siginfo_t *info,
|
||||
const struct timespec * timeout)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
@ -681,7 +703,7 @@ _sigwaitinfo(const sigset_t *set, siginfo_t *info)
|
||||
* it is not canceled.
|
||||
*/
|
||||
int
|
||||
__sigwaitinfo(const sigset_t *set, siginfo_t *info)
|
||||
__thr_sigwaitinfo(const sigset_t *set, siginfo_t *info)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
sigset_t newset;
|
||||
@ -707,7 +729,7 @@ _sigwait(const sigset_t *set, int *sig)
|
||||
* it is not canceled.
|
||||
*/
|
||||
int
|
||||
___sigwait(const sigset_t *set, int *sig)
|
||||
__thr_sigwait(const sigset_t *set, int *sig)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
sigset_t newset;
|
||||
@ -721,9 +743,8 @@ ___sigwait(const sigset_t *set, int *sig)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(_setcontext, setcontext);
|
||||
int
|
||||
_setcontext(const ucontext_t *ucp)
|
||||
__thr_setcontext(const ucontext_t *ucp)
|
||||
{
|
||||
ucontext_t uc;
|
||||
|
||||
@ -735,12 +756,11 @@ _setcontext(const ucontext_t *ucp)
|
||||
return __sys_setcontext(ucp);
|
||||
(void) memcpy(&uc, ucp, sizeof(uc));
|
||||
SIGDELSET(uc.uc_sigmask, SIGCANCEL);
|
||||
return __sys_setcontext(&uc);
|
||||
return (__sys_setcontext(&uc));
|
||||
}
|
||||
|
||||
__weak_reference(_swapcontext, swapcontext);
|
||||
int
|
||||
_swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
|
||||
__thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
|
||||
{
|
||||
ucontext_t uc;
|
||||
|
||||
@ -753,5 +773,5 @@ _swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
|
||||
SIGDELSET(uc.uc_sigmask, SIGCANCEL);
|
||||
ucp = &uc;
|
||||
}
|
||||
return __sys_swapcontext(oucp, ucp);
|
||||
return (__sys_swapcontext(oucp, ucp));
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014 The FreeBSD Foundation.
|
||||
* Copyright (C) 2005 David Xu <davidxu@freebsd.org>.
|
||||
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
|
||||
* Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
|
||||
* 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:
|
||||
@ -27,8 +31,6 @@
|
||||
* 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$
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -61,6 +63,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
@ -87,85 +92,19 @@
|
||||
#include <pthread.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "thr_private.h"
|
||||
|
||||
extern int __creat(const char *, mode_t);
|
||||
extern int __pselect(int, fd_set *, fd_set *, fd_set *,
|
||||
const struct timespec *, const sigset_t *);
|
||||
extern unsigned __sleep(unsigned int);
|
||||
extern int __system(const char *);
|
||||
extern int __tcdrain(int);
|
||||
extern int __usleep(useconds_t);
|
||||
extern pid_t __wait(int *);
|
||||
extern pid_t __waitpid(pid_t, int *, int);
|
||||
extern int __sys_aio_suspend(const struct aiocb * const[], int,
|
||||
const struct timespec *);
|
||||
extern int __sys_accept(int, struct sockaddr *, socklen_t *);
|
||||
extern int __sys_accept4(int, struct sockaddr *, socklen_t *, int);
|
||||
extern int __sys_connect(int, const struct sockaddr *, socklen_t);
|
||||
extern int __sys_fsync(int);
|
||||
extern int __sys_msync(void *, size_t, int);
|
||||
extern int __sys_pselect(int, fd_set *, fd_set *, fd_set *,
|
||||
const struct timespec *, const sigset_t *);
|
||||
extern int __sys_poll(struct pollfd *, unsigned, int);
|
||||
extern ssize_t __sys_recv(int, void *, size_t, int);
|
||||
extern ssize_t __sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
|
||||
extern ssize_t __sys_recvmsg(int, struct msghdr *, int);
|
||||
extern int __sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
extern int __sys_sendfile(int, int, off_t, size_t, struct sf_hdtr *,
|
||||
off_t *, int);
|
||||
extern ssize_t __sys_sendmsg(int, const struct msghdr *, int);
|
||||
extern ssize_t __sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t);
|
||||
extern ssize_t __sys_readv(int, const struct iovec *, int);
|
||||
extern pid_t __sys_wait4(pid_t, int *, int, struct rusage *);
|
||||
extern ssize_t __sys_writev(int, const struct iovec *, int);
|
||||
|
||||
int ___creat(const char *, mode_t);
|
||||
int ___pselect(int, fd_set *, fd_set *, fd_set *,
|
||||
const struct timespec *, const sigset_t *);
|
||||
unsigned ___sleep(unsigned);
|
||||
int ___system(const char *);
|
||||
int ___tcdrain(int);
|
||||
int ___usleep(useconds_t useconds);
|
||||
pid_t ___wait(int *);
|
||||
pid_t ___waitpid(pid_t, int *, int);
|
||||
int __accept(int, struct sockaddr *, socklen_t *);
|
||||
int __accept4(int, struct sockaddr *, socklen_t *, int);
|
||||
int __aio_suspend(const struct aiocb * const iocbs[], int,
|
||||
const struct timespec *);
|
||||
int __close(int);
|
||||
int __connect(int, const struct sockaddr *, socklen_t);
|
||||
int __fcntl(int, int,...);
|
||||
#ifdef SYSCALL_COMPAT
|
||||
extern int __fcntl_compat(int, int, ...);
|
||||
#endif
|
||||
int __fsync(int);
|
||||
int __msync(void *, size_t, int);
|
||||
int __nanosleep(const struct timespec *, struct timespec *);
|
||||
int __open(const char *, int,...);
|
||||
int __openat(int, const char *, int,...);
|
||||
int __poll(struct pollfd *, unsigned int, int);
|
||||
ssize_t __read(int, void *buf, size_t);
|
||||
ssize_t __readv(int, const struct iovec *, int);
|
||||
ssize_t __recvfrom(int, void *, size_t, int f, struct sockaddr *, socklen_t *);
|
||||
ssize_t __recvmsg(int, struct msghdr *, int);
|
||||
int __select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
ssize_t __sendmsg(int, const struct msghdr *, int);
|
||||
ssize_t __sendto(int, const void *, size_t, int,
|
||||
const struct sockaddr *, socklen_t);
|
||||
pid_t __wait3(int *, int, struct rusage *);
|
||||
pid_t __wait4(pid_t, int *, int, struct rusage *);
|
||||
ssize_t __write(int, const void *, size_t);
|
||||
ssize_t __writev(int, const struct iovec *, int);
|
||||
|
||||
__weak_reference(__accept, accept);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If thread is canceled, no socket is created.
|
||||
*/
|
||||
int
|
||||
__accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
static int
|
||||
__thr_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
@ -178,14 +117,12 @@ __accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__accept4, accept4);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If thread is canceled, no socket is created.
|
||||
*/
|
||||
int
|
||||
__accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
|
||||
static int
|
||||
__thr_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
@ -198,15 +135,14 @@ __accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__aio_suspend, aio_suspend);
|
||||
|
||||
int
|
||||
__aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
|
||||
static int
|
||||
__thr_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
|
||||
timespec *timeout)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_aio_suspend(iocbs, niocb, timeout);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
@ -214,8 +150,6 @@ __aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__close, close);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* According to manual of close(), the file descriptor is always deleted.
|
||||
@ -223,12 +157,13 @@ __weak_reference(__close, close);
|
||||
* descriptor is always deleted despite whether the thread is canceled
|
||||
* or not.
|
||||
*/
|
||||
int
|
||||
__close(int fd)
|
||||
static int
|
||||
__thr_close(int fd)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter2(curthread, 0);
|
||||
ret = __sys_close(fd);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
@ -236,18 +171,17 @@ __close(int fd)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__connect, connect);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If the thread is canceled, connection is not made.
|
||||
*/
|
||||
int
|
||||
__connect(int fd, const struct sockaddr *name, socklen_t namelen)
|
||||
static int
|
||||
__thr_connect(int fd, const struct sockaddr *name, socklen_t namelen)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_connect(fd, name, namelen);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
@ -255,27 +189,25 @@ __connect(int fd, const struct sockaddr *name, socklen_t namelen)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___creat, creat);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If thread is canceled, file is not created.
|
||||
*/
|
||||
int
|
||||
___creat(const char *path, mode_t mode)
|
||||
static int
|
||||
__thr_creat(const char *path, mode_t mode)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __creat(path, mode);
|
||||
ret = __libc_creat(path, mode);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__fcntl, fcntl);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* According to specification, only F_SETLKW is a cancellation point.
|
||||
@ -283,13 +215,14 @@ __weak_reference(__fcntl, fcntl);
|
||||
* is failure, this means the function does not generate side effect
|
||||
* if it is canceled.
|
||||
*/
|
||||
int
|
||||
__fcntl(int fd, int cmd,...)
|
||||
static int
|
||||
__thr_fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
curthread = _get_curthread();
|
||||
va_start(ap, cmd);
|
||||
if (cmd == F_OSETLKW || cmd == F_SETLKW) {
|
||||
_thr_cancel_enter(curthread);
|
||||
@ -311,18 +244,17 @@ __fcntl(int fd, int cmd,...)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__fsync, fsync);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled after system call.
|
||||
*/
|
||||
int
|
||||
__fsync(int fd)
|
||||
static int
|
||||
__thr_fsync(int fd)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter2(curthread, 0);
|
||||
ret = __sys_fsync(fd);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
@ -330,34 +262,32 @@ __fsync(int fd)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__msync, msync);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled after system call.
|
||||
*/
|
||||
int
|
||||
__msync(void *addr, size_t len, int flags)
|
||||
static int
|
||||
__thr_msync(void *addr, size_t len, int flags)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter2(curthread, 0);
|
||||
ret = __sys_msync(addr, len, flags);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__nanosleep, nanosleep);
|
||||
|
||||
int
|
||||
__nanosleep(const struct timespec *time_to_sleep,
|
||||
static int
|
||||
__thr_nanosleep(const struct timespec *time_to_sleep,
|
||||
struct timespec *time_remaining)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_nanosleep(time_to_sleep, time_remaining);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
@ -365,99 +295,97 @@ __nanosleep(const struct timespec *time_to_sleep,
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__open, open);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If the thread is canceled, file is not opened.
|
||||
*/
|
||||
int
|
||||
__open(const char *path, int flags,...)
|
||||
static int
|
||||
__thr_open(const char *path, int flags,...)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
int ret;
|
||||
int mode = 0;
|
||||
struct pthread *curthread;
|
||||
int mode, ret;
|
||||
va_list ap;
|
||||
|
||||
/* Check if the file is being created: */
|
||||
if (flags & O_CREAT) {
|
||||
if ((flags & O_CREAT) != 0) {
|
||||
/* Get the creation mode: */
|
||||
va_start(ap, flags);
|
||||
mode = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
} else {
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_open(path, flags, mode);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__openat, openat);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If the thread is canceled, file is not opened.
|
||||
*/
|
||||
int
|
||||
__openat(int fd, const char *path, int flags, ...)
|
||||
static int
|
||||
__thr_openat(int fd, const char *path, int flags, ...)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
int ret;
|
||||
int mode = 0;
|
||||
struct pthread *curthread;
|
||||
int mode, ret;
|
||||
va_list ap;
|
||||
|
||||
|
||||
/* Check if the file is being created: */
|
||||
if (flags & O_CREAT) {
|
||||
if ((flags & O_CREAT) != 0) {
|
||||
/* Get the creation mode: */
|
||||
va_start(ap, flags);
|
||||
mode = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
} else {
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_openat(fd, path, flags, mode);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__poll, poll);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns something,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
int
|
||||
__poll(struct pollfd *fds, unsigned int nfds, int timeout)
|
||||
static int
|
||||
__thr_poll(struct pollfd *fds, unsigned int nfds, int timeout)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_poll(fds, nfds, timeout);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___pselect, pselect);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns something,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
int
|
||||
___pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
static int
|
||||
__thr_pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
const struct timespec *timo, const sigset_t *mask)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_pselect(count, rfds, wfds, efds, timo, mask);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
@ -465,321 +393,353 @@ ___pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__read, read);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call got some data,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__read(int fd, void *buf, size_t nbytes)
|
||||
static ssize_t
|
||||
__thr_read(int fd, void *buf, size_t nbytes)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_read(fd, buf, nbytes);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__readv, readv);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call got some data,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__readv(int fd, const struct iovec *iov, int iovcnt)
|
||||
static ssize_t
|
||||
__thr_readv(int fd, const struct iovec *iov, int iovcnt)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_readv(fd, iov, iovcnt);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__recvfrom, recvfrom);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call got some data,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__recvfrom(int s, void *b, size_t l, int f, struct sockaddr *from,
|
||||
static ssize_t
|
||||
__thr_recvfrom(int s, void *b, size_t l, int f, struct sockaddr *from,
|
||||
socklen_t *fl)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_recvfrom(s, b, l, f, from, fl);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__recvmsg, recvmsg);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call got some data,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__recvmsg(int s, struct msghdr *m, int f)
|
||||
static ssize_t
|
||||
__thr_recvmsg(int s, struct msghdr *m, int f)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_recvmsg(s, m, f);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__select, select);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns something,
|
||||
* the thread is not canceled.
|
||||
*/
|
||||
int
|
||||
__select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
static int
|
||||
__thr_select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
struct timeval *timeout)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__sendmsg, sendmsg);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call sent
|
||||
* data, the thread is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__sendmsg(int s, const struct msghdr *m, int f)
|
||||
static ssize_t
|
||||
__thr_sendmsg(int s, const struct msghdr *m, int f)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_sendmsg(s, m, f);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__sendto, sendto);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call sent some
|
||||
* data, the thread is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t,
|
||||
static ssize_t
|
||||
__thr_sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t,
|
||||
socklen_t tl)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_sendto(s, m, l, f, t, tl);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___sleep, sleep);
|
||||
|
||||
unsigned int
|
||||
___sleep(unsigned int seconds)
|
||||
static unsigned int
|
||||
__thr_sleep(unsigned int seconds)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
unsigned int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sleep(seconds);
|
||||
ret = __libc_sleep(seconds);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___system, system);
|
||||
|
||||
int
|
||||
___system(const char *string)
|
||||
static int
|
||||
__thr_system(const char *string)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __system(string);
|
||||
ret = __libc_system(string);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___tcdrain, tcdrain);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* If thread is canceled, the system call is not completed,
|
||||
* this means not all bytes were drained.
|
||||
*/
|
||||
int
|
||||
___tcdrain(int fd)
|
||||
static int
|
||||
__thr_tcdrain(int fd)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __tcdrain(fd);
|
||||
ret = __libc_tcdrain(fd);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___usleep, usleep);
|
||||
|
||||
int
|
||||
___usleep(useconds_t useconds)
|
||||
static int
|
||||
__thr_usleep(useconds_t useconds)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __usleep(useconds);
|
||||
ret = __libc_usleep(useconds);
|
||||
_thr_cancel_leave(curthread, 1);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___wait, wait);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns
|
||||
* a child pid, the thread is not canceled.
|
||||
*/
|
||||
pid_t
|
||||
___wait(int *istat)
|
||||
static pid_t
|
||||
__thr_wait(int *istat)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
pid_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __wait(istat);
|
||||
ret = __libc_wait(istat);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
__weak_reference(__wait3, wait3);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns
|
||||
* a child pid, the thread is not canceled.
|
||||
*/
|
||||
pid_t
|
||||
__wait3(int *status, int options, struct rusage *rusage)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
pid_t ret;
|
||||
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = _wait4(WAIT_ANY, status, options, rusage);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__wait4, wait4);
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns
|
||||
* a child pid, the thread is not canceled.
|
||||
*/
|
||||
static pid_t
|
||||
__thr_wait3(int *status, int options, struct rusage *rusage)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
pid_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __libc_wait3(status, options, rusage);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns
|
||||
* a child pid, the thread is not canceled.
|
||||
*/
|
||||
pid_t
|
||||
__wait4(pid_t pid, int *status, int options, struct rusage *rusage)
|
||||
static pid_t
|
||||
__thr_wait4(pid_t pid, int *status, int options, struct rusage *rusage)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
pid_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_wait4(pid, status, options, rusage);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(___waitpid, waitpid);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the system call returns
|
||||
* a child pid, the thread is not canceled.
|
||||
*/
|
||||
pid_t
|
||||
___waitpid(pid_t wpid, int *status, int options)
|
||||
static pid_t
|
||||
__thr_waitpid(pid_t wpid, int *status, int options)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
pid_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __waitpid(wpid, status, options);
|
||||
ret = __libc_waitpid(wpid, status, options);
|
||||
_thr_cancel_leave(curthread, ret <= 0);
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__write, write);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the thread wrote some data,
|
||||
* it is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__write(int fd, const void *buf, size_t nbytes)
|
||||
static ssize_t
|
||||
__thr_write(int fd, const void *buf, size_t nbytes)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_write(fd, buf, nbytes);
|
||||
_thr_cancel_leave(curthread, (ret <= 0));
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
__weak_reference(__writev, writev);
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the thread wrote some data,
|
||||
* it is not canceled.
|
||||
*/
|
||||
ssize_t
|
||||
__writev(int fd, const struct iovec *iov, int iovcnt)
|
||||
static ssize_t
|
||||
__thr_writev(int fd, const struct iovec *iov, int iovcnt)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct pthread *curthread;
|
||||
ssize_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_writev(fd, iov, iovcnt);
|
||||
_thr_cancel_leave(curthread, (ret <= 0));
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void
|
||||
__thr_interpose_libc(void)
|
||||
{
|
||||
|
||||
__error_selector = __error_threaded;
|
||||
#define SLOT(name) \
|
||||
*(__libc_interposing_slot(INTERPOS_##name)) = \
|
||||
(interpos_func_t)__thr_##name;
|
||||
SLOT(accept);
|
||||
SLOT(accept4);
|
||||
SLOT(aio_suspend);
|
||||
SLOT(close);
|
||||
SLOT(connect);
|
||||
SLOT(creat);
|
||||
SLOT(fcntl);
|
||||
SLOT(fsync);
|
||||
SLOT(fork);
|
||||
SLOT(msync);
|
||||
SLOT(nanosleep);
|
||||
SLOT(open);
|
||||
SLOT(openat);
|
||||
SLOT(poll);
|
||||
SLOT(pselect);
|
||||
SLOT(raise);
|
||||
SLOT(read);
|
||||
SLOT(readv);
|
||||
SLOT(recvfrom);
|
||||
SLOT(recvmsg);
|
||||
SLOT(select);
|
||||
SLOT(sendmsg);
|
||||
SLOT(sendto);
|
||||
SLOT(setcontext);
|
||||
SLOT(sigaction);
|
||||
SLOT(sigprocmask);
|
||||
SLOT(sigsuspend);
|
||||
SLOT(sigwait);
|
||||
SLOT(sigtimedwait);
|
||||
SLOT(sigwaitinfo);
|
||||
SLOT(swapcontext);
|
||||
SLOT(system);
|
||||
SLOT(sleep);
|
||||
SLOT(tcdrain);
|
||||
SLOT(usleep);
|
||||
SLOT(pause);
|
||||
SLOT(wait);
|
||||
SLOT(wait3);
|
||||
SLOT(wait4);
|
||||
SLOT(waitpid);
|
||||
SLOT(write);
|
||||
SLOT(writev);
|
||||
#undef SLOT
|
||||
*(__libc_interposing_slot(
|
||||
INTERPOS__pthread_mutex_init_calloc_cb)) =
|
||||
(interpos_func_t)_pthread_mutex_init_calloc_cb;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user