Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jan 2015 11:54:21 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r277317 - in stable/10: contrib/jemalloc/include/jemalloc/internal contrib/jemalloc/src lib/libc lib/libc/compat-43 lib/libc/gen lib/libc/include lib/libc/stdlib lib/libc/stdlib/jemallo...
Message-ID:  <201501181154.t0IBsLn0089798@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Jan 18 11:54:20 2015
New Revision: 277317
URL: https://svnweb.freebsd.org/changeset/base/277317

Log:
  Fix known issues which blow up the process after dlopen("libthr.so")
  (or loading a dso linked to libthr.so into process which was not
  linked against threading library).
  
  MFC r276630:
  Remove interposing, fix malloc, reinstall signal handlers wrappers on
  libthr load.
  
  MFC r276681:
  Avoid calling internal libc function through PLT or accessing data
  though GOT.
  
  MFC r277032:
  Reduce the size of the interposing table and amount of
  cancellation-handling code in the libthr.
  
  MFC note:
  r276646 ("do not erronously export 'openat' symbol from rtld") is not
  applicable to stable/10 yet, since PATHFDS support was not merged.

Added:
  stable/10/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
     - copied unchanged from r276630, head/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
  stable/10/lib/libc/sys/accept.c
     - copied unchanged from r276630, head/lib/libc/sys/accept.c
  stable/10/lib/libc/sys/accept4.c
     - copied unchanged from r276630, head/lib/libc/sys/accept4.c
  stable/10/lib/libc/sys/aio_suspend.c
     - copied unchanged from r276630, head/lib/libc/sys/aio_suspend.c
  stable/10/lib/libc/sys/close.c
     - copied unchanged from r276630, head/lib/libc/sys/close.c
  stable/10/lib/libc/sys/connect.c
     - copied unchanged from r276630, head/lib/libc/sys/connect.c
  stable/10/lib/libc/sys/fork.c
     - copied unchanged from r276630, head/lib/libc/sys/fork.c
  stable/10/lib/libc/sys/fsync.c
     - copied unchanged from r276630, head/lib/libc/sys/fsync.c
  stable/10/lib/libc/sys/interposing_table.c
     - copied, changed from r276630, head/lib/libc/sys/interposing_table.c
  stable/10/lib/libc/sys/msync.c
     - copied unchanged from r276630, head/lib/libc/sys/msync.c
  stable/10/lib/libc/sys/nanosleep.c
     - copied unchanged from r276630, head/lib/libc/sys/nanosleep.c
  stable/10/lib/libc/sys/open.c
     - copied, changed from r276630, head/lib/libc/sys/open.c
  stable/10/lib/libc/sys/openat.c
     - copied unchanged from r276630, head/lib/libc/sys/openat.c
  stable/10/lib/libc/sys/poll.c
     - copied unchanged from r276630, head/lib/libc/sys/poll.c
  stable/10/lib/libc/sys/pselect.c
     - copied unchanged from r276630, head/lib/libc/sys/pselect.c
  stable/10/lib/libc/sys/read.c
     - copied unchanged from r276630, head/lib/libc/sys/read.c
  stable/10/lib/libc/sys/readv.c
     - copied unchanged from r276630, head/lib/libc/sys/readv.c
  stable/10/lib/libc/sys/recvfrom.c
     - copied unchanged from r276630, head/lib/libc/sys/recvfrom.c
  stable/10/lib/libc/sys/recvmsg.c
     - copied unchanged from r276630, head/lib/libc/sys/recvmsg.c
  stable/10/lib/libc/sys/select.c
     - copied unchanged from r276630, head/lib/libc/sys/select.c
  stable/10/lib/libc/sys/sendmsg.c
     - copied unchanged from r276630, head/lib/libc/sys/sendmsg.c
  stable/10/lib/libc/sys/sendto.c
     - copied unchanged from r276630, head/lib/libc/sys/sendto.c
  stable/10/lib/libc/sys/setcontext.c
     - copied unchanged from r276630, head/lib/libc/sys/setcontext.c
  stable/10/lib/libc/sys/sigaction.c
     - copied unchanged from r276630, head/lib/libc/sys/sigaction.c
  stable/10/lib/libc/sys/sigprocmask.c
     - copied unchanged from r276630, head/lib/libc/sys/sigprocmask.c
  stable/10/lib/libc/sys/sigsuspend.c
     - copied unchanged from r276630, head/lib/libc/sys/sigsuspend.c
  stable/10/lib/libc/sys/sigtimedwait.c
     - copied unchanged from r276630, head/lib/libc/sys/sigtimedwait.c
  stable/10/lib/libc/sys/sigwaitinfo.c
     - copied unchanged from r276630, head/lib/libc/sys/sigwaitinfo.c
  stable/10/lib/libc/sys/swapcontext.c
     - copied unchanged from r276630, head/lib/libc/sys/swapcontext.c
  stable/10/lib/libc/sys/wait4.c
     - copied unchanged from r276630, head/lib/libc/sys/wait4.c
  stable/10/lib/libc/sys/write.c
     - copied unchanged from r276630, head/lib/libc/sys/write.c
  stable/10/lib/libc/sys/writev.c
     - copied unchanged from r276630, head/lib/libc/sys/writev.c
