diff options
Diffstat (limited to 'libc')
| -rw-r--r-- | libc/inet/Makefile.in | 5 | ||||
| -rw-r--r-- | libc/inet/socketcalls.c | 85 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/Makefile.in | 9 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/fsync.c | 28 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/ioctl.c | 27 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/msync.c | 24 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/nanosleep.c | 28 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/pause.c | 33 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/poll.c | 40 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/select.c | 28 |
10 files changed, 236 insertions, 71 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index 66a84c06f..a61d38ee0 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -30,11 +30,6 @@ CSRC += accept.c bind.c connect.c getpeername.c getsockname.c getsockopt.c \ listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c sendto.c \ setsockopt.c shutdown.c socket.c socketpair.c -ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) -CSRC := $(filter-out accept.c connect.c recv.c recvfrom.c recvmsg.c send.c \ - sendmsg.c sendto.c, $(CSRC)) -endif - INET_DIR := $(top_srcdir)libc/inet INET_OUT := $(top_builddir)libc/inet diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c index 9a6e2e151..d684a3aaf 100644 --- a/libc/inet/socketcalls.c +++ b/libc/inet/socketcalls.c @@ -33,6 +33,12 @@ extern int __socketcall(int call, unsigned long *args) attribute_hidden; #define SYS_RECVMSG 17 #endif +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include <sysdep-cancel.h> +#include <pthreadP.h> +#else +#define SINGLE_THREAD_P 1 +#endif #ifdef L_accept extern __typeof(accept) __libc_accept; @@ -47,7 +53,17 @@ int __libc_accept(int s, struct sockaddr *addr, socklen_t * addrlen) args[0] = s; args[1] = (unsigned long) addr; args[2] = (unsigned long) addrlen; - return __socketcall(SYS_ACCEPT, args); + + if (SINGLE_THREAD_P) + return __socketcall(SYS_ACCEPT, args); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_ACCEPT, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif + } #endif libc_hidden_proto(accept) @@ -86,7 +102,16 @@ int __libc_connect(int sockfd, const struct sockaddr *saddr, socklen_t addrlen) args[0] = sockfd; args[1] = (unsigned long) saddr; args[2] = addrlen; + +if (SINGLE_THREAD_P) return __socketcall(SYS_CONNECT, args); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_CONNECT, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #endif libc_hidden_proto(connect) @@ -179,7 +204,16 @@ ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags) args[1] = (unsigned long) buffer; args[2] = len; args[3] = flags; - return (__socketcall(SYS_RECV, args)); + + if (SINGLE_THREAD_P) + return (__socketcall(SYS_RECV, args)); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_RECV, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #elif defined(__NR_recvfrom) libc_hidden_proto(recvfrom) @@ -212,7 +246,16 @@ ssize_t __libc_recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags, args[3] = flags; args[4] = (unsigned long) to; args[5] = (unsigned long) tolen; + +if (SINGLE_THREAD_P) return (__socketcall(SYS_RECVFROM, args)); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_RECVFROM, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #endif libc_hidden_proto(recvfrom) @@ -233,7 +276,16 @@ ssize_t __libc_recvmsg(int sockfd, struct msghdr *msg, int flags) args[0] = sockfd; args[1] = (unsigned long) msg; args[2] = flags; - return (__socketcall(SYS_RECVMSG, args)); + +if (SINGLE_THREAD_P) + return (__socketcall(SYS_RECVMSG, args)); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_RECVMSG, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #endif libc_hidden_proto(recvmsg) @@ -256,7 +308,16 @@ ssize_t __libc_send(int sockfd, const void *buffer, size_t len, int flags) args[1] = (unsigned long) buffer; args[2] = len; args[3] = flags; + +if (SINGLE_THREAD_P) return (__socketcall(SYS_SEND, args)); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_SEND, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #elif defined(__NR_sendto) libc_hidden_proto(sendto) @@ -283,7 +344,16 @@ ssize_t __libc_sendmsg(int sockfd, const struct msghdr *msg, int flags) args[0] = sockfd; args[1] = (unsigned long) msg; args[2] = flags; + +if (SINGLE_THREAD_P) return (__socketcall(SYS_SENDMSG, args)); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_SENDMSG, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #endif libc_hidden_proto(sendmsg) @@ -310,7 +380,16 @@ ssize_t __libc_sendto(int sockfd, const void *buffer, size_t len, int flags, args[3] = flags; args[4] = (unsigned long) to; args[5] = tolen; + +if (SINGLE_THREAD_P) return (__socketcall(SYS_SENDTO, args)); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_SENDTO, args); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } #endif libc_hidden_proto(sendto) 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) |
