summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/Makefile.in9
-rw-r--r--libc/sysdeps/linux/common/fsync.c28
-rw-r--r--libc/sysdeps/linux/common/ioctl.c27
-rw-r--r--libc/sysdeps/linux/common/msync.c24
-rw-r--r--libc/sysdeps/linux/common/nanosleep.c28
-rw-r--r--libc/sysdeps/linux/common/pause.c33
-rw-r--r--libc/sysdeps/linux/common/poll.c40
-rw-r--r--libc/sysdeps/linux/common/select.c28
8 files changed, 154 insertions, 63 deletions
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index 270a2de38..600a9adb8 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -25,9 +25,12 @@ CSRC := $(filter-out ssp.c,$(CSRC))
endif
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-CSRC := $(filter-out fork.c getpid.c raise.c pause.c open.c close.c \
- read.c write.c nanosleep.c __syscall_rt_sigaction.c msync.c \
- lseek.c __syscall_fcntl64.c, $(CSRC))
+CSRC := $(filter-out fork.c getpid.c raise.c open.c close.c read.c write.c waitpid.c, $(CSRC))
+
+endif
+
+ifeq ($(TARGET_ARCH),sh)
+CSRC := $(filter-out longjmp.c vfork.c,$(CSRC))
endif
diff --git a/libc/sysdeps/linux/common/fsync.c b/libc/sysdeps/linux/common/fsync.c
index 7ca709887..ecc203c74 100644
--- a/libc/sysdeps/linux/common/fsync.c
+++ b/libc/sysdeps/linux/common/fsync.c
@@ -9,27 +9,29 @@
#include "syscalls.h"
#include <unistd.h>
-#ifdef __UCLIBC__HAS_THREADS__
-# include <sysdep-cancel.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include "sysdep-cancel.h"
+#else
+#define SINGLE_THREAD_P 1
#endif
+#define __NR___syscall_fsync __NR_fsync
+static inline _syscall1(int, __syscall_fsync, int, fd);
+
extern __typeof(fsync) __libc_fsync;
-#ifdef __UCLIBC__HAS_THREADS__
-int __libc_fsync (int fd)
+
+int __libc_fsync(int fd)
{
if (SINGLE_THREAD_P)
- return INLINE_SYSCALL (fsync, 1, fd);
+ return __syscall_fsync(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
int oldtype = LIBC_CANCEL_ASYNC ();
-
- int result = INLINE_SYSCALL (fsync, 1, fd);
-
+ int result = __syscall_fsync(fd);
LIBC_CANCEL_RESET (oldtype);
-
return result;
-}
-#else
-# define __NR___libc_fsync __NR_fsync
-_syscall1(int, __libc_fsync, int, fd);
#endif
+}
+
weak_alias(__libc_fsync, fsync)
diff --git a/libc/sysdeps/linux/common/ioctl.c b/libc/sysdeps/linux/common/ioctl.c
index e8e3a1031..02393b98e 100644
--- a/libc/sysdeps/linux/common/ioctl.c
+++ b/libc/sysdeps/linux/common/ioctl.c
@@ -11,6 +11,12 @@
#include <stdarg.h>
#include <sys/ioctl.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
libc_hidden_proto(ioctl)
#define __NR___syscall_ioctl __NR_ioctl
@@ -19,13 +25,22 @@ _syscall3(int, __syscall_ioctl, int, fd, unsigned long int, request, void *, arg
int ioctl(int fd, unsigned long int request, ...)
{
- void *arg;
- va_list list;
+ void *arg;
+ va_list list;
+
+ va_start(list, request);
+ arg = va_arg(list, void *);
+
+ va_end(list);
- va_start(list, request);
- arg = va_arg(list, void *);
+ if (SINGLE_THREAD_P)
+ return __syscall_ioctl(fd, request, arg);
- va_end(list);
- return __syscall_ioctl(fd, request, arg);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_ioctl(fd, request, arg);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
}
libc_hidden_def(ioctl)
diff --git a/libc/sysdeps/linux/common/msync.c b/libc/sysdeps/linux/common/msync.c
index 494d4afd3..8882a4c91 100644
--- a/libc/sysdeps/linux/common/msync.c
+++ b/libc/sysdeps/linux/common/msync.c
@@ -11,7 +11,27 @@
#include <unistd.h>
#include <sys/mman.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
+#define __NR___syscall_msync __NR_msync
+static inline _syscall3(int, __syscall_msync, void *, addr, size_t, length,
+ int, flags);
+
extern __typeof(msync) __libc_msync;
-#define __NR___libc_msync __NR_msync
-_syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
+int __libc_msync(void * addr, size_t length, int flags)
+{
+ if (SINGLE_THREAD_P)
+ return __syscall_msync(addr, length, flags);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_msync(addr, length, flags);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
+}
weak_alias(__libc_msync,msync)
diff --git a/libc/sysdeps/linux/common/nanosleep.c b/libc/sysdeps/linux/common/nanosleep.c
index 76cab97f2..1e541500b 100644
--- a/libc/sysdeps/linux/common/nanosleep.c
+++ b/libc/sysdeps/linux/common/nanosleep.c
@@ -10,10 +10,32 @@
#include "syscalls.h"
#include <time.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#include <pthreadP.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
+#define __NR___syscall_nanosleep __NR_nanosleep
+static inline _syscall2(int, __syscall_nanosleep, const struct timespec *, req,
+ struct timespec *, rem);
+
extern __typeof(nanosleep) __libc_nanosleep;
-#define __NR___libc_nanosleep __NR_nanosleep
-_syscall2(int, __libc_nanosleep, const struct timespec *, req,
- struct timespec *, rem);
+
+int __libc_nanosleep(const struct timespec *req, struct timespec *rem)
+{
+ if (SINGLE_THREAD_P)
+ return __syscall_nanosleep(req, rem);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_nanosleep(req, rem);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
+}
+
libc_hidden_proto(nanosleep)
weak_alias(__libc_nanosleep,nanosleep)
libc_hidden_weak(nanosleep)
diff --git a/libc/sysdeps/linux/common/pause.c b/libc/sysdeps/linux/common/pause.c
index 751b6b6a9..74115b281 100644
--- a/libc/sysdeps/linux/common/pause.c
+++ b/libc/sysdeps/linux/common/pause.c
@@ -7,22 +7,25 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define __UCLIBC_HIDE_DEPRECATED__
-#include "syscalls.h"
-#include <unistd.h>
-
-extern __typeof(pause) __libc_pause;
-#ifdef __NR_pause
-#define __NR___libc_pause __NR_pause
-_syscall0(int, __libc_pause);
-#else
#include <signal.h>
-libc_hidden_proto(__sigpause)
-libc_hidden_proto(sigblock)
+#include <unistd.h>
+#include <sysdep-cancel.h>
-int __libc_pause(void)
+/* Suspend the process until a signal arrives.
+ This always returns -1 and sets errno to EINTR. */
+int
+__libc_pause (void)
{
- return (__sigpause(sigblock(0), 0));
+ sigset_t set;
+
+ __sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, NULL, &set);
+
+ /* pause is a cancellation point, but so is sigsuspend.
+ So no need for anything special here. */
+
+ return sigsuspend (&set);
}
-#endif
-weak_alias(__libc_pause,pause)
+weak_alias (__libc_pause, pause)
+
+LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c
index 61c6d18ea..7ce1446f5 100644
--- a/libc/sysdeps/linux/common/poll.c
+++ b/libc/sysdeps/linux/common/poll.c
@@ -20,31 +20,33 @@
#include "syscalls.h"
#include <sys/poll.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
libc_hidden_proto(poll)
#ifdef __NR_poll
-# ifdef __UCLIBC__HAS_THREADS__
-# include <sysdep-cancel.h>
-
-/* The real implementation. */
-int poll (struct pollfd *fds, nfsd_t nfds, int timeout)
-{
- if (SINGLE_THREAD_P)
- return INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
- int result = INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
+#define __NR___syscall_poll __NR_poll
+static inline _syscall3(int, __syscall_poll, struct pollfd *, fds,
+ unsigned long int, nfds, int, timeout);
- LIBC_CANCEL_RESET (oldtype);
-
- return result;
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+ if (SINGLE_THREAD_P)
+ return __syscall_poll(fds, nfds, timeout);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_poll(fds, nfds, timeout);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
}
-# else
-_syscall3(int, poll, struct pollfd *, fds,
- unsigned long int, nfds, int, timeout);
-# endif
-#else
+#else /* !__NR_poll */
#include <alloca.h>
#include <sys/types.h>
diff --git a/libc/sysdeps/linux/common/select.c b/libc/sysdeps/linux/common/select.c
index 9a50d198a..55f4c23fb 100644
--- a/libc/sysdeps/linux/common/select.c
+++ b/libc/sysdeps/linux/common/select.c
@@ -10,12 +10,36 @@
#include "syscalls.h"
#include <sys/select.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
+
libc_hidden_proto(select)
#ifdef __NR__newselect
# undef __NR_select
# define __NR_select __NR__newselect
#endif
-_syscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds,
- fd_set *, exceptfds, struct timeval *, timeout);
+
+#define __NR___syscall_select __NR_select
+static inline _syscall5(int, __syscall_select, int, n, fd_set *, readfds,
+ fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout);
+
+int select(int n, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
+ struct timeval * timeout)
+{
+ if (SINGLE_THREAD_P)
+ return __syscall_select(n, readfds, writefds, exceptfds, timeout);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_select(n, readfds, writefds, exceptfds, timeout);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
+}
+
libc_hidden_def(select)