Deleted:
  stable/10/lib/libc/gen/swapcontext.c
Modified:
  stable/10/contrib/jemalloc/include/jemalloc/internal/mutex.h
  stable/10/contrib/jemalloc/src/jemalloc.c
  stable/10/contrib/jemalloc/src/mutex.c
  stable/10/lib/libc/Makefile
  stable/10/lib/libc/compat-43/creat.c
  stable/10/lib/libc/gen/Makefile.inc
  stable/10/lib/libc/gen/Symbol.map
  stable/10/lib/libc/gen/pause.c
  stable/10/lib/libc/gen/raise.c
  stable/10/lib/libc/gen/sleep.c
  stable/10/lib/libc/gen/termios.c
  stable/10/lib/libc/gen/usleep.c
  stable/10/lib/libc/gen/wait.c
  stable/10/lib/libc/gen/wait3.c
  stable/10/lib/libc/gen/waitpid.c
  stable/10/lib/libc/include/libc_private.h
  stable/10/lib/libc/stdlib/Symbol.map
  stable/10/lib/libc/stdlib/jemalloc/Symbol.map
  stable/10/lib/libc/stdlib/system.c
  stable/10/lib/libc/sys/Makefile.inc
  stable/10/lib/libc/sys/Symbol.map
  stable/10/lib/libc/sys/__error.c
  stable/10/lib/libc/sys/fcntl.c
  stable/10/lib/libc/sys/sigwait.c
  stable/10/lib/libthr/Makefile
  stable/10/lib/libthr/pthread.map
  stable/10/lib/libthr/sys/thr_error.c
  stable/10/lib/libthr/thread/thr_create.c
  stable/10/lib/libthr/thread/thr_fork.c
  stable/10/lib/libthr/thread/thr_init.c
  stable/10/lib/libthr/thread/thr_printf.c
  stable/10/lib/libthr/thread/thr_private.h
  stable/10/lib/libthr/thread/thr_sig.c
  stable/10/lib/libthr/thread/thr_syscalls.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/jemalloc/include/jemalloc/internal/mutex.h
==============================================================================
--- stable/10/contrib/jemalloc/include/jemalloc/internal/mutex.h	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/contrib/jemalloc/include/jemalloc/internal/mutex.h	Sun Jan 18 11:54:20 2015	(r277317)
@@ -49,6 +49,7 @@ bool	malloc_mutex_init(malloc_mutex_t *m
 void	malloc_mutex_prefork(malloc_mutex_t *mutex);
 void	malloc_mutex_postfork_parent(malloc_mutex_t *mutex);
 void	malloc_mutex_postfork_child(malloc_mutex_t *mutex);
+bool	malloc_mutex_first_thread(void);
 bool	mutex_boot(void);
 
 #endif /* JEMALLOC_H_EXTERNS */

Modified: stable/10/contrib/jemalloc/src/jemalloc.c
==============================================================================
--- stable/10/contrib/jemalloc/src/jemalloc.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/contrib/jemalloc/src/jemalloc.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -1818,6 +1818,13 @@ jemalloc_postfork_child(void)
 	ctl_postfork_child();
 }
 
