View | Details | Raw Unified | Return to bug 196354 | Differences between
and this patch

Collapse All | Expand All

(-)b/contrib/jemalloc/include/jemalloc/internal/mutex.h (+1 lines)
Lines 49-54 bool malloc_mutex_init(malloc_mutex_t *mutex); Link Here
49
void	malloc_mutex_prefork(malloc_mutex_t *mutex);
49
void	malloc_mutex_prefork(malloc_mutex_t *mutex);
50
void	malloc_mutex_postfork_parent(malloc_mutex_t *mutex);
50
void	malloc_mutex_postfork_parent(malloc_mutex_t *mutex);
51
void	malloc_mutex_postfork_child(malloc_mutex_t *mutex);
51
void	malloc_mutex_postfork_child(malloc_mutex_t *mutex);
52
bool	malloc_mutex_first_thread(void);
52
bool	mutex_boot(void);
53
bool	mutex_boot(void);
53
54
54
#endif /* JEMALLOC_H_EXTERNS */
55
#endif /* JEMALLOC_H_EXTERNS */
(-)b/contrib/jemalloc/src/jemalloc.c (+7 lines)
Lines 2061-2066 jemalloc_postfork_child(void) Link Here
2061
	ctl_postfork_child();
2061
	ctl_postfork_child();
2062
}
2062
}
2063
2063
2064
void
2065
_malloc_first_thread(void)
2066
{
2067
2068
	(void)malloc_mutex_first_thread();
2069
}
2070
2064
/******************************************************************************/
2071
/******************************************************************************/
2065
/*
2072
/*
2066
 * The following functions are used for TLS allocation/deallocation in static
2073
 * The following functions are used for TLS allocation/deallocation in static
(-)b/contrib/jemalloc/src/mutex.c (-6 / +17 lines)
Lines 67-81 pthread_create(pthread_t *__restrict thread, Link Here
67
JEMALLOC_EXPORT int	_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
67
JEMALLOC_EXPORT int	_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
68
    void *(calloc_cb)(size_t, size_t));
68
    void *(calloc_cb)(size_t, size_t));
69
69
70
__weak_reference(_pthread_mutex_init_calloc_cb_stub,
70
#pragma weak _pthread_mutex_init_calloc_cb
71
    _pthread_mutex_init_calloc_cb);
72
73
int
71
int
74
_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
72
_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
75
    void *(calloc_cb)(size_t, size_t))
73
    void *(calloc_cb)(size_t, size_t))
76
{
74
{
77
75
78
	return (0);
76
	return (((int (*)(pthread_mutex_t *, void *(*)(size_t, size_t)))
77
	    __libc_interposing[INTERPOS__pthread_mutex_init_calloc_cb])(
78
	   mutex, calloc_cb));
79
}
79
}
80
#endif
80
#endif
81
81
Lines 144-150 malloc_mutex_postfork_child(malloc_mutex_t *mutex) Link Here
144
}
144
}
145
145
146
bool
146
bool
147
mutex_boot(void)
147
malloc_mutex_first_thread(void)
148
{
148
{
149
149
150
#ifdef JEMALLOC_MUTEX_INIT_CB
150
#ifdef JEMALLOC_MUTEX_INIT_CB
Lines 158-160 mutex_boot(void) Link Here
158
#endif
158
#endif
159
	return (false);
159
	return (false);
160
}
160
}
161
162
bool
163
mutex_boot(void)
164
{
165
166
#ifndef JEMALLOC_MUTEX_INIT_CB
167
	return (malloc_mutex_first_thread());
168
#else
169
	return (false);
170
#endif
171
}
(-)b/lib/libc/Makefile (+4 lines)
Lines 156-161 libkern.${LIBC_ARCH}:: ${KMSRCS} Link Here
156
	cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
156
	cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
157
.endif
157
.endif
158
158
159
.if ${MK_SYSCALL_COMPAT} != "no"
160
CFLAGS+=-DSYSCALL_COMPAT
161
.endif
162
159
.include <bsd.arch.inc.mk>
163
.include <bsd.arch.inc.mk>
160
164
161
.include <bsd.lib.mk>
165
.include <bsd.lib.mk>
(-)b/lib/libc/compat-43/Symbol.map (+1 lines)
Lines 28-31 FBSD_1.2 { Link Here
28
FBSDprivate_1.0 {
28
FBSDprivate_1.0 {
29
	__creat;
29
	__creat;
30
	_creat;
30
	_creat;
31
	__libc_creat;
31
};
32
};
(-)b/lib/libc/compat-43/creat.c (-4 / +16 lines)
Lines 36-46 __FBSDID("$FreeBSD$"); Link Here
36
#include "namespace.h"
36
#include "namespace.h"
37
#include <fcntl.h>
37
#include <fcntl.h>
38
#include "un-namespace.h"
38
#include "un-namespace.h"
39
#include "libc_private.h"
39
40
41
__weak_reference(__libc_creat, __creat);
42
__weak_reference(__libc_creat, _creat);
43
44
#pragma weak creat
40
int
45
int
41
__creat(const char *path, mode_t mode)
46
creat(const char *path, mode_t mode)
42
{
47
{
43
	return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
48
49
	return (((int (*)(const char *, mode_t))
50
	    __libc_interposing[INTERPOS_creat])(path, mode));
51
}
52
53
int
54
__libc_creat(const char *path, mode_t mode)
55
{
56
57
	return(__sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
44
}
58
}
45
__weak_reference(__creat, creat);
46
__weak_reference(__creat, _creat);
(-)b/lib/libc/gen/Makefile.inc (+1 lines)
Lines 5-10 Link Here
5
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
5
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
6
6
7
SRCS+=	__getosreldate.c \
7
SRCS+=	__getosreldate.c \
8
	__pthread_mutex_init_calloc_cb_stub.c \
8
	__xuname.c \
9
	__xuname.c \
9
	_once_stub.c \
10
	_once_stub.c \
10
	_pthread_stubs.c \
11
	_pthread_stubs.c \
(-)b/lib/libc/gen/Symbol.map (+11 lines)
Lines 487-492 FBSDprivate_1.0 { Link Here
487
	_rtld_atfork_post;
487
	_rtld_atfork_post;
488
	_rtld_error;		/* for private use */
488
	_rtld_error;		/* for private use */
489
	_rtld_get_stack_prot;
489
	_rtld_get_stack_prot;
490
	_rtld_is_dlopened;
490
	_rtld_thread_init;	/* for private use */
491
	_rtld_thread_init;	/* for private use */
491
	__elf_phdr_match_addr;
492
	__elf_phdr_match_addr;
492
	_err;
493
	_err;
Lines 532-537 FBSDprivate_1.0 { Link Here
532
	_libc_sem_post_compat;
533
	_libc_sem_post_compat;
533
	_libc_sem_getvalue_compat;
534
	_libc_sem_getvalue_compat;
534
535
536
	__libc_pause;
537
	__libc_raise;
538
	__libc_system;
539
	__libc_sleep;
540
	__libc_tcdrain;
541
	__libc_usleep;
542
	__libc_wait;
543
	__libc_wait3;
544
	__libc_waitpid;
545
535
	__elf_aux_vector;
546
	__elf_aux_vector;
536
	__pthread_map_stacks_exec;
547
	__pthread_map_stacks_exec;
537
	__fillcontextx;
548
	__fillcontextx;
(-)b/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c (+45 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <pthread.h>
37
#include "libc_private.h"
38
39
int
40
_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
41
    void *(calloc_cb)(size_t, size_t))
42
{
43
44
	return (0);
45
}
(-)b/lib/libc/gen/dlfcn.c (+7 lines)
Lines 233-235 _rtld_get_stack_prot(void) Link Here
233
	return (PROT_EXEC | PROT_READ | PROT_WRITE);
233
	return (PROT_EXEC | PROT_READ | PROT_WRITE);
234
}
234
}
235
235
236
#pragma weak _rtld_is_dlopened
237
int
238
_rtld_is_dlopened(void *arg)
239
{
240
241
	return (0);
242
}
(-)b/lib/libc/gen/pause.c (-3 / +15 lines)
Lines 38-48 __FBSDID("$FreeBSD$"); Link Here
38
#include <unistd.h>
38
#include <unistd.h>
39
#include "un-namespace.h"
39
#include "un-namespace.h"
40
40
41
#include "libc_private.h"
42
41
/*
43
/*
42
 * Backwards compatible pause.
44
 * Backwards compatible pause.
43
 */
45
 */
44
int
46
int
45
__pause(void)
47
__libc_pause(void)
46
{
48
{
47
	sigset_t oset;
49
	sigset_t oset;
48
50
Lines 50-54 __pause(void) Link Here
50
		return (-1);
52
		return (-1);
51
	return (_sigsuspend(&oset));
53
	return (_sigsuspend(&oset));
52
}
54
}
53
__weak_reference(__pause, pause);
55
54
__weak_reference(__pause, _pause);
56
#pragma weak pause
57
int
58
pause(void)
59
{
60
61
	return (((int (*)(void))
62
	    __libc_interposing[INTERPOS_pause])());
63
}
64
65
__weak_reference(__libc_pause, __pause);
66
__weak_reference(__libc_pause, _pause);
(-)b/lib/libc/gen/raise.c (-4 / +16 lines)
Lines 36-46 __FBSDID("$FreeBSD$"); Link Here
36
#include <signal.h>
36
#include <signal.h>
37
#include <unistd.h>
37
#include <unistd.h>
38
38
39
__weak_reference(__raise, raise);
39
#include "libc_private.h"
40
__weak_reference(__raise, _raise);
41
40
41
__weak_reference(__libc_raise, __raise);
42
__weak_reference(__libc_raise, _raise);
43
44
#pragma weak raise
42
int
45
int
43
__raise(int s)
46
raise(int s)
44
{
47
{
45
	return(kill(getpid(), s));
48
49
	return (((int (*)(int))
50
	    __libc_interposing[INTERPOS_raise])(s));
51
}
52
53
int
54
__libc_raise(int s)
55
{
56
57
	return (kill(getpid(), s));
46
}
58
}
(-)b/lib/libc/gen/sleep.c (-4 / +15 lines)
Lines 40-47 __FBSDID("$FreeBSD$"); Link Here
40
#include <unistd.h>
40
#include <unistd.h>
41
#include "un-namespace.h"
41
#include "un-namespace.h"
42
42
43
#include "libc_private.h"
44
45
#pragma weak sleep
46
unsigned int
47
sleep(unsigned int seconds)
48
{
49
50
	return (((unsigned int (*)(unsigned int))
51
	    __libc_interposing[INTERPOS_sleep])(seconds));
52
}
53
43
unsigned int
54
unsigned int
44
__sleep(unsigned int seconds)
55
__libc_sleep(unsigned int seconds)
45
{
56
{
46
	struct timespec time_to_sleep;
57
	struct timespec time_to_sleep;
47
	struct timespec time_remaining;
58
	struct timespec time_remaining;
Lines 51-57 __sleep(unsigned int seconds) Link Here
51
	 * the maximum value for a time_t is >= INT_MAX.
62
	 * the maximum value for a time_t is >= INT_MAX.
52
	 */
63
	 */
53
	if (seconds > INT_MAX)
64
	if (seconds > INT_MAX)
54
		return (seconds - INT_MAX + __sleep(INT_MAX));
65
		return (seconds - INT_MAX + __libc_sleep(INT_MAX));
55
66
56
	time_to_sleep.tv_sec = seconds;
67
	time_to_sleep.tv_sec = seconds;
57
	time_to_sleep.tv_nsec = 0;
68
	time_to_sleep.tv_nsec = 0;
Lines 63-67 __sleep(unsigned int seconds) Link Here
63
		(time_remaining.tv_nsec != 0)); /* round up */
74
		(time_remaining.tv_nsec != 0)); /* round up */
64
}
75
}
65
76
66
__weak_reference(__sleep, sleep);
77
__weak_reference(__libc_sleep, __sleep);
67
__weak_reference(__sleep, _sleep);
78
__weak_reference(__libc_sleep, _sleep);
(-)a/lib/libc/gen/swapcontext.c (-55 lines)
Removed Link Here
1
/*
2
 * Copyright (c) 2001 Daniel M. Eischen <deischen@freebsd.org>
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Neither the name of the author nor the names of its contributors
11
 *    may be used to endorse or promote products derived from this software
12
 *    without specific prior written permission.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 */
26
27
#include <sys/cdefs.h>
28
__FBSDID("$FreeBSD$");
29
30
#include <sys/param.h>
31
#include <sys/signal.h>
32
#include <sys/ucontext.h>
33
34
#include <errno.h>
35
#include <stddef.h>
36
37
__weak_reference(__swapcontext, swapcontext);
38
39
int
40
__swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
41
{
42
	int ret;
43
44
	if ((oucp == NULL) || (ucp == NULL)) {
45
		errno = EINVAL;
46
		return (-1);
47
	}
48
	oucp->uc_flags &= ~UCF_SWAPPED;
49
	ret = getcontext(oucp);
50
	if ((ret == 0) && !(oucp->uc_flags & UCF_SWAPPED)) {
51
		oucp->uc_flags |= UCF_SWAPPED;
52
		ret = setcontext(ucp);
53
	}
54
	return (ret);
55
}
(-)b/lib/libc/gen/termios.c (-3 / +15 lines)
Lines 46-51 __FBSDID("$FreeBSD$"); Link Here
46
#include <unistd.h>
46
#include <unistd.h>
47
#include "un-namespace.h"
47
#include "un-namespace.h"
48
48
49
#include "libc_private.h"
50
49
int
51
int
50
tcgetattr(int fd, struct termios *t)
52
tcgetattr(int fd, struct termios *t)
51
{
53
{
Lines 208-220 tcsendbreak(int fd, int len __unused) Link Here
208
}
210
}
209
211
210
int
212
int
211
__tcdrain(int fd)
213
__libc_tcdrain(int fd)
212
{
214
{
215
213
	return (_ioctl(fd, TIOCDRAIN, 0));
216
	return (_ioctl(fd, TIOCDRAIN, 0));
214
}
217
}
215
218
216
__weak_reference(__tcdrain, tcdrain);
219
#pragma weak tcdrain
217
__weak_reference(__tcdrain, _tcdrain);
220
int
221
tcdrain(int fd)
222
{
223
224
	return (((int (*)(int))
225
	    __libc_interposing[INTERPOS_tcdrain])(fd));
226
}
227
228
__weak_reference(__libc_tcdrain, __tcdrain);
229
__weak_reference(__libc_tcdrain, _tcdrain);
218
230
219
int
231
int
220
tcflush(int fd, int which)
232
tcflush(int fd, int which)
(-)b/lib/libc/gen/usleep.c (-3 / +14 lines)
Lines 38-45 __FBSDID("$FreeBSD$"); Link Here
38
#include <unistd.h>
38
#include <unistd.h>
39
#include "un-namespace.h"
39
#include "un-namespace.h"
40
40
41
#include "libc_private.h"
42
43
#pragma weak usleep
44
int
45
usleep(useconds_t useconds)
46
{
47
48
	return (((int (*)(useconds_t))
49
	    __libc_interposing[INTERPOS_usleep])(useconds));
50
}
51
41
int
52
int
42
__usleep(useconds_t useconds)
53
__libc_usleep(useconds_t useconds)
43
{
54
{
44
	struct timespec time_to_sleep;
55
	struct timespec time_to_sleep;
45
56
Lines 48-52 __usleep(useconds_t useconds) Link Here
48
	return (_nanosleep(&time_to_sleep, NULL));
59
	return (_nanosleep(&time_to_sleep, NULL));
49
}
60
}
50
61
51
__weak_reference(__usleep, usleep);
62
__weak_reference(__libc_usleep, __usleep);
52
__weak_reference(__usleep, _usleep);
63
__weak_reference(__libc_usleep, _usleep);
(-)b/lib/libc/gen/wait.c (-4 / +16 lines)
Lines 40-50 __FBSDID("$FreeBSD$"); Link Here
40
#include <sys/resource.h>
40
#include <sys/resource.h>
41
#include "un-namespace.h"
41
#include "un-namespace.h"
42
42
43
#include "libc_private.h"
44
45
#pragma weak wait
43
pid_t
46
pid_t
44
__wait(int *istat)
47
wait(int *istat)
45
{
48
{
46
	return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
49
50
	return (((pid_t (*)(int *))
51
	    __libc_interposing[INTERPOS_wait])(istat));
52
}
53
54
pid_t
55
__libc_wait(int *istat)
56
{
57
58
	return (__sys_wait4(WAIT_ANY, istat, 0, NULL));
47
}
59
}
48
60
49
__weak_reference(__wait, wait);
61
__weak_reference(__libc_wait, __wait);
50
__weak_reference(__wait, _wait);
62
__weak_reference(__libc_wait, _wait);
(-)b/lib/libc/gen/wait3.c (-5 / +16 lines)
Lines 40-50 __FBSDID("$FreeBSD$"); Link Here
40
#include <sys/resource.h>
40
#include <sys/resource.h>
41
#include "un-namespace.h"
41
#include "un-namespace.h"
42
42
43
#include "libc_private.h"
44
45
#pragma weak wait3
46
pid_t
47
wait3(int *istat, int options, struct rusage *rup)
48
{
49
50
	return (((pid_t (*)(int *, int, struct rusage *))
51
	    __libc_interposing[INTERPOS_wait3])(istat, options, rup));
52
}
53
54
__weak_reference(__libc_wait3, __wait3);
55
43
pid_t
56
pid_t
44
wait3(istat, options, rup)
57
__libc_wait3(int *istat, int options, struct rusage *rup)
45
	int *istat;
