summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
committerdeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
commit1635c221b7b2678beeeb2b5fa728edd7c8c3735b (patch)
treed7d4f61b9e319a781a335702fe846592726c22b9 /lib/libc/gen
parent08685e9e9fd9de1e8dc51cada55659344adaf0cc (diff)
downloadFreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.zip
FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.tar.gz
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/Makefile.inc4
-rw-r--r--lib/libc/gen/_pthread_stubs.c131
-rw-r--r--lib/libc/gen/_spinlock_stub.c16
-rw-r--r--lib/libc/gen/_thread_init.c38
-rw-r--r--lib/libc/gen/arc4random.c2
-rw-r--r--lib/libc/gen/closedir.c12
-rw-r--r--lib/libc/gen/daemon.c8
-rw-r--r--lib/libc/gen/devname.c1
-rw-r--r--lib/libc/gen/disklabel.c1
-rw-r--r--lib/libc/gen/exec.c12
-rw-r--r--lib/libc/gen/fstab.c2
-rw-r--r--lib/libc/gen/fts-compat.c4
-rw-r--r--lib/libc/gen/fts.c4
-rw-r--r--lib/libc/gen/getcap.c5
-rw-r--r--lib/libc/gen/getcwd.c4
-rw-r--r--lib/libc/gen/getlogin.c23
-rw-r--r--lib/libc/gen/getpass.c6
-rw-r--r--lib/libc/gen/getpwent.c2
-rw-r--r--lib/libc/gen/getvfsent.c3
-rw-r--r--lib/libc/gen/isatty.c17
-rw-r--r--lib/libc/gen/lockf.c2
-rw-r--r--lib/libc/gen/nlist.c6
-rw-r--r--lib/libc/gen/opendir.c19
-rw-r--r--lib/libc/gen/pause.c4
-rw-r--r--lib/libc/gen/popen.c16
-rw-r--r--lib/libc/gen/posixshm.c4
-rw-r--r--lib/libc/gen/pselect.c8
-rw-r--r--lib/libc/gen/psignal.c2
-rw-r--r--lib/libc/gen/readdir.c56
-rw-r--r--lib/libc/gen/scandir.c6
-rw-r--r--lib/libc/gen/seekdir.c8
-rw-r--r--lib/libc/gen/setjmperr.c2
-rw-r--r--lib/libc/gen/setmode.c7
-rw-r--r--lib/libc/gen/siginterrupt.c9
-rw-r--r--lib/libc/gen/signal.c7
-rw-r--r--lib/libc/gen/sleep.c5
-rw-r--r--lib/libc/gen/syslog.c12
-rw-r--r--lib/libc/gen/telldir.c10
-rw-r--r--lib/libc/gen/telldir.h5
-rw-r--r--lib/libc/gen/termios.c31
-rw-r--r--lib/libc/gen/ttyname.c124
-rw-r--r--lib/libc/gen/usleep.c2
-rw-r--r--lib/libc/gen/vis.c1
-rw-r--r--lib/libc/gen/wait.c10
-rw-r--r--lib/libc/gen/wait3.c6
-rw-r--r--lib/libc/gen/waitpid.c14
46 files changed, 454 insertions, 217 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index afe8e91..3f7bbb4 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -4,8 +4,8 @@
# machine-independent gen sources
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen ${.CURDIR}/../libc/gen
-SRCS+= _rand48.c _spinlock_stub.c alarm.c arc4random.c assert.c \
- basename.c \
+SRCS+= _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \
+ alarm.c arc4random.c assert.c basename.c \
clock.c closedir.c confstr.c \
crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \
dlfcn.c drand48.c erand48.c err.c errlst.c \
diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c
new file mode 100644
index 0000000..87b0ad2
--- /dev/null
+++ b/lib/libc/gen/_pthread_stubs.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <pthread.h>
+
+/*
+ * Weak symbols: All libc internal usage of these functions should
+ * use the weak symbol versions (_pthread_XXX). If libpthread is
+ * linked, it will override these functions with (non-weak) routines.
+ * The _pthread_XXX functions are provided solely for internal libc
+ * usage to avoid unwanted cancellation points and to differentiate
+ * between application locks and libc locks (threads holding the
+ * latter can't be allowed to exit/terminate).
+ */
+#pragma weak _pthread_getspecific=_pthread_getspecific_stub
+#pragma weak _pthread_key_create=_pthread_key_create_stub
+#pragma weak _pthread_key_delete=_pthread_key_delete_stub
+#pragma weak _pthread_mutex_destroy=_pthread_mutex_destroy_stub
+#pragma weak _pthread_mutex_init=_pthread_mutex_init_stub
+#pragma weak _pthread_mutex_lock=_pthread_mutex_lock_stub
+#pragma weak _pthread_mutex_trylock=_pthread_mutex_trylock_stub
+#pragma weak _pthread_mutex_unlock=_pthread_mutex_unlock_stub
+#pragma weak _pthread_mutexattr_init=_pthread_mutexattr_init_stub
+#pragma weak _pthread_mutexattr_destroy=_pthread_mutexattr_destroy_stub
+#pragma weak _pthread_mutexattr_settype=_pthread_mutexattr_settype_stub
+#pragma weak _pthread_once=_pthread_once_stub
+#pragma weak _pthread_setspecific=_pthread_setspecific_stub
+
+
+void *
+_pthread_getspecific_stub(pthread_key_t key)
+{
+ return (NULL);
+}
+
+int
+_pthread_key_create_stub(pthread_key_t *key, void (*destructor) (void *))
+{
+ return (0);
+}
+
+int
+_pthread_key_delete_stub(pthread_key_t key)
+{
+ return (0);
+}
+
+int
+_pthread_mutex_destroy_stub(pthread_mutex_t *mattr)
+{
+ return (0);
+}
+
+int
+_pthread_mutex_init_stub(pthread_mutex_t *mutex, const pthread_mutexattr_t *mattr)
+{
+ return (0);
+}
+
+int
+_pthread_mutex_lock_stub(pthread_mutex_t *mutex)
+{
+ return (0);
+}
+
+int
+_pthread_mutex_trylock_stub(pthread_mutex_t *mutex)
+{
+ return (0);
+}
+
+int
+_pthread_mutex_unlock_stub(pthread_mutex_t *mutex)
+{
+ return (0);
+}
+
+int
+_pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr)
+{
+ return (0);
+}
+
+int
+_pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr)
+{
+ return (0);
+}
+
+int
+_pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr, int type)
+{
+ return (0);
+}
+
+int
+_pthread_once_stub(pthread_once_t *once_control, void (*init_routine) (void))
+{
+ return (0);
+}
+
+int
+_pthread_setspecific_stub(pthread_key_t key, const void *value)
+{
+ return (0);
+}
diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c
index e3a800d..071fc20 100644
--- a/lib/libc/gen/_spinlock_stub.c
+++ b/lib/libc/gen/_spinlock_stub.c
@@ -35,18 +35,27 @@
#include <stdio.h>
-/* Don't build these stubs into libc_r: */
-#ifndef _THREAD_SAFE
#include "spinlock.h"
/*
- * Declare weak references in case the application is not linked
+ * Declare weak definitions in case the application is not linked
* with libpthread.
*/
+#pragma weak _atomic_lock=_atomic_lock_stub
#pragma weak _spinlock=_spinlock_stub
#pragma weak _spinlock_debug=_spinlock_debug_stub
/*
+ * This function is a stub for the _atomic_lock function in libpthread.
+ */
+long
+_atomic_lock_stub(volatile long *lck)
+{
+ return (0L);
+}
+
+
+/*
* This function is a stub for the spinlock function in libpthread.
*/
void
@@ -61,4 +70,3 @@ void
_spinlock_debug_stub(spinlock_t *lck, char *fname, int lineno)
{
}
-#endif
diff --git a/lib/libc/gen/_thread_init.c b/lib/libc/gen/_thread_init.c
new file mode 100644
index 0000000..d6be5f2
--- /dev/null
+++ b/lib/libc/gen/_thread_init.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#pragma weak _thread_init=_thread_init_stub
+#pragma weak _thread_autoinit_dummy_decl=_thread_autoinit_dummy_decl_stub
+
+int _thread_autoinit_dummy_decl_stub = 0;
+
+void
+_thread_init_stub(void)
+{
+ /* This is just a stub; there is nothing to do. */
+}
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c
index c0569e5..ad063b8 100644
--- a/lib/libc/gen/arc4random.c
+++ b/lib/libc/gen/arc4random.c
@@ -25,11 +25,13 @@
* RC4 is a registered trademark of RSA Laboratories.
*/
+#include "namespace.h"
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
+#include "un-namespace.h"
struct arc4_stream {
u_int8_t i;
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index b1d0842..317bbf8 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -37,11 +37,15 @@
static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <dirent.h>
+#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
+#include "un-namespace.h"
+#include "libc_private.h"
#include "telldir.h"
/*
@@ -53,12 +57,18 @@ closedir(dirp)
{
int fd;
- seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */
+ if (__isthreaded)
+ _pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
+ _seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */
fd = dirp->dd_fd;
dirp->dd_fd = -1;
dirp->dd_loc = 0;
free((void *)dirp->dd_buf);
_reclaim_telldir(dirp);
+ if (__isthreaded) {
+ _pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
+ _pthread_mutex_destroy((pthread_mutex_t *)&dirp->dd_lock);
+ }
free((void *)dirp);
return(_close(fd));
}
diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c
index 4f6c2f3..6f1639f 100644
--- a/lib/libc/gen/daemon.c
+++ b/lib/libc/gen/daemon.c
@@ -37,9 +37,11 @@
static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
+#include "un-namespace.h"
int
daemon(nochdir, noclose)
@@ -63,9 +65,9 @@ daemon(nochdir, noclose)
(void)chdir("/");
if (!noclose && (fd = _open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
- (void)dup2(fd, STDIN_FILENO);
- (void)dup2(fd, STDOUT_FILENO);
- (void)dup2(fd, STDERR_FILENO);
+ (void)_dup2(fd, STDIN_FILENO);
+ (void)_dup2(fd, STDOUT_FILENO);
+ (void)_dup2(fd, STDERR_FILENO);
if (fd > 2)
(void)_close(fd);
}
diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c
index 69c51e3..f7532b1 100644
--- a/lib/libc/gen/devname.c
+++ b/lib/libc/gen/devname.c
@@ -42,7 +42,6 @@ static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
#include <db.h>
#include <err.h>
-#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c
index c7ac0b4..19c0d19 100644
--- a/lib/libc/gen/disklabel.c
+++ b/lib/libc/gen/disklabel.c
@@ -45,7 +45,6 @@ static const char rcsid[] =
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
-#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c
index 04bd2d2..51ee6ed 100644
--- a/lib/libc/gen/exec.c
+++ b/lib/libc/gen/exec.c
@@ -41,6 +41,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -56,6 +57,7 @@ static const char rcsid[] =
#else
#include <varargs.h>
#endif
+#include "un-namespace.h"
extern char **environ;
@@ -97,7 +99,7 @@ execl(name, arg, va_alist)
while ((argv[n] = va_arg(ap, char *)) != NULL)
n++;
va_end(ap);
- return (execve(name, argv, environ));
+ return (_execve(name, argv, environ));
}
int
@@ -139,7 +141,7 @@ execle(name, arg, va_alist)
n++;
envp = va_arg(ap, char **);
va_end(ap);
- return (execve(name, argv, envp));
+ return (_execve(name, argv, envp));
}
int
@@ -189,7 +191,7 @@ execv(name, argv)
const char *name;
char * const *argv;
{
- (void)execve(name, argv, environ);
+ (void)_execve(name, argv, environ);
return (-1);
}
@@ -260,7 +262,7 @@ execvp(name, argv)
bcopy(name, buf + lp + 1, ln);
buf[lp + ln + 1] = '\0';
-retry: (void)execve(bp, argv, environ);
+retry: (void)_execve(bp, argv, environ);
switch(errno) {
case E2BIG:
goto done;
@@ -279,7 +281,7 @@ retry: (void)execve(bp, argv, environ);
memp[0] = "sh";
memp[1] = bp;
bcopy(argv + 1, memp + 2, cnt * sizeof(char *));
- (void)execve(_PATH_BSHELL, memp, environ);
+ (void)_execve(_PATH_BSHELL, memp, environ);
goto done;
case ENOMEM:
goto done;
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index ecd79fb..9170ae9 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -42,6 +42,7 @@ static char rcsid[] =
#endif
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
@@ -53,6 +54,7 @@ static char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
static FILE *_fs_fp;
static struct fstab _fs_fstab;
diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c
index f38f24e..c6b09ff 100644
--- a/lib/libc/gen/fts-compat.c
+++ b/lib/libc/gen/fts-compat.c
@@ -43,6 +43,7 @@ static char rcsid[] = "$FreeBSD$";
#endif
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -53,6 +54,7 @@ static char rcsid[] = "$FreeBSD$";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
static FTSENT *fts_alloc __P((FTS *, char *, int));
static FTSENT *fts_build __P((FTS *, int));
@@ -1082,7 +1084,7 @@ fts_safe_changedir(sp, p, fd)
return (0);
if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
return (-1);
- if (fstat(newfd, &sb)) {
+ if (_fstat(newfd, &sb)) {
ret = -1;
goto bail;
}
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index f38f24e..c6b09ff 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -43,6 +43,7 @@ static char rcsid[] = "$FreeBSD$";
#endif
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -53,6 +54,7 @@ static char rcsid[] = "$FreeBSD$";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
static FTSENT *fts_alloc __P((FTS *, char *, int));
static FTSENT *fts_build __P((FTS *, int));
@@ -1082,7 +1084,7 @@ fts_safe_changedir(sp, p, fd)
return (0);
if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
return (-1);
- if (fstat(newfd, &sb)) {
+ if (_fstat(newfd, &sb)) {
ret = -1;
goto bail;
}
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index edb828b..4500062 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -40,10 +40,10 @@
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <ctype.h>
-#include <db.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -51,6 +51,9 @@ static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
+
+#include <db.h>
#define BFRAG 1024
#define BSIZE 1024
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index e2ea820..3655388 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -47,6 +48,7 @@ static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
#define ISDOT(dp) \
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
@@ -166,7 +168,7 @@ getcwd(pt, size)
*bup = '\0';
/* Open and stat parent directory. */
- if (!(dir = opendir(up)) || fstat(dirfd(dir), &s))
+ if (!(dir = opendir(up)) || _fstat(dirfd(dir), &s))
goto err;
/* Add trailing slash for next directory. */
diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c
index 5adc46c..10261ae 100644
--- a/lib/libc/gen/getlogin.c
+++ b/lib/libc/gen/getlogin.c
@@ -44,22 +44,19 @@ static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93";
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include "namespace.h"
+#include <pthread.h>
+#include "un-namespace.h"
#include <libc_private.h>
-#ifndef _THREAD_SAFE
-#define THREAD_LOCK()
-#define THREAD_UNLOCK()
-#else
-#include <pthread.h>
-#include "pthread_private.h"
-static struct pthread_mutex logname_lock = PTHREAD_MUTEX_STATIC_INITIALIZER;
-static pthread_mutex_t logname_mutex = &logname_lock;
-#define THREAD_LOCK() if (__isthreaded) pthread_mutex_lock(&logname_mutex)
-#define THREAD_UNLOCK() if (__isthreaded) pthread_mutex_unlock(&logname_mutex)
-#endif /* _THREAD_SAFE */
+#define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex)
+#define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex)
+
+extern int _getlogin(char *, int);
-int _logname_valid; /* known to setlogin() */
+int _logname_valid; /* known to setlogin() */
+static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER;
static char *
getlogin_basic(int *status)
@@ -68,7 +65,7 @@ getlogin_basic(int *status)
if (_logname_valid == 0) {
#ifdef __NETBSD_SYSCALLS
- if (__getlogin(logname, sizeof(logname) - 1) < 0) {
+ if (_getlogin(logname, sizeof(logname) - 1) < 0) {
#else
if (_getlogin(logname, sizeof(logname)) < 0) {
#endif
diff --git a/lib/libc/gen/getpass.c b/lib/libc/gen/getpass.c
index 60e92b7..f44cf17 100644
--- a/lib/libc/gen/getpass.c
+++ b/lib/libc/gen/getpass.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/termios.h>
#include <signal.h>
@@ -44,6 +45,7 @@ static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93";
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
+#include "un-namespace.h"
static struct termios oterm, term;
static FILE *fp;
@@ -74,7 +76,7 @@ getpass(prompt)
sigemptyset(&nset);
sigaddset(&nset, SIGINT);
sigaddset(&nset, SIGTSTP);
- (void)sigprocmask(SIG_BLOCK, &nset, &oset);
+ (void)_sigprocmask(SIG_BLOCK, &nset, &oset);
(void)tcgetattr(fileno(fp), &oterm);
term = oterm;
@@ -89,7 +91,7 @@ getpass(prompt)
(void)_write(fileno(outfp), "\n", 1);
(void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &oterm);
- (void)sigprocmask(SIG_SETMASK, &oset, NULL);
+ (void)_sigprocmask(SIG_SETMASK, &oset, NULL);
if (fp != stdin)
(void)fclose(fp);
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 38c90b4..f3bccd5 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -40,6 +40,7 @@ static const char *rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "un-namespace.h"
#include <sys/param.h>
#include <fcntl.h>
#include <db.h>
@@ -62,6 +63,7 @@ static const char *rcsid[] =
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#endif
+#include "un-namespace.h"
extern void setnetgrent __P((char *));
extern int getnetgrent __P((char **, char **, char **));
diff --git a/lib/libc/gen/getvfsent.c b/lib/libc/gen/getvfsent.c
index bf3ca20..2b8998c 100644
--- a/lib/libc/gen/getvfsent.c
+++ b/lib/libc/gen/getvfsent.c
@@ -2,6 +2,8 @@
* getvfsent.c - get a listing of installed filesystems
* Written September 1994 by Garrett A. Wollman
* This file is in the public domain.
+ *
+ * $FreeBSD$
*/
#include <sys/param.h>
@@ -14,7 +16,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#include <errno.h>
#include <paths.h>
/* XXX hide some compatibility problems. */
diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c
index f14f470..2339c3a 100644
--- a/lib/libc/gen/isatty.c
+++ b/lib/libc/gen/isatty.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -37,10 +39,6 @@ static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93";
#include <termios.h>
#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-#endif
int
isatty(fd)
@@ -49,15 +47,6 @@ isatty(fd)
int retval;
struct termios t;
-#ifdef _THREAD_SAFE
- if (_FD_LOCK(fd, FD_READ, NULL) == 0) {
-#endif
- retval = (tcgetattr(fd, &t) != -1);
-#ifdef _THREAD_SAFE
- _FD_UNLOCK(fd, FD_READ);
- } else {
- retval = 0;
- }
-#endif
+ retval = (tcgetattr(fd, &t) != -1);
return(retval);
}
diff --git a/lib/libc/gen/lockf.c b/lib/libc/gen/lockf.c
index 15b5b21..b881b11 100644
--- a/lib/libc/gen/lockf.c
+++ b/lib/libc/gen/lockf.c
@@ -43,9 +43,11 @@ static const char rcsid[]=
"$FreeBSD$";
#endif
+#include "namespace.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
+#include "un-namespace.h"
int
lockf(filedes, function, size)
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index f459067..ed0fd48 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -47,6 +48,7 @@ static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
#define _NLIST_DO_AOUT
#define _NLIST_DO_ELF
@@ -117,7 +119,7 @@ __aout_fdnlist(fd, list)
struct stat st;
/* check that file is at least as large as struct exec! */
- if ((fstat(fd, &st) < 0) || (st.st_size < sizeof(struct exec)))
+ if ((_fstat(fd, &st) < 0) || (st.st_size < sizeof(struct exec)))
return (-1);
/* Check for files too large to mmap. */
@@ -257,7 +259,7 @@ __elf_fdnlist(fd, list)
if (lseek(fd, (off_t)0, SEEK_SET) == -1 ||
_read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) ||
!__elf_is_okay__(&ehdr) ||
- fstat(fd, &st) < 0)
+ _fstat(fd, &st) < 0)
return (-1);
/* calculate section header table size */
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c
index bd7fc82..51d7090 100644
--- a/lib/libc/gen/opendir.c
+++ b/lib/libc/gen/opendir.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
@@ -46,9 +47,9 @@ static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95";
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
+#include "un-namespace.h"
#include "telldir.h"
-
/*
* Open a directory.
*/
@@ -56,7 +57,6 @@ DIR *
opendir(name)
const char *name;
{
-
return (__opendir2(name, DTF_HIDEW|DTF_NODUP));
}
@@ -73,8 +73,8 @@ __opendir2(name, flags)
struct stat statb;
/*
- * stat() before open() because opening of special files may be
- * harmful. fstat() after open because the file may have changed.
+ * stat() before _open() because opening of special files may be
+ * harmful. _fstat() after open because the file may have changed.
*/
if (stat(name, &statb) != 0)
return (NULL);
@@ -85,7 +85,7 @@ __opendir2(name, flags)
if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1)
return (NULL);
dirp = NULL;
- if (fstat(fd, &statb) != 0)
+ if (_fstat(fd, &statb) != 0)
goto fail;
if (!S_ISDIR(statb.st_mode)) {
errno = ENOTDIR;
@@ -102,7 +102,7 @@ __opendir2(name, flags)
/*
* Use the system page size if that is a multiple of DIRBLKSIZ.
* Hopefully this can be a big win someday by allowing page
- * trades to user space to be done by getdirentries().
+ * trades to user space to be done by _getdirentries().
*/
incr = getpagesize();
if ((incr % DIRBLKSIZ) != 0)
@@ -114,7 +114,7 @@ __opendir2(name, flags)
if (flags & DTF_NODUP) {
struct statfs sfb;
- if (fstatfs(fd, &sfb) < 0)
+ if (_fstatfs(fd, &sfb) < 0)
goto fail;
unionstack = !strcmp(sfb.f_fstypename, "union");
} else {
@@ -140,7 +140,7 @@ __opendir2(name, flags)
do {
/*
* Always make at least DIRBLKSIZ bytes
- * available to getdirentries
+ * available to _getdirentries
*/
if (space < DIRBLKSIZ) {
space += incr;
@@ -151,7 +151,7 @@ __opendir2(name, flags)
ddptr = buf + (len - space);
}
- n = getdirentries(fd, ddptr, space, &dirp->dd_seek);
+ n = _getdirentries(fd, ddptr, space, &dirp->dd_seek);
if (n > 0) {
ddptr += n;
space -= n;
@@ -265,6 +265,7 @@ __opendir2(name, flags)
dirp->dd_loc = 0;
dirp->dd_fd = fd;
dirp->dd_flags = flags;
+ dirp->dd_lock = NULL;
/*
* Set up seek point for rewinddir.
diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c
index f7ddb18..ca98a65 100644
--- a/lib/libc/gen/pause.c
+++ b/lib/libc/gen/pause.c
@@ -48,7 +48,5 @@ __pause()
{
return sigpause(sigblock(0L));
}
-
-#ifndef _THREAD_SAFE
__weak_reference(__pause, pause);
-#endif
+__weak_reference(__pause, _pause);
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c
index 7939b8f..2070f83 100644
--- a/lib/libc/gen/popen.c
+++ b/lib/libc/gen/popen.c
@@ -40,6 +40,7 @@
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/wait.h>
@@ -50,6 +51,7 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
#include <stdlib.h>
#include <string.h>
#include <paths.h>
+#include "un-namespace.h"
extern char **environ;
@@ -70,7 +72,7 @@ popen(command, type)
struct pid *p;
/*
- * Lite2 introduced two-way popen() pipes using socketpair().
+ * Lite2 introduced two-way popen() pipes using _socketpair().
* FreeBSD's pipe() is bidirectional, so we use that.
*/
if (strchr(type, '+')) {
@@ -105,7 +107,7 @@ popen(command, type)
case 0: /* Child. */
if (*type == 'r') {
/*
- * The dup2() to STDIN_FILENO is repeated to avoid
+ * The _dup2() to STDIN_FILENO is repeated to avoid
* writing to pdes[1], which might corrupt the
* parent's copy. This isn't good enough in
* general, since the _exit() is no return, so
@@ -114,15 +116,15 @@ popen(command, type)
*/
(void)_close(pdes[0]);
if (pdes[1] != STDOUT_FILENO) {
- (void)dup2(pdes[1], STDOUT_FILENO);
+ (void)_dup2(pdes[1], STDOUT_FILENO);
(void)_close(pdes[1]);
if (twoway)
- (void)dup2(STDOUT_FILENO, STDIN_FILENO);
+ (void)_dup2(STDOUT_FILENO, STDIN_FILENO);
} else if (twoway && (pdes[1] != STDIN_FILENO))
- (void)dup2(pdes[1], STDIN_FILENO);
+ (void)_dup2(pdes[1], STDIN_FILENO);
} else {
if (pdes[0] != STDIN_FILENO) {
- (void)dup2(pdes[0], STDIN_FILENO);
+ (void)_dup2(pdes[0], STDIN_FILENO);
(void)_close(pdes[0]);
}
(void)_close(pdes[1]);
@@ -130,7 +132,7 @@ popen(command, type)
for (p = pidlist; p; p = p->next) {
(void)_close(fileno(p->fp));
}
- execve(_PATH_BSHELL, argv, environ);
+ _execve(_PATH_BSHELL, argv, environ);
_exit(127);
/* NOTREACHED */
}
diff --git a/lib/libc/gen/posixshm.c b/lib/libc/gen/posixshm.c
index e437940..51713f2 100644
--- a/lib/libc/gen/posixshm.c
+++ b/lib/libc/gen/posixshm.c
@@ -29,6 +29,7 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
@@ -36,6 +37,7 @@
#include <errno.h>
#include <unistd.h>
+#include "un-namespace.h"
int
shm_open(const char *path, int flags, mode_t mode)
@@ -48,7 +50,7 @@ shm_open(const char *path, int flags, mode_t mode)
fd = _open(path, flags, mode);
if (fd != -1) {
- if (fstat(fd, &stab) != 0 || !S_ISREG(stab.st_mode)) {
+ if (_fstat(fd, &stab) != 0 || !S_ISREG(stab.st_mode)) {
_close(fd);
errno = EINVAL;
return (-1);
diff --git a/lib/libc/gen/pselect.c b/lib/libc/gen/pselect.c
index 02456e2..abf273f 100644
--- a/lib/libc/gen/pselect.c
+++ b/lib/libc/gen/pselect.c
@@ -29,11 +29,13 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <sys/select.h>
#include <sys/time.h>
#include <errno.h>
#include <signal.h>
+#include "un-namespace.h"
/*
* Emulate the POSIX 1003.1g-2000 `pselect' interface. This is the
@@ -56,15 +58,15 @@ pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
tvp = 0;
if (mask != 0) {
- rv = sigprocmask(SIG_SETMASK, mask, &omask);
+ rv = _sigprocmask(SIG_SETMASK, mask, &omask);
if (rv != 0)
return rv;
}
- rv = select(count, rfds, wfds, efds, tvp);
+ rv = _select(count, rfds, wfds, efds, tvp);
if (mask != 0) {
sverrno = errno;
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
+ _sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
errno = sverrno;
}
diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c
index 7c25476..e51c463 100644
--- a/lib/libc/gen/psignal.c
+++ b/lib/libc/gen/psignal.c
@@ -41,9 +41,11 @@ static char sccsid[] = "@(#)psignal.c 8.1 (Berkeley) 6/4/93";
* Print the name of the signal indicated
* along with the supplied message.
*/
+#include "namespace.h"
#include <signal.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
void
psignal(sig, s)
diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c
index 43c7bc2..9698415 100644
--- a/lib/libc/gen/readdir.c
+++ b/lib/libc/gen/readdir.c
@@ -38,20 +38,21 @@
static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>
-#ifdef _THREAD_SAFE
#include <pthread.h>
-#include "pthread_private.h"
-#endif /* _THREAD_SAFE */
+#include "un-namespace.h"
+
+#include "libc_private.h"
/*
* get next entry in a directory.
*/
struct dirent *
-readdir(dirp)
+_readdir_unlocked(dirp)
DIR *dirp;
{
struct dirent *dp;
@@ -63,7 +64,7 @@ readdir(dirp)
dirp->dd_loc = 0;
}
if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) {
- dirp->dd_size = getdirentries(dirp->dd_fd,
+ dirp->dd_size = _getdirentries(dirp->dd_fd,
dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
if (dirp->dd_size <= 0)
return (NULL);
@@ -83,6 +84,22 @@ readdir(dirp)
}
}
+struct dirent *
+readdir(dirp)
+ DIR *dirp;
+{
+ struct dirent *dp;
+
+ if (__isthreaded) {
+ _pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
+ dp = _readdir_unlocked(dirp);
+ _pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
+ }
+ else
+ dp = _readdir_unlocked(dirp);
+ return (dp);
+}
+
int
readdir_r(dirp, entry, result)
DIR *dirp;
@@ -91,34 +108,25 @@ readdir_r(dirp, entry, result)
{
struct dirent *dp;
int saved_errno;
-#ifdef _THREAD_SAFE
- int ret;
-
- if ((ret = _FD_LOCK(dirp->dd_fd, FD_READ, NULL)) != 0)
- return (ret);
-#endif
saved_errno = errno;
errno = 0;
- dp = readdir(dirp);
+ if (__isthreaded) {
+ _pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
+ if ((dp = _readdir_unlocked(dirp)) != NULL)
+ memcpy(entry, dp, sizeof *entry);
+ _pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
+ }
+ else if ((dp = _readdir_unlocked(dirp)) != NULL)
+ memcpy(entry, dp, sizeof *entry);
+
if (errno != 0) {
- if (dp == NULL) {
-#ifdef _THREAD_SAFE
- _FD_UNLOCK(dirp->dd_fd, FD_READ);
-#endif
+ if (dp == NULL)
return (errno);
- }
} else
errno = saved_errno;
if (dp != NULL)
- memcpy(entry, dp, sizeof *entry);
-
-#ifdef _THREAD_SAFE
- _FD_UNLOCK(dirp->dd_fd, FD_READ);
-#endif
-
- if (dp != NULL)
*result = entry;
else
*result = NULL;
diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c
index 5c64b29..59128c8 100644
--- a/lib/libc/gen/scandir.c
+++ b/lib/libc/gen/scandir.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -42,11 +44,13 @@ static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
* struct dirent (through namelist). Returns -1 if there were any errors.
*/
+#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
+#include "un-namespace.h"
/*
* The DIRSIZ macro is the minimum record length which will hold the directory
@@ -74,7 +78,7 @@ scandir(dirname, namelist, select, dcomp)
if ((dirp = opendir(dirname)) == NULL)
return(-1);
- if (fstat(dirp->dd_fd, &stb) < 0)
+ if (_fstat(dirp->dd_fd, &stb) < 0)
goto fail;
/*
diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c
index 8ce57d2..2057b98 100644
--- a/lib/libc/gen/seekdir.c
+++ b/lib/libc/gen/seekdir.c
@@ -37,9 +37,13 @@
static char sccsid[] = "@(#)seekdir.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <dirent.h>
+#include <pthread.h>
+#include "un-namespace.h"
+#include "libc_private.h"
#include "telldir.h"
/*
@@ -51,5 +55,9 @@ seekdir(dirp, loc)
DIR *dirp;
long loc;
{
+ if (__isthreaded)
+ _pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
_seekdir(dirp, loc);
+ if (__isthreaded)
+ _pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
}
diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c
index e9b5d45..fd69cdb 100644
--- a/lib/libc/gen/setjmperr.c
+++ b/lib/libc/gen/setjmperr.c
@@ -44,8 +44,10 @@ static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93";
* If this routine returns, the program is aborted.
*/
+#include "namespace.h"
#include <setjmp.h>
#include <unistd.h>
+#include "un-namespace.h"
void
longjmperror()
diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c
index 2c12b81..f05607f 100644
--- a/lib/libc/gen/setmode.c
+++ b/lib/libc/gen/setmode.c
@@ -42,11 +42,11 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
-#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <stdlib.h>
@@ -54,6 +54,7 @@ static const char rcsid[] =
#ifdef SETMODE_DEBUG
#include <stdio.h>
#endif
+#include "un-namespace.h"
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
@@ -188,10 +189,10 @@ setmode(p)
* as best we can.
*/
sigfillset(&sigset);
- (void)sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+ (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset);
(void)umask(mask = umask(0));
mask = ~mask;
- (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+ (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL);
setlen = SET_LEN + 2;
diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c
index 06960ab..245d738 100644
--- a/lib/libc/gen/siginterrupt.c
+++ b/lib/libc/gen/siginterrupt.c
@@ -29,13 +29,18 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <signal.h>
+#include "un-namespace.h"
+#include "libc_private.h"
/*
* Set signal state to prevent restart of system calls
@@ -49,7 +54,7 @@ siginterrupt(sig, flag)
struct sigaction sa;
int ret;
- if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0)
+ if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0)
return (ret);
if (flag) {
sigaddset(&_sigintr, sig);
@@ -58,5 +63,5 @@ siginterrupt(sig, flag)
sigdelset(&_sigintr, sig);
sa.sa_flags |= SA_RESTART;
}
- return (sigaction(sig, &sa, (struct sigaction *)0));
+ return (_sigaction(sig, &sa, (struct sigaction *)0));
}
diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c
index c4057f5..5b3d71a 100644
--- a/lib/libc/gen/signal.c
+++ b/lib/libc/gen/signal.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -38,7 +40,10 @@ static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93";
/*
* Almost backwards compatible signal.
*/
+#include "namespace.h"
#include <signal.h>
+#include "un-namespace.h"
+#include "libc_private.h"
sigset_t _sigintr; /* shared with siginterrupt */
@@ -54,7 +59,7 @@ signal(s, a)
sa.sa_flags = 0;
if (!sigismember(&_sigintr, s))
sa.sa_flags |= SA_RESTART;
- if (sigaction(s, &sa, &osa) < 0)
+ if (_sigaction(s, &sa, &osa) < 0)
return (SIG_ERR);
return (osa.sa_handler);
}
diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c
index e4c4fbd..701eccd 100644
--- a/lib/libc/gen/sleep.c
+++ b/lib/libc/gen/sleep.c
@@ -39,10 +39,12 @@ static char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <errno.h>
#include <limits.h>
#include <time.h>
#include <unistd.h>
+#include "un-namespace.h"
unsigned int
__sleep(seconds)
@@ -68,6 +70,5 @@ __sleep(seconds)
(time_remaining.tv_nsec != 0)); /* round up */
}
-#ifndef _THREAD_SAFE
__weak_reference(__sleep, sleep);
-#endif
+__weak_reference(__sleep, _sleep);
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 18d00d7..d3326ed 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -39,6 +39,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/syslog.h>
@@ -59,6 +60,7 @@ static const char rcsid[] =
#else
#include <varargs.h>
#endif
+#include "un-namespace.h"
static int LogFile = -1; /* fd for log */
static int connected; /* have done connect */
@@ -235,7 +237,7 @@ vsyslog(pri, fmt, ap)
++v;
v->iov_base = "\n";
v->iov_len = 1;
- (void)writev(STDERR_FILENO, iov, 2);
+ (void)_writev(STDERR_FILENO, iov, 2);
}
/* Get connected, output the message to the local logger. */
@@ -270,7 +272,7 @@ vsyslog(pri, fmt, ap)
++v;
v->iov_base = "\r\n";
v->iov_len = 2;
- (void)writev(fd, iov, 2);
+ (void)_writev(fd, iov, 2);
(void)_close(fd);
}
}
@@ -295,7 +297,7 @@ connectlog()
struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */
if (LogFile == -1) {
- if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
+ if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
return;
(void)_fcntl(LogFile, F_SETFD, 1);
}
@@ -304,7 +306,7 @@ connectlog()
SyslogAddr.sun_family = AF_UNIX;
(void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
sizeof SyslogAddr.sun_path);
- connected = connect(LogFile, (struct sockaddr *)&SyslogAddr,
+ connected = _connect(LogFile, (struct sockaddr *)&SyslogAddr,
sizeof(SyslogAddr)) != -1;
if (!connected) {
@@ -314,7 +316,7 @@ connectlog()
*/
(void)strncpy(SyslogAddr.sun_path, _PATH_OLDLOG,
sizeof SyslogAddr.sun_path);
- connected = connect(LogFile,
+ connected = _connect(LogFile,
(struct sockaddr *)&SyslogAddr,
sizeof(SyslogAddr)) != -1;
}
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index 3c4b781..6661c23 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -37,12 +37,16 @@
static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/queue.h>
#include <dirent.h>
+#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
+#include "un-namespace.h"
+#include "libc_private.h"
#include "telldir.h"
/*
@@ -63,10 +67,14 @@ telldir(dirp)
if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL)
return (-1);
+ if (__isthreaded)
+ _pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
lp->loc_index = dirp->dd_td->td_loccnt++;
lp->loc_seek = dirp->dd_seek;
lp->loc_loc = dirp->dd_loc;
LIST_INSERT_HEAD(&dirp->dd_td->td_locq, lp, loc_lqe);
+ if (__isthreaded)
+ _pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
return (lp->loc_index);
}
@@ -94,7 +102,7 @@ _seekdir(dirp, loc)
dirp->dd_seek = lp->loc_seek;
dirp->dd_loc = 0;
while (dirp->dd_loc < lp->loc_loc) {
- dp = readdir(dirp);
+ dp = _readdir_unlocked(dirp);
if (dp == NULL)
break;
}
diff --git a/lib/libc/gen/telldir.h b/lib/libc/gen/telldir.h
index be8a9f5..4fb4cb6 100644
--- a/lib/libc/gen/telldir.h
+++ b/lib/libc/gen/telldir.h
@@ -59,7 +59,8 @@ struct _telldir {
long td_loccnt; /* index of entry for sequential readdir's */
};
-void _reclaim_telldir __P((DIR *));
-void _seekdir __P((DIR *, long));
+struct dirent *_readdir_unlocked(DIR *);
+void _reclaim_telldir(DIR *);
+void _seekdir(DIR *, long);
#endif
diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c
index f321876..b262305 100644
--- a/lib/libc/gen/termios.c
+++ b/lib/libc/gen/termios.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
@@ -45,6 +46,7 @@ static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#include <errno.h>
#include <termios.h>
#include <unistd.h>
+#include "un-namespace.h"
int
tcgetattr(fd, t)
@@ -52,7 +54,7 @@ tcgetattr(fd, t)
struct termios *t;
{
- return (ioctl(fd, TIOCGETA, t));
+ return (_ioctl(fd, TIOCGETA, t));
}
int
@@ -69,11 +71,11 @@ tcsetattr(fd, opt, t)
}
switch (opt & ~TCSASOFT) {
case TCSANOW:
- return (ioctl(fd, TIOCSETA, t));
+ return (_ioctl(fd, TIOCSETA, t));
case TCSADRAIN:
- return (ioctl(fd, TIOCSETAW, t));
+ return (_ioctl(fd, TIOCSETAW, t));
case TCSAFLUSH:
- return (ioctl(fd, TIOCSETAF, t));
+ return (_ioctl(fd, TIOCSETAF, t));
default:
errno = EINVAL;
return (-1);
@@ -92,7 +94,7 @@ tcsetpgrp(fd, pgrp)
int s;
s = pgrp;
- return (ioctl(fd, TIOCSPGRP, &s));
+ return (_ioctl(fd, TIOCSPGRP, &s));
}
pid_t
@@ -101,7 +103,7 @@ tcgetpgrp(fd)
{
int s;
- if (ioctl(fd, TIOCGPGRP, &s) < 0)
+ if (_ioctl(fd, TIOCGPGRP, &s) < 0)
return ((pid_t)-1);
return ((pid_t)s);
@@ -180,10 +182,10 @@ tcsendbreak(fd, len)
sleepytime.tv_sec = 0;
sleepytime.tv_usec = 400000;
- if (ioctl(fd, TIOCSBRK, 0) == -1)
+ if (_ioctl(fd, TIOCSBRK, 0) == -1)
return (-1);
- (void)select(0, 0, 0, 0, &sleepytime);
- if (ioctl(fd, TIOCCBRK, 0) == -1)
+ (void)_select(0, 0, 0, 0, &sleepytime);
+ if (_ioctl(fd, TIOCCBRK, 0) == -1)
return (-1);
return (0);
}
@@ -192,12 +194,11 @@ int
__tcdrain(fd)
int fd;
{
- return (ioctl(fd, TIOCDRAIN, 0));
+ return (_ioctl(fd, TIOCDRAIN, 0));
}
-#ifndef _THREAD_SAFE
__weak_reference(__tcdrain, tcdrain);
-#endif
+__weak_reference(__tcdrain, _tcdrain);
int
tcflush(fd, which)
@@ -219,7 +220,7 @@ tcflush(fd, which)
errno = EINVAL;
return (-1);
}
- return (ioctl(fd, TIOCFLUSH, &com));
+ return (_ioctl(fd, TIOCFLUSH, &com));
}
int
@@ -231,9 +232,9 @@ tcflow(fd, action)
switch (action) {
case TCOOFF:
- return (ioctl(fd, TIOCSTOP, 0));
+ return (_ioctl(fd, TIOCSTOP, 0));
case TCOON:
- return (ioctl(fd, TIOCSTART, 0));
+ return (_ioctl(fd, TIOCSTART, 0));
case TCION:
case TCIOFF:
if (tcgetattr(fd, &term) == -1)
diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c
index cb01870..55fc918 100644
--- a/lib/libc/gen/ttyname.c
+++ b/lib/libc/gen/ttyname.c
@@ -29,12 +29,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -42,42 +45,44 @@ static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
-#include <db.h>
#include <string.h>
#include <paths.h>
-
-#ifdef _THREAD_SAFE
#include <pthread.h>
-#include "pthread_private.h"
-static struct pthread_mutex _ttyname_lockd = PTHREAD_MUTEX_STATIC_INITIALIZER;
-static pthread_mutex_t ttyname_lock = &_ttyname_lockd;
-static pthread_key_t ttyname_key;
-static int ttyname_init = 0;
+#include "un-namespace.h"
+
+#include <db.h>
+#include "libc_private.h"
+
+static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
+static char *oldttyname __P((int, struct stat *));
+static char *ttyname_threaded(int fd);
+static char *ttyname_unthreaded(int fd);
-char *
+static pthread_mutex_t ttyname_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_key_t ttyname_key;
+static int ttyname_init = 0;
+
+char *
ttyname(int fd)
{
char *ret;
- if (_FD_LOCK(fd, FD_READ, NULL) == 0) {
- ret = __ttyname_basic(fd);
- _FD_UNLOCK(fd, FD_READ);
- } else {
- ret = NULL;
- }
-
+ if (__isthreaded == 0)
+ ret = ttyname_unthreaded(fd);
+ else
+ ret = ttyname_threaded(fd);
return (ret);
}
-char *
-__ttyname_r_basic(int fd, char *buf, size_t len)
+char *
+ttyname_r(int fd, char *buf, size_t len)
{
- register struct dirent *dirp;
- register DIR *dp;
- struct stat dsb;
- struct stat sb;
- char *rval;
- int minlen;
+ struct dirent *dirp;
+ DIR *dp;
+ struct stat dsb;
+ struct stat sb;
+ char *rval;
+ int minlen;
rval = NULL;
@@ -85,7 +90,7 @@ __ttyname_r_basic(int fd, char *buf, size_t len)
if (!isatty(fd))
return (rval);
/* Must be a character device. */
- if (_thread_sys_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
+ if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
return (rval);
/* Must have enough room */
if (len <= sizeof(_PATH_DEV))
@@ -110,25 +115,27 @@ __ttyname_r_basic(int fd, char *buf, size_t len)
return (rval);
}
-char *
-__ttyname_basic(int fd)
+static char *
+ttyname_threaded(int fd)
{
- char *buf;
+ char *buf;
- pthread_mutex_lock(&ttyname_lock);
if (ttyname_init == 0) {
- if (pthread_key_create(&ttyname_key, free)) {
- pthread_mutex_unlock(&ttyname_lock);
- return (NULL);
+ _pthread_mutex_lock(&ttyname_lock);
+ if (ttyname_init == 0) {
+ if (_pthread_key_create(&ttyname_key, free)) {
+ _pthread_mutex_unlock(&ttyname_lock);
+ return (NULL);
+ }
+ ttyname_init = 1;
}
- ttyname_init = 1;
+ _pthread_mutex_unlock(&ttyname_lock);
}
- pthread_mutex_unlock(&ttyname_lock);
/* Must have thread specific data field to put data */
- if ((buf = pthread_getspecific(ttyname_key)) == NULL) {
+ if ((buf = _pthread_getspecific(ttyname_key)) == NULL) {
if ((buf = malloc(sizeof(_PATH_DEV) + MAXNAMLEN)) != NULL) {
- if (pthread_setspecific(ttyname_key, buf) != 0) {
+ if (_pthread_setspecific(ttyname_key, buf) != 0) {
free(buf);
return (NULL);
}
@@ -136,34 +143,16 @@ __ttyname_basic(int fd)
return (NULL);
}
}
- return (__ttyname_r_basic(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN));
+ return (ttyname_r(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN));
}
-char *
-ttyname_r(int fd, char *buf, size_t len)
-{
- char *ret;
-
- if (_FD_LOCK(fd, FD_READ, NULL) == 0) {
- ret = __ttyname_r_basic(fd, buf, len);
- _FD_UNLOCK(fd, FD_READ);
- } else {
- ret = NULL;
- }
- return (ret);
-}
-#else
-static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
-static char *oldttyname __P((int, struct stat *));
-
-char *
-ttyname(fd)
- int fd;
+static char *
+ttyname_unthreaded(int fd)
{
- struct stat sb;
- struct termios ttyb;
- DB *db;
- DBT data, key;
+ struct stat sb;
+ struct termios ttyb;
+ DB *db;
+ DBT data, key;
struct {
mode_t type;
dev_t dev;
@@ -173,7 +162,7 @@ ttyname(fd)
if (tcgetattr(fd, &ttyb) < 0)
return (NULL);
/* Must be a character device. */
- if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
+ if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
return (NULL);
if ( (db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)) ) {
@@ -194,13 +183,11 @@ ttyname(fd)
}
static char *
-oldttyname(fd, sb)
- int fd;
- struct stat *sb;
+oldttyname(int fd, struct stat *sb)
{
- register struct dirent *dirp;
- register DIR *dp;
- struct stat dsb;
+ struct dirent *dirp;
+ struct stat dsb;
+ DIR *dp;
if ((dp = opendir(_PATH_DEV)) == NULL)
return (NULL);
@@ -219,4 +206,3 @@ oldttyname(fd, sb)
(void)closedir(dp);
return (NULL);
}
-#endif
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c
index 651edf9..647b5c0 100644
--- a/lib/libc/gen/usleep.c
+++ b/lib/libc/gen/usleep.c
@@ -39,8 +39,10 @@ static char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <time.h>
#include <unistd.h>
+#include "un-namespace.h"
int
usleep(useconds)
diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c
index 7f10aa5..35f24bf 100644
--- a/lib/libc/gen/vis.c
+++ b/lib/libc/gen/vis.c
@@ -40,6 +40,7 @@ static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 7/19/93";
#include <sys/types.h>
#include <limits.h>
#include <ctype.h>
+#include <stdio.h>
#include <vis.h>
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c
index 366e262..baba6cd 100644
--- a/lib/libc/gen/wait.c
+++ b/lib/libc/gen/wait.c
@@ -37,18 +37,18 @@
static char sccsid[] = "@(#)wait.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#include "un-namespace.h"
pid_t
-__wait(istat)
- int *istat;
+__wait(int *istat)
{
- return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
+ return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
}
-#ifndef _THREAD_SAFE
__weak_reference(__wait, wait);
-#endif
+__weak_reference(__wait, _wait);
diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c
index c8d8f9e..21623d4 100644
--- a/lib/libc/gen/wait3.c
+++ b/lib/libc/gen/wait3.c
@@ -29,16 +29,20 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)wait3.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#include "un-namespace.h"
pid_t
wait3(istat, options, rup)
@@ -46,5 +50,5 @@ wait3(istat, options, rup)
int options;
struct rusage *rup;
{
- return (wait4(WAIT_ANY, istat, options, rup));
+ return (_wait4(WAIT_ANY, istat, options, rup));
}
diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c
index 350157a..fbdf16b 100644
--- a/lib/libc/gen/waitpid.c
+++ b/lib/libc/gen/waitpid.c
@@ -37,24 +37,18 @@
static char sccsid[] = "@(#)waitpid.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#include "un-namespace.h"
pid_t
-#if __STDC__
__waitpid(pid_t pid, int *istat, int options)
-#else
-__waitpid(pid, istat, options)
- pid_t pid;
- int *istat;
- int options;
-#endif
{
- return (wait4(pid, istat, options, (struct rusage *)0));
+ return (_wait4(pid, istat, options, (struct rusage *)0));
}
-#ifndef _THREAD_SAFE
__weak_reference(__waitpid, waitpid);
-#endif
+__weak_reference(__waitpid, _waitpid);
OpenPOWER on IntegriCloud