+void
+_malloc_first_thread(void)
+{
+
+	(void)malloc_mutex_first_thread();
+}
+
 /******************************************************************************/
 /*
  * The following functions are used for TLS allocation/deallocation in static

Modified: stable/10/contrib/jemalloc/src/mutex.c
==============================================================================
--- stable/10/contrib/jemalloc/src/mutex.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/contrib/jemalloc/src/mutex.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -67,15 +67,15 @@ pthread_create(pthread_t *__restrict thr
 JEMALLOC_EXPORT int	_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
     void *(calloc_cb)(size_t, size_t));
 
-__weak_reference(_pthread_mutex_init_calloc_cb_stub,
-    _pthread_mutex_init_calloc_cb);
-
+#pragma weak _pthread_mutex_init_calloc_cb
 int
-_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
+_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
     void *(calloc_cb)(size_t, size_t))
 {
 
-	return (0);
+	return (((int (*)(pthread_mutex_t *, void *(*)(size_t, size_t)))
+	    __libc_interposing[INTERPOS__pthread_mutex_init_calloc_cb])(
+	   mutex, calloc_cb));
 }
 #endif
 
@@ -144,7 +144,7 @@ malloc_mutex_postfork_child(malloc_mutex
 }
 
 bool
-mutex_boot(void)
+malloc_mutex_first_thread(void)
 {
 
 #ifdef JEMALLOC_MUTEX_INIT_CB
@@ -158,3 +158,14 @@ mutex_boot(void)
 #endif
 	return (false);
 }
+
+bool
+mutex_boot(void)
+{
+
+#ifndef JEMALLOC_MUTEX_INIT_CB
+	return (malloc_mutex_first_thread());
+#else
+	return (false);
+#endif
+}

Modified: stable/10/lib/libc/Makefile
==============================================================================
--- stable/10/lib/libc/Makefile	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/Makefile	Sun Jan 18 11:54:20 2015	(r277317)
@@ -156,6 +156,10 @@ libkern.${LIBC_ARCH}:: ${KMSRCS}
 	cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
 .endif
 
+.if !defined(WITHOUT_SYSCALL_COMPAT)
+CFLAGS+=-DSYSCALL_COMPAT
+.endif
+
 .include <bsd.lib.mk>
 
 # Disable warnings in contributed sources.

Modified: stable/10/lib/libc/compat-43/creat.c
==============================================================================
--- stable/10/lib/libc/compat-43/creat.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/compat-43/creat.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -36,11 +36,18 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include <fcntl.h>
 #include "un-namespace.h"
+#include "libc_private.h"
 
+__weak_reference(__creat, creat);
+__weak_reference(__creat, _creat);
+
+#pragma weak creat
 int
 __creat(const char *path, mode_t mode)
 {
-	return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
+
+	return (((int (*)(int, const char *, int, ...))
+	    __libc_interposing[INTERPOS_openat])(AT_FDCWD, path, O_WRONLY |
+	    O_CREAT | O_TRUNC, mode));
 }
-__weak_reference(__creat, creat);
-__weak_reference(__creat, _creat);
+

Modified: stable/10/lib/libc/gen/Makefile.inc
==============================================================================
--- stable/10/lib/libc/gen/Makefile.inc	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/Makefile.inc	Sun Jan 18 11:54:20 2015	(r277317)
@@ -5,6 +5,7 @@
 .PATH: ${.CURDIR}/${LIBC_ARCH}/gen ${.CURDIR}/gen
 
 SRCS+=	__getosreldate.c \
+	__pthread_mutex_init_calloc_cb_stub.c \
 	__xuname.c \
 	_once_stub.c \
 	_pthread_stubs.c \

Modified: stable/10/lib/libc/gen/Symbol.map
==============================================================================
--- stable/10/lib/libc/gen/Symbol.map	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/Symbol.map	Sun Jan 18 11:54:20 2015	(r277317)
@@ -529,6 +529,8 @@ FBSDprivate_1.0 {
 	_libc_sem_post_compat;
 	_libc_sem_getvalue_compat;
 
+	__libc_tcdrain;
+
 	__elf_aux_vector;
 	__pthread_map_stacks_exec;
 	__fillcontextx;

Copied: stable/10/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c (from r276630, head/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c	Sun Jan 18 11:54:20 2015	(r277317, copy of r276630, head/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <pthread.h>
+#include "libc_private.h"
+
+int
+_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
+    void *(calloc_cb)(size_t, size_t))
+{
+
+	return (0);
+}

Modified: stable/10/lib/libc/gen/pause.c
==============================================================================
--- stable/10/lib/libc/gen/pause.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/pause.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -33,10 +33,10 @@ static char sccsid[] = "@(#)pause.c	8.1 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "namespace.h"
 #include <signal.h>
 #include <unistd.h>
-#include "un-namespace.h"
+
+#include "libc_private.h"
 
 /*
  * Backwards compatible pause.
@@ -46,9 +46,10 @@ __pause(void)
 {
 	sigset_t oset;
 
-	if (_sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
+	if (sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
 		return (-1);
-	return (_sigsuspend(&oset));
+	return (sigsuspend(&oset));
 }
+
 __weak_reference(__pause, pause);
 __weak_reference(__pause, _pause);

Modified: stable/10/lib/libc/gen/raise.c
==============================================================================
--- stable/10/lib/libc/gen/raise.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/raise.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -36,11 +36,17 @@ __FBSDID("$FreeBSD$");
 #include <signal.h>
 #include <unistd.h>
 
+#include "libc_private.h"
+
 __weak_reference(__raise, raise);
 __weak_reference(__raise, _raise);
 
 int
 __raise(int s)
 {
-	return(kill(getpid(), s));
+	long id;
+
+	if (__sys_thr_self(&id) == -1)
+		return (-1);
+	return (__sys_thr_kill(id, s));
 }

Modified: stable/10/lib/libc/gen/sleep.c
==============================================================================
--- stable/10/lib/libc/gen/sleep.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/sleep.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include "un-namespace.h"
 
+#include "libc_private.h"
+
 unsigned int
 __sleep(unsigned int seconds)
 {
@@ -55,12 +57,14 @@ __sleep(unsigned int seconds)
 
 	time_to_sleep.tv_sec = seconds;
 	time_to_sleep.tv_nsec = 0;
-	if (_nanosleep(&time_to_sleep, &time_remaining) != -1)
+	if (((int (*)(const struct timespec *, struct timespec *))
+	    __libc_interposing[INTERPOS_nanosleep])(
+	    &time_to_sleep, &time_remaining) != -1)
 		return (0);
 	if (errno != EINTR)
 		return (seconds);		/* best guess */
 	return (time_remaining.tv_sec +
-		(time_remaining.tv_nsec != 0)); /* round up */
+	    (time_remaining.tv_nsec != 0)); /* round up */
 }
 
 __weak_reference(__sleep, sleep);