46
	int options;
47
	struct rusage *rup;
48
{
58
{
49
	return (_wait4(WAIT_ANY, istat, options, rup));
59
60
	return (__sys_wait4(WAIT_ANY, istat, options, rup));
50
}
61
}
(-)b/lib/libc/gen/waitpid.c (-4 / +16 lines)
Lines 40-50 __FBSDID("$FreeBSD$"); Link Here
40
#include <sys/resource.h>
40
#include <sys/resource.h>
41
#include "un-namespace.h"
41
#include "un-namespace.h"
42
42
43
#include "libc_private.h"
44
45
#pragma weak waitpid
43
pid_t
46
pid_t
44
__waitpid(pid_t pid, int *istat, int options)
47
waitpid(pid_t pid, int *istat, int options)
45
{
48
{
46
	return (_wait4(pid, istat, options, (struct rusage *)0));
49
50
	return (((pid_t (*)(pid_t, int *, int))
51
	    __libc_interposing[INTERPOS_waitpid])(pid, istat, options));
52
}
53
54
pid_t
55
__libc_waitpid(pid_t pid, int *istat, int options)
56
{
57
58
	return (__sys_wait4(pid, istat, options, NULL));
47
}
59
}
48
60
49
__weak_reference(__waitpid, waitpid);
61
__weak_reference(__libc_waitpid, __waitpid);
50
__weak_reference(__waitpid, _waitpid);
62
__weak_reference(__libc_waitpid, _waitpid);
(-)b/lib/libc/include/libc_private.h (-20 / +138 lines)
Lines 173-178 typedef pthread_func_t pthread_func_entry_t[2]; Link Here
173
173
174
extern pthread_func_entry_t __thr_jtable[];
174
extern pthread_func_entry_t __thr_jtable[];
175
175
176
extern int *(*__error_selector)(void);
177
int	_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
178
	    void *(calloc_cb)(__size_t, __size_t));
179
180
typedef int (*interpos_func_t)(void);
181
interpos_func_t *__libc_interposing_slot(int interposno);
182
extern interpos_func_t __libc_interposing[];
183
184
enum {
185
	INTERPOS_accept,
186
	INTERPOS_accept4,
187
	INTERPOS_aio_suspend,
188
	INTERPOS_close,
189
	INTERPOS_connect,
190
	INTERPOS_creat,
191
	INTERPOS_fcntl,
192
	INTERPOS_fsync,
193
	INTERPOS_msync,
194
	INTERPOS_nanosleep,
195
	INTERPOS_open,
196
	INTERPOS_openat,
197
	INTERPOS_poll,
198
	INTERPOS_pselect,
199
	INTERPOS_raise,
200
	INTERPOS_recvfrom,
201
	INTERPOS_recvmsg,
202
	INTERPOS_select,
203
	INTERPOS_sendmsg,
204
	INTERPOS_sendto,
205
	INTERPOS_setcontext,
206
	INTERPOS_sigaction,
207
	INTERPOS_sigprocmask,
208
	INTERPOS_sigsuspend,
209
	INTERPOS_sigwait,
210
	INTERPOS_sigtimedwait,
211
	INTERPOS_sigwaitinfo,
212
	INTERPOS_swapcontext,
213
	INTERPOS_system,
214
	INTERPOS_sleep,
215
	INTERPOS_tcdrain,
216
	INTERPOS_usleep,
217
	INTERPOS_pause,
218
	INTERPOS_read,
219
	INTERPOS_readv,
220
	INTERPOS_wait,
221
	INTERPOS_wait3,
222
	INTERPOS_wait4,
223
	INTERPOS_waitpid,
224
	INTERPOS_write,
225
	INTERPOS_writev,
226
	INTERPOS__pthread_mutex_init_calloc_cb,
227
	INTERPOS_MAX
228
};
229
176
/*
230
/*
177
 * yplib internal interfaces
231
 * yplib internal interfaces
178
 */
232
 */
Lines 215-256 void _malloc_thread_cleanup(void); Link Here
215
void _malloc_prefork(void);
269
void _malloc_prefork(void);
216
void _malloc_postfork(void);
270
void _malloc_postfork(void);
217
271
272
void _malloc_first_thread(void);
273
218
/*
274
/*
219
 * Function to clean up streams, called from abort() and exit().
275
 * Function to clean up streams, called from abort() and exit().
220
 */
276
 */
221
extern void (*__cleanup)(void) __hidden;
277
void (*__cleanup)(void) __hidden;
222
278
223
/*
279
/*
224
 * Get kern.osreldate to detect ABI revisions.  Explicitly
280
 * Get kern.osreldate to detect ABI revisions.  Explicitly
225
 * ignores value of $OSVERSION and caches result.  Prototypes
281
 * ignores value of $OSVERSION and caches result.  Prototypes
226
 * for the wrapped "new" pad-less syscalls are here for now.
282
 * for the wrapped "new" pad-less syscalls are here for now.
227
 */
283
 */
228
extern int __getosreldate(void);
284
int __getosreldate(void);
229
#include <sys/_types.h>
285
#include <sys/_types.h>
230
/* Without pad */
286
#include <sys/_sigset.h>
231
extern __off_t	__sys_lseek(int, __off_t, int);
232
extern int	__sys_ftruncate(int, __off_t);
233
extern int	__sys_truncate(const char *, __off_t);
234
extern __ssize_t __sys_pread(int, void *, __size_t, __off_t);
235
extern __ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
236
extern void *	__sys_mmap(void *, __size_t, int, int, int, __off_t);
237
287
238
/* With pad */
288
/* With pad */
239
extern __off_t	__sys_freebsd6_lseek(int, int, __off_t, int);
289
__off_t	__sys_freebsd6_lseek(int, int, __off_t, int);
240
extern int	__sys_freebsd6_ftruncate(int, int, __off_t);
290
int	__sys_freebsd6_ftruncate(int, int, __off_t);
241
extern int	__sys_freebsd6_truncate(const char *, int, __off_t);
291
int	__sys_freebsd6_truncate(const char *, int, __off_t);
242
extern __ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t);
292
__ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t);
243
extern __ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t);
293
__ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t);
244
extern void *	__sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t);
294
void *	__sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t);
245
246
/* Without back-compat translation */
247
extern int	__sys_fcntl(int, int, ...);
248
295
296
struct aiocb;
297
struct fd_set;
298
struct iovec;
299
struct msghdr;
300
struct pollfd;
301
struct rusage;
302
struct sigaction;
303
struct sockaddr;
249
struct timespec;
304
struct timespec;
250
struct timeval;
305
struct timeval;
251
struct timezone;
306
struct timezone;
252
int	__sys_gettimeofday(struct timeval *, struct timezone *);
307
struct __siginfo;
253
int	__sys_clock_gettime(__clockid_t, struct timespec *ts);
308
struct __ucontext;
309
int		__sys_aio_suspend(const struct aiocb * const[], int,
310
		    const struct timespec *);
311
int		__sys_accept(int, struct sockaddr *, __socklen_t *);
312
int		__sys_accept4(int, struct sockaddr *, __socklen_t *, int);
313
int		__sys_clock_gettime(__clockid_t, struct timespec *ts);
314
int		__sys_close(int);
315
int		__sys_connect(int, const struct sockaddr *, __socklen_t);
316
int		__sys_fcntl(int, int, ...);
317
int		__sys_fsync(int);
318
int		__sys_ftruncate(int, __off_t);
319
int		__sys_gettimeofday(struct timeval *, struct timezone *);
320
__off_t		__sys_lseek(int, __off_t, int);
321
void	       *__sys_mmap(void *, __size_t, int, int, int, __off_t);
322
int		__sys_msync(void *, __size_t, int);
323
int		__sys_nanosleep(const struct timespec *, struct timespec *);
324
int		__sys_open(const char *, int, ...);
325
int		__sys_openat(int, const char *, int, ...);
326
int		__sys_pselect(int, struct fd_set *, struct fd_set *,
327
		    struct fd_set *, const struct timespec *,
328
		    const __sigset_t *);
329
int		__sys_poll(struct pollfd *, unsigned, int);
330
__ssize_t	__sys_pread(int, void *, __size_t, __off_t);
331
__ssize_t	__sys_pwrite(int, const void *, __size_t, __off_t);
332
__ssize_t	__sys_read(int, void *, __size_t);
333
__ssize_t	__sys_readv(int, const struct iovec *, int);
334
__ssize_t	__sys_recv(int, void *, __size_t, int);
335
__ssize_t	__sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
336
		    __socklen_t *);
337
__ssize_t	__sys_recvmsg(int, struct msghdr *, int);
338
int		__sys_select(int, struct fd_set *, struct fd_set *,
339
		    struct fd_set *, struct timeval *);
340
__ssize_t	__sys_sendmsg(int, const struct msghdr *, int);
341
__ssize_t	__sys_sendto(int, const void *, __size_t, int,
342
		    const struct sockaddr *, __socklen_t);
343
int		__sys_setcontext(const struct __ucontext *);
344
int		__sys_sigaction(int, const struct sigaction *,
345
		    struct sigaction *);
346
int		__sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
347
int		__sys_sigsuspend(const __sigset_t *);
348
int		__sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
349
		    const struct timespec *);
350
int		__sys_sigwait(const __sigset_t *, int *);
351
int		__sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
352
int		__sys_swapcontext(struct __ucontext *,
353
		    const struct __ucontext *);
354
int		__sys_truncate(const char *, __off_t);
355
__pid_t		__sys_wait4(__pid_t, int *, int, struct rusage *);
356
__ssize_t	__sys_write(int, const void *, __size_t);
357
__ssize_t	__sys_writev(int, const struct iovec *, int);
358
359
int		__libc_creat(const char *path, __mode_t mode);
360
int		__libc_pause(void);
361
int		__libc_raise(int);
362
int		__libc_sigwait(const __sigset_t * __restrict,
363
		    int * restrict sig);
364
int		__libc_system(const char *);
365
unsigned int	__libc_sleep(unsigned int);
366
int		__libc_tcdrain(int);
367
int		__libc_usleep(__useconds_t);
368
__pid_t		__libc_wait(int *);
369
__pid_t		__libc_wait3(int *, int, struct rusage *);
370
__pid_t		__libc_waitpid(__pid_t, int *, int);
371
int		__fcntl_compat(int fd, int cmd, ...);
254
372
255
/* execve() with PATH processing to implement posix_spawnp() */
373
/* execve() with PATH processing to implement posix_spawnp() */
256
int _execvpe(const char *, char * const *, char * const *);
374
int _execvpe(const char *, char * const *, char * const *);
(-)b/lib/libc/stdlib/Symbol.map (+1 lines)
Lines 118-121 FBSD_1.4 { Link Here
118
FBSDprivate_1.0 {
118
FBSDprivate_1.0 {
119
	__system;
119
	__system;
120
	_system;
120
	_system;
121
	__libc_system;
121
};
122
};
(-)b/lib/libc/stdlib/jemalloc/Symbol.map (+1 lines)
Lines 55-58 FBSDprivate_1.0 { Link Here
55
	_malloc_thread_cleanup;
55
	_malloc_thread_cleanup;
56
	_malloc_prefork;
56
	_malloc_prefork;
57
	_malloc_postfork;
57
	_malloc_postfork;
58
	_malloc_first_thread;
58
};
59
};
(-)b/lib/libc/stdlib/system.c (-3 / +12 lines)
Lines 46-53 __FBSDID("$FreeBSD$"); Link Here
46
#include "un-namespace.h"
46
#include "un-namespace.h"
47
#include "libc_private.h"
47
#include "libc_private.h"
48
48
49
#pragma weak system
49
int
50
int
50
__system(const char *command)
51
system(const char *command)
52
{
53
54
	return (((int (*)(const char *))
55
	    __libc_interposing[INTERPOS_system])(command));
56
}
57
58
int
59
__libc_system(const char *command)
51
{
60
{
52
	pid_t pid, savedpid;
61
	pid_t pid, savedpid;
53
	int pstat;
62
	int pstat;
Lines 95-99 __system(const char *command) Link Here
95
	return(pid == -1 ? -1 : pstat);
104
	return(pid == -1 ? -1 : pstat);
96
}
105
}
97
106
98
__weak_reference(__system, system);
107
__weak_reference(__libc_system, __system);
99
__weak_reference(__system, _system);
108
__weak_reference(__libc_system, _system);
(-)b/lib/libc/sys/Makefile.inc (-7 / +50 lines)
Lines 20-36 NOASM+= clock_gettime.o gettimeofday.o Link Here
20
PSEUDO+= _clock_gettime.o _gettimeofday.o
20
PSEUDO+= _clock_gettime.o _gettimeofday.o
21
21
22
# Sources common to both syscall interfaces:
22
# Sources common to both syscall interfaces:
23
SRCS+=	stack_protector.c stack_protector_compat.c __error.c
23
SRCS+=	\
24
	stack_protector.c \
25
	stack_protector_compat.c \
26
	__error.c \
27
	interposing_table.c
28
24
.if ${MK_SYSCALL_COMPAT} != "no"
29
.if ${MK_SYSCALL_COMPAT} != "no"
25
SYSCALL_COMPAT_SRCS=	fcntl.c ftruncate.c lseek.c mmap.c pread.c \
30
SYSCALL_COMPAT_SRCS= \
26
	pwrite.c truncate.c
31
	ftruncate.c \
32
	lseek.c \
33
	mmap.c \
34
	pread.c \
35
	pwrite.c \
36
	truncate.c
27
SRCS+=	${SYSCALL_COMPAT_SRCS}
37
SRCS+=	${SYSCALL_COMPAT_SRCS}
28
NOASM+=	${SYSCALL_COMPAT_SRCS:S/.c/.o/}
38
NOASM+=	${SYSCALL_COMPAT_SRCS:S/.c/.o/}
29
PSEUDO+= _fcntl.o
30
.endif
39
.endif
31
SRCS+= sigwait.c
40
32
NOASM+= sigwait.o
41
INTERPOSED = \
33
PSEUDO+= _sigwait.o
42
	accept \
43
	accept4 \
44
	aio_suspend \
45
	close \
46
	connect \
47
	fcntl \
48
	fsync \
49
	msync \
50
	nanosleep \
51
	open \
52
	openat \
53
	poll \
54
	pselect \
55
	read \
56
	readv \
57
	recvfrom \
58
	recvmsg \
59
	select \
60
	sendmsg \
61
	sendto \
62
	setcontext \
63
	sigaction \
64
	sigprocmask \
65
	sigsuspend \
66
	sigtimedwait \
67
	sigwait \
68
	sigwaitinfo \
69
	swapcontext \
70
	wait4 \
71
	write \
72
	writev
