summaryrefslogtreecommitdiffstats
path: root/lib/libc_r
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2000-01-27 23:07:25 +0000
committerjasone <jasone@FreeBSD.org>2000-01-27 23:07:25 +0000
commit8abe2a2d86ee5f72093b3feeabf05c9f6f963576 (patch)
tree2ebe01199c17764ebcd26435b5ce1c06ebb67ad5 /lib/libc_r
parent1731b249ccd9d7586d511eda8756f5c6b57b871c (diff)
downloadFreeBSD-src-8abe2a2d86ee5f72093b3feeabf05c9f6f963576.zip
FreeBSD-src-8abe2a2d86ee5f72093b3feeabf05c9f6f963576.tar.gz
Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/Makefile2
-rw-r--r--lib/libc_r/uthread/Makefile.inc8
-rw-r--r--lib/libc_r/uthread/uthread_accept.c4
-rw-r--r--lib/libc_r/uthread/uthread_aio_suspend.c51
-rw-r--r--lib/libc_r/uthread/uthread_bind.c4
-rw-r--r--lib/libc_r/uthread/uthread_close.c17
-rw-r--r--lib/libc_r/uthread/uthread_cond.c9
-rw-r--r--lib/libc_r/uthread/uthread_connect.c4
-rw-r--r--lib/libc_r/uthread/uthread_creat.c48
-rw-r--r--lib/libc_r/uthread/uthread_dup.c4
-rw-r--r--lib/libc_r/uthread/uthread_dup2.c4
-rw-r--r--lib/libc_r/uthread/uthread_execve.c4
-rw-r--r--lib/libc_r/uthread/uthread_exit.c4
-rw-r--r--lib/libc_r/uthread/uthread_fchflags.c4
-rw-r--r--lib/libc_r/uthread/uthread_fchmod.c4
-rw-r--r--lib/libc_r/uthread/uthread_fchown.c4
-rw-r--r--lib/libc_r/uthread/uthread_fcntl.c35
-rw-r--r--lib/libc_r/uthread/uthread_flock.c4
-rw-r--r--lib/libc_r/uthread/uthread_fork.c4
-rw-r--r--lib/libc_r/uthread/uthread_fstat.c4
-rw-r--r--lib/libc_r/uthread/uthread_fstatfs.c4
-rw-r--r--lib/libc_r/uthread/uthread_fsync.c18
-rw-r--r--lib/libc_r/uthread/uthread_getdirentries.c4
-rw-r--r--lib/libc_r/uthread/uthread_getpeername.c4
-rw-r--r--lib/libc_r/uthread/uthread_getsockname.c4
-rw-r--r--lib/libc_r/uthread/uthread_getsockopt.c4
-rw-r--r--lib/libc_r/uthread/uthread_ioctl.c4
-rw-r--r--lib/libc_r/uthread/uthread_listen.c4
-rw-r--r--lib/libc_r/uthread/uthread_msync.c26
-rw-r--r--lib/libc_r/uthread/uthread_nanosleep.c17
-rw-r--r--lib/libc_r/uthread/uthread_open.c29
-rw-r--r--lib/libc_r/uthread/uthread_pause.c48
-rw-r--r--lib/libc_r/uthread/uthread_pipe.c4
-rw-r--r--lib/libc_r/uthread/uthread_poll.c4
-rw-r--r--lib/libc_r/uthread/uthread_read.c19
-rw-r--r--lib/libc_r/uthread/uthread_readv.c4
-rw-r--r--lib/libc_r/uthread/uthread_recvfrom.c4
-rw-r--r--lib/libc_r/uthread/uthread_recvmsg.c4
-rw-r--r--lib/libc_r/uthread/uthread_select.c6
-rw-r--r--lib/libc_r/uthread/uthread_sem.c3
-rw-r--r--lib/libc_r/uthread/uthread_sendmsg.c4
-rw-r--r--lib/libc_r/uthread/uthread_sendto.c4
-rw-r--r--lib/libc_r/uthread/uthread_setsockopt.c4
-rw-r--r--lib/libc_r/uthread/uthread_shutdown.c4
-rw-r--r--lib/libc_r/uthread/uthread_sigaction.c4
-rw-r--r--lib/libc_r/uthread/uthread_sigpending.c4
-rw-r--r--lib/libc_r/uthread/uthread_sigprocmask.c4
-rw-r--r--lib/libc_r/uthread/uthread_sigsuspend.c14
-rw-r--r--lib/libc_r/uthread/uthread_sigwait.c1
-rw-r--r--lib/libc_r/uthread/uthread_sleep.c48
-rw-r--r--lib/libc_r/uthread/uthread_socket.c4
-rw-r--r--lib/libc_r/uthread/uthread_socketpair.c4
-rw-r--r--lib/libc_r/uthread/uthread_spinlock.c2
-rw-r--r--lib/libc_r/uthread/uthread_system.c48
-rw-r--r--lib/libc_r/uthread/uthread_tcdrain.c48
-rw-r--r--lib/libc_r/uthread/uthread_wait.c47
-rw-r--r--lib/libc_r/uthread/uthread_wait4.c6
-rw-r--r--lib/libc_r/uthread/uthread_waitpid.c49
-rw-r--r--lib/libc_r/uthread/uthread_write.c21
-rw-r--r--lib/libc_r/uthread/uthread_writev.c4
60 files changed, 625 insertions, 135 deletions
diff --git a/lib/libc_r/Makefile b/lib/libc_r/Makefile
index e79d5c5..1b0afbb 100644
--- a/lib/libc_r/Makefile
+++ b/lib/libc_r/Makefile
@@ -26,7 +26,7 @@ PRECIOUSLIB= yes
# This is a list of syscalls that are renamed as _thread_sys_{syscall}
# so that libc_r can provide replacement functions.
#
-HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \
+HIDDEN_SYSCALLS= aio_suspend.o accept.o bind.o close.o connect.o dup.o dup2.o \
execve.o fchflags.o fchmod.o fchown.o fcntl.o \
flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \
diff --git a/lib/libc_r/uthread/Makefile.inc b/lib/libc_r/uthread/Makefile.inc
index 2a13365..a88f955 100644
--- a/lib/libc_r/uthread/Makefile.inc
+++ b/lib/libc_r/uthread/Makefile.inc
@@ -5,6 +5,7 @@
SRCS+= \
uthread_accept.c \
+ uthread_aio_suspend.c \
uthread_attr_destroy.c \
uthread_attr_init.c \
uthread_attr_getdetachstate.c \
@@ -31,6 +32,7 @@ SRCS+= \
uthread_condattr_destroy.c \
uthread_condattr_init.c \
uthread_connect.c \
+ uthread_creat.c \
uthread_create.c \
uthread_detach.c \
uthread_dup.c \
@@ -76,6 +78,7 @@ SRCS+= \
uthread_nanosleep.c \
uthread_once.c \
uthread_open.c \
+ uthread_pause.c \
uthread_pipe.c \
uthread_poll.c \
uthread_priority_queue.c \
@@ -106,14 +109,19 @@ SRCS+= \
uthread_sigsuspend.c \
uthread_sigwait.c \
uthread_single_np.c \
+ uthread_sleep.c \
uthread_socket.c \
uthread_socketpair.c \
uthread_spec.c \
uthread_spinlock.c \
uthread_suspend_np.c \
uthread_switch_np.c \
+ uthread_system.c \
+ uthread_tcdrain.c \
uthread_vfork.c \
+ uthread_wait.c \
uthread_wait4.c \
+ uthread_waitpid.c \
uthread_write.c \
uthread_writev.c \
uthread_yield.c
diff --git a/lib/libc_r/uthread/uthread_accept.c b/lib/libc_r/uthread/uthread_accept.c
index 9d1bcd8..3fc481c 100644
--- a/lib/libc_r/uthread/uthread_accept.c
+++ b/lib/libc_r/uthread/uthread_accept.c
@@ -41,7 +41,7 @@
#include "pthread_private.h"
int
-_libc_accept(int fd, struct sockaddr * name, socklen_t *namelen)
+_accept(int fd, struct sockaddr * name, socklen_t *namelen)
{
int ret;
@@ -107,5 +107,5 @@ _libc_accept(int fd, struct sockaddr * name, socklen_t *namelen)
return (ret);
}
-__weak_reference(_libc_accept, accept);
+__weak_reference(_accept, accept);
#endif
diff --git a/lib/libc_r/uthread/uthread_aio_suspend.c b/lib/libc_r/uthread/uthread_aio_suspend.c
new file mode 100644
index 0000000..3bc373a
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_aio_suspend.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <aio.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+int
+_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
+ timespec *timeout)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = _aio_suspend(iocbs, niocb, timeout);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+
+__weak_reference(_aio_suspend, aio_suspend);
+#endif
diff --git a/lib/libc_r/uthread/uthread_bind.c b/lib/libc_r/uthread/uthread_bind.c
index 7cb3028..cf9b074 100644
--- a/lib/libc_r/uthread/uthread_bind.c
+++ b/lib/libc_r/uthread/uthread_bind.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_bind(int fd, const struct sockaddr * name, socklen_t namelen)
+_bind(int fd, const struct sockaddr * name, socklen_t namelen)
{
int ret;
@@ -49,5 +49,5 @@ _libc_bind(int fd, const struct sockaddr * name, socklen_t namelen)
return (ret);
}
-__weak_reference(_libc_bind, bind);
+__weak_reference(_bind, bind);
#endif
diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c
index fe2d9e2..9dee2bc 100644
--- a/lib/libc_r/uthread/uthread_close.c
+++ b/lib/libc_r/uthread/uthread_close.c
@@ -41,15 +41,13 @@
#include "pthread_private.h"
int
-_libc_close(int fd)
+_close(int fd)
{
int flags;
int ret;
struct stat sb;
struct fd_table_entry *entry;
- _thread_enter_cancellation_point();
-
if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) {
/*
* Don't allow silly programs to close the kernel pipe.
@@ -99,9 +97,18 @@ _libc_close(int fd)
/* Close the file descriptor: */
ret = _thread_sys_close(fd);
}
- _thread_leave_cancellation_point();
return (ret);
}
-__weak_reference(_libc_close, close);
+int
+close(int fd)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = _close(fd);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c
index ced48e3..d236607 100644
--- a/lib/libc_r/uthread/uthread_cond.c
+++ b/lib/libc_r/uthread/uthread_cond.c
@@ -160,6 +160,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
int rval = 0;
int interrupted = 0;
+ _thread_enter_cancellation_point();
+
if (cond == NULL)
rval = EINVAL;
@@ -286,6 +288,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
_thread_leave_cancellation_point();
}
+ _thread_leave_cancellation_point();
+
/* Return the completion status: */
return (rval);
}
@@ -297,12 +301,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int interrupted = 0;
+ _thread_enter_cancellation_point();
+
if (cond == NULL || abstime == NULL)
rval = EINVAL;
if (abstime->tv_sec < 0 ||
abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
errno = EINVAL;
+ _thread_leave_cancellation_point();
return (-1);
}
@@ -448,6 +455,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
_thread_leave_cancellation_point();
}
+ _thread_leave_cancellation_point();
+
/* Return the completion status: */
return (rval);
}
diff --git a/lib/libc_r/uthread/uthread_connect.c b/lib/libc_r/uthread/uthread_connect.c
index 03fea27..4e3ed5c 100644
--- a/lib/libc_r/uthread/uthread_connect.c
+++ b/lib/libc_r/uthread/uthread_connect.c
@@ -40,7 +40,7 @@
#include "pthread_private.h"
int
-_libc_connect(int fd, const struct sockaddr * name, socklen_t namelen)
+_connect(int fd, const struct sockaddr * name, socklen_t namelen)
{
struct sockaddr tmpname;
int errnolen, ret, tmpnamelen;
@@ -76,5 +76,5 @@ _libc_connect(int fd, const struct sockaddr * name, socklen_t namelen)
return (ret);
}
-__weak_reference(_libc_connect, connect);
+__weak_reference(_connect, connect);
#endif
diff --git a/lib/libc_r/uthread/uthread_creat.c b/lib/libc_r/uthread/uthread_creat.c
new file mode 100644
index 0000000..bb8e7c2
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_creat.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <fcntl.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+int
+creat(const char *path, mode_t mode)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = __creat(path, mode);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_dup.c b/lib/libc_r/uthread/uthread_dup.c
index 63bd9bf..15d8c19 100644
--- a/lib/libc_r/uthread/uthread_dup.c
+++ b/lib/libc_r/uthread/uthread_dup.c
@@ -37,7 +37,7 @@
#include "pthread_private.h"
int
-_libc_dup(int fd)
+_dup(int fd)
{
int ret;
@@ -68,5 +68,5 @@ _libc_dup(int fd)
return (ret);
}
-__weak_reference(_libc_dup, dup);
+__weak_reference(_dup, dup);
#endif
diff --git a/lib/libc_r/uthread/uthread_dup2.c b/lib/libc_r/uthread/uthread_dup2.c
index b8b8a73..ccf0e55 100644
--- a/lib/libc_r/uthread/uthread_dup2.c
+++ b/lib/libc_r/uthread/uthread_dup2.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_dup2(int fd, int newfd)
+_dup2(int fd, int newfd)
{
int ret;
int newfd_opened;
@@ -84,5 +84,5 @@ _libc_dup2(int fd, int newfd)
return (ret);
}
-__weak_reference(_libc_dup2, dup2);
+__weak_reference(_dup2, dup2);
#endif
diff --git a/lib/libc_r/uthread/uthread_execve.c b/lib/libc_r/uthread/uthread_execve.c
index af42e39..8aeb24c 100644
--- a/lib/libc_r/uthread/uthread_execve.c
+++ b/lib/libc_r/uthread/uthread_execve.c
@@ -39,7 +39,7 @@
#include "pthread_private.h"
int
-_libc_execve(const char *name, char *const * argv, char *const * envp)
+_execve(const char *name, char *const * argv, char *const * envp)
{
int flags;
int i;
@@ -111,5 +111,5 @@ _libc_execve(const char *name, char *const * argv, char *const * envp)
return (ret);
}
-__weak_reference(_libc_execve, execve);
+__weak_reference(_execve, execve);
#endif
diff --git a/lib/libc_r/uthread/uthread_exit.c b/lib/libc_r/uthread/uthread_exit.c
index 57ac114..22e2ce8 100644
--- a/lib/libc_r/uthread/uthread_exit.c
+++ b/lib/libc_r/uthread/uthread_exit.c
@@ -41,7 +41,7 @@
#include <pthread.h>
#include "pthread_private.h"
-void _libc__exit(int status)
+void __exit(int status)
{
int flags;
int i;
@@ -77,7 +77,7 @@ void _libc__exit(int status)
_thread_sys__exit(status);
}
-__weak_reference(_libc__exit, _exit);
+__weak_reference(__exit, _exit);
void
_thread_exit(char *fname, int lineno, char *string)
diff --git a/lib/libc_r/uthread/uthread_fchflags.c b/lib/libc_r/uthread/uthread_fchflags.c
index 3334b56..ef33d86 100644
--- a/lib/libc_r/uthread/uthread_fchflags.c
+++ b/lib/libc_r/uthread/uthread_fchflags.c
@@ -12,7 +12,7 @@
#include "pthread_private.h"
int
-_libc_fchflags(int fd, u_long flags)
+_fchflags(int fd, u_long flags)
{
int ret;
@@ -23,5 +23,5 @@ _libc_fchflags(int fd, u_long flags)
return (ret);
}
-__weak_reference(_libc_fchflags, fchflags);
+__weak_reference(_fchflags, fchflags);
#endif
diff --git a/lib/libc_r/uthread/uthread_fchmod.c b/lib/libc_r/uthread/uthread_fchmod.c
index 1f87637..f57a9ea 100644
--- a/lib/libc_r/uthread/uthread_fchmod.c
+++ b/lib/libc_r/uthread/uthread_fchmod.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_fchmod(int fd, mode_t mode)
+_fchmod(int fd, mode_t mode)
{
int ret;
@@ -49,5 +49,5 @@ _libc_fchmod(int fd, mode_t mode)
return (ret);
}
-__weak_reference(_libc_fchmod, fchmod);
+__weak_reference(_fchmod, fchmod);
#endif
diff --git a/lib/libc_r/uthread/uthread_fchown.c b/lib/libc_r/uthread/uthread_fchown.c
index d49d7d1..98fae73 100644
--- a/lib/libc_r/uthread/uthread_fchown.c
+++ b/lib/libc_r/uthread/uthread_fchown.c
@@ -39,7 +39,7 @@
#include "pthread_private.h"
int
-_libc_fchown(int fd, uid_t owner, gid_t group)
+_fchown(int fd, uid_t owner, gid_t group)
{
int ret;
@@ -50,5 +50,5 @@ _libc_fchown(int fd, uid_t owner, gid_t group)
return (ret);
}
-__weak_reference(_libc_fchown, fchown);
+__weak_reference(_fchown, fchown);
#endif
diff --git a/lib/libc_r/uthread/uthread_fcntl.c b/lib/libc_r/uthread/uthread_fcntl.c
index 6cd2b12..06e2e3b 100644
--- a/lib/libc_r/uthread/uthread_fcntl.c
+++ b/lib/libc_r/uthread/uthread_fcntl.c
@@ -39,7 +39,7 @@
#include "pthread_private.h"
int
-_libc_fcntl(int fd, int cmd,...)
+_fcntl(int fd, int cmd,...)
{
int flags = 0;
int nonblock;
@@ -47,8 +47,6 @@ _libc_fcntl(int fd, int cmd,...)
int ret;
va_list ap;
- _thread_enter_cancellation_point();
-
/* Lock the file descriptor: */
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
/* Initialise the variable argument list: */
@@ -137,11 +135,36 @@ _libc_fcntl(int fd, int cmd,...)
/* Unlock the file descriptor: */
_FD_UNLOCK(fd, FD_RDWR);
}
- _thread_leave_cancellation_point();
-
/* Return the completion status: */
return (ret);
}
-__weak_reference(_libc_fcntl, fcntl);
+int
+fcntl(int fd, int cmd,...)
+{
+ int ret;
+ va_list ap;
+
+ _thread_enter_cancellation_point();
+
+ va_start(ap, cmd);
+ switch (cmd) {
+ case F_DUPFD:
+ case F_SETFD:
+ case F_SETFL:
+ ret = fcntl(fd, cmd, va_arg(ap, int));
+ break;
+ case F_GETFD:
+ case F_GETFL:
+ ret = fcntl(fd, cmd);
+ break;
+ default:
+ ret = fcntl(fd, cmd, va_arg(ap, void *));
+ }
+ va_end(ap);
+
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_flock.c b/lib/libc_r/uthread/uthread_flock.c
index 20de6dc..56d6fbc 100644
--- a/lib/libc_r/uthread/uthread_flock.c
+++ b/lib/libc_r/uthread/uthread_flock.c
@@ -37,7 +37,7 @@
#include "pthread_private.h"
int
-_libc_flock(int fd, int operation)
+_flock(int fd, int operation)
{
int ret;
@@ -48,5 +48,5 @@ _libc_flock(int fd, int operation)
return (ret);
}
-__weak_reference(_libc_flock, flock);
+__weak_reference(_flock, flock);
#endif
diff --git a/lib/libc_r/uthread/uthread_fork.c b/lib/libc_r/uthread/uthread_fork.c
index 8c112e8..88f1c43 100644
--- a/lib/libc_r/uthread/uthread_fork.c
+++ b/lib/libc_r/uthread/uthread_fork.c
@@ -41,7 +41,7 @@
#include "pthread_private.h"
pid_t
-_libc_fork(void)
+_fork(void)
{
int i, flags;
pid_t ret;
@@ -221,5 +221,5 @@ _libc_fork(void)
return (ret);
}
-__weak_reference(_libc_fork, fork);
+__weak_reference(_fork, fork);
#endif
diff --git a/lib/libc_r/uthread/uthread_fstat.c b/lib/libc_r/uthread/uthread_fstat.c
index 3f182c3..8df1f1a 100644
--- a/lib/libc_r/uthread/uthread_fstat.c
+++ b/lib/libc_r/uthread/uthread_fstat.c
@@ -42,7 +42,7 @@
#include "pthread_private.h"
int
-_libc_fstat(int fd, struct stat * buf)
+_fstat(int fd, struct stat * buf)
{
int ret;
@@ -56,5 +56,5 @@ _libc_fstat(int fd, struct stat * buf)
return (ret);
}
-__weak_reference(_libc_fstat, fstat);
+__weak_reference(_fstat, fstat);
#endif
diff --git a/lib/libc_r/uthread/uthread_fstatfs.c b/lib/libc_r/uthread/uthread_fstatfs.c
index 84ef0bd..0962cbd 100644
--- a/lib/libc_r/uthread/uthread_fstatfs.c
+++ b/lib/libc_r/uthread/uthread_fstatfs.c
@@ -42,7 +42,7 @@
#include "pthread_private.h"
int
-_libc_fstatfs(int fd, struct statfs * buf)
+_fstatfs(int fd, struct statfs * buf)
{
int ret;
@@ -56,5 +56,5 @@ _libc_fstatfs(int fd, struct statfs * buf)
return (ret);
}
-__weak_reference(_libc_fstatfs, fstatfs);
+__weak_reference(_fstatfs, fstatfs);
#endif
diff --git a/lib/libc_r/uthread/uthread_fsync.c b/lib/libc_r/uthread/uthread_fsync.c
index 048e60b..0d88320 100644
--- a/lib/libc_r/uthread/uthread_fsync.c
+++ b/lib/libc_r/uthread/uthread_fsync.c
@@ -37,18 +37,26 @@
#include "pthread_private.h"
int
-_libc_fsync(int fd)
+_fsync(int fd)
{
- int ret;
+ int ret;
- _thread_enter_cancellation_point();
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
ret = _thread_sys_fsync(fd);
_FD_UNLOCK(fd, FD_RDWR);
}
- _thread_leave_cancellation_point();
return (ret);
}
-__weak_reference(_libc_fsync, fsync);
+int
+fsync(int fd)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = _fsync(fd);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_getdirentries.c b/lib/libc_r/uthread/uthread_getdirentries.c
index 0bd4c85..c1a2edc 100644
--- a/lib/libc_r/uthread/uthread_getdirentries.c
+++ b/lib/libc_r/uthread/uthread_getdirentries.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_getdirentries(int fd, char *buf, int nbytes, long *basep)
+_getdirentries(int fd, char *buf, int nbytes, long *basep)
{
int ret;
@@ -49,5 +49,5 @@ _libc_getdirentries(int fd, char *buf, int nbytes, long *basep)
return (ret);
}
-__weak_reference(_libc_getdirentries, getdirentries);
+__weak_reference(_getdirentries, getdirentries);
#endif
diff --git a/lib/libc_r/uthread/uthread_getpeername.c b/lib/libc_r/uthread/uthread_getpeername.c
index 94c87d6..afc2f3c 100644
--- a/lib/libc_r/uthread/uthread_getpeername.c
+++ b/lib/libc_r/uthread/uthread_getpeername.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen)
+_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen)
{
int ret;
@@ -49,5 +49,5 @@ _libc_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen)
return ret;
}
-__weak_reference(_libc_getpeername, getpeername);
+__weak_reference(_getpeername, getpeername);
#endif
diff --git a/lib/libc_r/uthread/uthread_getsockname.c b/lib/libc_r/uthread/uthread_getsockname.c
index 91d11fe..e8816c7 100644
--- a/lib/libc_r/uthread/uthread_getsockname.c
+++ b/lib/libc_r/uthread/uthread_getsockname.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_getsockname(int s, struct sockaddr * name, socklen_t *namelen)
+_getsockname(int s, struct sockaddr * name, socklen_t *namelen)
{
int ret;
@@ -49,5 +49,5 @@ _libc_getsockname(int s, struct sockaddr * name, socklen_t *namelen)
return ret;
}
-__weak_reference(_libc_getsockname, getsockname);
+__weak_reference(_getsockname, getsockname);
#endif
diff --git a/lib/libc_r/uthread/uthread_getsockopt.c b/lib/libc_r/uthread/uthread_getsockopt.c
index a698c2b..45a0834 100644
--- a/lib/libc_r/uthread/uthread_getsockopt.c
+++ b/lib/libc_r/uthread/uthread_getsockopt.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_getsockopt(int fd, int level, int optname, void *optval, socklen_t
+_getsockopt(int fd, int level, int optname, void *optval, socklen_t
*optlen)
{
int ret;
@@ -50,5 +50,5 @@ _libc_getsockopt(int fd, int level, int optname, void *optval, socklen_t
return ret;
}
-__weak_reference(_libc_getsockopt, getsockopt);
+__weak_reference(_getsockopt, getsockopt);
#endif
diff --git a/lib/libc_r/uthread/uthread_ioctl.c b/lib/libc_r/uthread/uthread_ioctl.c
index 1857643..0a3d14e 100644
--- a/lib/libc_r/uthread/uthread_ioctl.c
+++ b/lib/libc_r/uthread/uthread_ioctl.c
@@ -39,7 +39,7 @@
#include "pthread_private.h"
int
-_libc_ioctl(int fd, unsigned long request,...)
+_ioctl(int fd, unsigned long request,...)
{
int ret;
int *op;
@@ -77,5 +77,5 @@ _libc_ioctl(int fd, unsigned long request,...)
return (ret);
}
-__weak_reference(_libc_ioctl, ioctl);
+__weak_reference(_ioctl, ioctl);
#endif
diff --git a/lib/libc_r/uthread/uthread_listen.c b/lib/libc_r/uthread/uthread_listen.c
index 00ffe5b..1632b60 100644
--- a/lib/libc_r/uthread/uthread_listen.c
+++ b/lib/libc_r/uthread/uthread_listen.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_listen(int fd, int backlog)
+_listen(int fd, int backlog)
{
int ret;
@@ -49,5 +49,5 @@ _libc_listen(int fd, int backlog)
return (ret);
}
-__weak_reference(_libc_listen, listen);
+__weak_reference(_listen, listen);
#endif
diff --git a/lib/libc_r/uthread/uthread_msync.c b/lib/libc_r/uthread/uthread_msync.c
index 9559ec4..2ae6ac7 100644
--- a/lib/libc_r/uthread/uthread_msync.c
+++ b/lib/libc_r/uthread/uthread_msync.c
@@ -13,30 +13,30 @@
#include "pthread_private.h"
int
-_libc_msync(addr, len, flags)
- void *addr;
- size_t len;
- int flags;
+_msync(void *addr, size_t len, int flags)
{
int ret;
+ ret = _thread_sys_msync(addr, len, flags);
+
+ return (ret);
+}
+
+int
+msync(void *addr, size_t len, int flags)
+{
+ int ret;
+
/*
* XXX This is quite pointless unless we know how to get the
* file descriptor associated with the memory, and lock it for
* write. The only real use of this wrapper is to guarantee
* a cancellation point, as per the standard. sigh.
*/
-
- /* This is a cancellation point: */
_thread_enter_cancellation_point();
-
- ret = _thread_sys_msync(addr, len, flags);
-
- /* No longer in a cancellation point: */
+ ret = _msync(addr, len, flags);
_thread_leave_cancellation_point();
- return (ret);
+ return ret;
}
-
-__weak_reference(_libc_msync, msync);
#endif
diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c
index e9052f9..3bbc9a6 100644
--- a/lib/libc_r/uthread/uthread_nanosleep.c
+++ b/lib/libc_r/uthread/uthread_nanosleep.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_nanosleep(const struct timespec * time_to_sleep,
+_nanosleep(const struct timespec * time_to_sleep,
struct timespec * time_remaining)
{
int ret = 0;
@@ -47,7 +47,6 @@ _libc_nanosleep(const struct timespec * time_to_sleep,
struct timespec remaining_time;
struct timeval tv;
- _thread_enter_cancellation_point();
/* Check if the time to sleep is legal: */
if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 ||
time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) {
@@ -117,9 +116,19 @@ _libc_nanosleep(const struct timespec * time_to_sleep,
ret = -1;
}
}
- _thread_leave_cancellation_point();
return (ret);
}
-__weak_reference(_libc_nanosleep, nanosleep);
+int
+nanosleep(const struct timespec * time_to_sleep, struct timespec *
+ time_remaining)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = _nanosleep(time_to_sleep, time_remaining);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_open.c b/lib/libc_r/uthread/uthread_open.c
index 4bc2f1a..e7fef91 100644
--- a/lib/libc_r/uthread/uthread_open.c
+++ b/lib/libc_r/uthread/uthread_open.c
@@ -42,14 +42,12 @@
#include "pthread_private.h"
int
-_libc_open(const char *path, int flags,...)
+_open(const char *path, int flags,...)
{
int fd;
int mode = 0;
va_list ap;
- _thread_enter_cancellation_point();
-
/* Check if the file is being created: */
if (flags & O_CREAT) {
/* Get the creation mode: */
@@ -69,11 +67,30 @@ _libc_open(const char *path, int flags,...)
fd = -1;
}
- _thread_leave_cancellation_point();
-
/* Return the file descriptor or -1 on error: */
return (fd);
}
-__weak_reference(_libc_open, open);
+int
+open(const char *path, int flags,...)
+{
+ int ret;
+ int mode = 0;
+ va_list ap;
+
+ _thread_enter_cancellation_point();
+
+ /* Check if the file is being created: */
+ if (flags & O_CREAT) {
+ /* Get the creation mode: */
+ va_start(ap, flags);
+ mode = va_arg(ap, int);
+ va_end(ap);
+ }
+
+ ret = _open(path, flags, mode);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_pause.c b/lib/libc_r/uthread/uthread_pause.c
new file mode 100644
index 0000000..a841556
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_pause.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <unistd.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+int
+pause(void)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = __pause();
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_pipe.c b/lib/libc_r/uthread/uthread_pipe.c
index b815e1a..770384c 100644
--- a/lib/libc_r/uthread/uthread_pipe.c
+++ b/lib/libc_r/uthread/uthread_pipe.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_pipe(int fds[2])
+_pipe(int fds[2])
{
int ret;
if ((ret = _thread_sys_pipe(fds)) >= 0) {
@@ -52,5 +52,5 @@ _libc_pipe(int fds[2])
return (ret);
}
-__weak_reference(_libc_pipe, pipe);
+__weak_reference(_pipe, pipe);
#endif
diff --git a/lib/libc_r/uthread/uthread_poll.c b/lib/libc_r/uthread/uthread_poll.c
index fb6a266..d395250 100644
--- a/lib/libc_r/uthread/uthread_poll.c
+++ b/lib/libc_r/uthread/uthread_poll.c
@@ -44,7 +44,7 @@
int
-_libc_poll(struct pollfd *fds, unsigned int nfds, int timeout)
+_poll(struct pollfd *fds, unsigned int nfds, int timeout)
{
struct timespec ts;
int numfds = nfds;
@@ -97,5 +97,5 @@ _libc_poll(struct pollfd *fds, unsigned int nfds, int timeout)
return (ret);
}
-__weak_reference(_libc_poll, poll);
+__weak_reference(_poll, poll);
#endif
diff --git a/lib/libc_r/uthread/uthread_read.c b/lib/libc_r/uthread/uthread_read.c
index ad66df3..b4d9694 100644
--- a/lib/libc_r/uthread/uthread_read.c
+++ b/lib/libc_r/uthread/uthread_read.c
@@ -42,16 +42,13 @@
#include "pthread_private.h"
ssize_t
-_libc_read(int fd, void *buf, size_t nbytes)
+_read(int fd, void *buf, size_t nbytes)
{
int ret;
int type;
- _thread_enter_cancellation_point();
-
/* POSIX says to do just this: */
if (nbytes == 0) {
- _thread_leave_cancellation_point();
return (0);
}
@@ -65,7 +62,6 @@ _libc_read(int fd, void *buf, size_t nbytes)
/* File is not open for read: */
errno = EBADF;
_FD_UNLOCK(fd, FD_READ);
- _thread_leave_cancellation_point();
return (-1);
}
@@ -97,9 +93,18 @@ _libc_read(int fd, void *buf, size_t nbytes)
}
_FD_UNLOCK(fd, FD_READ);
}
- _thread_leave_cancellation_point();
return (ret);
}
-__weak_reference(_libc_read, read);
+ssize_t
+read(int fd, void *buf, size_t nbytes)
+{
+ ssize_t ret;
+
+ _thread_enter_cancellation_point();
+ ret = _read(fd, buf, nbytes);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_readv.c b/lib/libc_r/uthread/uthread_readv.c
index c1965d8..2c66a98 100644
--- a/lib/libc_r/uthread/uthread_readv.c
+++ b/lib/libc_r/uthread/uthread_readv.c
@@ -42,7 +42,7 @@
#include "pthread_private.h"
ssize_t
-_libc_readv(int fd, const struct iovec * iov, int iovcnt)
+_readv(int fd, const struct iovec * iov, int iovcnt)
{
int ret;
int type;
@@ -91,5 +91,5 @@ _libc_readv(int fd, const struct iovec * iov, int iovcnt)
return (ret);
}
-__weak_reference(_libc_readv, readv);
+__weak_reference(_readv, readv);
#endif
diff --git a/lib/libc_r/uthread/uthread_recvfrom.c b/lib/libc_r/uthread/uthread_recvfrom.c
index 897e218..ed761ca 100644
--- a/lib/libc_r/uthread/uthread_recvfrom.c
+++ b/lib/libc_r/uthread/uthread_recvfrom.c
@@ -40,7 +40,7 @@
#include "pthread_private.h"
ssize_t
-_libc_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from,
+_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from,
socklen_t *from_len)
{
int ret;
@@ -72,5 +72,5 @@ _libc_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from,
return (ret);
}
-__weak_reference(_libc_recvfrom, recvfrom);
+__weak_reference(_recvfrom, recvfrom);
#endif
diff --git a/lib/libc_r/uthread/uthread_recvmsg.c b/lib/libc_r/uthread/uthread_recvmsg.c
index d89c963..cbad5f5 100644
--- a/lib/libc_r/uthread/uthread_recvmsg.c
+++ b/lib/libc_r/uthread/uthread_recvmsg.c
@@ -40,7 +40,7 @@
#include "pthread_private.h"
ssize_t
-_libc_recvmsg(int fd, struct msghdr *msg, int flags)
+_recvmsg(int fd, struct msghdr *msg, int flags)
{
int ret;
@@ -71,5 +71,5 @@ _libc_recvmsg(int fd, struct msghdr *msg, int flags)
return (ret);
}
-__weak_reference(_libc_recvmsg, recvmsg);
+__weak_reference(_recvmsg, recvmsg);
#endif
diff --git a/lib/libc_r/uthread/uthread_select.c b/lib/libc_r/uthread/uthread_select.c
index a7ceecc..d0e61e2 100644
--- a/lib/libc_r/uthread/uthread_select.c
+++ b/lib/libc_r/uthread/uthread_select.c
@@ -45,8 +45,8 @@
#include "pthread_private.h"
int
-_libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set *
- exceptfds, struct timeval * timeout)
+_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
+ struct timeval * timeout)
{
struct timespec ts;
int i, ret = 0, f_wait = 1;
@@ -204,5 +204,5 @@ _libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set *
return (ret);
}
-__weak_reference(_libc_select, select);
+__weak_reference(_select, select);
#endif
diff --git a/lib/libc_r/uthread/uthread_sem.c b/lib/libc_r/uthread/uthread_sem.c
index 8adb0d4..d35f9bc 100644
--- a/lib/libc_r/uthread/uthread_sem.c
+++ b/lib/libc_r/uthread/uthread_sem.c
@@ -147,6 +147,8 @@ sem_wait(sem_t *sem)
{
int retval;
+ _thread_enter_cancellation_point();
+
_SEM_CHECK_VALIDITY(sem);
pthread_mutex_lock(&(*sem)->lock);
@@ -162,6 +164,7 @@ sem_wait(sem_t *sem)
retval = 0;
RETURN:
+ _thread_leave_cancellation_point();
return retval;
}
diff --git a/lib/libc_r/uthread/uthread_sendmsg.c b/lib/libc_r/uthread/uthread_sendmsg.c
index d280519..c515269 100644
--- a/lib/libc_r/uthread/uthread_sendmsg.c
+++ b/lib/libc_r/uthread/uthread_sendmsg.c
@@ -40,7 +40,7 @@
#include "pthread_private.h"
ssize_t
-_libc_sendmsg(int fd, const struct msghdr *msg, int flags)
+_sendmsg(int fd, const struct msghdr *msg, int flags)
{
int ret;
@@ -70,5 +70,5 @@ _libc_sendmsg(int fd, const struct msghdr *msg, int flags)
return (ret);
}
-__weak_reference(_libc_sendmsg, sendmsg);
+__weak_reference(_sendmsg, sendmsg);
#endif
diff --git a/lib/libc_r/uthread/uthread_sendto.c b/lib/libc_r/uthread/uthread_sendto.c
index dc134bc..6c1df48 100644
--- a/lib/libc_r/uthread/uthread_sendto.c
+++ b/lib/libc_r/uthread/uthread_sendto.c
@@ -40,7 +40,7 @@
#include "pthread_private.h"
ssize_t
-_libc_sendto(int fd, const void *msg, size_t len, int flags, const struct
+_sendto(int fd, const void *msg, size_t len, int flags, const struct
sockaddr * to, socklen_t to_len)
{
int ret;
@@ -71,5 +71,5 @@ _libc_sendto(int fd, const void *msg, size_t len, int flags, const struct
return (ret);
}
-__weak_reference(_libc_sendto, sendto);
+__weak_reference(_sendto, sendto);
#endif
diff --git a/lib/libc_r/uthread/uthread_setsockopt.c b/lib/libc_r/uthread/uthread_setsockopt.c
index eb917f5..fe0a55e 100644
--- a/lib/libc_r/uthread/uthread_setsockopt.c
+++ b/lib/libc_r/uthread/uthread_setsockopt.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_setsockopt(int fd, int level, int optname, const void *optval, socklen_t
+_setsockopt(int fd, int level, int optname, const void *optval, socklen_t
optlen)
{
int ret;
@@ -50,5 +50,5 @@ _libc_setsockopt(int fd, int level, int optname, const void *optval, socklen_t
return ret;
}
-__weak_reference(_libc_setsockopt, setsockopt);
+__weak_reference(_setsockopt, setsockopt);
#endif
diff --git a/lib/libc_r/uthread/uthread_shutdown.c b/lib/libc_r/uthread/uthread_shutdown.c
index cffe4b6..8ce4d6d 100644
--- a/lib/libc_r/uthread/uthread_shutdown.c
+++ b/lib/libc_r/uthread/uthread_shutdown.c
@@ -39,7 +39,7 @@
#include "pthread_private.h"
int
-_libc_shutdown(int fd, int how)
+_shutdown(int fd, int how)
{
int ret;
@@ -70,5 +70,5 @@ _libc_shutdown(int fd, int how)
return (ret);
}
-__weak_reference(_libc_shutdown, shutdown);
+__weak_reference(_shutdown, shutdown);
#endif
diff --git a/lib/libc_r/uthread/uthread_sigaction.c b/lib/libc_r/uthread/uthread_sigaction.c
index f2f7286..e0aa523 100644
--- a/lib/libc_r/uthread/uthread_sigaction.c
+++ b/lib/libc_r/uthread/uthread_sigaction.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
+_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
{
int ret = 0;
struct sigaction gact;
@@ -106,5 +106,5 @@ _libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
return (ret);
}
-__weak_reference(_libc_sigaction, sigaction);
+__weak_reference(_sigaction, sigaction);
#endif
diff --git a/lib/libc_r/uthread/uthread_sigpending.c b/lib/libc_r/uthread/uthread_sigpending.c
index feb4300..a630f0c 100644
--- a/lib/libc_r/uthread/uthread_sigpending.c
+++ b/lib/libc_r/uthread/uthread_sigpending.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_sigpending(sigset_t * set)
+_sigpending(sigset_t * set)
{
int ret = 0;
@@ -54,5 +54,5 @@ _libc_sigpending(sigset_t * set)
return (ret);
}
-__weak_reference(_libc_sigpending, sigpending);
+__weak_reference(_sigpending, sigpending);
#endif
diff --git a/lib/libc_r/uthread/uthread_sigprocmask.c b/lib/libc_r/uthread/uthread_sigprocmask.c
index 28ab4fa..b10089c 100644
--- a/lib/libc_r/uthread/uthread_sigprocmask.c
+++ b/lib/libc_r/uthread/uthread_sigprocmask.c
@@ -41,7 +41,7 @@
#include "pthread_private.h"
int
-_libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset)
+_sigprocmask(int how, const sigset_t * set, sigset_t * oset)
{
int ret = 0;
@@ -90,5 +90,5 @@ _libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset)
return (ret);
}
-__weak_reference(_libc_sigprocmask, sigprocmask);
+__weak_reference(_sigprocmask, sigprocmask);
#endif
diff --git a/lib/libc_r/uthread/uthread_sigsuspend.c b/lib/libc_r/uthread/uthread_sigsuspend.c
index b64897a..28959c8 100644
--- a/lib/libc_r/uthread/uthread_sigsuspend.c
+++ b/lib/libc_r/uthread/uthread_sigsuspend.c
@@ -38,7 +38,7 @@
#include "pthread_private.h"
int
-_libc_sigsuspend(const sigset_t * set)
+_sigsuspend(const sigset_t * set)
{
int ret = -1;
sigset_t oset;
@@ -68,5 +68,15 @@ _libc_sigsuspend(const sigset_t * set)
return (ret);
}
-__weak_reference(_libc_sigsuspend, sigsuspend);
+int
+sigsuspend(const sigset_t * set)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = _sigsuspend(set);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_sigwait.c b/lib/libc_r/uthread/uthread_sigwait.c
index faa227e..a509687 100644
--- a/lib/libc_r/uthread/uthread_sigwait.c
+++ b/lib/libc_r/uthread/uthread_sigwait.c
@@ -143,6 +143,7 @@ sigwait(const sigset_t * set, int *sig)
}
_thread_leave_cancellation_point();
+
/* Return the completion status: */
return (ret);
}
diff --git a/lib/libc_r/uthread/uthread_sleep.c b/lib/libc_r/uthread/uthread_sleep.c
new file mode 100644
index 0000000..34a5925
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_sleep.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <unistd.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+unsigned int
+sleep(unsigned int seconds)
+{
+ unsigned int ret;
+
+ _thread_enter_cancellation_point();
+ ret = __sleep(seconds);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_socket.c b/lib/libc_r/uthread/uthread_socket.c
index bab70df..d1fe141 100644
--- a/lib/libc_r/uthread/uthread_socket.c
+++ b/lib/libc_r/uthread/uthread_socket.c
@@ -40,7 +40,7 @@
#include "pthread_private.h"
int
-_libc_socket(int af, int type, int protocol)
+_socket(int af, int type, int protocol)
{
int fd;
@@ -56,5 +56,5 @@ _libc_socket(int af, int type, int protocol)
return (fd);
}
-__weak_reference(_libc_socket, socket);
+__weak_reference(_socket, socket);
#endif
diff --git a/lib/libc_r/uthread/uthread_socketpair.c b/lib/libc_r/uthread/uthread_socketpair.c
index f35ab94..023bfa9 100644
--- a/lib/libc_r/uthread/uthread_socketpair.c
+++ b/lib/libc_r/uthread/uthread_socketpair.c
@@ -41,7 +41,7 @@
#include "pthread_private.h"
int
-_libc_socketpair(int af, int type, int protocol, int pair[2])
+_socketpair(int af, int type, int protocol, int pair[2])
{
int ret;
if (!((ret = _thread_sys_socketpair(af, type, protocol, pair)) < 0))
@@ -54,5 +54,5 @@ _libc_socketpair(int af, int type, int protocol, int pair[2])
return (ret);
}
-__weak_reference(_libc_socketpair, socketpair);
+__weak_reference(_socketpair, socketpair);
#endif
diff --git a/lib/libc_r/uthread/uthread_spinlock.c b/lib/libc_r/uthread/uthread_spinlock.c
index 4e94ffc..e797f90 100644
--- a/lib/libc_r/uthread/uthread_spinlock.c
+++ b/lib/libc_r/uthread/uthread_spinlock.c
@@ -90,7 +90,7 @@ _spinlock_debug(spinlock_t *lck, char *fname, int lineno)
char str[256];
snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno);
_thread_sys_write(2,str,strlen(str));
- sleep(1);
+ __sleep(1);
cnt = 0;
}
diff --git a/lib/libc_r/uthread/uthread_system.c b/lib/libc_r/uthread/uthread_system.c
new file mode 100644
index 0000000..9265975
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_system.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdlib.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+int
+system(const char *string)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = __system(string);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_tcdrain.c b/lib/libc_r/uthread/uthread_tcdrain.c
new file mode 100644
index 0000000..d040599
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_tcdrain.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <termios.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+int
+tcdrain(int fd)
+{
+ int ret;
+
+ _thread_enter_cancellation_point();
+ ret = __tcdrain(fd);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_wait.c b/lib/libc_r/uthread/uthread_wait.c
new file mode 100644
index 0000000..abc19cc
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_wait.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+pid_t
+wait(int *istat)
+{
+ pid_t ret;
+
+ _thread_enter_cancellation_point();
+ ret = __wait(istat);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_wait4.c b/lib/libc_r/uthread/uthread_wait4.c
index 4c3f1de..90eb0ab 100644
--- a/lib/libc_r/uthread/uthread_wait4.c
+++ b/lib/libc_r/uthread/uthread_wait4.c
@@ -38,11 +38,10 @@
#include "pthread_private.h"
pid_t
-_libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
+_wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
{
pid_t ret;
- _thread_enter_cancellation_point();
_thread_kern_sig_defer();
/* Perform a non-blocking wait4 syscall: */
@@ -62,10 +61,9 @@ _libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
}
_thread_kern_sig_undefer();
- _thread_leave_cancellation_point();
return (ret);
}
-__weak_reference(_libc_wait4, wait4);
+__weak_reference(_wait4, wait4);
#endif
diff --git a/lib/libc_r/uthread/uthread_waitpid.c b/lib/libc_r/uthread/uthread_waitpid.c
new file mode 100644
index 0000000..a847295
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_waitpid.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
+ * 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(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.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+pid_t
+waitpid(pid_t wpid, int *status, int options)
+{
+ pid_t ret;
+
+ _thread_enter_cancellation_point();
+ ret = __waitpid(wpid, status, options);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
+#endif
diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c
index f25c606..6408a64 100644
--- a/lib/libc_r/uthread/uthread_write.c
+++ b/lib/libc_r/uthread/uthread_write.c
@@ -42,7 +42,7 @@
#include "pthread_private.h"
ssize_t
-_libc_write(int fd, const void *buf, size_t nbytes)
+_write(int fd, const void *buf, size_t nbytes)
{
int blocking;
int type;
@@ -50,12 +50,9 @@ _libc_write(int fd, const void *buf, size_t nbytes)
ssize_t num = 0;
ssize_t ret;
- _thread_enter_cancellation_point();
/* POSIX says to do just this: */
- if (nbytes == 0) {
- _thread_leave_cancellation_point();
+ if (nbytes == 0)
return (0);
- }
/* Lock the file descriptor for write: */
if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
@@ -67,7 +64,6 @@ _libc_write(int fd, const void *buf, size_t nbytes)
/* File is not open for write: */
errno = EBADF;
_FD_UNLOCK(fd, FD_WRITE);
- _thread_leave_cancellation_point();
return (-1);
}
@@ -133,9 +129,18 @@ _libc_write(int fd, const void *buf, size_t nbytes)
}
_FD_UNLOCK(fd, FD_RDWR);
}
- _thread_leave_cancellation_point();
return (ret);
}
-__weak_reference(_libc_write, write);
+ssize_t
+write(int fd, const void *buf, size_t nbytes)
+{
+ ssize_t ret;
+
+ _thread_enter_cancellation_point();
+ ret = _write(fd, buf, nbytes);
+ _thread_leave_cancellation_point();
+
+ return ret;
+}
#endif
diff --git a/lib/libc_r/uthread/uthread_writev.c b/lib/libc_r/uthread/uthread_writev.c
index 74da521..7c5fffe 100644
--- a/lib/libc_r/uthread/uthread_writev.c
+++ b/lib/libc_r/uthread/uthread_writev.c
@@ -44,7 +44,7 @@
#include "pthread_private.h"
ssize_t
-_libc_writev(int fd, const struct iovec * iov, int iovcnt)
+_writev(int fd, const struct iovec * iov, int iovcnt)
{
int blocking;
int idx = 0;
@@ -201,5 +201,5 @@ _libc_writev(int fd, const struct iovec * iov, int iovcnt)
return (ret);
}
-__weak_reference(_libc_writev, writev);
+__weak_reference(_writev, writev);
#endif
OpenPOWER on IntegriCloud