Modified: stable/10/lib/libc/gen/termios.c
==============================================================================
--- stable/10/lib/libc/gen/termios.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/termios.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include "un-namespace.h"
 
+#include "libc_private.h"
+
 int
 tcgetattr(int fd, struct termios *t)
 {
@@ -208,13 +210,23 @@ tcsendbreak(int fd, int len __unused)
 }
 
 int
-__tcdrain(int fd)
+__libc_tcdrain(int fd)
 {
+
 	return (_ioctl(fd, TIOCDRAIN, 0));
 }
 
-__weak_reference(__tcdrain, tcdrain);
-__weak_reference(__tcdrain, _tcdrain);
+#pragma weak tcdrain
+int
+tcdrain(int fd)
+{
+
+	return (((int (*)(int))
+	    __libc_interposing[INTERPOS_tcdrain])(fd));
+}
+
+__weak_reference(__libc_tcdrain, __tcdrain);
+__weak_reference(__libc_tcdrain, _tcdrain);
 
 int
 tcflush(int fd, int which)

Modified: stable/10/lib/libc/gen/usleep.c
==============================================================================
--- stable/10/lib/libc/gen/usleep.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/usleep.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include "un-namespace.h"
 
+#include "libc_private.h"
+
 int
 __usleep(useconds_t useconds)
 {
@@ -45,7 +47,8 @@ __usleep(useconds_t useconds)
 
 	time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
 	time_to_sleep.tv_sec = useconds / 1000000;
-	return (_nanosleep(&time_to_sleep, NULL));
+	return (((int (*)(const struct timespec *, struct timespec *))
+	    __libc_interposing[INTERPOS_nanosleep])(&time_to_sleep, NULL));
 }
 
 __weak_reference(__usleep, usleep);

Modified: stable/10/lib/libc/gen/wait.c
==============================================================================
--- stable/10/lib/libc/gen/wait.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/wait.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -40,10 +40,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/resource.h>
 #include "un-namespace.h"
 
+#include "libc_private.h"
+
 pid_t
 __wait(int *istat)
 {
-	return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
+
+	return (((pid_t (*)(pid_t, int *, int, struct rusage *))
+	    __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, 0, NULL));
 }
 
 __weak_reference(__wait, wait);

Modified: stable/10/lib/libc/gen/wait3.c
==============================================================================
--- stable/10/lib/libc/gen/wait3.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/wait3.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -40,11 +40,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/resource.h>
 #include "un-namespace.h"
 
+#include "libc_private.h"
+
 pid_t