73
74
SRCS+=	${INTERPOSED:S/$/.c/}
75
NOASM+=	${INTERPOSED:S/$/.o/}
76
PSEUDO+=	${INTERPOSED:C/^.*$/_&.o/}
34
77
35
# Add machine dependent asm sources:
78
# Add machine dependent asm sources:
36
SRCS+=${MDASM}
79
SRCS+=${MDASM}
(-)b/lib/libc/sys/Symbol.map (+4 lines)
Lines 1046-1054 FBSDprivate_1.0 { Link Here
1046
	__sys_wait6;
1046
	__sys_wait6;
1047
	_write;
1047
	_write;
1048
	__sys_write;
1048
	__sys_write;
1049
	__write_p;
1049
	_writev;
1050
	_writev;
1050
	__sys_writev;
1051
	__sys_writev;
1051
	__error_unthreaded;
1052
	__error_unthreaded;
1053
	__error_selector;
1052
	nlm_syscall;
1054
	nlm_syscall;
1053
	gssd_syscall;
1055
	gssd_syscall;
1056
	__libc_interposing_slot;
1057
	__libc_sigwait;
1054
};
1058
};
(-)b/lib/libc/sys/__error.c (-6 / +9 lines)
Lines 32-45 __FBSDID("$FreeBSD$"); Link Here
32
32
33
extern int errno;
33
extern int errno;
34
34
35
/*
36
 * Declare a weak reference in case the application is not linked
37
 * with libpthread.
38
 */
39
__weak_reference(__error_unthreaded, __error);
40
41
int *
35
int *
42
__error_unthreaded(void)
36
__error_unthreaded(void)
43
{
37
{
44
	return(&errno);
38
	return(&errno);
45
}
39
}
40
41
int *(*__error_selector)(void) = __error_unthreaded;
42
43
int *
44
__error(void)
45
{
46
47
	return (__error_selector());
48
}
(-)b/lib/libc/sys/accept.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_accept, __accept);
42
43
#pragma weak accept
44
int
45
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
46
{
47
48
	return (((int (*)(int, struct sockaddr *, socklen_t *))
49
	    __libc_interposing[INTERPOS_accept])(s, addr, addrlen));
50
}
(-)b/lib/libc/sys/accept4.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_accept4, __accept4);
42
43
#pragma weak accept4
44
int
45
accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
46
{
47
48
	return (((int (*)(int, struct sockaddr *, socklen_t *, int))
49
	    __libc_interposing[INTERPOS_accept4])(s, addr, addrlen, flags));
50
}
(-)b/lib/libc/sys/aio_suspend.c (+51 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/aio.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_aio_suspend, __aio_suspend);
41
42
#pragma weak aio_suspend
43
int
44
aio_suspend(const struct aiocb * const iocbs[], int niocb,
45
    const struct timespec *timeout)
46
{
47
48
	return (((int (*)(const struct aiocb * const[], int,
49
	    const struct timespec *))
50
	    __libc_interposing[INTERPOS_aio_suspend])(iocbs, niocb, timeout));
51
}
(-)b/lib/libc/sys/close.c (+48 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/fcntl.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_close, __close);
41
42
#pragma weak close
43
int
44
close(int fd)
45
{
46
47
	return (((int (*)(int))__libc_interposing[INTERPOS_close])(fd));
48
}
(-)b/lib/libc/sys/connect.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_connect, __connect);
42
43
#pragma weak connect
44
int
45
connect(int s, const struct sockaddr *addr, socklen_t addrlen)
46
{
47
48
	return (((int (*)(int, const struct sockaddr *, socklen_t))
49
	    __libc_interposing[INTERPOS_connect])(s, addr, addrlen));
50
}
(-)b/lib/libc/sys/fcntl.c (-1 / +21 lines)
Lines 34-40 __FBSDID("$FreeBSD$"); Link Here
34
#include <sys/syscall.h>
34
#include <sys/syscall.h>
35
#include "libc_private.h"
35
#include "libc_private.h"
36
36
37
__weak_reference(__fcntl_compat, fcntl);
37
#pragma weak fcntl
38
int
39
fcntl(int fd, int cmd, ...)
40
{
41
	va_list args;
42
	long arg;
43
44
	va_start(args, cmd);
45
	arg = va_arg(args, long);
46
	va_end(args);
47
48
	return (((int (*)(int, int, ...))
49
	    __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg));
50
}
51
52
#ifdef SYSCALL_COMPAT
53
__weak_reference(__fcntl_compat, __fcntl);
38
54
39
int
55
int
40
__fcntl_compat(int fd, int cmd, ...)
56
__fcntl_compat(int fd, int cmd, ...)
Lines 87-89 __fcntl_compat(int fd, int cmd, ...) Link Here
87
		return (__sys_fcntl(fd, cmd, arg));
103
		return (__sys_fcntl(fd, cmd, arg));
88
	}
104
	}
89
}
105
}
106
#else
107
__weak_reference(__sys_fcntl, __fcntl_compat);
108
__weak_reference(__sys_fcntl, __fcntl);
109
#endif
(-)b/lib/libc/sys/fsync.c (+47 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/fcntl.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_fsync, __fsync);
41
42
int
43
fsync(int fd)
44
{
45
46
	return (((int (*)(int))__libc_interposing[INTERPOS_fsync])(fd));
47
}
(-)b/lib/libc/sys/interposing_table.c (+92 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include "libc_private.h"
38
39
#define	SLOT(a, b) \
40
	[INTERPOS_##a] = (interpos_func_t)b
41
interpos_func_t __libc_interposing[INTERPOS_MAX] = {
42
	SLOT(accept, __sys_accept),
43
	SLOT(accept4, __sys_accept4),
44
	SLOT(aio_suspend, __sys_aio_suspend),
45
	SLOT(close, __sys_close),
46
	SLOT(connect, __sys_connect),
47
	SLOT(creat, __libc_creat),
48
	SLOT(fcntl, __fcntl_compat),
49
	SLOT(fsync, __sys_fsync),
50
	SLOT(msync, __sys_msync),
51
	SLOT(nanosleep, __sys_nanosleep),
52
	SLOT(open, __sys_open),
53
	SLOT(openat, __sys_openat),
54
	SLOT(poll, __sys_poll),
55
	SLOT(pselect, __sys_pselect),
56
	SLOT(raise, __libc_raise),
57
	SLOT(read, __sys_read),
58
	SLOT(readv, __sys_readv),
59
	SLOT(recvfrom, __sys_recvfrom),
60
	SLOT(recvmsg, __sys_recvmsg),
61
	SLOT(select, __sys_select),
62
	SLOT(sendmsg, __sys_sendmsg),
63
	SLOT(sendto, __sys_sendto),
64
	SLOT(setcontext, __sys_setcontext),
65
	SLOT(sigaction, __sys_sigaction),
66
	SLOT(sigprocmask, __sys_sigprocmask),
67
	SLOT(sigsuspend, __sys_sigsuspend),
68
	SLOT(sigwait, __libc_sigwait),
69
	SLOT(sigtimedwait, __sys_sigtimedwait),
70
	SLOT(sigwaitinfo, __sys_sigwaitinfo),
71
	SLOT(swapcontext, __sys_swapcontext),
72
	SLOT(system, __libc_system),
73
	SLOT(sleep, __libc_sleep),
74
	SLOT(tcdrain, __libc_tcdrain),
75
	SLOT(usleep, __libc_usleep),
76
	SLOT(pause, __libc_pause),
77
	SLOT(wait, __libc_wait),
78
	SLOT(wait3, __libc_wait3),
79
	SLOT(wait4, __sys_wait4),
80
	SLOT(waitpid, __libc_waitpid),
81
	SLOT(write, __sys_write),
82
	SLOT(writev, __sys_writev),
83
	SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub),
84
};
85
#undef SLOT
86
87
interpos_func_t *
88
__libc_interposing_slot(int interposno)
89
{
90
91
	return (&__libc_interposing[interposno]);
92
}
(-)b/lib/libc/sys/msync.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/fcntl.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_msync, __msync);
41
42
#pragma weak msync
43
int
44
msync(void *addr, size_t len, int flags)
45
{
46
47
	return (((int (*)(void *, size_t, int))
48
	    __libc_interposing[INTERPOS_msync])(addr, len, flags));
49
}
(-)b/lib/libc/sys/nanosleep.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <time.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_nanosleep, __nanosleep);
41
42
#pragma weak nanosleep
43
int
44
nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
45
{
46
47
	return (((int (*)(const struct timespec *, struct timespec *))
48
	    __libc_interposing[INTERPOS_nanosleep])(rqtp, rmtp));
49
}
(-)b/lib/libc/sys/open.c (+59 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/fcntl.h>
38
#include <stdarg.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_open, __open);
42
43
#pragma weak open
44
int
45
open(const char *path, int flags, ...)
46
{
47
	va_list ap;
48
	int mode;
49
50
	if ((flags & O_CREAT) != 0) {
51
		va_start(ap, flags);
52
		mode = va_arg(ap, int);
53
		va_end(ap);
54
	} else {
55
		mode = 0;
56
	}
57
	return (((int (*)(const char *, int, ...))
58
	    __libc_interposing[INTERPOS_open])(path, flags, mode));
59
}
(-)b/lib/libc/sys/openat.c (+59 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/fcntl.h>
38
#include <stdarg.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_openat, __openat);
42
43
#pragma weak openat
44
int
45
openat(int fd, const char *path, int flags, ...)
46
{
47
	va_list ap;
48
	int mode;
49
50
	if ((flags & O_CREAT) != 0) {
51
		va_start(ap, flags);
52
		mode = va_arg(ap, int);
53
		va_end(ap);
54
	} else {
55
		mode = 0;
56
	}
57
	return (((int (*)(int, const char *, int, ...))
58
	    __libc_interposing[INTERPOS_openat])(fd, path, flags, mode));
59
}
(-)b/lib/libc/sys/poll.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/poll.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_poll, __poll);
41
42
#pragma weak poll
43
int
44
poll(struct pollfd pfd[], nfds_t nfds, int timeout)
45
{
46
47
	return (((int (*)(struct pollfd *, nfds_t, int))
48
	    __libc_interposing[INTERPOS_poll])(pfd, nfds, timeout));
49
}
(-)b/lib/libc/sys/pselect.c (+51 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/select.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_pselect, __pselect);
41
42
#pragma weak pselect
43
int
44
pselect(int n, fd_set *rs, fd_set *ws, fd_set *es, const struct timespec *t,
45
    const sigset_t *s)
46
{
47
48
	return (((int (*)(int, fd_set *, fd_set *, fd_set *,
49
	    const struct timespec *, const sigset_t *))
50
	    __libc_interposing[INTERPOS_pselect])(n, rs, ws, es, t, s));
51
}
(-)b/lib/libc/sys/read.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <unistd.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_read, __read);
42
43
#pragma weak read
44
ssize_t
45
read(int fd, void *buf, size_t nbytes)
46
{
47
48
	return (((ssize_t (*)(int, void *, size_t))
49
	    __libc_interposing[INTERPOS_read])(fd, buf, nbytes));
50
}
(-)b/lib/libc/sys/readv.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <unistd.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_readv, __readv);
42
43
#pragma weak readv
44
ssize_t
45
readv(int fd, const struct iovec *iov, int iovcnt)
46
{
47
48
	return (((ssize_t (*)(int, const struct iovec *, int))
49
	    __libc_interposing[INTERPOS_readv])(fd, iov, iovcnt));
50
}
(-)b/lib/libc/sys/recvfrom.c (+53 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_recvfrom, __recvfrom);
42
43
#pragma weak recvfrom
44
ssize_t
45
recvfrom(int s, void *buf, size_t len, int flags,
46
    struct sockaddr * __restrict from, socklen_t * __restrict fromlen)
47
{
48
49
	return (((ssize_t (*)(int, void *, size_t, int,
50
	    struct sockaddr *, socklen_t *))
51
	    __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
52
	   from, fromlen));
53
}
(-)b/lib/libc/sys/recvmsg.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_recvmsg, __recvmsg);
42
43
#pragma weak recvmsg
44
ssize_t
45
recvmsg(int s, struct msghdr *msg, int flags)
46
{
47
48
	return (((int (*)(int, struct msghdr *, int))
49
	    __libc_interposing[INTERPOS_recvmsg])(s, msg, flags));
50
}
(-)b/lib/libc/sys/select.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/select.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_select, __select);
41
42
#pragma weak select
43
int
44
select(int n, fd_set *rs, fd_set *ws, fd_set *es, struct timeval *t)
45
{
46
47
	return (((int (*)(int, fd_set *, fd_set *, fd_set *, struct timeval *))
48
	    __libc_interposing[INTERPOS_select])(n, rs, ws, es, t));
49
}
(-)b/lib/libc/sys/sendmsg.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_sendmsg, __sendmsg);
42
43
#pragma weak sendmsg
44
ssize_t
45
sendmsg(int s, const struct msghdr *msg, int flags)
46
{
47
48
	return (((int (*)(int, const struct msghdr *, int))
49
	    __libc_interposing[INTERPOS_sendmsg])(s, msg, flags));
50
}
(-)b/lib/libc/sys/sendto.c (+53 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <sys/socket.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_sendto, __sendto);
42
43
#pragma weak sendto
44
ssize_t
45
sendto(int s, const void *msg, size_t len, int flags,
46
    const struct sockaddr *to, socklen_t tolen)
47
{
48
49
	return (((ssize_t (*)(int, const void *, size_t, int,
50
	    const struct sockaddr *, socklen_t))
51
	    __libc_interposing[INTERPOS_sendto])(s, msg, len, flags,
52
	    to, tolen));
53
}
(-)b/lib/libc/sys/setcontext.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <ucontext.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_setcontext, __setcontext);
41
42
#pragma weak setcontext
43
int
44
setcontext(const ucontext_t *uc)
45
{
46
47
	return (((int (*)(const ucontext_t *))
48
	    __libc_interposing[INTERPOS_setcontext])(uc));
49
}
(-)b/lib/libc/sys/sigaction.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <signal.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_sigaction, __sigaction);
41
42
#pragma weak sigaction
43
int
44
sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
45
{
46
47
	return (((int (*)(int, const struct sigaction *, struct sigaction *))
48
	    __libc_interposing[INTERPOS_sigaction])(sig, act, oact));
49
}
(-)b/lib/libc/sys/sigprocmask.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <signal.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_sigprocmask, __sigprocmask);
41
42
#pragma weak sigprocmask
43
int
44
sigprocmask(int how, const sigset_t *set, sigset_t *oset)
45
{
46
47
	return (((int (*)(int, const sigset_t *, sigset_t *))
48
	    __libc_interposing[INTERPOS_sigprocmask])(how, set, oset));
49
}
(-)b/lib/libc/sys/sigsuspend.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <signal.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_sigsuspend, __sigsuspend);
41
42
#pragma weak sigsuspend
43
int
44
sigsuspend(const sigset_t *set)
45
{
46
47
	return (((int (*)(const sigset_t *))
48
	    __libc_interposing[INTERPOS_sigsuspend])(set));
49
}
(-)b/lib/libc/sys/sigtimedwait.c (+51 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <signal.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_sigtimedwait, __sigtimedwait);
41
42
#pragma weak sigtimedwait
43
int
44
sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info,
45
    const struct timespec * __restrict t)