-wait3(istat, options, rup)
-	int *istat;
-	int options;
-	struct rusage *rup;
+__wait3(int *istat, int options, struct rusage *rup)
 {
-	return (_wait4(WAIT_ANY, istat, options, rup));
+
+	return (((pid_t (*)(pid_t, int *, int, struct rusage *))
+	    __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, options, rup));
 }
+
+__weak_reference(__wait3, wait3);

Modified: stable/10/lib/libc/gen/waitpid.c
==============================================================================
--- stable/10/lib/libc/gen/waitpid.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/gen/waitpid.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -40,10 +40,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/resource.h>
 #include "un-namespace.h"
 
+#include "libc_private.h"
+
 pid_t
 __waitpid(pid_t pid, int *istat, int options)
 {
-	return (_wait4(pid, istat, options, (struct rusage *)0));
+
+	return (((pid_t (*)(pid_t, int *, int, struct rusage *))
+	    __libc_interposing[INTERPOS_wait4])(pid, istat, options, NULL));
 }
 
 __weak_reference(__waitpid, waitpid);

Modified: stable/10/lib/libc/include/libc_private.h
==============================================================================
--- stable/10/lib/libc/include/libc_private.h	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/include/libc_private.h	Sun Jan 18 11:54:20 2015	(r277317)
@@ -173,6 +173,52 @@ typedef pthread_func_t pthread_func_entr
 
 extern pthread_func_entry_t __thr_jtable[];
 
+void	__set_error_selector(int *(*arg)(void));
+int	_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
+	    void *(calloc_cb)(__size_t, __size_t));
+
+typedef int (*interpos_func_t)(void);
+interpos_func_t *__libc_interposing_slot(int interposno);
+extern interpos_func_t __libc_interposing[] __hidden;
+
+enum {
+	INTERPOS_accept,
+	INTERPOS_accept4,
+	INTERPOS_aio_suspend,
+	INTERPOS_close,
+	INTERPOS_connect,
+	INTERPOS_fcntl,
+	INTERPOS_fsync,
+	INTERPOS_fork,
+	INTERPOS_msync,
+	INTERPOS_nanosleep,
+	INTERPOS_openat,
+	INTERPOS_poll,
+	INTERPOS_pselect,
+	INTERPOS_recvfrom,
+	INTERPOS_recvmsg,
+	INTERPOS_select,
+	INTERPOS_sendmsg,
+	INTERPOS_sendto,
+	INTERPOS_setcontext,
+	INTERPOS_sigaction,
+	INTERPOS_sigprocmask,
+	INTERPOS_sigsuspend,
+	INTERPOS_sigwait,
+	INTERPOS_sigtimedwait,
+	INTERPOS_sigwaitinfo,
+	INTERPOS_swapcontext,
+	INTERPOS_system,
+	INTERPOS_tcdrain,
+	INTERPOS_read,
+	INTERPOS_readv,
+	INTERPOS_wait4,
+	INTERPOS_write,
+	INTERPOS_writev,
+	INTERPOS__pthread_mutex_init_calloc_cb,
+	INTERPOS_MAX
+};
+
 /*
  * yplib internal interfaces
  */
@@ -215,42 +261,101 @@ void _malloc_thread_cleanup(void);
 void _malloc_prefork(void);
 void _malloc_postfork(void);
 
+void _malloc_first_thread(void);
+
 /*
  * Function to clean up streams, called from abort() and exit().
  */
-extern void (*__cleanup)(void) __hidden;
+void (*__cleanup)(void) __hidden;
 
 /*
  * Get kern.osreldate to detect ABI revisions.  Explicitly
  * ignores value of $OSVERSION and caches result.  Prototypes
  * for the wrapped "new" pad-less syscalls are here for now.
  */
-extern int __getosreldate(void);
+int __getosreldate(void);
 #include <sys/_types.h>
-/* Without pad */
-extern __off_t	__sys_lseek(int, __off_t, int);
-extern int	__sys_ftruncate(int, __off_t);
-extern int	__sys_truncate(const char *, __off_t);
-extern __ssize_t __sys_pread(int, void *, __size_t, __off_t);
-extern __ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
-extern void *	__sys_mmap(void *, __size_t, int, int, int, __off_t);
+#include <sys/_sigset.h>
 
 /* With pad */
-extern __off_t	__sys_freebsd6_lseek(int, int, __off_t, int);
-extern int	__sys_freebsd6_ftruncate(int, int, __off_t);
-extern int	__sys_freebsd6_truncate(const char *, int, __off_t);
-extern __ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t);
-extern __ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t);
-extern void *	__sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t);
-
-/* Without back-compat translation */
-extern int	__sys_fcntl(int, int, ...);
-
+__off_t	__sys_freebsd6_lseek(int, int, __off_t, int);
+int	__sys_freebsd6_ftruncate(int, int, __off_t);
+int	__sys_freebsd6_truncate(const char *, int, __off_t);
+__ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t);
+__ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t);
+void *	__sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t);
+
+struct aiocb;
+struct fd_set;
+struct iovec;
+struct msghdr;
+struct pollfd;
+struct rusage;
+struct sigaction;
+struct sockaddr;
 struct timespec;
 struct timeval;
 struct timezone;
-int	__sys_gettimeofday(struct timeval *, struct timezone *);
-int	__sys_clock_gettime(__clockid_t, struct timespec *ts);
+struct __siginfo;
+struct __ucontext;
+int		__sys_aio_suspend(const struct aiocb * const[], int,
+		    const struct timespec *);
+int		__sys_accept(int, struct sockaddr *, __socklen_t *);
+int		__sys_accept4(int, struct sockaddr *, __socklen_t *, int);
+int		__sys_clock_gettime(__clockid_t, struct timespec *ts);
+int		__sys_close(int);
+int		__sys_connect(int, const struct sockaddr *, __socklen_t);
+int		__sys_fcntl(int, int, ...);
+int		__sys_fsync(int);
+__pid_t		__sys_fork(void);
+int		__sys_ftruncate(int, __off_t);
+int		__sys_gettimeofday(struct timeval *, struct timezone *);
+__off_t		__sys_lseek(int, __off_t, int);
+void	       *__sys_mmap(void *, __size_t, int, int, int, __off_t);
+int		__sys_msync(void *, __size_t, int);
+int		__sys_nanosleep(const struct timespec *, struct timespec *);
+int		__sys_open(const char *, int, ...);
+int		__sys_openat(int, const char *, int, ...);
+int		__sys_pselect(int, struct fd_set *, struct fd_set *,
+		    struct fd_set *, const struct timespec *,
+		    const __sigset_t *);
+int		__sys_poll(struct pollfd *, unsigned, int);
+__ssize_t	__sys_pread(int, void *, __size_t, __off_t);
+__ssize_t	__sys_pwrite(int, const void *, __size_t, __off_t);
+__ssize_t	__sys_read(int, void *, __size_t);
+__ssize_t	__sys_readv(int, const struct iovec *, int);
+__ssize_t	__sys_recv(int, void *, __size_t, int);
+__ssize_t	__sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
+		    __socklen_t *);
+__ssize_t	__sys_recvmsg(int, struct msghdr *, int);
+int		__sys_select(int, struct fd_set *, struct fd_set *,
+		    struct fd_set *, struct timeval *);
+__ssize_t	__sys_sendmsg(int, const struct msghdr *, int);
+__ssize_t	__sys_sendto(int, const void *, __size_t, int,
+		    const struct sockaddr *, __socklen_t);
+int		__sys_setcontext(const struct __ucontext *);
+int		__sys_sigaction(int, const struct sigaction *,
+		    struct sigaction *);
+int		__sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
+int		__sys_sigsuspend(const __sigset_t *);
+int		__sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
+		    const struct timespec *);
+int		__sys_sigwait(const __sigset_t *, int *);
+int		__sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
+int		__sys_swapcontext(struct __ucontext *,
+		    const struct __ucontext *);
+int		__sys_thr_kill(long, int);
+int		__sys_thr_self(long *);
+int		__sys_truncate(const char *, __off_t);
+__pid_t		__sys_wait4(__pid_t, int *, int, struct rusage *);
+__ssize_t	__sys_write(int, const void *, __size_t);
+__ssize_t	__sys_writev(int, const struct iovec *, int);
+
+int		__libc_sigwait(const __sigset_t * __restrict,
+		    int * restrict sig);
+int		__libc_system(const char *);
+int		__libc_tcdrain(int);
+int		__fcntl_compat(int fd, int cmd, ...);
 
 /* execve() with PATH processing to implement posix_spawnp() */
 int _execvpe(const char *, char * const *, char * const *);