46
{
47
48
	return (((int (*)(const sigset_t *, siginfo_t *,
49
	    const struct timespec *))
50
	    __libc_interposing[INTERPOS_sigtimedwait])(set, info, t));
51
}
(-)b/lib/libc/sys/sigwait.c (-3 / +11 lines)
Lines 28-40 __FBSDID("$FreeBSD$"); Link Here
28
28
29
#include <errno.h>
29
#include <errno.h>
30
#include <signal.h>
30
#include <signal.h>
31
#include "libc_private.h"
31
32
32
int __sys_sigwait(const sigset_t * restrict, int * restrict);
33
__weak_reference(__libc_sigwait, __sigwait);
33
34
34
__weak_reference(__sigwait, sigwait);
35
#pragma weak sigwait
36
int
37
sigwait(const sigset_t *set, int *sig)
38
{
39
40
	return (((int (*)(const sigset_t *, int *))
41
	    __libc_interposing[INTERPOS_sigwait])(set, sig));
42
}
35
43
36
int
44
int
37
__sigwait(const sigset_t * restrict set, int * restrict sig)
45
__libc_sigwait(const sigset_t *set, int *sig)
38
{
46
{
39
	int ret;
47
	int ret;
40
48
(-)b/lib/libc/sys/sigwaitinfo.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <signal.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_sigwaitinfo, __sigwaitinfo);
41
42
#pragma weak sigwaitinfo
43
int
44
sigwaitinfo(const sigset_t * __restrict set, siginfo_t * __restrict info)
45
{
46
47
	return (((int (*)(const sigset_t *, siginfo_t *))
48
	    __libc_interposing[INTERPOS_sigwaitinfo])(set, info));
49
}
(-)b/lib/libc/sys/swapcontext.c (+46 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2001 Daniel M. Eischen <deischen@freebsd.org>
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Neither the name of the author nor the names of its contributors
11
 *    may be used to endorse or promote products derived from this software
12
 *    without specific prior written permission.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 */
26
27
#include <sys/cdefs.h>
28
__FBSDID("$FreeBSD$");
29
30
#include <sys/param.h>
31
#include <sys/signal.h>
32
#include <sys/ucontext.h>
33
#include <errno.h>
34
#include <stddef.h>
35
#include "libc_private.h"
36
37
__weak_reference(__sys_swapcontext, __swapcontext);
38
39
#pragma weak swapcontext
40
int
41
swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
42
{
43
44
	return (((int (*)(ucontext_t *, const ucontext_t *))
45
	    __libc_interposing[INTERPOS_swapcontext])(oucp, ucp));
46
}
(-)b/lib/libc/sys/wait4.c (+49 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/wait.h>
38
#include "libc_private.h"
39
40
__weak_reference(__sys_wait4, __wait4);
41
42
#pragma weak wait4
43
pid_t
44
wait4(pid_t pid, int *status, int options, struct rusage *ru)
45
{
46
47
	return (((pid_t (*)(pid_t, int *, int, struct rusage *))
48
	    __libc_interposing[INTERPOS_wait4])(pid, status, options, ru));
49
}
(-)b/lib/libc/sys/write.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <unistd.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_write, __write);
42
43
#pragma weak write
44
ssize_t
45
write(int fd, const void *buf, size_t nbytes)
46
{
47
48
	return (((ssize_t (*)(int, const void *, size_t))
49
	    __libc_interposing[INTERPOS_write])(fd, buf, nbytes));
50
}
(-)b/lib/libc/sys/writev.c (+50 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
3
 * All rights reserved.
4
 *
5
 * Portions of this software were developed by Konstantin Belousov
6
 * under sponsorship from the FreeBSD Foundation.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice(s), this list of conditions and the following disclaimer as
13
 *    the first lines of this file unmodified other than the possible
14
 *    addition of one or more copyright notices.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice(s), this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
21
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#include <sys/cdefs.h>
34
__FBSDID("$FreeBSD$");
35
36
#include <sys/types.h>
37
#include <sys/syscall.h>
38
#include <unistd.h>
39
#include "libc_private.h"
40
41
__weak_reference(__sys_writev, __writev);
42
43
#pragma weak writev
44
ssize_t
45
writev(int fd, const struct iovec *iov, int iovcnt)
46
{
47
48
	return (((ssize_t (*)(int, const struct iovec *, int))
49
	    __libc_interposing[INTERPOS_writev])(fd, iov, iovcnt));
50
}
(-)b/lib/libthr/Makefile (-1 lines)
Lines 40-46 MAN= libthr.3 Link Here
40
40
41
# enable extra internal consistancy checks
41
# enable extra internal consistancy checks
42
CFLAGS+=-D_PTHREADS_INVARIANTS
42
CFLAGS+=-D_PTHREADS_INVARIANTS
43
#CFLAGS+=-g
44
43
45
PRECIOUSLIB=
44
PRECIOUSLIB=
46
45
(-)b/lib/libthr/pthread.map (-96 lines)
Lines 6-27 Link Here
6
 * Use the same naming scheme as libc.
6
 * Use the same naming scheme as libc.
7
 */
7
 */
8
FBSD_1.0 {
8
FBSD_1.0 {
9
	__error;
10
	accept;
11
	aio_suspend;
12
	close;
13
	connect;
14
	creat;
15
	execve;
16
	fcntl;
17
	fork;
18
	fsync;
19
	msync;
20
	nanosleep;
21
	open;
22
	pause;
23
	poll;
24
	pselect;
25
	pthread_atfork;
9
	pthread_atfork;
26
	pthread_barrier_destroy;
10
	pthread_barrier_destroy;
27
	pthread_barrier_init;
11
	pthread_barrier_init;
Lines 139-168 FBSD_1.0 { Link Here
139
	pthread_testcancel;
123
	pthread_testcancel;
140
	pthread_timedjoin_np;
124
	pthread_timedjoin_np;
141
	pthread_yield;
125
	pthread_yield;
142
	raise;
143
	read;
144
	readv;
145
	recvfrom;
146
	recvmsg;
147
	select;
148
	sendmsg;
149
	sendto;
150
	sigaction;
151
	sigprocmask;
152
	sigsuspend;
153
	sigwait;
154
	sigwaitinfo;
155
	sigtimedwait;
156
	sleep;
157
	system;
158
	tcdrain;
159
	usleep;
160
	wait;
161
	wait3;
162
	wait4;
163
	waitpid;
164
	write;
165
	writev;
166
};
126
};
167
127
168
/*
128
/*
Lines 170-197 FBSD_1.0 { Link Here
170
 * These are not part of our application ABI.
130
 * These are not part of our application ABI.
171
 */
131
 */
172
FBSDprivate_1.0 {
132
FBSDprivate_1.0 {
173
	___creat;
174
	___pause;
175
	___pselect;
176
	___sigwait;
177
	___sleep;
178
	___system;
179
	___tcdrain;
180
	___usleep;
181
	___wait;
182
	___waitpid;
183
	__accept;
184
	__accept4;
185
	__aio_suspend;
186
	__close;
187
	__connect;
188
	__fcntl;
189
	__fsync;
190
	__msync;
191
	__nanosleep;
192
	__open;
193
	__openat;
194
	__poll;
195
	__pthread_cond_timedwait;
133
	__pthread_cond_timedwait;
196
	__pthread_cond_wait;
134
	__pthread_cond_wait;
197
	__pthread_cxa_finalize;
135
	__pthread_cxa_finalize;
Lines 199-219 FBSDprivate_1.0 { Link Here
199
	__pthread_mutex_lock;
137
	__pthread_mutex_lock;
200
	__pthread_mutex_timedlock;
138
	__pthread_mutex_timedlock;
201
	__pthread_mutex_trylock;
139
	__pthread_mutex_trylock;
202
	__read;
203
	__readv;
204
	__recvfrom;
205
	__recvmsg;
206
	__select;
207
	__sendmsg;
208
	__sendto;
209
	__sigsuspend;
210
	__sigtimedwait;
211
	__sigwaitinfo;
212
	__wait3;
213
	__wait4;
214
	__write;
215
	__writev;
216
	_fork;
217
	_pthread_atfork;
140
	_pthread_atfork;
218
	_pthread_barrier_destroy;
141
	_pthread_barrier_destroy;
219
	_pthread_barrier_init;
142
	_pthread_barrier_init;
Lines 345-362 FBSDprivate_1.0 { Link Here
345
	_pthread_testcancel;
268
	_pthread_testcancel;
346
	_pthread_timedjoin_np;
269
	_pthread_timedjoin_np;
347
	_pthread_yield;
270
	_pthread_yield;
348
	_raise;
349
	_setcontext;
350
	_sigaction;
351
	_sigprocmask;
352
	_sigsuspend;
353
	_sigtimedwait;
354
	_sigwait;
355
	_sigwaitinfo;
356
	_spinlock;
357
	_spinlock_debug;
358
	_spinunlock;
359
	_swapcontext;
360
271
361
	/* Debugger needs these. */
272
	/* Debugger needs these. */
362
	_libthr_debug;
273
	_libthr_debug;
Lines 404-415 FBSD_1.1 { Link Here
404
};
315
};
405
316
406
FBSD_1.2 {
317
FBSD_1.2 {
407
	openat;
408
	pthread_getthreadid_np;
318
	pthread_getthreadid_np;
409
	setcontext;
410
	swapcontext;
411
};
412
413
FBSD_1.3 {
414
	accept4;
415
};
319
};
(-)b/lib/libthr/sys/thr_error.c (-1 / +2 lines)
Lines 42-49 Link Here
42
#undef errno
42
#undef errno
43
extern	int	errno;
43
extern	int	errno;
44
44
45
__weak_reference(__error_threaded, __error);
45
int *
46
int *
46
__error(void)
47
__error_threaded(void)
47
{
48
{
48
	struct pthread *curthread;
49
	struct pthread *curthread;
49
50
(-)b/lib/libthr/thread/thr_create.c (-2 / +6 lines)
Lines 40-45 Link Here
40
#include <pthread_np.h>
40
#include <pthread_np.h>
41
#include "un-namespace.h"
41
#include "un-namespace.h"
42
42
43
#include "libc_private.h"
43
#include "thr_private.h"
44
#include "thr_private.h"
44
45
45
static int  create_stack(struct pthread_attr *pattr);
46
static int  create_stack(struct pthread_attr *pattr);
Lines 66-73 _pthread_create(pthread_t * thread, const pthread_attr_t * attr, Link Here
66
	/*
67
	/*
67
	 * Tell libc and others now they need lock to protect their data.
68
	 * Tell libc and others now they need lock to protect their data.
68
	 */
69
	 */
69
	if (_thr_isthreaded() == 0 && _thr_setthreaded(1))
70
	if (_thr_isthreaded() == 0) {
70
		return (EAGAIN);
71
		_malloc_first_thread();
72
		if (_thr_setthreaded(1))
73
			return (EAGAIN);
74
	}
71
75
72
	curthread = _get_curthread();
76
	curthread = _get_curthread();
73
	if ((new_thread = _thr_alloc(curthread)) == NULL)
77
	if ((new_thread = _thr_alloc(curthread)) == NULL)
(-)b/lib/libthr/thread/thr_init.c (-2 / +8 lines)
Lines 37-42 Link Here
37
#include <sys/types.h>
37
#include <sys/types.h>
38
#include <sys/signalvar.h>
38
#include <sys/signalvar.h>
39
#include <sys/ioctl.h>
39
#include <sys/ioctl.h>
40
#include <sys/link_elf.h>
40
#include <sys/resource.h>
41
#include <sys/resource.h>
41
#include <sys/sysctl.h>
42
#include <sys/sysctl.h>
42
#include <sys/ttycom.h>
43
#include <sys/ttycom.h>
Lines 302-308 _thread_init_hack(void) Link Here
302
void
303
void
303
_libpthread_init(struct pthread *curthread)
304
_libpthread_init(struct pthread *curthread)
304
{
305
{
305
	int fd, first = 0;
306
	int fd, first, dlopened;
306
307
307
	/* Check if this function has already been called: */
308
	/* Check if this function has already been called: */
308
	if ((_thr_initial != NULL) && (curthread == NULL))
309
	if ((_thr_initial != NULL) && (curthread == NULL))
Lines 316-321 _libpthread_init(struct pthread *curthread) Link Here
316
	if (sizeof(jmp_table) != (sizeof(pthread_func_t) * PJT_MAX * 2))
317
	if (sizeof(jmp_table) != (sizeof(pthread_func_t) * PJT_MAX * 2))
317
		PANIC("Thread jump table not properly initialized");
318
		PANIC("Thread jump table not properly initialized");
318
	memcpy(__thr_jtable, jmp_table, sizeof(jmp_table));
319
	memcpy(__thr_jtable, jmp_table, sizeof(jmp_table));
320
	__thr_interpose_libc();
319
321
320
	/*
322
	/*
321
	 * Check for the special case of this process running as
323
	 * Check for the special case of this process running as
Lines 349-355 _libpthread_init(struct pthread *curthread) Link Here
349
		if (curthread == NULL)
351
		if (curthread == NULL)
350
			PANIC("Can't allocate initial thread");
352
			PANIC("Can't allocate initial thread");
351
		init_main_thread(curthread);
353
		init_main_thread(curthread);
354
	} else {
355
		first = 0;
352
	}
356
	}
357
		
353
	/*
358
	/*
354
	 * Add the thread to the thread list queue.
359
	 * Add the thread to the thread list queue.
355
	 */
360
	 */
Lines 361-367 _libpthread_init(struct pthread *curthread) Link Here
361
366
362
	if (first) {
367
	if (first) {
363
		_thr_initial = curthread;
368
		_thr_initial = curthread;
364
		_thr_signal_init();
369
		dlopened = _rtld_is_dlopened(&_thread_autoinit_dummy_decl) != 0;
370
		_thr_signal_init(dlopened);
365
		if (_thread_event_mask & TD_CREATE)
371
		if (_thread_event_mask & TD_CREATE)
366
			_thr_report_creation(curthread, curthread);
372
			_thr_report_creation(curthread, curthread);
367
		/*
373
		/*
(-)b/lib/libthr/thread/thr_printf.c (+1 lines)
Lines 31-36 Link Here
31
#include <unistd.h>
31
#include <unistd.h>
32
#include <pthread.h>
32
#include <pthread.h>
33
33
34
#include "libc_private.h"
34
#include "thr_private.h"
35
#include "thr_private.h"
35
36
36
static void	pchar(int fd, char c);
37
static void	pchar(int fd, char c);
(-)b/lib/libthr/thread/thr_private.h (-2 / +19 lines)
Lines 763-769 void _thr_cancel_leave(struct pthread *, int) __hidden; Link Here
763
void	_thr_testcancel(struct pthread *) __hidden;
763
void	_thr_testcancel(struct pthread *) __hidden;
764
void	_thr_signal_block(struct pthread *) __hidden;
764
void	_thr_signal_block(struct pthread *) __hidden;
765
void	_thr_signal_unblock(struct pthread *) __hidden;
765
void	_thr_signal_unblock(struct pthread *) __hidden;
766
void	_thr_signal_init(void) __hidden;
766
void	_thr_signal_init(int) __hidden;
767
void	_thr_signal_deinit(void) __hidden;
767
void	_thr_signal_deinit(void) __hidden;
768
int	_thr_send_sig(struct pthread *, int sig) __hidden;
768
int	_thr_send_sig(struct pthread *, int sig) __hidden;
769
void	_thr_list_init(void) __hidden;
769
void	_thr_list_init(void) __hidden;
Lines 839-845 int __sys_close(int); Link Here
839
int	__sys_fork(void);
839
int	__sys_fork(void);
840
pid_t	__sys_getpid(void);
840
pid_t	__sys_getpid(void);
841
ssize_t __sys_read(int, void *, size_t);
841
ssize_t __sys_read(int, void *, size_t);
842
ssize_t __sys_write(int, const void *, size_t);
843
void	__sys_exit(int);
842
void	__sys_exit(int);
844
#endif
843
#endif
845
844
Lines 906-917 int _sleepq_remove(struct sleepqueue *, struct pthread *) __hidden; Link Here
906
void	_sleepq_drop(struct sleepqueue *,
905
void	_sleepq_drop(struct sleepqueue *,
907
		void (*cb)(struct pthread *, void *arg), void *) __hidden;
906
		void (*cb)(struct pthread *, void *arg), void *) __hidden;
908
907
908
int	_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
909
	    void *(calloc_cb)(size_t, size_t));
910
909
struct dl_phdr_info;
911
struct dl_phdr_info;
910
void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
912
void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
911
void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
913
void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
912
void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
914
void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
913
void _thr_stack_fix_protection(struct pthread *thrd);
915
void _thr_stack_fix_protection(struct pthread *thrd);
914
916
917
int *__error_threaded(void);
918
void __thr_interpose_libc(void) __hidden;
919
int __thr_pause(void) __hidden;
920
int __thr_raise(int sig);
921
int __thr_setcontext(const ucontext_t *ucp);
922
int __thr_sigaction(int sig, const struct sigaction *act,
923
    struct sigaction *oact) __hidden;
924
int __thr_sigprocmask(int how, const sigset_t *set, sigset_t *oset);
925
int __thr_sigsuspend(const sigset_t * set);
926
int __thr_sigtimedwait(const sigset_t *set, siginfo_t *info,
927
    const struct timespec * timeout);
928
int __thr_sigwait(const sigset_t *set, int *sig);
929
int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info);
930
int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp);
931
915
__END_DECLS
932
__END_DECLS
916
933
917
#endif  /* !_THR_PRIVATE_H */
934
#endif  /* !_THR_PRIVATE_H */
(-)b/lib/libthr/thread/thr_sig.c (-75 / +95 lines)
Lines 38-43 Link Here
38
#include "un-namespace.h"
38
#include "un-namespace.h"
39
#include "libc_private.h"
39
#include "libc_private.h"
40
40
41
#include "libc_private.h"
41
#include "thr_private.h"
42
#include "thr_private.h"
42
43
43
/* #define DEBUG_SIGNAL */
44
/* #define DEBUG_SIGNAL */
Lines 54-77 struct usigaction { Link Here
54
55
55
static struct usigaction _thr_sigact[_SIG_MAXSIG];
56
static struct usigaction _thr_sigact[_SIG_MAXSIG];
56
57
58
static inline struct usigaction *
59
__libc_sigaction_slot(int signo)
60
{
61
62
	return (&_thr_sigact[signo - 1]);
63
}
64
57
static void thr_sighandler(int, siginfo_t *, void *);
65
static void thr_sighandler(int, siginfo_t *, void *);
58
static void handle_signal(struct sigaction *, int, siginfo_t *, ucontext_t *);
66
static void handle_signal(struct sigaction *, int, siginfo_t *, ucontext_t *);
59
static void check_deferred_signal(struct pthread *);
67
static void check_deferred_signal(struct pthread *);
60
static void check_suspend(struct pthread *);
68
static void check_suspend(struct pthread *);
61
static void check_cancel(struct pthread *curthread, ucontext_t *ucp);
69
static void check_cancel(struct pthread *curthread, ucontext_t *ucp);
62
70
63
int	___pause(void);
64
int	_raise(int);
65
int	__sigtimedwait(const sigset_t *set, siginfo_t *info,
66
	const struct timespec * timeout);
67
int	_sigtimedwait(const sigset_t *set, siginfo_t *info,
71
int	_sigtimedwait(const sigset_t *set, siginfo_t *info,
68
	const struct timespec * timeout);
72
	const struct timespec * timeout);
69
int	__sigwaitinfo(const sigset_t *set, siginfo_t *info);
70
int	_sigwaitinfo(const sigset_t *set, siginfo_t *info);
73
int	_sigwaitinfo(const sigset_t *set, siginfo_t *info);
71
int	___sigwait(const sigset_t *set, int *sig);
72
int	_sigwait(const sigset_t *set, int *sig);
74
int	_sigwait(const sigset_t *set, int *sig);
73
int	__sigsuspend(const sigset_t *sigmask);
74
int	_sigaction(int, const struct sigaction *, struct sigaction *);
75
int	_setcontext(const ucontext_t *);
75
int	_setcontext(const ucontext_t *);
76
int	_swapcontext(ucontext_t *, const ucontext_t *);
76
int	_swapcontext(ucontext_t *, const ucontext_t *);
77
77
Lines 143-150 sigcancel_handler(int sig __unused, Link Here
143
	errno = err;
143
	errno = err;
144
}
144
}
145
145
146
typedef void (*ohandler)(int sig, int code,
146
typedef void (*ohandler)(int sig, int code, struct sigcontext *scp,
147
	struct sigcontext *scp, char *addr, __sighandler_t *catcher);
147
    char *addr, __sighandler_t *catcher);
148
148
149
/*
149
/*
150
 * The signal handler wrapper is entered with all signal masked.
150
 * The signal handler wrapper is entered with all signal masked.
Lines 152-166 typedef void (*ohandler)(int sig, int code, Link Here
152
static void
152
static void
153
thr_sighandler(int sig, siginfo_t *info, void *_ucp)
153
thr_sighandler(int sig, siginfo_t *info, void *_ucp)
154
{
154
{
155
	struct pthread *curthread = _get_curthread();
155
	struct pthread *curthread;
156
	ucontext_t *ucp = _ucp;
156
	ucontext_t *ucp;
157
	struct sigaction act;
157
	struct sigaction act;
158
	struct usigaction *usa;
158
	int err;
159
	int err;
159
160
160
	err = errno;
161
	err = errno;
161
	_thr_rwl_rdlock(&_thr_sigact[sig-1].lock);
162
	curthread = _get_curthread();
162
	act = _thr_sigact[sig-1].sigact;
163
	ucp = _ucp;
163
	_thr_rwl_unlock(&_thr_sigact[sig-1].lock);
164
	usa = __libc_sigaction_slot(sig);
165
	_thr_rwl_rdlock(&usa->lock);
166
	act = usa->sigact;
167
	_thr_rwl_unlock(&usa->lock);
164
	errno = err;
168
	errno = err;
165
	curthread->deferred_run = 0;
169
	curthread->deferred_run = 0;
166
170
Lines 234-245 handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp) Link Here
234
	 * so after setjmps() returns once more, the user code may need to
238
	 * so after setjmps() returns once more, the user code may need to
235
	 * re-set cancel_enable flag by calling pthread_setcancelstate().
239
	 * re-set cancel_enable flag by calling pthread_setcancelstate().
236
	 */
240
	 */
237
	if ((actp->sa_flags & SA_SIGINFO) != 0)
241
	if ((actp->sa_flags & SA_SIGINFO) != 0) {
238
		(*(sigfunc))(sig, info, ucp);
242
		sigfunc(sig, info, ucp);
239
	else {
243
	} else {
240
		((ohandler)(*sigfunc))(
244
		((ohandler)sigfunc)(sig, info->si_code,
241
			sig, info->si_code, (struct sigcontext *)ucp,
245
		    (struct sigcontext *)ucp, info->si_addr,
242
			info->si_addr, (__sighandler_t *)sigfunc);
246
		    (__sighandler_t *)sigfunc);
243
	}
247
	}
244
	err = errno;
248
	err = errno;
245
249
Lines 395-403 check_suspend(struct pthread *curthread) Link Here
395
}
399
}
396
400
397
void
401
void
398
_thr_signal_init(void)
402
_thr_signal_init(int dlopened)
399
{
403
{
400
	struct sigaction act;
404
	struct sigaction act, nact, oact;
405
	struct usigaction *usa;
406
	sigset_t oldset;
407
	int sig, error;
408
409
	if (dlopened) {
410
		__sys_sigprocmask(SIG_SETMASK, &_thr_maskset, &oldset);
411
		for (sig = 1; sig <= _SIG_MAXSIG; sig++) {
412
			if (sig == SIGCANCEL)
413
				continue;
414
			error = __sys_sigaction(sig, NULL, &oact);
415
			if (error == -1 || oact.sa_handler == SIG_DFL ||
416
			    oact.sa_handler == SIG_IGN)
417
				continue;
418
			usa = __libc_sigaction_slot(sig);
419
			usa->sigact = oact;
420
			nact = oact;
421
			remove_thr_signals(&usa->sigact.sa_mask);
422
			nact.sa_flags &= ~SA_NODEFER;
423
			nact.sa_flags |= SA_SIGINFO;
424
			nact.sa_sigaction = thr_sighandler;
425
			nact.sa_mask = _thr_maskset;
426
			(void)__sys_sigaction(sig, &nact, NULL);
427
		}
428
		__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
429
	}
401
430
402
	/* Install SIGCANCEL handler. */
431
	/* Install SIGCANCEL handler. */
403
	SIGFILLSET(act.sa_mask);
432
	SIGFILLSET(act.sa_mask);
Lines 418-435 _thr_sigact_unload(struct dl_phdr_info *phdr_info) Link Here
418
	struct pthread *curthread = _get_curthread();
447
	struct pthread *curthread = _get_curthread();
419
	struct urwlock *rwlp;
448
	struct urwlock *rwlp;
420
	struct sigaction *actp;
449
	struct sigaction *actp;
450
	struct usigaction *usa;
421
	struct sigaction kact;
451
	struct sigaction kact;
422
	void (*handler)(int);
452
	void (*handler)(int);
423
	int sig;
453
	int sig;
424
 
454
 
425
	_thr_signal_block(curthread);
455
	_thr_signal_block(curthread);
426
	for (sig = 1; sig <= _SIG_MAXSIG; sig++) {
456
	for (sig = 1; sig <= _SIG_MAXSIG; sig++) {
427
		actp = &_thr_sigact[sig-1].sigact;
457
		usa = __libc_sigaction_slot(sig);
458
		actp = &usa->sigact;
428
retry:
459
retry:
429
		handler = actp->sa_handler;
460
		handler = actp->sa_handler;
430
		if (handler != SIG_DFL && handler != SIG_IGN &&
461
		if (handler != SIG_DFL && handler != SIG_IGN &&
431
		    __elf_phdr_match_addr(phdr_info, handler)) {
462
		    __elf_phdr_match_addr(phdr_info, handler)) {
432
			rwlp = &_thr_sigact[sig-1].lock;
463
			rwlp = &usa->lock;
433
			_thr_rwl_wrlock(rwlp);
464
			_thr_rwl_wrlock(rwlp);
434
			if (handler != actp->sa_handler) {
465
			if (handler != actp->sa_handler) {
435
				_thr_rwl_unlock(rwlp);
466
				_thr_rwl_unlock(rwlp);
Lines 455-461 _thr_signal_prefork(void) Link Here
455
	int i;
486
	int i;
456
487
457
	for (i = 1; i <= _SIG_MAXSIG; ++i)
488
	for (i = 1; i <= _SIG_MAXSIG; ++i)
458
		_thr_rwl_rdlock(&_thr_sigact[i-1].lock);
489
		_thr_rwl_rdlock(&__libc_sigaction_slot(i)->lock);
459
}
490
}
460
491
461
void
492
void
Lines 464-470 _thr_signal_postfork(void) Link Here
464
	int i;
495
	int i;
465
496
466
	for (i = 1; i <= _SIG_MAXSIG; ++i)
497
	for (i = 1; i <= _SIG_MAXSIG; ++i)
467
		_thr_rwl_unlock(&_thr_sigact[i-1].lock);
498
		_thr_rwl_unlock(&__libc_sigaction_slot(i)->lock);
468
}
499
}
469
500
470
void
501
void
Lines 472-479 _thr_signal_postfork_child(void) Link Here
472
{
503
{
473
	int i;
504
	int i;
474
505
475
	for (i = 1; i <= _SIG_MAXSIG; ++i)
506
	for (i = 1; i <= _SIG_MAXSIG; ++i) {
476
		bzero(&_thr_sigact[i-1].lock, sizeof(struct urwlock));
507
		bzero(&__libc_sigaction_slot(i) -> lock,
508
		    sizeof(struct urwlock));
509
	}
477
}
510
}
478
511
479
void
512
void
Lines 481-564 _thr_signal_deinit(void) Link Here
481
{
514
{
482
}
515
}
483
516
484
__weak_reference(___pause, pause);
485
486
int
517
int
487
___pause(void)
518
__thr_pause(void)
488
{
519
{
489
	sigset_t oset;
520
	sigset_t oset;
490
521
491
	if (_sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
522
	if (_sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
492
		return (-1);
523
		return (-1);
493
	return (__sigsuspend(&oset));
524
	return (__thr_sigsuspend(&oset));
494
}
525
}
495
526
496
__weak_reference(_raise, raise);
497
498
int
527
int
499
_raise(int sig)
528
__thr_raise(int sig)
500
{
529
{
501
	return _thr_send_sig(_get_curthread(), sig);
502
}
503
530
504
__weak_reference(_sigaction, sigaction);
531
	return (_thr_send_sig(_get_curthread(), sig));
532
}
505
533
506
int
534
int
507
_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
535
__thr_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
508
{
536
{
509
	struct sigaction newact, oldact, oldact2;
537
	struct sigaction newact, oldact, oldact2;
510
	sigset_t oldset;
538
	sigset_t oldset;
511
	int ret = 0, err = 0;
539
	struct usigaction *usa;
540
	int ret, err;
512
541
513
	if (!_SIG_VALID(sig) || sig == SIGCANCEL) {
542
	if (!_SIG_VALID(sig) || sig == SIGCANCEL) {
514
		errno = EINVAL;
543
		errno = EINVAL;
515
		return (-1);
544
		return (-1);
516
	}
545
	}
517
546
518
	if (act)
547
	ret = 0;
519
		newact = *act;
548
	err = 0;
549
	usa = __libc_sigaction_slot(sig);
520
550
521
	__sys_sigprocmask(SIG_SETMASK, &_thr_maskset, &oldset);
551
	__sys_sigprocmask(SIG_SETMASK, &_thr_maskset, &oldset);
522
	_thr_rwl_wrlock(&_thr_sigact[sig-1].lock);
552
	_thr_rwl_wrlock(&usa->lock);
523
 
553
 
524
	if (act != NULL) {
554
	if (act != NULL) {
525
		oldact2 = _thr_sigact[sig-1].sigact;
555
		oldact2 = usa->sigact;
556
		newact = *act;
526
557
527
 		/*
558
 		/*
528
		 * if a new sig handler is SIG_DFL or SIG_IGN,
559
		 * if a new sig handler is SIG_DFL or SIG_IGN,
529
		 * don't remove old handler from _thr_sigact[],
560
		 * don't remove old handler from __libc_sigact[],
530
		 * so deferred signals still can use the handlers,
561
		 * so deferred signals still can use the handlers,
531
		 * multiple threads invoking sigaction itself is
562
		 * multiple threads invoking sigaction itself is
532
		 * a race condition, so it is not a problem.
563
		 * a race condition, so it is not a problem.
533
		 */
564
		 */
534
		if (newact.sa_handler != SIG_DFL &&
565
		if (newact.sa_handler != SIG_DFL &&
535
		    newact.sa_handler != SIG_IGN) {
566
		    newact.sa_handler != SIG_IGN) {
536
			_thr_sigact[sig-1].sigact = newact;
567
			usa->sigact = newact;
537
			remove_thr_signals(
568
			remove_thr_signals(&usa->sigact.sa_mask);
538
				&_thr_sigact[sig-1].sigact.sa_mask);
539
			newact.sa_flags &= ~SA_NODEFER;
569
			newact.sa_flags &= ~SA_NODEFER;
540
			newact.sa_flags |= SA_SIGINFO;
570
			newact.sa_flags |= SA_SIGINFO;
541
			newact.sa_sigaction = thr_sighandler;
571
			newact.sa_sigaction = thr_sighandler;
542
			newact.sa_mask = _thr_maskset; /* mask all signals */
572
			newact.sa_mask = _thr_maskset; /* mask all signals */
543
		}
573
		}
544
		if ((ret = __sys_sigaction(sig, &newact, &oldact))) {
574
		ret = __sys_sigaction(sig, &newact, &oldact);
575
		if (ret == -1) {
545
			err = errno;
576
			err = errno;
546
			_thr_sigact[sig-1].sigact = oldact2;
577
			usa->sigact = oldact2;
547
		}
578
		}
548
	} else if (oact != NULL) {
579
	} else if (oact != NULL) {
549
		ret = __sys_sigaction(sig, NULL, &oldact);
580
		ret = __sys_sigaction(sig, NULL, &oldact);
550
		err = errno;
581
		err = errno;
551
	}
582
	}
552
583
553
	if (oldact.sa_handler != SIG_DFL &&
584
	if (oldact.sa_handler != SIG_DFL && oldact.sa_handler != SIG_IGN) {
554
	    oldact.sa_handler != SIG_IGN) {
555
		if (act != NULL)
585
		if (act != NULL)
556
			oldact = oldact2;
586
			oldact = oldact2;
557
		else if (oact != NULL)
587
		else if (oact != NULL)
558
			oldact = _thr_sigact[sig-1].sigact;
588
			oldact = usa->sigact;
559
	}
589
	}
560
590
561
	_thr_rwl_unlock(&_thr_sigact[sig-1].lock);
591
	_thr_rwl_unlock(&usa->lock);
562
	__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
592
	__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
563
593
564
	if (ret == 0) {
594
	if (ret == 0) {
Lines 570-579 _sigaction(int sig, const struct sigaction * act, struct sigaction * oact) Link Here
570
	return (ret);
600
	return (ret);
571
}
601
}
572
602
573
__weak_reference(_sigprocmask, sigprocmask);
574
575
int
603
int
576
_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
604
__thr_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
577
{
605
{
578
	const sigset_t *p = set;
606
	const sigset_t *p = set;
579
	sigset_t newset;
607
	sigset_t newset;
Lines 598-605 _pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) Link Here
598
	return (0);
626
	return (0);
599
}
627
}
600
628
601
__weak_reference(__sigsuspend, sigsuspend);
602
603
int
629
int
604
_sigsuspend(const sigset_t * set)
630
_sigsuspend(const sigset_t * set)
605
{
631
{
Lines 609-615 _sigsuspend(const sigset_t * set) Link Here
609
}
635
}
610
636
611
int
637
int
612
__sigsuspend(const sigset_t * set)
638
__thr_sigsuspend(const sigset_t * set)
613
{
639
{
614
	struct pthread *curthread;
640
	struct pthread *curthread;
615
	sigset_t newset;
641
	sigset_t newset;
Lines 633-642 __sigsuspend(const sigset_t * set) Link Here
633
	return (ret);
659
	return (ret);
634
}
660
}
635
661
636
__weak_reference(___sigwait, sigwait);
637
__weak_reference(__sigtimedwait, sigtimedwait);
638
__weak_reference(__sigwaitinfo, sigwaitinfo);
639
640
int
662
int
641
_sigtimedwait(const sigset_t *set, siginfo_t *info,
663
_sigtimedwait(const sigset_t *set, siginfo_t *info,
642
	const struct timespec * timeout)
664
	const struct timespec * timeout)
Lines 653-660 _sigtimedwait(const sigset_t *set, siginfo_t *info, Link Here
653
 *   it is not canceled.
675
 *   it is not canceled.
654
 */
676
 */
655
int
677
int
656
__sigtimedwait(const sigset_t *set, siginfo_t *info,
678
__thr_sigtimedwait(const sigset_t *set, siginfo_t *info,
657
	const struct timespec * timeout)
679
    const struct timespec * timeout)
658
{
680
{
659
	struct pthread	*curthread = _get_curthread();
681
	struct pthread	*curthread = _get_curthread();
660
	sigset_t newset;
682
	sigset_t newset;
Lines 681-687 _sigwaitinfo(const sigset_t *set, siginfo_t *info) Link Here
681
 *   it is not canceled.
703
 *   it is not canceled.
682
 */ 
704
 */ 
683
int
705
int
684
__sigwaitinfo(const sigset_t *set, siginfo_t *info)
706
__thr_sigwaitinfo(const sigset_t *set, siginfo_t *info)
685
{
707
{
686
	struct pthread	*curthread = _get_curthread();
708
	struct pthread	*curthread = _get_curthread();
687
	sigset_t newset;
709
	sigset_t newset;
Lines 707-713 _sigwait(const sigset_t *set, int *sig) Link Here
707
 *   it is not canceled.
729
 *   it is not canceled.
708
 */ 
730
 */ 
709
int
731
int
710
___sigwait(const sigset_t *set, int *sig)
732
__thr_sigwait(const sigset_t *set, int *sig)
711
{
733
{
712
	struct pthread	*curthread = _get_curthread();
734
	struct pthread	*curthread = _get_curthread();
713
	sigset_t newset;
735
	sigset_t newset;
Lines 721-729 ___sigwait(const sigset_t *set, int *sig) Link Here
721
	return (ret);
743
	return (ret);
722
}
744
}
723
745
724
__weak_reference(_setcontext, setcontext);
725
int
746
int
726
_setcontext(const ucontext_t *ucp)
747
__thr_setcontext(const ucontext_t *ucp)
727
{
748
{
728
	ucontext_t uc;
749
	ucontext_t uc;
729
750
Lines 735-746 _setcontext(const ucontext_t *ucp) Link Here
735
		return __sys_setcontext(ucp);
756
		return __sys_setcontext(ucp);
736
	(void) memcpy(&uc, ucp, sizeof(uc));
757
	(void) memcpy(&uc, ucp, sizeof(uc));
737
	SIGDELSET(uc.uc_sigmask, SIGCANCEL);
758
	SIGDELSET(uc.uc_sigmask, SIGCANCEL);
738
	return __sys_setcontext(&uc);
759
	return (__sys_setcontext(&uc));
739
}
760
}
740
761
741
__weak_reference(_swapcontext, swapcontext);
742
int
762
int
743
_swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
763
__thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
744
{
764
{
745
	ucontext_t uc;
765
	ucontext_t uc;
746
766
Lines 753-757 _swapcontext(ucontext_t *oucp, const ucontext_t *ucp) Link Here
753
		SIGDELSET(uc.uc_sigmask, SIGCANCEL);
773
		SIGDELSET(uc.uc_sigmask, SIGCANCEL);
754
		ucp = &uc;
774
		ucp = &uc;
755
	}
775
	}
756
	return __sys_swapcontext(oucp, ucp);
776
	return (__sys_swapcontext(oucp, ucp));
757
}
777
}
(-)b/lib/libthr/thread/thr_syscalls.c (-266 / +225 lines)
Lines 1-9 Link Here
1
/*
1
/*
2
 * Copyright (c) 2014 The FreeBSD Foundation.
2
 * Copyright (C) 2005 David Xu <davidxu@freebsd.org>.
3
 * Copyright (C) 2005 David Xu <davidxu@freebsd.org>.
3
 * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
4
 * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
4
 * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
5
 * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
5
 * All rights reserved.
6
 * All rights reserved.
6
 * 
7
 * 
8
 * Portions of this software were developed by Konstantin Belousov
9
 * under sponsorship from the FreeBSD Foundation.
10
 *
7
 * Redistribution and use in source and binary forms, with or without
11
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
12
 * modification, are permitted provided that the following conditions
9
 * are met:
13
 * are met:
Lines 27-34 Link Here
27
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
 *
31
 * $FreeBSD$
32
 */
34
 */
33
35
34
/*
36
/*
Lines 61-66 Link Here
61
 *
63
 *
62
 */
64
 */
63
65
66
#include <sys/cdefs.h>
67
__FBSDID("$FreeBSD$");
68
64
#include "namespace.h"
69
#include "namespace.h"
65
#include <sys/types.h>
70
#include <sys/types.h>
66
#include <sys/mman.h>
71
#include <sys/mman.h>
Lines 87-171 Link Here
87
#include <pthread.h>
92
#include <pthread.h>
88
#include "un-namespace.h"
93
#include "un-namespace.h"
89
94
95
#include "libc_private.h"
90
#include "thr_private.h"
96
#include "thr_private.h"
91
97
92
extern int	__creat(const char *, mode_t);
93
extern int	__pselect(int, fd_set *, fd_set *, fd_set *,
94
			const struct timespec *, const sigset_t *);
95
extern unsigned	__sleep(unsigned int);
96
extern int	__system(const char *);
97
extern int	__tcdrain(int);
98
extern int	__usleep(useconds_t);
99
extern pid_t	__wait(int *);
100
extern pid_t	__waitpid(pid_t, int *, int);
101
extern int	__sys_aio_suspend(const struct aiocb * const[], int,
102
			const struct timespec *);
103
extern int	__sys_accept(int, struct sockaddr *, socklen_t *);
104
extern int	__sys_accept4(int, struct sockaddr *, socklen_t *, int);
105
extern int	__sys_connect(int, const struct sockaddr *, socklen_t);
106
extern int	__sys_fsync(int);
107
extern int	__sys_msync(void *, size_t, int);
108
extern int	__sys_pselect(int, fd_set *, fd_set *, fd_set *,
109
			const struct timespec *, const sigset_t *);
110
extern int	__sys_poll(struct pollfd *, unsigned, int);
111
extern ssize_t	__sys_recv(int, void *, size_t, int);
112
extern ssize_t	__sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
113
extern ssize_t	__sys_recvmsg(int, struct msghdr *, int);
114
extern int	__sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
115
extern int	__sys_sendfile(int, int, off_t, size_t, struct sf_hdtr *,
116
			off_t *, int);
117
extern ssize_t	__sys_sendmsg(int, const struct msghdr *, int);
118
extern ssize_t	__sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t);
119
extern ssize_t	__sys_readv(int, const struct iovec *, int);
120
extern pid_t	__sys_wait4(pid_t, int *, int, struct rusage *);
121
extern ssize_t	__sys_writev(int, const struct iovec *, int);
122
123
int	___creat(const char *, mode_t);
124
int	___pselect(int, fd_set *, fd_set *, fd_set *, 
125
		const struct timespec *, const sigset_t *);
126
unsigned	___sleep(unsigned);
127
int	___system(const char *);
128
int	___tcdrain(int);
129
int	___usleep(useconds_t useconds);
130
pid_t	___wait(int *);
131
pid_t	___waitpid(pid_t, int *, int);
132
int	__accept(int, struct sockaddr *, socklen_t *);
133
int	__accept4(int, struct sockaddr *, socklen_t *, int);
134
int	__aio_suspend(const struct aiocb * const iocbs[], int,
135
		const struct timespec *);
136
int	__close(int);
137
int	__connect(int, const struct sockaddr *, socklen_t);
138
int	__fcntl(int, int,...);
139
#ifdef SYSCALL_COMPAT
98
#ifdef SYSCALL_COMPAT
140
extern int __fcntl_compat(int, int,...);
99
extern int __fcntl_compat(int, int, ...);
141
#endif
100
#endif
142
int	__fsync(int);
143
int	__msync(void *, size_t, int);
144
int	__nanosleep(const struct timespec *, struct timespec *);
145
int	__open(const char *, int,...);
146
int	__openat(int, const char *, int,...);
147
int	__poll(struct pollfd *, unsigned int, int);
148
ssize_t	__read(int, void *buf, size_t);
149
ssize_t	__readv(int, const struct iovec *, int);
150
ssize_t	__recvfrom(int, void *, size_t, int f, struct sockaddr *, socklen_t *);
151
ssize_t	__recvmsg(int, struct msghdr *, int);
152
int	__select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
153
ssize_t	__sendmsg(int, const struct msghdr *, int);
154
ssize_t	__sendto(int, const void *, size_t, int,
155
		const struct sockaddr *, socklen_t);
156
pid_t	__wait3(int *, int, struct rusage *);
157
pid_t	__wait4(pid_t, int *, int, struct rusage *);
158
ssize_t	__write(int, const void *, size_t);
159
ssize_t	__writev(int, const struct iovec *, int);
160
161
__weak_reference(__accept, accept);
162
101
163
/*
102
/*
164
 * Cancellation behavior:
103
 * Cancellation behavior:
165
 *   If thread is canceled, no socket is created.
104
 *   If thread is canceled, no socket is created.
166
 */
105
 */
167
int
106
static int
168
__accept(int s, struct sockaddr *addr, socklen_t *addrlen)
107
__thr_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
169
{
108
{
170
	struct pthread *curthread;
109
	struct pthread *curthread;
171
	int ret;
110
	int ret;
Lines 178-191 __accept(int s, struct sockaddr *addr, socklen_t *addrlen) Link Here
178
 	return (ret);
117
 	return (ret);
179
}
118
}
180
119
181
__weak_reference(__accept4, accept4);
182
183
/*
120
/*
184
 * Cancellation behavior:
121
 * Cancellation behavior:
185
 *   If thread is canceled, no socket is created.
122
 *   If thread is canceled, no socket is created.
186
 */
123
 */
187
int
124
static int
188
__accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
125
__thr_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
189
{
126
{
190
	struct pthread *curthread;
127
	struct pthread *curthread;
191
	int ret;
128
	int ret;
Lines 198-212 __accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) Link Here
198
 	return (ret);
135
 	return (ret);
199
}
136
}
200
137
201
__weak_reference(__aio_suspend, aio_suspend);
138
static int
202
139
__thr_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
203
int
204
__aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
205
    timespec *timeout)
140
    timespec *timeout)
206
{
141
{
207
	struct pthread *curthread = _get_curthread();
142
	struct pthread *curthread;
208
	int ret;
143
	int ret;
209
144
145
	curthread = _get_curthread();
210
	_thr_cancel_enter(curthread);
146
	_thr_cancel_enter(curthread);
211
	ret = __sys_aio_suspend(iocbs, niocb, timeout);
147
	ret = __sys_aio_suspend(iocbs, niocb, timeout);
212
	_thr_cancel_leave(curthread, 1);
148
	_thr_cancel_leave(curthread, 1);
Lines 214-221 __aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct Link Here
214
	return (ret);
150
	return (ret);
215
}
151
}
216
152
217
__weak_reference(__close, close);
218
219
/*
153
/*
220
 * Cancellation behavior:
154
 * Cancellation behavior:
221
 *   According to manual of close(), the file descriptor is always deleted.
155
 *   According to manual of close(), the file descriptor is always deleted.
Lines 223-234 __weak_reference(__close, close); Link Here
223
 *   descriptor is always deleted despite whether the thread is canceled
157
 *   descriptor is always deleted despite whether the thread is canceled
224
 *   or not.
158
 *   or not.
225
 */
159
 */
226
int
160
static int
227
__close(int fd)
161
__thr_close(int fd)
228
{
162
{
229
	struct pthread	*curthread = _get_curthread();
163
	struct pthread *curthread;
230
	int	ret;
164
	int ret;
231
165
166
	curthread = _get_curthread();
232
	_thr_cancel_enter2(curthread, 0);
167
	_thr_cancel_enter2(curthread, 0);
233
	ret = __sys_close(fd);
168
	ret = __sys_close(fd);
234
	_thr_cancel_leave(curthread, 1);
169
	_thr_cancel_leave(curthread, 1);
Lines 236-253 __close(int fd) Link Here
236
	return (ret);
171
	return (ret);
237
}
172
}
238
173
239
__weak_reference(__connect, connect);
240
241
/*
174
/*
242
 * Cancellation behavior:
175
 * Cancellation behavior:
243
 *   If the thread is canceled, connection is not made.
176
 *   If the thread is canceled, connection is not made.
244
 */
177
 */
245
int
178
static int
246
__connect(int fd, const struct sockaddr *name, socklen_t namelen)
179
__thr_connect(int fd, const struct sockaddr *name, socklen_t namelen)
247
{
180
{
248
	struct pthread *curthread = _get_curthread();
181
	struct pthread *curthread;
249
	int ret;
182
	int ret;
250
183
184
	curthread = _get_curthread();
251
	_thr_cancel_enter(curthread);
185
	_thr_cancel_enter(curthread);
252
	ret = __sys_connect(fd, name, namelen);
186
	ret = __sys_connect(fd, name, namelen);
253
	_thr_cancel_leave(curthread, ret == -1);
187
	_thr_cancel_leave(curthread, ret == -1);
Lines 255-281 __connect(int fd, const struct sockaddr *name, socklen_t namelen) Link Here
255
 	return (ret);
189
 	return (ret);
256
}
190
}
257
191
258
__weak_reference(___creat, creat);
259
192
260
/*
193
/*
261
 * Cancellation behavior:
194
 * Cancellation behavior:
262
 *   If thread is canceled, file is not created.
195
 *   If thread is canceled, file is not created.
263
 */
196
 */
264
int
197
static int
265
___creat(const char *path, mode_t mode)
198
__thr_creat(const char *path, mode_t mode)
266
{
199
{
267
	struct pthread *curthread = _get_curthread();
200
	struct pthread *curthread;
268
	int ret;
201
	int ret;
269
202
203
	curthread = _get_curthread();
270
	_thr_cancel_enter(curthread);
204
	_thr_cancel_enter(curthread);
271
	ret = __creat(path, mode);
205
	ret = __libc_creat(path, mode);
272
	_thr_cancel_leave(curthread, ret == -1);
206
	_thr_cancel_leave(curthread, ret == -1);
273
	
207
	
274
	return ret;
208
	return (ret);
275
}
209
}
276
210
277
__weak_reference(__fcntl, fcntl);
278
279
/*
211
/*
280
 * Cancellation behavior:
212
 * Cancellation behavior:
281
 *   According to specification, only F_SETLKW is a cancellation point.
213
 *   According to specification, only F_SETLKW is a cancellation point.
Lines 283-295 __weak_reference(__fcntl, fcntl); Link Here
283
 *   is failure, this means the function does not generate side effect
215
 *   is failure, this means the function does not generate side effect
284
 *   if it is canceled.
216
 *   if it is canceled.
285
 */
217
 */
286
int
218
static int
287
__fcntl(int fd, int cmd,...)
219
__thr_fcntl(int fd, int cmd, ...)
288
{
220
{
289
	struct pthread *curthread = _get_curthread();
221
	struct pthread *curthread;
290
	int	ret;
222
	int ret;
291
	va_list	ap;
223
	va_list	ap;
292
224
225
	curthread = _get_curthread();
293
	va_start(ap, cmd);
226
	va_start(ap, cmd);
294
	if (cmd == F_OSETLKW || cmd == F_SETLKW) {
227
	if (cmd == F_OSETLKW || cmd == F_SETLKW) {
295
		_thr_cancel_enter(curthread);
228
		_thr_cancel_enter(curthread);
Lines 311-328 __fcntl(int fd, int cmd,...) Link Here
311
	return (ret);
244
	return (ret);
312
}
245
}
313
246
314
__weak_reference(__fsync, fsync);
315
316
/*
247
/*
317
 * Cancellation behavior:
248
 * Cancellation behavior:
318
 *   Thread may be canceled after system call.
249
 *   Thread may be canceled after system call.
319
 */
250
 */
320
int
251
static int
321
__fsync(int fd)
252
__thr_fsync(int fd)
322
{
253
{
323
	struct pthread *curthread = _get_curthread();
254
	struct pthread *curthread;
324
	int	ret;
255
	int ret;
325
256
257
	curthread = _get_curthread();
326
	_thr_cancel_enter2(curthread, 0);
258
	_thr_cancel_enter2(curthread, 0);
327
	ret = __sys_fsync(fd);
259
	ret = __sys_fsync(fd);
328
	_thr_cancel_leave(curthread, 1);
260
	_thr_cancel_leave(curthread, 1);
Lines 330-363 __fsync(int fd) Link Here
330
	return (ret);
262
	return (ret);
331
}
263
}
332
264
333
__weak_reference(__msync, msync);
334
335
/*
265
/*
336
 * Cancellation behavior:
266
 * Cancellation behavior:
337
 *   Thread may be canceled after system call.
267
 *   Thread may be canceled after system call.
338
 */
268
 */
339
int
269
static int
340
__msync(void *addr, size_t len, int flags)
270
__thr_msync(void *addr, size_t len, int flags)
341
{
271
{
342
	struct pthread *curthread = _get_curthread();
272
	struct pthread *curthread;
343
	int	ret;
273
	int ret;
344
274
275
	curthread = _get_curthread();
345
	_thr_cancel_enter2(curthread, 0);
276
	_thr_cancel_enter2(curthread, 0);
346
	ret = __sys_msync(addr, len, flags);
277
	ret = __sys_msync(addr, len, flags);
347
	_thr_cancel_leave(curthread, 1);
278
	_thr_cancel_leave(curthread, 1);
348
279
349
	return ret;
280
	return (ret);
350
}
281
}
351
282
352
__weak_reference(__nanosleep, nanosleep);
283
static int
353
284
__thr_nanosleep(const struct timespec *time_to_sleep,
354
int
355
__nanosleep(const struct timespec *time_to_sleep,
356
    struct timespec *time_remaining)
285
    struct timespec *time_remaining)
357
{
286
{
358
	struct pthread *curthread = _get_curthread();
287
	struct pthread *curthread;
359
	int		ret;
288
	int ret;
360
289
290
	curthread = _get_curthread();
361
	_thr_cancel_enter(curthread);
291
	_thr_cancel_enter(curthread);
362
	ret = __sys_nanosleep(time_to_sleep, time_remaining);
292
	ret = __sys_nanosleep(time_to_sleep, time_remaining);
363
	_thr_cancel_leave(curthread, 1);
293
	_thr_cancel_leave(curthread, 1);
Lines 365-463 __nanosleep(const struct timespec *time_to_sleep, Link Here
365
	return (ret);
295
	return (ret);
366
}
296
}
367
297
368
__weak_reference(__open, open);
369
370
/*
298
/*
371
 * Cancellation behavior:
299
 * Cancellation behavior:
372
 *   If the thread is canceled, file is not opened.
300
 *   If the thread is canceled, file is not opened.
373
 */
301
 */
374
int
302
static int
375
__open(const char *path, int flags,...)
303
__thr_open(const char *path, int flags,...)
376
{
304
{
377
	struct pthread *curthread = _get_curthread();
305
	struct pthread *curthread;
378
	int	ret;
306
	int mode, ret;
379
	int	mode = 0;
380
	va_list	ap;
307
	va_list	ap;
381
308
382
	/* Check if the file is being created: */
309
	/* Check if the file is being created: */
383
	if (flags & O_CREAT) {
310
	if ((flags & O_CREAT) != 0) {
384
		/* Get the creation mode: */
311
		/* Get the creation mode: */
385
		va_start(ap, flags);
312
		va_start(ap, flags);
386
		mode = va_arg(ap, int);
313
		mode = va_arg(ap, int);
387
		va_end(ap);
314
		va_end(ap);
315
	} else {
316
		mode = 0;
388
	}
317
	}
389
	
318
	
319
	curthread = _get_curthread();
390
	_thr_cancel_enter(curthread);
320
	_thr_cancel_enter(curthread);
391
	ret = __sys_open(path, flags, mode);
321
	ret = __sys_open(path, flags, mode);
392
	_thr_cancel_leave(curthread, ret == -1);
322
	_thr_cancel_leave(curthread, ret == -1);
393
323
394
	return ret;
324
	return (ret);
395
}
325
}
396
326
397
__weak_reference(__openat, openat);
398
399
/*
327
/*
400
 * Cancellation behavior:
328
 * Cancellation behavior:
401
 *   If the thread is canceled, file is not opened.
329
 *   If the thread is canceled, file is not opened.
402
 */
330
 */
403
int
331
static int
404
__openat(int fd, const char *path, int flags, ...)
332
__thr_openat(int fd, const char *path, int flags, ...)
405
{
333
{
406
	struct pthread *curthread = _get_curthread();
334
	struct pthread *curthread;
407
	int	ret;
335
	int mode, ret;
408
	int	mode = 0;
409
	va_list	ap;
336
	va_list	ap;
410
337
411
	
338
	
412
	/* Check if the file is being created: */
339
	/* Check if the file is being created: */
413
	if (flags & O_CREAT) {
340
	if ((flags & O_CREAT) != 0) {
414
		/* Get the creation mode: */
341
		/* Get the creation mode: */
415
		va_start(ap, flags);
342
		va_start(ap, flags);
416
		mode = va_arg(ap, int);
343
		mode = va_arg(ap, int);
417
		va_end(ap);
344
		va_end(ap);
345
	} else {
346
		mode = 0;
418
	}
347
	}
419
	
348
	
349
	curthread = _get_curthread();
420
	_thr_cancel_enter(curthread);
350
	_thr_cancel_enter(curthread);
421
	ret = __sys_openat(fd, path, flags, mode);
351
	ret = __sys_openat(fd, path, flags, mode);
422
	_thr_cancel_leave(curthread, ret == -1);
352
	_thr_cancel_leave(curthread, ret == -1);
423
353
424
	return ret;
354
	return (ret);
425
}
355
}
426
356
427
__weak_reference(__poll, poll);
428
429
/*
357
/*
430
 * Cancellation behavior:
358
 * Cancellation behavior:
431
 *   Thread may be canceled at start, but if the system call returns something,
359
 *   Thread may be canceled at start, but if the system call returns something,
432
 *   the thread is not canceled.
360
 *   the thread is not canceled.
433
 */
361
 */
434
int
362
static int
435
__poll(struct pollfd *fds, unsigned int nfds, int timeout)
363
__thr_poll(struct pollfd *fds, unsigned int nfds, int timeout)
436
{
364
{
437
	struct pthread *curthread = _get_curthread();
365
	struct pthread *curthread;
438
	int ret;
366
	int ret;
439
367
368
	curthread = _get_curthread();
440
	_thr_cancel_enter(curthread);
369
	_thr_cancel_enter(curthread);
441
	ret = __sys_poll(fds, nfds, timeout);
370
	ret = __sys_poll(fds, nfds, timeout);
442
	_thr_cancel_leave(curthread, ret == -1);
371
	_thr_cancel_leave(curthread, ret == -1);
443
372
444
	return ret;
373
	return (ret);
445
}
374
}
446
375
447
__weak_reference(___pselect, pselect);
448
449
/*
376
/*
450
 * Cancellation behavior:
377
 * Cancellation behavior:
451
 *   Thread may be canceled at start, but if the system call returns something,
378
 *   Thread may be canceled at start, but if the system call returns something,
452
 *   the thread is not canceled.
379
 *   the thread is not canceled.
453
 */
380
 */
454
int 
381
static int
455
___pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, 
382
__thr_pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, 
456
	const struct timespec *timo, const sigset_t *mask)
383
	const struct timespec *timo, const sigset_t *mask)
457
{
384
{
458
	struct pthread *curthread = _get_curthread();
385
	struct pthread *curthread;
459
	int ret;
386
	int ret;
460
387
388
	curthread = _get_curthread();
461
	_thr_cancel_enter(curthread);
389
	_thr_cancel_enter(curthread);
462
	ret = __sys_pselect(count, rfds, wfds, efds, timo, mask);
390
	ret = __sys_pselect(count, rfds, wfds, efds, timo, mask);
463
	_thr_cancel_leave(curthread, ret == -1);
391
	_thr_cancel_leave(curthread, ret == -1);
Lines 465-785 ___pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, Link Here
465
	return (ret);
393
	return (ret);
466
}
394
}
467
395
468
__weak_reference(__read, read);
469
470
/*
396
/*
471
 * Cancellation behavior:
397
 * Cancellation behavior:
472
 *   Thread may be canceled at start, but if the system call got some data, 
398
 *   Thread may be canceled at start, but if the system call got some data, 
473
 *   the thread is not canceled.
399
 *   the thread is not canceled.
474
 */
400
 */
475
ssize_t
401
static ssize_t
476
__read(int fd, void *buf, size_t nbytes)
402
__thr_read(int fd, void *buf, size_t nbytes)
477
{
403
{
478
	struct pthread *curthread = _get_curthread();
404
	struct pthread *curthread;
479
	ssize_t	ret;
405
	ssize_t	ret;
480
406
407
	curthread = _get_curthread();
481
	_thr_cancel_enter(curthread);
408
	_thr_cancel_enter(curthread);
482
	ret = __sys_read(fd, buf, nbytes);
409
	ret = __sys_read(fd, buf, nbytes);
483
	_thr_cancel_leave(curthread, ret == -1);
410
	_thr_cancel_leave(curthread, ret == -1);
484
411
485
	return ret;
412
	return (ret);
486
}
413
}
487
414
488
__weak_reference(__readv, readv);
489
490
/*
415
/*
491
 * Cancellation behavior:
416
 * Cancellation behavior:
492
 *   Thread may be canceled at start, but if the system call got some data, 
417
 *   Thread may be canceled at start, but if the system call got some data, 
493
 *   the thread is not canceled.
418
 *   the thread is not canceled.
494
 */
419
 */
495
ssize_t
420
static ssize_t
496
__readv(int fd, const struct iovec *iov, int iovcnt)
421
__thr_readv(int fd, const struct iovec *iov, int iovcnt)
497
{
422
{
498
	struct pthread *curthread = _get_curthread();
423
	struct pthread *curthread;
499
	ssize_t ret;
424
	ssize_t ret;
500
425
426
	curthread = _get_curthread();
501
	_thr_cancel_enter(curthread);
427
	_thr_cancel_enter(curthread);
502
	ret = __sys_readv(fd, iov, iovcnt);
428
	ret = __sys_readv(fd, iov, iovcnt);
503
	_thr_cancel_leave(curthread, ret == -1);
429
	_thr_cancel_leave(curthread, ret == -1);
504
	return ret;
430
	return (ret);
505
}
431
}
506
432
507
__weak_reference(__recvfrom, recvfrom);
508
509
/*
433
/*
510
 * Cancellation behavior:
434
 * Cancellation behavior:
511
 *   Thread may be canceled at start, but if the system call got some data, 
435
 *   Thread may be canceled at start, but if the system call got some data, 
512
 *   the thread is not canceled.
436
 *   the thread is not canceled.
513
 */
437
 */
514
ssize_t
438
static ssize_t
515
__recvfrom(int s, void *b, size_t l, int f, struct sockaddr *from,
439
__thr_recvfrom(int s, void *b, size_t l, int f, struct sockaddr *from,
516
    socklen_t *fl)
440
    socklen_t *fl)
517
{
441
{
518
	struct pthread *curthread = _get_curthread();
442
	struct pthread *curthread;
519
	ssize_t ret;
443
	ssize_t ret;
520
444
445
	curthread = _get_curthread();
521
	_thr_cancel_enter(curthread);
446
	_thr_cancel_enter(curthread);
522
	ret = __sys_recvfrom(s, b, l, f, from, fl);
447
	ret = __sys_recvfrom(s, b, l, f, from, fl);
523
	_thr_cancel_leave(curthread, ret == -1);
448
	_thr_cancel_leave(curthread, ret == -1);
524
	return (ret);
449
	return (ret);
525
}
450
}
526
451
527
__weak_reference(__recvmsg, recvmsg);
528
529
/*
452
/*
530
 * Cancellation behavior:
453
 * Cancellation behavior:
531
 *   Thread may be canceled at start, but if the system call got some data, 
454
 *   Thread may be canceled at start, but if the system call got some data, 
532
 *   the thread is not canceled.
455
 *   the thread is not canceled.
533
 */
456
 */
534
ssize_t
457
static ssize_t
535
__recvmsg(int s, struct msghdr *m, int f)
458
__thr_recvmsg(int s, struct msghdr *m, int f)
536
{
459
{
537
	struct pthread *curthread = _get_curthread();
460
	struct pthread *curthread;
538
	ssize_t ret;
461
	ssize_t ret;
539
462
463
	curthread = _get_curthread();
540
	_thr_cancel_enter(curthread);
464
	_thr_cancel_enter(curthread);
541
	ret = __sys_recvmsg(s, m, f);
465
	ret = __sys_recvmsg(s, m, f);
542
	_thr_cancel_leave(curthread, ret == -1);
466
	_thr_cancel_leave(curthread, ret == -1);
543
	return (ret);
467
	return (ret);
544
}
468
}
545
469
546
__weak_reference(__select, select);
547
548
/*
470
/*
549
 * Cancellation behavior:
471
 * Cancellation behavior:
550
 *   Thread may be canceled at start, but if the system call returns something,
472
 *   Thread may be canceled at start, but if the system call returns something,
551
 *   the thread is not canceled.
473
 *   the thread is not canceled.
552
 */
474
 */
553
int 
475
static int 
554
__select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
476
__thr_select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
555
	struct timeval *timeout)
477
	struct timeval *timeout)
556
{
478
{
557
	struct pthread *curthread = _get_curthread();
479
	struct pthread *curthread;
558
	int ret;
480
	int ret;
559
481
482
	curthread = _get_curthread();
560
	_thr_cancel_enter(curthread);
483
	_thr_cancel_enter(curthread);
561
	ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
484
	ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
562
	_thr_cancel_leave(curthread, ret == -1);
485
	_thr_cancel_leave(curthread, ret == -1);
563
	return ret;
486
	return (ret);
564
}
487
}
565
488
566
__weak_reference(__sendmsg, sendmsg);
567
568
/*
489
/*
569
 * Cancellation behavior:
490
 * Cancellation behavior:
570
 *   Thread may be canceled at start, but if the system call sent
491
 *   Thread may be canceled at start, but if the system call sent
571
 *   data, the thread is not canceled.
492
 *   data, the thread is not canceled.
572
 */
493
 */
573
ssize_t
494
static ssize_t
574
__sendmsg(int s, const struct msghdr *m, int f)
495
__thr_sendmsg(int s, const struct msghdr *m, int f)
575
{
496
{
576
	struct pthread *curthread = _get_curthread();
497
	struct pthread *curthread;
577
	ssize_t ret;
498
	ssize_t ret;
578
499
500
	curthread = _get_curthread();
579
	_thr_cancel_enter(curthread);
501
	_thr_cancel_enter(curthread);
580
	ret = __sys_sendmsg(s, m, f);
502
	ret = __sys_sendmsg(s, m, f);
581
	_thr_cancel_leave(curthread, ret <= 0);
503
	_thr_cancel_leave(curthread, ret <= 0);
582
	return (ret);
504
	return (ret);
583
}
505
}
584
506
585
__weak_reference(__sendto, sendto);
586
587
/*
507
/*
588
 * Cancellation behavior:
508
 * Cancellation behavior:
589
 *   Thread may be canceled at start, but if the system call sent some
509
 *   Thread may be canceled at start, but if the system call sent some
590
 *   data, the thread is not canceled.
510
 *   data, the thread is not canceled.
591
 */
511
 */
592
ssize_t
512
static ssize_t
593
__sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t,
513
__thr_sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t,
594
    socklen_t tl)
514
    socklen_t tl)
595
{
515
{
596
	struct pthread *curthread = _get_curthread();
516
	struct pthread *curthread;
597
	ssize_t ret;
517
	ssize_t ret;
598
518
519
	curthread = _get_curthread();
599
	_thr_cancel_enter(curthread);
520
	_thr_cancel_enter(curthread);
600
	ret = __sys_sendto(s, m, l, f, t, tl);
521
	ret = __sys_sendto(s, m, l, f, t, tl);
601
	_thr_cancel_leave(curthread, ret <= 0);
522
	_thr_cancel_leave(curthread, ret <= 0);
602
	return (ret);
523
	return (ret);
603
}
524
}
604
525
605
__weak_reference(___sleep, sleep);
526
static unsigned int
606
527
__thr_sleep(unsigned int seconds)
607
unsigned int
608
___sleep(unsigned int seconds)
609
{
528
{
610
	struct pthread *curthread = _get_curthread();
529
	struct pthread *curthread;
611
	unsigned int	ret;
530
	unsigned int ret;
612
531
532
	curthread = _get_curthread();
613
	_thr_cancel_enter(curthread);
533
	_thr_cancel_enter(curthread);
614
	ret = __sleep(seconds);
534
	ret = __libc_sleep(seconds);
615
	_thr_cancel_leave(curthread, 1);
535
	_thr_cancel_leave(curthread, 1);
616
	
617
	return (ret);
536
	return (ret);
618
}
537
}
619
538
620
__weak_reference(___system, system);
539
static int
621
540
__thr_system(const char *string)
622
int
623
___system(const char *string)
624
{
541
{
625
	struct pthread *curthread = _get_curthread();
542
	struct pthread *curthread;
626
	int	ret;
543
	int ret;
627
544
545
	curthread = _get_curthread();
628
	_thr_cancel_enter(curthread);
546
	_thr_cancel_enter(curthread);
629
	ret = __system(string);
547
	ret = __libc_system(string);
630
	_thr_cancel_leave(curthread, 1);
548
	_thr_cancel_leave(curthread, 1);
631
	
549
	return (ret);
632
	return ret;
633
}
550
}
634
551
635
__weak_reference(___tcdrain, tcdrain);
636
637
/*
552
/*
638
 * Cancellation behavior:
553
 * Cancellation behavior:
639
 *   If thread is canceled, the system call is not completed,
554
 *   If thread is canceled, the system call is not completed,
640
 *   this means not all bytes were drained.
555
 *   this means not all bytes were drained.
641
 */
556
 */
642
int
557
static int
643
___tcdrain(int fd)
558
__thr_tcdrain(int fd)
644
{
559
{
645
	struct pthread *curthread = _get_curthread();
560
	struct pthread *curthread;
646
	int	ret;
561
	int ret;
647
	
562
	
563
	curthread = _get_curthread();
648
	_thr_cancel_enter(curthread);
564
	_thr_cancel_enter(curthread);
649
	ret = __tcdrain(fd);
565
	ret = __libc_tcdrain(fd);
650
	_thr_cancel_leave(curthread, ret == -1);
566
	_thr_cancel_leave(curthread, ret == -1);
651
	return (ret);
567
	return (ret);
652
}
568
}
653
569
654
__weak_reference(___usleep, usleep);
570
static int
655
571
__thr_usleep(useconds_t useconds)
656
int
657
___usleep(useconds_t useconds)
658
{
572
{
659
	struct pthread *curthread = _get_curthread();
573
	struct pthread *curthread;
660
	int		ret;
574
	int ret;
661
575
576
	curthread = _get_curthread();
662
	_thr_cancel_enter(curthread);
577
	_thr_cancel_enter(curthread);
663
	ret = __usleep(useconds);
578
	ret = __libc_usleep(useconds);
664
	_thr_cancel_leave(curthread, 1);
579
	_thr_cancel_leave(curthread, 1);
665
	
666
	return (ret);
580
	return (ret);
667
}
581
}
668
582
669
__weak_reference(___wait, wait);
670
671
/*
583
/*
672
 * Cancellation behavior:
584
 * Cancellation behavior:
673
 *   Thread may be canceled at start, but if the system call returns
585
 *   Thread may be canceled at start, but if the system call returns
674
 *   a child pid, the thread is not canceled.
586
 *   a child pid, the thread is not canceled.
675
 */
587
 */
676
pid_t
588
static pid_t
677
___wait(int *istat)
589
__thr_wait(int *istat)
678
{
590
{
679
	struct pthread *curthread = _get_curthread();
591
	struct pthread *curthread;
680
	pid_t	ret;
592
	pid_t ret;
681
593
594
	curthread = _get_curthread();
682
	_thr_cancel_enter(curthread);
595
	_thr_cancel_enter(curthread);
683
	ret = __wait(istat);
596
	ret = __libc_wait(istat);
684
	_thr_cancel_leave(curthread, ret <= 0);
597
	_thr_cancel_leave(curthread, ret <= 0);
685
598
	return (ret);
686
	return ret;
687
}
599
}
688
600
689
__weak_reference(__wait3, wait3);
690
691
/*
601
/*
692
 * Cancellation behavior:
602
 * Cancellation behavior:
693
 *   Thread may be canceled at start, but if the system call returns
603
 *   Thread may be canceled at start, but if the system call returns
694
 *   a child pid, the thread is not canceled.
604
 *   a child pid, the thread is not canceled.
695
 */
605
 */
696
pid_t
606
static pid_t
697
__wait3(int *status, int options, struct rusage *rusage)
607
__thr_wait3(int *status, int options, struct rusage *rusage)
698
{
608
{
699
	struct pthread *curthread = _get_curthread();
609
	struct pthread *curthread;
700
	pid_t ret;
610
	pid_t ret;
701
611
612
	curthread = _get_curthread();
702
	_thr_cancel_enter(curthread);
613
	_thr_cancel_enter(curthread);
703
	ret = _wait4(WAIT_ANY, status, options, rusage);
614
	ret = __libc_wait3(status, options, rusage);
704
	_thr_cancel_leave(curthread, ret <= 0);
615
	_thr_cancel_leave(curthread, ret <= 0);
705
706
	return (ret);
616
	return (ret);
707
}
617
}
708
618
709
__weak_reference(__wait4, wait4);
710
711
/*
619
/*
712
 * Cancellation behavior:
620
 * Cancellation behavior:
713
 *   Thread may be canceled at start, but if the system call returns
621
 *   Thread may be canceled at start, but if the system call returns
714
 *   a child pid, the thread is not canceled.
622
 *   a child pid, the thread is not canceled.
715
 */
623
 */
716
pid_t
624
static pid_t
717
__wait4(pid_t pid, int *status, int options, struct rusage *rusage)
625
__thr_wait4(pid_t pid, int *status, int options, struct rusage *rusage)
718
{
626
{
719
	struct pthread *curthread = _get_curthread();
627
	struct pthread *curthread;
720
	pid_t ret;
628
	pid_t ret;
721
629
630
	curthread = _get_curthread();
722
	_thr_cancel_enter(curthread);
631
	_thr_cancel_enter(curthread);
723
	ret = __sys_wait4(pid, status, options, rusage);
632
	ret = __sys_wait4(pid, status, options, rusage);
724
	_thr_cancel_leave(curthread, ret <= 0);
633
	_thr_cancel_leave(curthread, ret <= 0);
725
634
	return (ret);
726
	return ret;
727
}
635
}
728
636
729
__weak_reference(___waitpid, waitpid);
730
731
/*
637
/*
732
 * Cancellation behavior:
638
 * Cancellation behavior:
733
 *   Thread may be canceled at start, but if the system call returns
639
 *   Thread may be canceled at start, but if the system call returns
734
 *   a child pid, the thread is not canceled.
640
 *   a child pid, the thread is not canceled.
735
 */
641
 */
736
pid_t
642
static pid_t
737
___waitpid(pid_t wpid, int *status, int options)
643
__thr_waitpid(pid_t wpid, int *status, int options)
738
{
644
{
739
	struct pthread *curthread = _get_curthread();
645
	struct pthread *curthread;
740
	pid_t	ret;
646
	pid_t ret;
741
647
648
	curthread = _get_curthread();
742
	_thr_cancel_enter(curthread);
649
	_thr_cancel_enter(curthread);
743
	ret = __waitpid(wpid, status, options);
650
	ret = __libc_waitpid(wpid, status, options);
744
	_thr_cancel_leave(curthread, ret <= 0);
651
	_thr_cancel_leave(curthread, ret <= 0);
745
	
652
	return (ret);
746
	return ret;
747
}
653
}
748
654
749
__weak_reference(__write, write);
750
751
/*
655
/*
752
 * Cancellation behavior:
656
 * Cancellation behavior:
753
 *   Thread may be canceled at start, but if the thread wrote some data,
657
 *   Thread may be canceled at start, but if the thread wrote some data,
754
 *   it is not canceled.
658
 *   it is not canceled.
755
 */
659
 */
756
ssize_t
660
static ssize_t
757
__write(int fd, const void *buf, size_t nbytes)
661
__thr_write(int fd, const void *buf, size_t nbytes)
758
{
662
{
759
	struct pthread *curthread = _get_curthread();
663
	struct pthread *curthread;
760
	ssize_t	ret;
664
	ssize_t	ret;
761
665
666
	curthread = _get_curthread();
762
	_thr_cancel_enter(curthread);
667
	_thr_cancel_enter(curthread);
763
	ret = __sys_write(fd, buf, nbytes);
668
	ret = __sys_write(fd, buf, nbytes);
764
	_thr_cancel_leave(curthread, (ret <= 0));
669
	_thr_cancel_leave(curthread, (ret <= 0));
765
	return ret;
670
	return (ret);
766
}
671
}
767
672
768
__weak_reference(__writev, writev);
769
770
/*
673
/*
771
 * Cancellation behavior:
674
 * Cancellation behavior:
772
 *   Thread may be canceled at start, but if the thread wrote some data,
675
 *   Thread may be canceled at start, but if the thread wrote some data,
773
 *   it is not canceled.
676
 *   it is not canceled.
774
 */
677
 */
775
ssize_t
678
static ssize_t
776
__writev(int fd, const struct iovec *iov, int iovcnt)
679
__thr_writev(int fd, const struct iovec *iov, int iovcnt)
777
{
680
{
778
	struct pthread *curthread = _get_curthread();
681
	struct pthread *curthread;
779
	ssize_t ret;
682
	ssize_t ret;
780
683
684
	curthread = _get_curthread();
781
	_thr_cancel_enter(curthread);
685
	_thr_cancel_enter(curthread);
782
	ret = __sys_writev(fd, iov, iovcnt);
686
	ret = __sys_writev(fd, iov, iovcnt);
783
	_thr_cancel_leave(curthread, (ret <= 0));
687
	_thr_cancel_leave(curthread, (ret <= 0));
784
	return ret;
688
	return (ret);
689
}
690
691
void
692
__thr_interpose_libc(void)
693
{
694
695
	__error_selector = __error_threaded;
696
#define	SLOT(name)					\
697
	*(__libc_interposing_slot(INTERPOS_##name)) =	\
698
	    (interpos_func_t)__thr_##name;
699
	SLOT(accept);
700
	SLOT(accept4);
701
	SLOT(aio_suspend);
702
	SLOT(close);
703
	SLOT(connect);
704
	SLOT(creat);
705
	SLOT(fcntl);
706
	SLOT(fsync);
707
	SLOT(msync);
708
	SLOT(nanosleep);
709
	SLOT(open);
710
	SLOT(openat);
711
	SLOT(poll);
712
	SLOT(pselect);
713
	SLOT(raise);
714
	SLOT(read);
715
	SLOT(readv);
716
	SLOT(recvfrom);
717
	SLOT(recvmsg);
718
	SLOT(select);
719
	SLOT(sendmsg);
720
	SLOT(sendto);
721
	SLOT(setcontext);
722
	SLOT(sigaction);
723
	SLOT(sigprocmask);
724
	SLOT(sigsuspend);
725
	SLOT(sigwait);
726
	SLOT(sigtimedwait);
727
	SLOT(sigwaitinfo);
728
	SLOT(swapcontext);
729
	SLOT(system);
730
	SLOT(sleep);
731
	SLOT(tcdrain);
732
	SLOT(usleep);
733
	SLOT(pause);
734
	SLOT(wait);
735
	SLOT(wait3);
736
	SLOT(wait4);
737
	SLOT(waitpid);
738
	SLOT(write);
739
	SLOT(writev);
740
#undef SLOT
741
	*(__libc_interposing_slot(
742
	    INTERPOS__pthread_mutex_init_calloc_cb)) =
743
	    (interpos_func_t)_pthread_mutex_init_calloc_cb;
785
}
744
}
(-)b/libexec/rtld-elf/Symbol.map (+1 lines)
Lines 30-34 FBSDprivate_1.0 { Link Here
30
    _rtld_atfork_post;
30
    _rtld_atfork_post;
31
    _rtld_addr_phdr;
31
    _rtld_addr_phdr;
32
    _rtld_get_stack_prot;
32
    _rtld_get_stack_prot;
33
    _rtld_is_dlopened;
33
    _r_debug_postinit;
34
    _r_debug_postinit;
34
};
35
};
(-)b/libexec/rtld-elf/rtld.c (+22 lines)
Lines 2222-2227 do_load_object(int fd, const char *name, char *path, struct stat *sbp, Link Here
2222
	return (NULL);
2222
	return (NULL);
2223
    }
2223
    }
2224
2224
2225
    obj->dlopened = (flags & RTLD_LO_DLOPEN) != 0;
2225
    *obj_tail = obj;
2226
    *obj_tail = obj;
2226
    obj_tail = &obj->next;
2227
    obj_tail = &obj->next;
2227
    obj_count++;
2228
    obj_count++;
Lines 4884-4889 _rtld_get_stack_prot(void) Link Here
4884
	return (stack_prot);
4885
	return (stack_prot);
4885
}
4886
}
4886
4887
4888
int
4889
_rtld_is_dlopened(void *arg)
4890
{
4891
	Obj_Entry *obj;
4892
	RtldLockState lockstate;
4893
	int res;
4894
4895
	rlock_acquire(rtld_bind_lock, &lockstate);
4896
	obj = dlcheck(arg);
4897
	if (obj == NULL)
4898
		obj = obj_from_addr(arg);
4899
	if (obj == NULL) {
4900
		_rtld_error("No shared object contains address");
4901
		lock_release(rtld_bind_lock, &lockstate);
4902
		return (-1);
4903
	}
4904
	res = obj->dlopened ? 1 : 0;
4905
	lock_release(rtld_bind_lock, &lockstate);
4906
	return (res);
4907
}
4908
4887
static void
4909
static void
4888
map_stacks_exec(RtldLockState *lockstate)
4910
map_stacks_exec(RtldLockState *lockstate)
4889
{
4911
{
(-)b/libexec/rtld-elf/rtld.h (+1 lines)
Lines 275-280 typedef struct Struct_Obj_Entry { Link Here
275
    bool crt_no_init : 1;	/* Object' crt does not call _init/_fini */
275
    bool crt_no_init : 1;	/* Object' crt does not call _init/_fini */
276
    bool valid_hash_sysv : 1;	/* A valid System V hash hash tag is available */
276
    bool valid_hash_sysv : 1;	/* A valid System V hash hash tag is available */
277
    bool valid_hash_gnu : 1;	/* A valid GNU hash tag is available */
277
    bool valid_hash_gnu : 1;	/* A valid GNU hash tag is available */
278
    bool dlopened : 1;		/* dlopen()-ed (vs. load statically) */
278
279
279
    struct link_map linkmap;	/* For GDB and dlinfo() */
280
    struct link_map linkmap;	/* For GDB and dlinfo() */
280
    Objlist dldags;		/* Object belongs to these dlopened DAGs (%) */
281
    Objlist dldags;		/* Object belongs to these dlopened DAGs (%) */
(-)b/sys/sys/link_elf.h (+1 lines)
Lines 94-99 typedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *); Link Here
94
extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
94
extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
95
int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
95
int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
96
int _rtld_get_stack_prot(void);
96
int _rtld_get_stack_prot(void);
97
int _rtld_is_dlopened(void *);
97
98
98
#ifdef __ARM_EABI__
99
#ifdef __ARM_EABI__
99
void * dl_unwind_find_exidx(const void *, int *);
100
void * dl_unwind_find_exidx(const void *, int *);

Return to bug 196354