Modified: stable/10/lib/libc/stdlib/Symbol.map
==============================================================================
--- stable/10/lib/libc/stdlib/Symbol.map	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/stdlib/Symbol.map	Sun Jan 18 11:54:20 2015	(r277317)
@@ -107,4 +107,5 @@ FBSD_1.3 {
 FBSDprivate_1.0 {
 	__system;
 	_system;
+	__libc_system;
 };

Modified: stable/10/lib/libc/stdlib/jemalloc/Symbol.map
==============================================================================
--- stable/10/lib/libc/stdlib/jemalloc/Symbol.map	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/stdlib/jemalloc/Symbol.map	Sun Jan 18 11:54:20 2015	(r277317)
@@ -43,4 +43,5 @@ FBSDprivate_1.0 {
 	_malloc_thread_cleanup;
 	_malloc_prefork;
 	_malloc_postfork;
+	_malloc_first_thread;
 };

Modified: stable/10/lib/libc/stdlib/system.c
==============================================================================
--- stable/10/lib/libc/stdlib/system.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/stdlib/system.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -46,8 +46,17 @@ __FBSDID("$FreeBSD$");
 #include "un-namespace.h"
 #include "libc_private.h"
 
+#pragma weak system
 int
-__system(const char *command)
+system(const char *command)
+{
+
+	return (((int (*)(const char *))
+	    __libc_interposing[INTERPOS_system])(command));
+}
+
+int
+__libc_system(const char *command)
 {
 	pid_t pid, savedpid;
 	int pstat;
@@ -95,5 +104,5 @@ __system(const char *command)
 	return(pid == -1 ? -1 : pstat);
 }
 
-__weak_reference(__system, system);
-__weak_reference(__system, _system);
+__weak_reference(__libc_system, __system);
+__weak_reference(__libc_system, _system);

Modified: stable/10/lib/libc/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/sys/Makefile.inc	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/sys/Makefile.inc	Sun Jan 18 11:54:20 2015	(r277317)
@@ -20,17 +20,61 @@ NOASM+=  clock_gettime.o gettimeofday.o
 PSEUDO+= _clock_gettime.o _gettimeofday.o
 
 # Sources common to both syscall interfaces:
-SRCS+=	stack_protector.c stack_protector_compat.c __error.c
+SRCS+=	\
+	stack_protector.c \
+	stack_protector_compat.c \
+	__error.c \
+	interposing_table.c
+
 .if !defined(WITHOUT_SYSCALL_COMPAT)
-SYSCALL_COMPAT_SRCS=	fcntl.c ftruncate.c lseek.c mmap.c pread.c \
-	pwrite.c truncate.c
+SYSCALL_COMPAT_SRCS= \
+	ftruncate.c \
+	lseek.c \
+	mmap.c \
+	pread.c \
+	pwrite.c \
+	truncate.c
 SRCS+=	${SYSCALL_COMPAT_SRCS}
 NOASM+=	${SYSCALL_COMPAT_SRCS:S/.c/.o/}
-PSEUDO+= _fcntl.o
 .endif
-SRCS+= sigwait.c
-NOASM+= sigwait.o
-PSEUDO+= _sigwait.o
+
+INTERPOSED = \
+	accept \
+	accept4 \
+	aio_suspend \
+	close \
+	connect \
+	fcntl \
+	fsync \
+	fork \
+	msync \
+	nanosleep \
+	open \
+	openat \
+	poll \
+	pselect \
+	read \
+	readv \
+	recvfrom \
+	recvmsg \
+	select \
+	sendmsg \
+	sendto \
+	setcontext \
+	sigaction \
+	sigprocmask \
+	sigsuspend \
+	sigtimedwait \
+	sigwait \
+	sigwaitinfo \
+	swapcontext \
+	wait4 \
+	write \
+	writev
+
+SRCS+=	${INTERPOSED:S/$/.c/}
+NOASM+=	${INTERPOSED:S/$/.o/}
+PSEUDO+=	${INTERPOSED:C/^.*$/_&.o/}
 
 # Add machine dependent asm sources:
 SRCS+=${MDASM}

Modified: stable/10/lib/libc/sys/Symbol.map
==============================================================================
--- stable/10/lib/libc/sys/Symbol.map	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/sys/Symbol.map	Sun Jan 18 11:54:20 2015	(r277317)
@@ -245,7 +245,6 @@ FBSD_1.0 {
 	setaudit;
 	setaudit_addr;
 	setauid;
-	setcontext;
 	setegid;
 	seteuid;
 	setgid;
@@ -286,7 +285,6 @@ FBSD_1.0 {
 	__stack_chk_guard;
 	stat;
 	statfs;
-	swapcontext;
 	swapoff;
 	swapon;
 	symlink;
@@ -351,7 +349,6 @@ FBSD_1.1 {
 	mkfifoat;
 	mknodat;
 	msgctl;
-	openat;
 	readlinkat;
 	renameat;
 	setfib;
@@ -1048,7 +1045,9 @@ FBSDprivate_1.0 {
 	__sys_write;
 	_writev;
 	__sys_writev;
-	__error_unthreaded;
+	__set_error_selector;
 	nlm_syscall;
 	gssd_syscall;
+	__libc_interposing_slot;
+	__libc_sigwait;
 };

Modified: stable/10/lib/libc/sys/__error.c
==============================================================================
--- stable/10/lib/libc/sys/__error.c	Sun Jan 18 10:53:48 2015	(r277316)
+++ stable/10/lib/libc/sys/__error.c	Sun Jan 18 11:54:20 2015	(r277317)
@@ -32,14 +32,25 @@ __FBSDID("$FreeBSD$");
 
 extern int errno;
 
-/*
- * Declare a weak reference in case the application is not linked
- * with libpthread.
- */
-__weak_reference(__error_unthreaded, __error);
+static int *
+__error_unthreaded(void)
+{
+
+	return (&errno);
+}
+
+static int *(*__error_selector)(void) = __error_unthreaded;
+
+void
+__set_error_selector(int *(*arg)(void))
+{
+
+	__error_selector = arg;
+}
 
 int *
-__error_unthreaded(void)
+__error(void)
 {
-	return(&errno);
+
+	return (__error_selector());
 }

Copied: stable/10/lib/libc/sys/accept.c (from r276630, head/lib/libc/sys/accept.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libc/sys/accept.c	Sun Jan 18 11:54:20 2015	(r277317, copy of r276630, head/lib/libc/sys/accept.c)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/socket.h>
+#include "libc_private.h"
+
+__weak_reference(__sys_accept, __accept);
+
+#pragma weak accept
+int
+accept(int s, struct sockaddr *addr, socklen_t *addrlen)
+{
+
+	return (((int (*)(int, struct sockaddr *, socklen_t *))
+	    __libc_interposing[INTERPOS_accept])(s, addr, addrlen));
+}

Copied: stable/10/lib/libc/sys/accept4.c (from r276630, head/lib/libc/sys/accept4.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libc/sys/accept4.c	Sun Jan 18 11:54:20 2015	(r277317, copy of r276630, head/lib/libc/sys/accept4.c)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/socket.h>
+#include "libc_private.h"
+
+__weak_reference(__sys_accept4, __accept4);
+
+#pragma weak accept4
+int
+accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
+{
+
+	return (((int (*)(int, struct sockaddr *, socklen_t *, int))
+	    __libc_interposing[INTERPOS_accept4])(s, addr, addrlen, flags));
+}

Copied: stable/10/lib/libc/sys/aio_suspend.c (from r276630, head/lib/libc/sys/aio_suspend.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libc/sys/aio_suspend.c	Sun Jan 18 11:54:20 2015	(r277317, copy of r276630, head/lib/libc/sys/aio_suspend.c)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/aio.h>
+#include "libc_private.h"
+
+__weak_reference(__sys_aio_suspend, __aio_suspend);
+
+#pragma weak aio_suspend
+int
+aio_suspend(const struct aiocb * const iocbs[], int niocb,
+    const struct timespec *timeout)
+{
+
+	return (((int (*)(const struct aiocb * const[], int,
+	    const struct timespec *))
+	    __libc_interposing[INTERPOS_aio_suspend])(iocbs, niocb, timeout));
+}

Copied: stable/10/lib/libc/sys/close.c (from r276630, head/lib/libc/sys/close.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libc/sys/close.c	Sun Jan 18 11:54:20 2015	(r277317, copy of r276630, head/lib/libc/sys/close.c)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include "libc_private.h"
+
+__weak_reference(__sys_close, __close);
+
+#pragma weak close
+int
+close(int fd)
+{
+
+	return (((int (*)(int))__libc_interposing[INTERPOS_close])(fd));
+}

Copied: stable/10/lib/libc/sys/connect.c (from r276630, head/lib/libc/sys/connect.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libc/sys/connect.c	Sun Jan 18 11:54:20 2015	(r277317, copy of r276630, head/lib/libc/sys/connect.c)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/socket.h>
+#include "libc_private.h"
+
+__weak_reference(__sys_connect, __connect);
+
+#pragma weak connect
+int
+connect(int s, const struct sockaddr *addr, socklen_t addrlen)
+{
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501181154.t0IBsLn0089798>