Hi, I would like to get some feedback for following three patches. The test suite runs over all architectures showed no regressions.
The goal is to simplify the addition of new architectures and remove the need to add assembly code to sysdep-cancel.h. Most of the work was done in 2011 in commit 9f68f0cbf8c8eea6a7f9e195e4617bbaa808d7c6, but it was not finished for NPTL and RT components of uClibc. best regards Waldemar
>From 6b3527bd637b8a4e97d2e462719ac7d7d0226361 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb <w...@uclibc-ng.org> Date: Fri, 14 Jul 2017 19:37:28 +0200 Subject: [PATCH 1/3] rt: convert mq_timedsend/mq_timedreceive to use cancel.h macros Signed-off-by: Waldemar Brodkorb <w...@uclibc-ng.org> --- include/cancel.h | 4 ---- librt/Makefile.in | 9 +-------- librt/mq_receive.c | 45 ++++----------------------------------------- librt/mq_send.c | 42 ++++-------------------------------------- librt/mq_timedreceive.S | 8 -------- librt/mq_timedreceive.c | 16 ++++++++++++++++ librt/mq_timedsend.S | 8 -------- librt/mq_timedsend.c | 16 ++++++++++++++++ 8 files changed, 41 insertions(+), 107 deletions(-) delete mode 100644 librt/mq_timedreceive.S create mode 100644 librt/mq_timedreceive.c delete mode 100644 librt/mq_timedsend.S create mode 100644 librt/mq_timedsend.c diff --git a/include/cancel.h b/include/cancel.h index 163c70409..a72efa4e2 100644 --- a/include/cancel.h +++ b/include/cancel.h @@ -36,8 +36,6 @@ #include <features.h> -#ifndef NOT_IN_libc - #define __NC(name) _NC(name) #define _NC(name) __##name##_nocancel @@ -97,6 +95,4 @@ strong_alias(__NC(name),name) # undef LIBC_CANCEL_HANDLED # define LIBC_CANCEL_HANDLED() -#endif /* NOT_IN_libc */ - #endif diff --git a/librt/Makefile.in b/librt/Makefile.in index 8405ec08c..3fdc98dc0 100644 --- a/librt/Makefile.in +++ b/librt/Makefile.in @@ -17,11 +17,8 @@ librt_filter_SRC := ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) librt_filter_SRC += mq_notify.c timer_create.c timer_delete.c \ timer_getoverr.c timer_gettime.c timer_settime.c -# these should really be guarded by ADVANCED_REALTIME, we use them in mq_send.c/mq_receive.c -librt_SSRC := $(wildcard $(librt_DIR)/*.S) else librt_filter_SRC += clock_nanosleep.c clock_getcpuclockid.c clock_gettime.c -librt_SSRC := endif librt_filter_SRC += $(if $(UCLIBC_HAS_ADVANCED_REALTIME),, \ @@ -36,17 +33,13 @@ librt_filter_SRC += $(if $(HAS_NO_THREADS),dso_handle.c) librt_SRC := $(filter-out $(librt_filter_SRC),$(librt_SRC)) librt_OBJ := $(patsubst %.c,$(librt_OUT)/%.o,$(librt_SRC)) -librt_OBJ += $(patsubst $(librt_DIR)/%.S,$(librt_OUT)/%.o,$(librt_SSRC)) - -ASFLAGS-mq_timedreceive.S = -D_LIBC_REENTRANT -ASFLAGS-mq_timedsend.S = -D_LIBC_REENTRANT ifeq ($(DOPIC),y) librt-a-y += $(librt_OBJ:.o=.os) else librt-a-y += $(librt_OBJ) endif -librt-so-y += $(librt_OBJ:.o=.oS) +librt-so-y += $(librt_OBJ:.o=.os) librt-dep-y := $(libc.depend) diff --git a/librt/mq_receive.c b/librt/mq_receive.c index 2be1c1a98..e6fd62b87 100644 --- a/librt/mq_receive.c +++ b/librt/mq_receive.c @@ -2,52 +2,15 @@ * mq_receive.c - functions for receiving from message queue. */ +#include <errno.h> +#include <stddef.h> #include <sys/syscall.h> -#ifdef __NR_mq_timedreceive - -#include <stddef.h> #include <mqueue.h> -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ -# ifndef __UCLIBC_HAS_ADVANCED_REALTIME__ -extern ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, - unsigned int *msg_prio, - const struct timespec *abs_timeout); -# endif -librt_hidden_proto(mq_timedreceive) -#else - -# define __NR___syscall_mq_timedreceive __NR_mq_timedreceive -static _syscall5(int, __syscall_mq_timedreceive, int, mqdes, - char *, msg_ptr, size_t, msg_len, unsigned int *, - msg_prio, const void *, abs_timeout) - -# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__ -/* - * Receive the oldest from highest priority messages. - * Stop waiting if abs_timeout expires. - */ -ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, - unsigned int *msg_prio, - const struct timespec *abs_timeout) -{ - return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, - abs_timeout); -} -# endif - -#endif - -/* Receive the oldest from highest priority messages */ -ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, - unsigned int *msg_prio) +#ifdef __NR_mq_timedreceive +ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio) { -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL); -#else - return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL); -#endif } - #endif diff --git a/librt/mq_send.c b/librt/mq_send.c index 5e50d1a19..fb4fa6555 100644 --- a/librt/mq_send.c +++ b/librt/mq_send.c @@ -2,49 +2,15 @@ * mq_send.c - functions for sending to message queue. */ +#include <errno.h> +#include <stddef.h> #include <sys/syscall.h> -#ifdef __NR_mq_timedsend - -#include <stddef.h> #include <mqueue.h> -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ -# ifndef __UCLIBC_HAS_ADVANCED_REALTIME__ -extern int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio, const struct timespec *abs_timeout); -# endif -librt_hidden_proto(mq_timedsend) -#else - -# define __NR___syscall_mq_timedsend __NR_mq_timedsend -static _syscall5(int, __syscall_mq_timedsend, int, mqdes, - const char *, msg_ptr, size_t, msg_len, unsigned int, - msg_prio, const void *, abs_timeout) - -# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__ -/* - * Add a message to queue. If O_NONBLOCK is set and queue is full, wait - * for sufficient room in the queue until abs_timeout expires. - */ -int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio, const struct timespec *abs_timeout) -{ - return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, - abs_timeout); -} -# endif -#endif - -/* Add a message to queue */ -int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio) +#ifdef __NR_mq_timedsend +int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio) { -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL); -#else - return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL); -#endif } - #endif diff --git a/librt/mq_timedreceive.S b/librt/mq_timedreceive.S deleted file mode 100644 index 00fecac03..000000000 --- a/librt/mq_timedreceive.S +++ /dev/null @@ -1,8 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_mq_timedreceive -#error Missing definition of NR_timedreceive needed for cancellation. -#endif -PSEUDO(mq_timedreceive, mq_timedreceive, 5) -ret_ERRVAL -PSEUDO_END(mq_timedreceive) -librt_hidden_def(mq_timedreceive) diff --git a/librt/mq_timedreceive.c b/librt/mq_timedreceive.c new file mode 100644 index 000000000..9f5efc4fa --- /dev/null +++ b/librt/mq_timedreceive.c @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/syscall.h> +#include <mqueue.h> +#include <unistd.h> +#include <cancel.h> + +#define __NR___mq_timedreceive_nocancel __NR_mq_timedreceive +_syscall5(ssize_t, __NC(mq_timedreceive), mqd_t, mqdes, char *__restrict, msg_ptr, size_t, msg_len, unsigned int *__restrict, msq_prio, const struct timespec *__restrict, abs_timeout) + +CANCELLABLE_SYSCALL(ssize_t, mq_timedreceive, (mqd_t mqdes, char *__restrict msg_ptr, size_t msq_len, unsigned int *__restrict msq_prio, const struct timespec *__restrict abs_timeout), + (mqdes, msg_ptr, msq_len, msq_prio, abs_timeout)) +lt_libc_hidden(mq_timedreceive) diff --git a/librt/mq_timedsend.S b/librt/mq_timedsend.S deleted file mode 100644 index ee8d48334..000000000 --- a/librt/mq_timedsend.S +++ /dev/null @@ -1,8 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_mq_timedsend -#error Missing definition of NR_timedsend needed for cancellation. -#endif -PSEUDO(mq_timedsend, mq_timedsend, 5) -ret_ERRVAL -PSEUDO_END(mq_timedsend) -librt_hidden_def(mq_timedsend) diff --git a/librt/mq_timedsend.c b/librt/mq_timedsend.c new file mode 100644 index 000000000..7c2e97ee3 --- /dev/null +++ b/librt/mq_timedsend.c @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/syscall.h> +#include <mqueue.h> +#include <unistd.h> +#include <cancel.h> + +#define __NR___mq_timedsend_nocancel __NR_mq_timedsend +_syscall5(int, __NC(mq_timedsend), mqd_t, mqdes, const char *, msg_ptr, size_t, msg_len, unsigned int, msq_prio, const struct timespec *, abs_timeout) + +CANCELLABLE_SYSCALL(int, mq_timedsend, (mqd_t mqdes, const char *msg_ptr, size_t msq_len, unsigned int msq_prio, const struct timespec *abs_timeout), + (mqdes, msg_ptr, msq_len, msq_prio, abs_timeout)) +lt_libc_hidden(mq_timedsend) -- 2.11.0
>From a8f52a4b75a93f0ac08d4b74dedc46004e006768 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb <w...@uclibc-ng.org> Date: Sun, 16 Jul 2017 11:34:54 +0200 Subject: [PATCH 2/3] nptl: remove sysdep-cancel ASM macros, convert to C Signed-off-by: Waldemar Brodkorb <w...@uclibc-ng.org> --- include/unistd.h | 5 ----- libpthread/nptl/sysdeps/unix/sysv/linux/accept.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/accept.c | 23 +++++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/connect.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/connect.c | 23 +++++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/creat.S | 7 ------ libpthread/nptl/sysdeps/unix/sysv/linux/creat.c | 22 ++++++++++++++++++ .../nptl/sysdeps/unix/sysv/linux/exit-thread.S | 22 ------------------ libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S | 7 ------ libpthread/nptl/sysdeps/unix/sysv/linux/msync.S | 7 ------ libpthread/nptl/sysdeps/unix/sysv/linux/msync.c | 19 ++++++++++++++++ .../nptl/sysdeps/unix/sysv/linux/nanosleep.S | 9 -------- .../nptl/sysdeps/unix/sysv/linux/nanosleep.c | 21 +++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/pause.S | 7 ------ .../nptl/sysdeps/unix/sysv/linux/pt-accept.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S | 9 -------- .../nptl/sysdeps/unix/sysv/linux/pt-connect.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S | 7 ------ libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S | 7 ------ .../nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S | 9 -------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S | 9 -------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S | 7 ------ libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S | 9 -------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S | 12 ---------- .../nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S | 12 ---------- .../nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S | 12 ---------- .../nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S | 12 ---------- .../nptl/sysdeps/unix/sysv/linux/pt-sendto.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S | 9 -------- libpthread/nptl/sysdeps/unix/sysv/linux/recv.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/recv.c | 19 ++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.c | 26 ++++++++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.c | 23 +++++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/send.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/send.c | 19 ++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.c | 23 +++++++++++++++++++ libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S | 12 ---------- libpthread/nptl/sysdeps/unix/sysv/linux/sendto.c | 26 ++++++++++++++++++++++ 42 files changed, 244 insertions(+), 322 deletions(-) delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/accept.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/accept.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/connect.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/connect.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/creat.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/creat.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/msync.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/msync.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pause.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/recv.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/recv.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/send.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/send.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.c delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sendto.c diff --git a/include/unistd.h b/include/unistd.h index f48ce21b3..c7364cf99 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -830,11 +830,6 @@ extern __pid_t vfork (void) __THROW; libc_hidden_proto(vfork) #endif /* Use BSD. */ -#if 0 /* psm: seems unused , exit-thread.S is not compiled */ -/* Special exit function which only terminates the current thread. */ -extern void __exit_thread (int val) __attribute__ ((__noreturn__)); -#endif - /* Return the pathname of the terminal FD is open on, or NULL on errors. The returned storage is good only until the next call to this function. */ extern char *ttyname (int __fd) __THROW; diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/accept.S b/libpthread/nptl/sysdeps/unix/sysv/linux/accept.S deleted file mode 100644 index 529763d80..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/accept.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_accept -#error Missing definition of NR_accept needed for cancellation. -#endif -PSEUDO (__libc_accept, accept, 3) -ret -PSEUDO_END(__libc_accept) -libc_hidden_def (__libc_accept) -weak_alias (__libc_accept, __accept) -libc_hidden_weak (__accept) -weak_alias (__libc_accept, accept) -libc_hidden_weak (accept) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/accept.c b/libpthread/nptl/sysdeps/unix/sysv/linux/accept.c new file mode 100644 index 000000000..edc110371 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/accept.c @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +#ifndef __NR_accept +#error Missing definition of NR_accept needed for cancellation. +#endif + +int +accept (int fd, __SOCKADDR_ARG addr, socklen_t *len) +{ + return _syscall3(int, __NC(accept), int, fd, __SOCKADDR_ARG, + addr.__sockaddr__, socklen_t*, len); +} + +CANCELLABLE_SYSCALL(int, accept, (int fd, __SOCKADDR_ARG addr, + socklen_t *len), (fd, addr, len)) + +lt_libc_hidden(accept) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/connect.S b/libpthread/nptl/sysdeps/unix/sysv/linux/connect.S deleted file mode 100644 index 441843fa0..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/connect.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_connect -#error Missing definition of NR_connect needed for cancellation. -#endif -PSEUDO (__libc_connect, connect, 3) -ret -PSEUDO_END(__libc_connect) -libc_hidden_def (__libc_connect) -weak_alias (__libc_connect, __connect) -libc_hidden_weak (__connect) -weak_alias (__libc_connect, connect) -libc_hidden_weak (connect) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/connect.c b/libpthread/nptl/sysdeps/unix/sysv/linux/connect.c new file mode 100644 index 000000000..e0d022f45 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/connect.c @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +#ifndef __NR_connect +#error Missing definition of NR_connect needed for cancellation. +#endif + +int +connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len) +{ + return _syscall3(int, __NC(connect), int, fd, __CONST_SOCKADDR_ARG, + addr.__sockaddr__, socklen_t, len); +} + +CANCELLABLE_SYSCALL(int, connect, (int fd, __CONST_SOCKADDR_ARG addr, + socklen_t len), (fd, addr, len)) + +lt_libc_hidden(connect) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/creat.S b/libpthread/nptl/sysdeps/unix/sysv/linux/creat.S deleted file mode 100644 index cd0e1b879..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/creat.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_creat, creat, 2) -ret -PSEUDO_END(__libc_creat) -libc_hidden_def (__libc_creat) -weak_alias (__libc_creat, creat) -libc_hidden_weak (creat) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/creat.c b/libpthread/nptl/sysdeps/unix/sysv/linux/creat.c new file mode 100644 index 000000000..a4c7c68e1 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/creat.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <fcntl.h> +#include <sys/types.h> +#include <cancel.h> + +int +creat (const char *file, mode_t mode) +{ +# ifdef __NR_creat + return _syscall2(int, __NC(creat), const char*, file, mode_t, mode) +# else + return __open (file, O_WRONLY | O_CREAT | O_TRUNC, mode); +# endif +} + +CANCELLABLE_SYSCALL(int, creat, (const char *file, mode_t mode), (file, mode)) + +lt_libc_hidden(creat) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S b/libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S deleted file mode 100644 index a4a7d5d16..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 1991,92,97,99,2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> - -PSEUDO (__exit_thread, exit, 1) - /* Shouldn't get here. */ -PSEUDO_END(__exit_thread) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S b/libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S deleted file mode 100644 index 70a920ba1..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_lseek, lseek, 3) -ret -PSEUDO_END (__libc_lseek) -libc_hidden_def (__libc_lseek) -weak_alias (__libc_lseek, lseek) -libc_hidden_weak (lseek) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/msync.S b/libpthread/nptl/sysdeps/unix/sysv/linux/msync.S deleted file mode 100644 index 074a0d717..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/msync.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_msync, msync, 3) -ret -PSEUDO_END(__libc_msync) -libc_hidden_def (__libc_msync) -weak_alias (__libc_msync, msync) -libc_hidden_weak (msync) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/msync.c b/libpthread/nptl/sysdeps/unix/sysv/linux/msync.c new file mode 100644 index 000000000..48ee95653 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/msync.c @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/mman.h> +#include <cancel.h> + +int +msync (void *addr, size_t length, int flags) +{ + return _syscall3(int, __NC(msync), const void* addr, + size_t, lenght, int, flags); +} + +CANCELLABLE_SYSCALL(int, msync, (const void *addr, + size_t lenght, int flags), (addr, length, flags)) + +lt_libc_hidden(msync) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S deleted file mode 100644 index 71efe32f9..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S +++ /dev/null @@ -1,9 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_nanosleep, nanosleep, 3) -ret -PSEUDO_END (__libc_nanosleep) -libc_hidden_def (__libc_nanosleep) -weak_alias (__libc_nanosleep, __nanosleep) -libc_hidden_weak (__nanosleep) -weak_alias (__libc_nanosleep, nanosleep) -libc_hidden_weak (nanosleep) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c new file mode 100644 index 000000000..73fae44bc --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <time.h> +#include <cancel.h> + +/* Pause execution for a number of nanoseconds. */ +int +nanosleep (const struct timespec *requested_time, + struct timespec *remaining) +{ + return _syscall2(int, __NC(nanosleep), const struct timespec*, + requested_time, struct timespec* remaining) +} + +CANCELLABLE_SYSCALL(int, nanosleep, (const struct timespec *requested_time, + struct timespec *remaining), (requested_time, remaining)) + +lt_libc_hidden(nanosleep) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pause.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pause.S deleted file mode 100644 index 3841018a8..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pause.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_pause, pause, 0) -ret -PSEUDO_END (__libc_pause) -libc_hidden_def (__libc_pause) -weak_alias (__libc_pause, pause) -libc_hidden_weak (pause) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S deleted file mode 100644 index 24062101d..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_accept -#error Missing definition of NR_accept needed for cancellation. -#endif -PSEUDO (__libc_accept, accept, 3) -ret -PSEUDO_END(__libc_accept) -libpthread_hidden_def (__libc_accept) -weak_alias (__libc_accept, __accept) -libpthread_hidden_weak (__accept) -weak_alias (__libc_accept, accept) -libpthread_hidden_weak (accept) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S deleted file mode 100644 index ab32ca598..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S +++ /dev/null @@ -1,9 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_close, close, 1) -ret -PSEUDO_END (__libc_close) -libpthread_hidden_def (__libc_close) -weak_alias (__libc_close, __close) -libpthread_hidden_weak (__close) -weak_alias (__libc_close, close) -libpthread_hidden_weak (close) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S deleted file mode 100644 index b5124f8ec..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_connect -#error Missing definition of NR_connect needed for cancellation. -#endif -PSEUDO (__libc_connect, connect, 3) -ret -PSEUDO_END(__libc_connect) -libpthread_hidden_def (__libc_connect) -weak_alias (__libc_connect, __connect) -libpthread_hidden_weak (__connect) -weak_alias (__libc_connect, connect) -libpthread_hidden_weak (connect) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S deleted file mode 100644 index 4db71722a..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_lseek, lseek, 3) -ret -PSEUDO_END (__libc_lseek) -libpthread_hidden_def (__libc_lseek) -weak_alias (__libc_lseek, lseek) -libpthread_hidden_weak (lseek) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S deleted file mode 100644 index 640270ad9..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_msync, msync, 3) -ret -PSEUDO_END(__libc_msync) -libpthread_hidden_def (__libc_msync) -weak_alias (__libc_msync, msync) -libpthread_hidden_weak (msync) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S deleted file mode 100644 index 08d8f0150..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S +++ /dev/null @@ -1,9 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_nanosleep, nanosleep, 3) -ret -PSEUDO_END (__libc_nanosleep) -libpthread_hidden_def (__libc_nanosleep) -weak_alias (__libc_nanosleep, __nanosleep) -libpthread_hidden_weak (__nanosleep) -weak_alias (__libc_nanosleep, nanosleep) -libpthread_hidden_weak (nanosleep) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S deleted file mode 100644 index 39ed92cc7..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S +++ /dev/null @@ -1,9 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_open, open, 3) -ret -PSEUDO_END (__libc_open) -libpthread_hidden_def (__libc_open) -weak_alias (__libc_open, __open) -libpthread_hidden_weak (__open) -weak_alias (__libc_open, open) -libpthread_hidden_weak (open) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S deleted file mode 100644 index c6cb57180..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S +++ /dev/null @@ -1,7 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_pause, pause, 0) -ret -PSEUDO_END (__libc_pause) -libpthread_hidden_def (__libc_pause) -weak_alias (__libc_pause, pause) -libpthread_hidden_weak (pause) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S deleted file mode 100644 index 623ba27a8..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S +++ /dev/null @@ -1,9 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_read, read, 3) -ret -PSEUDO_END (__libc_read) -libpthread_hidden_def (__libc_read) -weak_alias (__libc_read, __read) -libpthread_hidden_weak (__read) -weak_alias (__libc_read, read) -libpthread_hidden_weak (read) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S deleted file mode 100644 index 6d2e3c2d6..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_recv -#error Missing definition of NR_recv needed for cancellation. -#endif -PSEUDO (__libc_recv, recv, 4) -ret -PSEUDO_END(__libc_recv) -libpthread_hidden_def (__libc_recv) -weak_alias (__libc_recv, __recv) -libpthread_hidden_weak (__recv) -weak_alias (__libc_recv, recv) -libpthread_hidden_weak (recv) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S deleted file mode 100644 index 96aeeaa3d..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_recvfrom -#error Missing definition of NR_recvfrom needed for cancellation. -#endif -PSEUDO (__libc_recvfrom, recvfrom, 6) -ret -PSEUDO_END(__libc_recvfrom) -libpthread_hidden_def (__libc_recvfrom) -weak_alias (__libc_recvfrom, __recvfrom) -libpthread_hidden_weak (__recvfrom) -weak_alias (__libc_recvfrom, recvfrom) -libpthread_hidden_weak (recvfrom) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S deleted file mode 100644 index f7161e47c..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_recvmsg -#error Missing definition of NR_recvmsg needed for cancellation. -#endif -PSEUDO (__libc_recvmsg, recvmsg, 3) -ret -PSEUDO_END(__libc_recvmsg) -libpthread_hidden_def (__libc_recvmsg) -weak_alias (__libc_recvmsg, __recvmsg) -libpthread_hidden_weak (__recvmsg) -weak_alias (__libc_recvmsg, recvmsg) -libpthread_hidden_weak (recvmsg) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S deleted file mode 100644 index 76bed39ec..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_send -#error Missing definition of NR_send needed for cancellation. -#endif -PSEUDO (__libc_send, send, 4) -ret -PSEUDO_END (__libc_send) -libpthread_hidden_def (__libc_send) -weak_alias (__libc_send, __send) -libpthread_hidden_weak (__send) -weak_alias (__libc_send, send) -libpthread_hidden_weak (send) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S deleted file mode 100644 index d17096eae..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_sendmsg -#error Missing definition of NR_sendmsg needed for cancellation. -#endif -PSEUDO (__libc_sendmsg, sendmsg, 3) -ret -PSEUDO_END(__libc_sendmsg) -libpthread_hidden_def (__libc_sendmsg) -weak_alias (__libc_sendmsg, __sendmsg) -libpthread_hidden_weak (__sendmsg) -weak_alias (__libc_sendmsg, sendmsg) -libpthread_hidden_weak (sendmsg) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S deleted file mode 100644 index d07a71f8a..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_sendto -#error Missing definition of NR_sendto needed for cancellation. -#endif -PSEUDO (__libc_sendto, sendto, 6) -ret -PSEUDO_END(__libc_sendto) -libpthread_hidden_def (__libc_sendto) -weak_alias (__libc_sendto, __sendto) -libpthread_hidden_weak (__sendto) -weak_alias (__libc_sendto, sendto) -libpthread_hidden_weak (sendto) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S deleted file mode 100644 index 6bc666779..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S +++ /dev/null @@ -1,9 +0,0 @@ -#include <sysdep-cancel.h> -PSEUDO (__libc_write, write, 3) -ret -PSEUDO_END (__libc_write) -libpthread_hidden_def (__libc_write) -weak_alias (__libc_write, __write) -libpthread_hidden_weak (__write) -weak_alias (__libc_write, write) -libpthread_hidden_weak (write) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recv.S b/libpthread/nptl/sysdeps/unix/sysv/linux/recv.S deleted file mode 100644 index 95fa6516e..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/recv.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_recv -#error Missing definition of NR_recv needed for cancellation. -#endif -PSEUDO (__libc_recv, recv, 4) -ret -PSEUDO_END(__libc_recv) -libc_hidden_def (__libc_recv) -weak_alias (__libc_recv, __recv) -libc_hidden_weak (__recv) -weak_alias (__libc_recv, recv) -libc_hidden_weak (recv) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recv.c b/libpthread/nptl/sysdeps/unix/sysv/linux/recv.c new file mode 100644 index 000000000..144871c53 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/recv.c @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +ssize_t +recv (int fd, void *buf, size_t len, int flags) +{ + return _syscall4(ssize_t, __NC(recv), int, fd, void* buf, + size_t, len, int, flags); +} + +CANCELLABLE_SYSCALL(ssize_t, recv, (int fd, void *buf, + size_t len, int flags), (fd, buf, len, flags)) + +lt_libc_hidden(recv) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S b/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S deleted file mode 100644 index d9cc1e9b4..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_recvfrom -#error Missing definition of NR_recvfrom needed for cancellation. -#endif -PSEUDO (__libc_recvfrom, recvfrom, 6) -ret -PSEUDO_END(__libc_recvfrom) -libc_hidden_def (__libc_recvfrom) -weak_alias (__libc_recvfrom, __recvfrom) -libc_hidden_weak (__recvfrom) -weak_alias (__libc_recvfrom, recvfrom) -libc_hidden_weak (recvfrom) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.c b/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.c new file mode 100644 index 000000000..623b62fa0 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +#ifndef __NR_recvfrom +#error Missing definition of NR_recvfrom needed for cancellation. +#endif + +ssize_t +recvfrom (int fd, const void *buf, size_t len, int flags, + __SOCKADDR_ARG addr, socklen_t addrlen) +{ + return _syscall6(ssize_t, __NC(recvfrom), int, fd, const void* buf, + size_t, len, int, flags, __SOCKADDR_ARG, + addr.__sockaddr__, socklen_t, addrlen); +} + +CANCELLABLE_SYSCALL(ssize_t, recvfrom, (int fd, const void *buf, + size_t len, int flags, __SOCKADDR_ARG addr, + socklen_t addrlen), (fd, buf, len, flags, addr, addrlen)) + +lt_libc_hidden(recvfrom) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S deleted file mode 100644 index c761b907c..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_recvmsg -#error Missing definition of NR_recvmsg needed for cancellation. -#endif -PSEUDO (__libc_recvmsg, recvmsg, 3) -ret -PSEUDO_END(__libc_recvmsg) -libc_hidden_def (__libc_recvmsg) -weak_alias (__libc_recvmsg, __recvmsg) -libc_hidden_weak (__recvmsg) -weak_alias (__libc_recvmsg, recvmsg) -libc_hidden_weak (recvmsg) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.c b/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.c new file mode 100644 index 000000000..d0f277a97 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.c @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +#ifndef __NR_recvmsg +#error Missing definition of NR_recvmsg needed for cancellation. +#endif + +ssize_t +recvmsg (int fd, const struct msghdr *msg, int flags) +{ + return _syscall3(ssize_t, __NC(recvmsg), int, fd, const struct msghdr*, msg, + int, flags); +} + +CANCELLABLE_SYSCALL(ssize_t, recvmsg, (int fd, const struct msghdr *msg, + int flags), (fd, msg, flags)) + +lt_libc_hidden(recvmsg) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/send.S b/libpthread/nptl/sysdeps/unix/sysv/linux/send.S deleted file mode 100644 index eb744c712..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/send.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_send -#error Missing definition of NR_send needed for cancellation. -#endif -PSEUDO (__libc_send, send, 4) -ret -PSEUDO_END (__libc_send) -libc_hidden_def (__libc_send) -weak_alias (__libc_send, __send) -libc_hidden_weak (__send) -weak_alias (__libc_send, send) -libc_hidden_weak (send) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/send.c b/libpthread/nptl/sysdeps/unix/sysv/linux/send.c new file mode 100644 index 000000000..a403dde85 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/send.c @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +ssize_t +send (int fd, const void *buf, size_t len, int flags) +{ + return _syscall4(ssize_t, __NC(send), int, fd, const void* buf, + size_t, len, int, flags); +} + +CANCELLABLE_SYSCALL(ssize_t, send, (int fd, const void *buf, + size_t len, int flags), (fd, buf, len, flags)) + +lt_libc_hidden(send) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S deleted file mode 100644 index 4c41e01c1..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_sendmsg -#error Missing definition of NR_sendmsg needed for cancellation. -#endif -PSEUDO (__libc_sendmsg, sendmsg, 3) -ret -PSEUDO_END(__libc_sendmsg) -libc_hidden_def (__libc_sendmsg) -weak_alias (__libc_sendmsg, __sendmsg) -libc_hidden_weak (__sendmsg) -weak_alias (__libc_sendmsg, sendmsg) -libc_hidden_weak (sendmsg) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.c new file mode 100644 index 000000000..4e055daf5 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.c @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +#ifndef __NR_sendmsg +#error Missing definition of NR_sendmsg needed for cancellation. +#endif + +ssize_t +sendmsg (int fd, const struct msghdr *msg, int flags) +{ + return _syscall3(ssize_t, __NC(sendmsg), int, fd, const struct msghdr*, msg, + int, flags); +} + +CANCELLABLE_SYSCALL(ssize_t, sendmsg, (int fd, const struct msghdr *msg, + int flags), (fd, msg, flags)) + +lt_libc_hidden(sendmsg) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S deleted file mode 100644 index 7cb5278e9..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S +++ /dev/null @@ -1,12 +0,0 @@ -#include <sysdep-cancel.h> -#ifndef __NR_sendto -#error Missing definition of NR_sendto needed for cancellation. -#endif -PSEUDO (__libc_sendto, sendto, 6) -ret -PSEUDO_END(__libc_sendto) -libc_hidden_def (__libc_sendto) -weak_alias (__libc_sendto, __sendto) -libc_hidden_weak (__sendto) -weak_alias (__libc_sendto, sendto) -libc_hidden_weak (sendto) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.c new file mode 100644 index 000000000..216d928ce --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 Waldemar Brodkorb <w...@uclibc-ng.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/socket.h> +#include <cancel.h> + +#ifndef __NR_sendto +#error Missing definition of NR_sendto needed for cancellation. +#endif + +ssize_t +sendto (int fd, const void *buf, size_t len, int flags, + __CONST_SOCKADDR_ARG addr, socklen_t addrlen) +{ + return _syscall6(ssize_t, __NC(sendto), int, fd, const void* buf, + size_t, len, int, flags, __CONST_SOCKADDR_ARG, + addr.__sockaddr__, socklen_t, addrlen); +} + +CANCELLABLE_SYSCALL(ssize_t, sendto, (int fd, const void *buf, + size_t len, int flags, __CONST_SOCKADDR_ARG addr, + socklen_t addrlen), (fd, buf, len, flags, addr, addrlen)) + +lt_libc_hidden(sendto) -- 2.11.0
>From e07e7168fd40f340696e83668e3fae2ebfc718ea Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb <w...@uclibc-ng.org> Date: Thu, 20 Jul 2017 20:30:28 +0200 Subject: [PATCH 3/3] nptl: remove asm from sysdep-cancel.h Similar to a changeset planned in GNU C library remove any assembly code from sysdep-cancel.h. Cleanup unneeded defines in clone.S. Signed-off-by: Waldemar Brodkorb <w...@uclibc-ng.org> --- libc/sysdeps/linux/aarch64/clone.S | 8 - libc/sysdeps/linux/arm/clone.S | 7 - libc/sysdeps/linux/i386/clone.S | 1 - libc/sysdeps/linux/microblaze/clone.S | 4 - libc/sysdeps/linux/mips/clone.S | 3 - libc/sysdeps/linux/nds32/clone.S | 3 - libc/sysdeps/linux/or1k/clone.c | 1 - libc/sysdeps/linux/powerpc/clone.S | 3 - libc/sysdeps/linux/sh/clone.S | 1 - libc/sysdeps/linux/sparc/clone.S | 4 - libc/sysdeps/linux/x86_64/clone.S | 4 - libc/sysdeps/linux/xtensa/clone.S | 5 - .../unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------- .../sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +----------- .../sysdeps/unix/sysv/linux/arc/sysdep-cancel.h | 96 +-------- .../sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 212 +------------------ .../sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 121 +---------- .../sysdeps/unix/sysv/linux/metag/sysdep-cancel.h | 111 +--------- .../unix/sysv/linux/microblaze/sysdep-cancel.h | 120 +---------- .../sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 156 +------------- .../sysdeps/unix/sysv/linux/nds32/sysdep-cancel.h | 235 +-------------------- .../sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 106 +--------- .../sysdeps/unix/sysv/linux/or1k/sysdep-cancel.h | 84 +------- .../unix/sysv/linux/powerpc/sysdep-cancel.h | 84 +------- .../sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 134 +----------- .../sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 78 +------ .../sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h | 63 +----- .../sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h | 125 +---------- 28 files changed, 52 insertions(+), 1935 deletions(-) diff --git a/libc/sysdeps/linux/aarch64/clone.S b/libc/sysdeps/linux/aarch64/clone.S index 7437eec8d..74984aabb 100644 --- a/libc/sysdeps/linux/aarch64/clone.S +++ b/libc/sysdeps/linux/aarch64/clone.S @@ -1,7 +1,5 @@ /* Copyright (C) 1996-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -23,12 +21,6 @@ #define _ERRNO_H 1 #include <bits/errno.h> -#define CLONE_VM_BIT 8 -#define CLONE_VM (1 << CLONE_VM_BIT) - -#define CLONE_THREAD_BIT 16 -#define CLONE_THREAD (1 << CLONE_THREAD_BIT) - /* int clone(int (*fn)(void *arg), x0 void *child_stack, x1 int flags, x2 diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S index b156e932b..8ca50fce4 100644 --- a/libc/sysdeps/linux/arm/clone.S +++ b/libc/sysdeps/linux/arm/clone.S @@ -27,13 +27,6 @@ #include <bits/arm_asm.h> #include <bits/arm_bx.h> -#if defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_HAS_LINUXTHREADS__ -#include <sysdep-cancel.h> -#endif - -#define CLONE_VM 0x00000100 -#define CLONE_THREAD 0x00010000 - #if defined(__NR_clone) /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ diff --git a/libc/sysdeps/linux/i386/clone.S b/libc/sysdeps/linux/i386/clone.S index 68e87b567..ec1aeeaf1 100644 --- a/libc/sysdeps/linux/i386/clone.S +++ b/libc/sysdeps/linux/i386/clone.S @@ -1,5 +1,4 @@ /* Copyright (C) 1996-2000,02,03,04,2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. Contributed by Richard Henderson (r...@tamu.edu) The GNU C Library is free software; you can redistribute it and/or diff --git a/libc/sysdeps/linux/microblaze/clone.S b/libc/sysdeps/linux/microblaze/clone.S index 69c20453f..cbc95ce26 100644 --- a/libc/sysdeps/linux/microblaze/clone.S +++ b/libc/sysdeps/linux/microblaze/clone.S @@ -23,10 +23,6 @@ #define _ERRNO_H 1 #include <bits/errno.h> -#if defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_HAS_LINUXTHREADS__ -#include <sysdep-cancel.h> -#endif - /* int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, pid_t *ptid, struct user_desc *tls, pid_t *ctid); diff --git a/libc/sysdeps/linux/mips/clone.S b/libc/sysdeps/linux/mips/clone.S index 326d1d34a..f95adaf0d 100644 --- a/libc/sysdeps/linux/mips/clone.S +++ b/libc/sysdeps/linux/mips/clone.S @@ -25,9 +25,6 @@ #define _ERRNO_H 1 #include <bits/errno.h> -#define CLONE_VM 0x00000100 -#define CLONE_THREAD 0x00010000 - /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, void *parent_tidptr, void *tls, void *child_tidptr) */ diff --git a/libc/sysdeps/linux/nds32/clone.S b/libc/sysdeps/linux/nds32/clone.S index 0e6e432de..b28619bf1 100644 --- a/libc/sysdeps/linux/nds32/clone.S +++ b/libc/sysdeps/linux/nds32/clone.S @@ -28,9 +28,6 @@ #define _ERRNO_H 1 #include <bits/errno.h> -#define CLONE_VM 0x00000100 -#define CLONE_THREAD 0x00010000 - /* int clone(int (*fn)(void *), void *child_stack, int flags, void *arg); _syscall2(int, clone, int, flags, void *, child_stack) */ diff --git a/libc/sysdeps/linux/or1k/clone.c b/libc/sysdeps/linux/or1k/clone.c index 2b61b638f..2cb39810f 100644 --- a/libc/sysdeps/linux/or1k/clone.c +++ b/libc/sysdeps/linux/or1k/clone.c @@ -1,5 +1,4 @@ /* Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/libc/sysdeps/linux/powerpc/clone.S b/libc/sysdeps/linux/powerpc/clone.S index 45319d00d..452dc7016 100644 --- a/libc/sysdeps/linux/powerpc/clone.S +++ b/libc/sysdeps/linux/powerpc/clone.S @@ -21,9 +21,6 @@ #include <bits/errno.h> #include <sysdep.h> -#define CLONE_VM 0x00000100 -#define CLONE_THREAD 0x00010000 - /* This is the only really unusual system call in PPC linux, but not because of any weirdness in the system call itself; because of all the freaky stuff we have to do to make the call useful. */ diff --git a/libc/sysdeps/linux/sh/clone.S b/libc/sysdeps/linux/sh/clone.S index 334f83f1a..cfc61e6d6 100644 --- a/libc/sysdeps/linux/sh/clone.S +++ b/libc/sysdeps/linux/sh/clone.S @@ -1,5 +1,4 @@ /* Copyright (C) 1999, 2000, 2003, 2004, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/libc/sysdeps/linux/sparc/clone.S b/libc/sysdeps/linux/sparc/clone.S index c1e587060..9d979d10d 100644 --- a/libc/sysdeps/linux/sparc/clone.S +++ b/libc/sysdeps/linux/sparc/clone.S @@ -1,6 +1,5 @@ /* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. Contributed by Richard Henderson (r...@tamu.edu). The GNU C Library is free software; you can redistribute it and/or @@ -24,9 +23,6 @@ #include <asm/unistd.h> #include <sysdep.h> -#define CLONE_VM 0x00000100 -#define CLONE_THREAD 0x00010000 - /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, pid_t *ptid, void *tls, pid_t *ctid); */ diff --git a/libc/sysdeps/linux/x86_64/clone.S b/libc/sysdeps/linux/x86_64/clone.S index 3dda8da02..9ffcd49c4 100644 --- a/libc/sysdeps/linux/x86_64/clone.S +++ b/libc/sysdeps/linux/x86_64/clone.S @@ -1,5 +1,4 @@ /* Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,9 +22,6 @@ #include <bits/errno.h> #include <sys/syscall.h> -#define CLONE_VM 0x00000100 -#define CLONE_THREAD 0x00010000 - /* The userland implementation is: int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg), the kernel entry is: diff --git a/libc/sysdeps/linux/xtensa/clone.S b/libc/sysdeps/linux/xtensa/clone.S index 913ec5a5f..ebfdcc1f6 100644 --- a/libc/sysdeps/linux/xtensa/clone.S +++ b/libc/sysdeps/linux/xtensa/clone.S @@ -22,7 +22,6 @@ #define _ERRNO_H 1 #include <bits/errno.h> #define __ASSEMBLY__ -#include <linux/sched.h> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, a2 a3 a4 a5 @@ -69,10 +68,6 @@ ENTRY (__clone) .Lthread_start: -#if CLONE_THREAD != 0x00010000 || CLONE_VM != 0x00000100 -# error invalid values for CLONE_THREAD or CLONE_VM -#endif - /* start child thread */ movi a0, 0 /* terminate the stack frame */ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h index 0942e819e..a6c98b6f8 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h @@ -22,102 +22,23 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ -ENTRY (__##syscall_name##_nocancel); \ -.Lpseudo_nocancel: \ - DO_CALL (syscall_name, args); \ -.Lpseudo_finish: \ - cmn x0, 4095; \ - b.cs .Lsyscall_error; \ - .subsection 2; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ -ENTRY (name); \ - SINGLE_THREAD_P(16); \ - cbz w16, .Lpseudo_nocancel; \ - /* Setup common stack frame no matter the number of args. \ - Also save the first arg, since it's basically free. */ \ - stp x30, x0, [sp, -64]!; \ - cfi_adjust_cfa_offset (64); \ - cfi_rel_offset (x30, 0); \ - DOCARGS_##args; /* save syscall args around CENABLE. */ \ - CENABLE; \ - mov x16, x0; /* save mask around syscall. */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - DO_CALL (syscall_name, args); \ - str x0, [sp, 8]; /* save result around CDISABLE. */ \ - mov x0, x16; /* restore mask for CDISABLE. */ \ - CDISABLE; \ - /* Break down the stack frame, restoring result at once. */ \ - ldp x30, x0, [sp], 64; \ - cfi_adjust_cfa_offset (-64); \ - cfi_restore (x30); \ - b .Lpseudo_finish; \ - cfi_endproc; \ - .size name, .-name; \ - .previous - -# undef PSEUDO_END -# define PSEUDO_END(name) \ - SYSCALL_ERROR_HANDLER; \ - cfi_endproc - -# define DOCARGS_0 -# define DOCARGS_1 -# define DOCARGS_2 str x1, [sp, 16] -# define DOCARGS_3 stp x1, x2, [sp, 16] -# define DOCARGS_4 DOCARGS_3; str x3, [sp, 32] -# define DOCARGS_5 DOCARGS_3; stp x3, x4, [sp, 32] -# define DOCARGS_6 DOCARGS_5; str x5, [sp, 48] - -# define UNDOCARGS_0 -# define UNDOCARGS_1 ldr x0, [sp, 8] -# define UNDOCARGS_2 ldp x0, x1, [sp, 8] -# define UNDOCARGS_3 UNDOCARGS_1; ldp x1, x2, [sp, 16] -# define UNDOCARGS_4 UNDOCARGS_2; ldp x2, x3, [sp, 24] -# define UNDOCARGS_5 UNDOCARGS_3; ldp x3, x4, [sp, 32] -# define UNDOCARGS_6 UNDOCARGS_4; ldp x4, x5, [sp, 40] - # if defined IS_IN_libpthread -# define CENABLE bl __pthread_enable_asynccancel -# define CDISABLE bl __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE bl __libc_enable_asynccancel -# define CDISABLE bl __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE bl __librt_enable_asynccancel -# define CDISABLE bl __librt_disable_asynccancel -# else -# error Unsupported library # endif # if defined IS_IN_libpthread || !defined NOT_IN_libc -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P(R) \ - adrp x##R, __local_multiple_threads; \ - ldr w##R, [x##R, :lo12:__local_multiple_threads] -# endif +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else /* There is no __local_multiple_threads for librt, so use the TCB. */ -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(R) \ - mrs x##R, tpidr_el0; \ - sub x##R, x##R, PTHREAD_SIZEOF; \ - ldr w##R, [x##R, PTHREAD_MULTIPLE_THREADS_OFFSET] -# endif # endif -#elif !defined __ASSEMBLER__ +#else /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -125,8 +46,6 @@ extern int __local_multiple_threads attribute_hidden; #endif -#ifndef __ASSEMBLER__ # define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h index 51f1bd42a..4f60558bf 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h @@ -23,143 +23,20 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# ifdef PROF -# define PSEUDO_PROF \ - .set noat; \ - lda AT, _mcount; \ - jsr AT, (AT), _mcount; \ - .set at -# else -# define PSEUDO_PROF -# endif - -/* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END - besides "ret". */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .globl name; \ - .align 4; \ - .type name, @function; \ - .usepv name, std; \ - cfi_startproc; \ -__LABEL(name) \ - ldgp gp, 0(pv); \ - PSEUDO_PROF; \ - PSEUDO_PREPARE_ARGS \ - SINGLE_THREAD_P(t0); \ - bne t0, $pseudo_cancel; \ - lda v0, SYS_ify(syscall_name); \ - call_pal PAL_callsys; \ - bne a3, SYSCALL_ERROR_LABEL; \ -__LABEL($pseudo_ret) \ - .subsection 2; \ - cfi_startproc; \ -__LABEL($pseudo_cancel) \ - subq sp, 64, sp; \ - cfi_def_cfa_offset(64); \ - stq ra, 0(sp); \ - cfi_offset(ra, -64); \ - SAVE_ARGS_##args; \ - CENABLE; \ - LOAD_ARGS_##args; \ - /* Save the CENABLE return value in RA. That register \ - is preserved across syscall and the real return \ - address is saved on the stack. */ \ - mov v0, ra; \ - lda v0, SYS_ify(syscall_name); \ - call_pal PAL_callsys; \ - stq v0, 8(sp); \ - mov ra, a0; \ - bne a3, $multi_error; \ - CDISABLE; \ - ldq ra, 0(sp); \ - ldq v0, 8(sp); \ - addq sp, 64, sp; \ - cfi_remember_state; \ - cfi_restore(ra); \ - cfi_def_cfa_offset(0); \ - ret; \ - cfi_restore_state; \ -__LABEL($multi_error) \ - CDISABLE; \ - ldq ra, 0(sp); \ - ldq v0, 8(sp); \ - addq sp, 64, sp; \ - cfi_restore(ra); \ - cfi_def_cfa_offset(0); \ -__LABEL($syscall_error) \ - SYSCALL_ERROR_HANDLER; \ - cfi_endproc; \ - .previous - -# undef PSEUDO_END -# define PSEUDO_END(sym) \ - cfi_endproc; \ - .subsection 2; \ - .size sym, .-sym - -# define SAVE_ARGS_0 /* Nothing. */ -# define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp) -# define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp) -# define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp) -# define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp) -# define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp) -# define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp) - -# define LOAD_ARGS_0 /* Nothing. */ -# define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp) -# define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp) -# define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp) -# define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp) -# define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp) -# define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp) - # ifdef IS_IN_libpthread -# define __local_enable_asynccancel __pthread_enable_asynccancel -# define __local_disable_asynccancel __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define __local_enable_asynccancel __libc_enable_asynccancel -# define __local_disable_asynccancel __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define __local_enable_asynccancel __librt_enable_asynccancel -# define __local_disable_asynccancel __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -# ifdef __PIC__ -# define CENABLE bsr ra, __local_enable_asynccancel !samegp -# define CDISABLE bsr ra, __local_disable_asynccancel !samegp -# else -# define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp) -# define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp) # endif # if defined IS_IN_libpthread || !defined NOT_IN_libc -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (__local_multiple_threads == 0, 1) -# elif defined(__PIC__) -# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel -# else -# define SINGLE_THREAD_P(reg) \ - ldah reg, __local_multiple_threads(gp) !gprelhigh; \ - ldl reg, __local_multiple_threads(reg) !gprellow -# endif # else -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - call_pal PAL_rduniq; \ - ldl reg, MULTIPLE_THREADS_OFFSET($0) -# endif # endif #else @@ -169,8 +46,6 @@ extern int __local_multiple_threads attribute_hidden; #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h index 01fd844d1..cfe55751f 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h @@ -12,107 +12,13 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -#ifdef __ASSEMBLER__ - -#undef ret -#define ret - -# undef PSEUDO -# define PSEUDO(name, syscall_name, nargs) \ - /* vanilla version */ ` \ - ENTRY(name##_nocancel) ` \ - DO_CALL (__NR_##syscall_name) ` \ - jls [blink] ` \ - b __syscall_error@plt ` \ - END(name##_nocancel) ` \ - /* thread cancellation variant */ ` \ - ENTRY(name) ` \ - SINGLE_THREAD_P ` \ - bz name##_nocancel ` \ - DOCARGS_##nargs /* stash syscall args */ ` \ - CENABLE /* call enable_asynccancel */ ` \ - mov r9, r0 /* Safe-keep mask */ ` \ - UNDOCARGS_##nargs /* restore syscall args */ ` \ - DO_CALL (__NR_##syscall_name) ` \ - push r0 /* save syscall return value */ ` \ - mov r0, r9 /* prep mask for disable_asynccancel */ ` \ - CDISABLE ` \ - pop r0 /* get syscall ret value back */ ` \ - pop blink /* UNDOCARGS above left blink on stack */ ` \ - cmp r0, -1024 ` \ - jls [blink] ` \ - b __syscall_error@plt ` \ - END(name) - -#undef PSEUDO_END -#define PSEUDO_END(name) \ - # ifdef IS_IN_libpthread -# define CENABLE bl __pthread_enable_asynccancel -# define CDISABLE bl __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE bl __libc_enable_asynccancel -# define CDISABLE bl __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE bl __librt_enable_asynccancel -# define CDISABLE bl __librt_disable_asynccancel -# else -# error Unsupported library # endif -#define DO_CALL(num) \ - mov r8, num ` \ - ARC_TRAP_INSN ` \ - cmp r0, -1024 - -.macro push reg - st.a \reg, [sp, -4] -.endm - -.macro pop reg - ld.ab \reg, [sp, 4] -.endm - -#define DOCARGS_0 push blink - -/* don't pop blink at this point */ -#define UNDOCARGS_0 ld blink, [sp] - -#define DOCARGS_1 DOCARGS_0` push r0 -#define UNDOCARGS_1 pop r0` UNDOCARGS_0 - -#define DOCARGS_2 DOCARGS_1` push r1 -#define UNDOCARGS_2 pop r1` UNDOCARGS_1 - -#define DOCARGS_3 DOCARGS_2` push r2 -#define UNDOCARGS_3 pop r2` UNDOCARGS_2 - -#define DOCARGS_4 DOCARGS_3` push r3 -#define UNDOCARGS_4 pop r3` UNDOCARGS_3 - -#define DOCARGS_5 DOCARGS_4` push r4 -#define UNDOCARGS_5 pop r4` UNDOCARGS_4 - -#define DOCARGS_6 DOCARGS_5` push r5 -#define UNDOCARGS_6 pop r5` UNDOCARGS_5 - -#define DOCARGS_7 DOCARGS_6` push r6 -#define UNDOCARGS_7 pop r6` UNDOCARGS_6 - -# define SINGLE_THREAD_P \ - THREAD_SELF r9 ` \ - ld r10, [r9, MULTIPLE_THREADS_OFFSET]` \ - cmp r10, 0 - -/* ld r2, [r1, -TLS_PRE_TCB_SIZE + MULTIPLE_THREADS_OFFSET] */ -#else /* !__ASSEMBLER__ */ - -/* TBD: Can use @__local_multiple_threads for libc/libpthread like ARM */ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ likely(THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0) -#endif /* __ASSEMBLER__ */ - #endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h index 6f683ab72..ab2a2de52 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h @@ -1,5 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. +/* Copyright (C) 2003-2017 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,222 +22,23 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -/* NOTE: We do mark syscalls with unwind annotations, for the benefit of - cancellation; but they're really only accurate at the point of the - syscall. The ARM unwind directives are not rich enough without adding - a custom personality function. */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ - PSEUDO_PROLOGUE; \ - .type __##syscall_name##_nocancel,%function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - cfi_sections(.debug_frame); \ - cfi_startproc; \ - DO_CALL (syscall_name, args); \ - PSEUDO_RET; \ - cfi_endproc; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name); \ - SINGLE_THREAD_P; \ - DOARGS_##args; \ - bne .Lpseudo_cancel; \ - cfi_remember_state; \ - DO_CALL (syscall_name, 0); \ - UNDOARGS_##args; \ - cmn r0, $4096; \ - PSEUDO_RET; \ - cfi_restore_state; \ - .Lpseudo_cancel: \ - .fnstart; \ - DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \ - CENABLE; \ - mov ip, r0; /* put mask in safe place. */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - ldr r7, =SYS_ify (syscall_name); \ - swi 0x0; /* do the call. */ \ - .fnend; /* Past here we can't easily unwind. */ \ - mov r7, r0; /* save syscall return value. */ \ - mov r0, ip; /* get mask back. */ \ - CDISABLE; \ - mov r0, r7; /* retrieve return value. */ \ - RESTORE_LR_##args; \ - UNDOARGS_##args; \ - cmn r0, $4096 - -/* DOARGS pushes four bytes on the stack for five arguments, eight bytes for - six arguments, and nothing for fewer. In order to preserve doubleword - alignment, sometimes we must save an extra register. */ - -# define RESTART_UNWIND \ - .fnend; \ - .fnstart; \ - .save {r7, lr} - -# define DOCARGS_0 \ - stmfd sp!, {r7, lr}; \ - cfi_adjust_cfa_offset (8); \ - cfi_rel_offset (r7, 0); \ - cfi_rel_offset (lr, 4); \ - .save {r7, lr} -# define UNDOCARGS_0 -# define RESTORE_LR_0 \ - ldmfd sp!, {r7, lr}; \ - cfi_adjust_cfa_offset (-8); \ - cfi_restore (r7); \ - cfi_restore (lr) - -# define DOCARGS_1 \ - stmfd sp!, {r0, r1, r7, lr}; \ - cfi_adjust_cfa_offset (16); \ - cfi_rel_offset (r7, 8); \ - cfi_rel_offset (lr, 12); \ - .save {r7, lr}; \ - .pad #8 -# define UNDOCARGS_1 \ - ldr r0, [sp], #8; \ - cfi_adjust_cfa_offset (-8); \ - RESTART_UNWIND -# define RESTORE_LR_1 \ - RESTORE_LR_0 - -# define DOCARGS_2 \ - stmfd sp!, {r0, r1, r7, lr}; \ - cfi_adjust_cfa_offset (16); \ - cfi_rel_offset (r7, 8); \ - cfi_rel_offset (lr, 12); \ - .save {r7, lr}; \ - .pad #8 -# define UNDOCARGS_2 \ - ldmfd sp!, {r0, r1}; \ - cfi_adjust_cfa_offset (-8); \ - RESTART_UNWIND -# define RESTORE_LR_2 \ - RESTORE_LR_0 - -# define DOCARGS_3 \ - stmfd sp!, {r0, r1, r2, r3, r7, lr}; \ - cfi_adjust_cfa_offset (24); \ - cfi_rel_offset (r7, 16); \ - cfi_rel_offset (lr, 20); \ - .save {r7, lr}; \ - .pad #16 -# define UNDOCARGS_3 \ - ldmfd sp!, {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - RESTART_UNWIND -# define RESTORE_LR_3 \ - RESTORE_LR_0 - -# define DOCARGS_4 \ - stmfd sp!, {r0, r1, r2, r3, r7, lr}; \ - cfi_adjust_cfa_offset (24); \ - cfi_rel_offset (r7, 16); \ - cfi_rel_offset (lr, 20); \ - .save {r7, lr}; \ - .pad #16 -# define UNDOCARGS_4 \ - ldmfd sp!, {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - RESTART_UNWIND -# define RESTORE_LR_4 \ - RESTORE_LR_0 - -/* r4 is only stmfd'ed for correct stack alignment. */ -# define DOCARGS_5 \ - .save {r4}; \ - stmfd sp!, {r0, r1, r2, r3, r4, r7, lr}; \ - cfi_adjust_cfa_offset (28); \ - cfi_rel_offset (r7, 20); \ - cfi_rel_offset (lr, 24); \ - .save {r7, lr}; \ - .pad #20 -# define UNDOCARGS_5 \ - ldmfd sp!, {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - .fnend; \ - .fnstart; \ - .save {r4}; \ - .save {r7, lr}; \ - .pad #4 -# define RESTORE_LR_5 \ - ldmfd sp!, {r4, r7, lr}; \ - cfi_adjust_cfa_offset (-12); \ - /* r4 will be marked as restored later. */ \ - cfi_restore (r7); \ - cfi_restore (lr) - -# define DOCARGS_6 \ - .save {r4, r5}; \ - stmfd sp!, {r0, r1, r2, r3, r7, lr}; \ - cfi_adjust_cfa_offset (24); \ - cfi_rel_offset (r7, 16); \ - cfi_rel_offset (lr, 20); \ - .save {r7, lr}; \ - .pad #16 -# define UNDOCARGS_6 \ - ldmfd sp!, {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - .fnend; \ - .fnstart; \ - .save {r4, r5}; \ - .save {r7, lr} -# define RESTORE_LR_6 \ - RESTORE_LR_0 - # ifdef IS_IN_libpthread -# define CENABLE bl PLTJMP(__pthread_enable_asynccancel) -# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel) # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE bl PLTJMP(__libc_enable_asynccancel) -# define CDISABLE bl PLTJMP(__libc_disable_asynccancel) # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE bl PLTJMP(__librt_enable_asynccancel) -# define CDISABLE bl PLTJMP(__librt_disable_asynccancel) -# else -# error Unsupported library # endif # if defined IS_IN_libpthread || !defined NOT_IN_libc -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P \ - ldr ip, 1b; \ -2: \ - ldr ip, [pc, ip]; \ - teq ip, #0; -# define PSEUDO_PROLOGUE \ - 1: .word __local_multiple_threads - 2f - 8; -# endif +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else /* There is no __local_multiple_threads for librt, so use the TCB. */ -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define PSEUDO_PROLOGUE -# define SINGLE_THREAD_P \ - stmfd sp!, {r0, lr}; \ - cfi_adjust_cfa_offset (8); \ - cfi_rel_offset (lr, 4); \ - bl __aeabi_read_tp; \ - ldr ip, [r0, #MULTIPLE_THREADS_OFFSET]; \ - ldmfd sp!, {r0, lr}; \ - cfi_adjust_cfa_offset (-8); \ - cfi_restore (lr); \ - teq ip, #0 -# define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P -# endif # endif -#elif !defined __ASSEMBLER__ +#else /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -246,8 +46,6 @@ extern int __local_multiple_threads attribute_hidden; #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h index b0eb02600..ba88c55e2 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h @@ -1,5 +1,4 @@ /* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. Contributed by Jakub Jelinek <ja...@redhat.com>, 2002. The GNU C Library is free software; you can redistribute it and/or @@ -24,131 +23,17 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \ - jne L(pseudo_cancel); \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - cmpl $-4095, %eax; \ - jae SYSCALL_ERROR_LABEL; \ - ret; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - L(pseudo_cancel): \ - CENABLE \ - SAVE_OLDTYPE_##args \ - PUSHCARGS_##args \ - DOCARGS_##args \ - movl $SYS_ify (syscall_name), %eax; \ - ENTER_KERNEL; \ - POPCARGS_##args; \ - POPSTATE_##args \ - cmpl $-4095, %eax; \ - jae SYSCALL_ERROR_LABEL; \ - L(pseudo_end): - -# define SAVE_OLDTYPE_0 movl %eax, %ecx; -# define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0 -# define SAVE_OLDTYPE_2 pushl %eax; cfi_adjust_cfa_offset (4); -# define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2 -# define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2 -# define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2 -# define SAVE_OLDTYPE_6 SAVE_OLDTYPE_2 - -# define PUSHCARGS_0 /* No arguments to push. */ -# define DOCARGS_0 /* No arguments to frob. */ -# define POPCARGS_0 /* No arguments to pop. */ -# define _PUSHCARGS_0 /* No arguments to push. */ -# define _POPCARGS_0 /* No arguments to pop. */ - -# define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0 -# define DOCARGS_1 _DOARGS_1 (4) -# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx); -# define _PUSHCARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (ebx, 0); _PUSHCARGS_0 -# define _POPCARGS_1 _POPCARGS_0; popl %ebx; \ - cfi_adjust_cfa_offset (-4); cfi_restore (ebx); - -# define PUSHCARGS_2 PUSHCARGS_1 -# define DOCARGS_2 _DOARGS_2 (12) -# define POPCARGS_2 POPCARGS_1 -# define _PUSHCARGS_2 _PUSHCARGS_1 -# define _POPCARGS_2 _POPCARGS_1 - -# define PUSHCARGS_3 _PUSHCARGS_2 -# define DOCARGS_3 _DOARGS_3 (20) -# define POPCARGS_3 _POPCARGS_3 -# define _PUSHCARGS_3 _PUSHCARGS_2 -# define _POPCARGS_3 _POPCARGS_2 - -# define PUSHCARGS_4 _PUSHCARGS_4 -# define DOCARGS_4 _DOARGS_4 (28) -# define POPCARGS_4 _POPCARGS_4 -# define _PUSHCARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (esi, 0); _PUSHCARGS_3 -# define _POPCARGS_4 _POPCARGS_3; popl %esi; \ - cfi_adjust_cfa_offset (-4); cfi_restore (esi); - -# define PUSHCARGS_5 _PUSHCARGS_5 -# define DOCARGS_5 _DOARGS_5 (36) -# define POPCARGS_5 _POPCARGS_5 -# define _PUSHCARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (edi, 0); _PUSHCARGS_4 -# define _POPCARGS_5 _POPCARGS_4; popl %edi; \ - cfi_adjust_cfa_offset (-4); cfi_restore (edi); - -# define PUSHCARGS_6 _PUSHCARGS_6 -# define DOCARGS_6 _DOARGS_6 (44) -# define POPCARGS_6 _POPCARGS_6 -# define _PUSHCARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (ebp, 0); _PUSHCARGS_5 -# define _POPCARGS_6 _POPCARGS_5; popl %ebp; \ - cfi_adjust_cfa_offset (-4); cfi_restore (ebp); - -# ifdef IS_IN_libpthread -# define CENABLE call __pthread_enable_asynccancel; -# define CDISABLE call __pthread_disable_asynccancel -# elif !defined NOT_IN_libc -# define CENABLE call __libc_enable_asynccancel; -# define CDISABLE call __libc_disable_asynccancel -# elif defined IS_IN_librt -# define CENABLE call __librt_enable_asynccancel; -# define CDISABLE call __librt_disable_asynccancel -# else -# error Unsupported library -# endif -# define POPSTATE_0 \ - pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \ - CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4); -# define POPSTATE_1 POPSTATE_0 -# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; \ - cfi_adjust_cfa_offset (-4); -# define POPSTATE_3 POPSTATE_2 -# define POPSTATE_4 POPSTATE_3 -# define POPSTATE_5 POPSTATE_4 -# define POPSTATE_6 POPSTATE_5 - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h index c44b1039d..72823c0f2 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h @@ -1,5 +1,4 @@ /* Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,120 +22,16 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -/* NOTE: We do mark syscalls with unwind annotations, for the benefit of - cancellation; but they're really only accurate at the point of the - syscall. The ARM unwind directives are not rich enough without adding - a custom personality function. */ - -#ifdef __ASSEMBLER__ -#undef ret -#define ret \ - CMP D0Re0, #-4095; \ - MOVLO PC, D1RtP; \ - MOV D1Ar1, D0Re0; \ - B SYSCALL_ERROR; -#endif /* __ASSEMBLER__ */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ - .type ___##syscall_name##_nocancel,%function; \ - .globl ___##syscall_name##_nocancel; \ - ___##syscall_name##_nocancel: \ - cfi_startproc; \ - DO_CALL (syscall_name, args); \ - MOV PC, D1RtP; \ - cfi_endproc; \ - .size ___##syscall_name##_nocancel,.-___##syscall_name##_nocancel; \ - .globl _##name; \ - .type _##name, @function; \ -name##: \ -_##name##: \ - DOCARGS_##args; \ - SINGLE_THREAD_P; \ - UNDOCARGS_##args; \ - BNE .Lpseudo_cancel; \ - cfi_remember_state; \ - DO_CALL (syscall_name, 0); \ - ret \ - cfi_restore_state; \ - .Lpseudo_cancel: \ - MSETL [A0StP++], D0FrT, D0.5; \ - DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \ - CENABLE; \ - MOV D0FrT, D0Re0; /* put mask in safe place. */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - DO_CALL(syscall_name, 0); /* do the call. */ \ - MOV D0.5, D0Re0; /* save syscall return value. */ \ - MOV D1Ar1, D0FrT; /* get mask back. */ \ - CDISABLE; \ - MOV D0Re0, D0.5; /* retrieve return value. */ \ - GETL D0.5, D1.5, [--A0StP]; \ - GETL D0FrT, D1RtP, [--A0StP]; - -# define DOCARGS_0 -# define UNDOCARGS_0 - -# define DOCARGS_1 \ - SETL [A0StP++], D1Ar1, D0Ar2 -# define UNDOCARGS_1 \ - GETL D1Ar1, D0Ar2, [--A0StP] - -# define DOCARGS_2 DOCARGS_1 - -# define UNDOCARGS_2 UNDOCARGS_2 - -# define DOCARGS_3 \ - MSETL [A0StP++], D1Ar1, D1Ar3 - -# define UNDOCARGS_3 \ - GETL D1Ar1, D0Ar2, [--A0StP]; \ - GETL D1Ar3, D0Ar4, [--A0StP] - -# define DOCARGS_4 DOCARGS_3 -# define UNDOCARGS_4 UNDOCARGS_3 - -# define DOCARGS_5 \ - MSETL [A0StP++], D1Ar1, D1Ar3, D1Ar5 -# define UNDOCARGS_5 \ - GETL D1Ar1, D0Ar2, [--A0StP]; \ - GETL D1Ar3, D0Ar4, [--A0StP]; \ - GETL D1Ar5, D0Ar6, [--A0StP] - -# define DOCARGS_6 DOCARGS_5 -# define UNDOCARGS_6 UNDOCARGS_5 - # ifdef IS_IN_libpthread -# define CENABLE CALLR D1RtP, ___pthread_enable_asynccancel@PLT -# define CDISABLE CALLR D1RtP, ___pthread_disable_asynccancel@PLT # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE CALLR D1RtP, ___libc_enable_asynccancel@PLT -# define CDISABLE CALLR D1RtP, ___libc_disable_asynccancel@PLT # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE CALLR D1RtP, ___librt_enable_asynccancel@PLT -# define CDISABLE CALLR D1RtP, ___librt_disable_asynccancel@PLT -# else -# error Unsupported library # endif -#ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +#define SINGLE_THREAD_P \ likely(THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0) #else -# define SINGLE_THREAD_P \ - SETL [A0StP++], D0FrT, D1RtP; \ - CALLR D1RtP, ___metag_load_tp@PLT; \ - SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE; \ - GETD D0Re0, [D0Re0 + #MULTIPLE_THREADS_OFFSET]; \ - CMP D0Re0, #0; \ - GETL D0FrT, D1RtP, [--A0StP] -#endif - - -#elif !defined __ASSEMBLER__ /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -144,8 +39,6 @@ _##name##: \ #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ likely(THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h index a03e42a40..0baa76f2e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h @@ -1,5 +1,4 @@ -/* Copyright (C) 2014-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. +/* Copyright (C) 2014-2017 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,129 +22,28 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# if !defined IS_IN_librt || !defined(PIC) -# define AC_STACK_SIZE 16 /* space for r15, async_cancel arg and 2 temp words */ -# define AC_SET_GOT /* empty */ -# define AC_RESTORE_GOT /* empty */ -# else -# define AC_STACK_SIZE 20 /* extra 4 bytes for r20 */ -# define AC_SET_GOT \ - swi r20, r1, AC_STACK_SIZE-4; \ - mfs r20, rpc; \ - addik r20, r20, _GLOBAL_OFFSET_TABLE_+8; -# define AC_RESTORE_GOT \ - lwi r20, r1, AC_STACK_SIZE-4; -# endif - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P(r12); \ - bnei r12, L(pseudo_cancel); \ - .globl __##syscall_name##_nocancel; \ - .type __##syscall_name##_nocancel,@function; \ -__##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - addik r4, r0, -4095; \ - cmpu r4, r4, r3; \ - bgei r4, SYSCALL_ERROR_LABEL; \ - rtsd r15, 8; \ - nop; \ - .size __##syscall_name##_nocancel, .-__##syscall_name##_nocancel; \ -L(pseudo_cancel): \ - addik r1, r1, -AC_STACK_SIZE; \ - swi r15, r1, 0; \ - AC_SET_GOT \ - DOCARGS_##args \ - CENABLE; \ - swi r3, r1, 8; \ - UNDOCARGS_##args \ - DO_CALL (syscall_name, args); \ - swi r3, r1, 12; \ - lwi r5, r1, 8; \ - CDISABLE; \ - lwi r3, r1, 12; \ - lwi r15, r1, 0; \ - AC_RESTORE_GOT \ - addik r1, r1, AC_STACK_SIZE; \ - addik r4, r0, -4095; \ - cmpu r4, r4, r3; \ - bgei r4, SYSCALL_ERROR_LABEL; \ - rtsd r15, 8; \ - nop; - -/* - * Macros to save/restore syscall arguments across CENABLE - * The arguments are saved into the caller's stack (original r1 + 4) - */ - -# define DOCARGS_0 -# define DOCARGS_1 swi r5, r1, AC_STACK_SIZE + 4; -# define DOCARGS_2 swi r6, r1, AC_STACK_SIZE + 8; DOCARGS_1 -# define DOCARGS_3 swi r7, r1, AC_STACK_SIZE + 12; DOCARGS_2 -# define DOCARGS_4 swi r8, r1, AC_STACK_SIZE + 16; DOCARGS_3 -# define DOCARGS_5 swi r9, r1, AC_STACK_SIZE + 20; DOCARGS_4 -# define DOCARGS_6 swi r10, r1, AC_STACK_SIZE + 24; DOCARGS_5 - -# define UNDOCARGS_0 -# define UNDOCARGS_1 lwi r5, r1, AC_STACK_SIZE + 4; -# define UNDOCARGS_2 UNDOCARGS_1 lwi r6, r1, AC_STACK_SIZE + 8; -# define UNDOCARGS_3 UNDOCARGS_2 lwi r7, r1, AC_STACK_SIZE + 12; -# define UNDOCARGS_4 UNDOCARGS_3 lwi r8, r1, AC_STACK_SIZE + 16; -# define UNDOCARGS_5 UNDOCARGS_4 lwi r9, r1, AC_STACK_SIZE + 20; -# define UNDOCARGS_6 UNDOCARGS_5 lwi r10, r1, AC_STACK_SIZE + 24; - -# ifdef PIC -# define PSEUDO_JMP(sym) brlid r15, sym##@PLTPC; addk r0, r0, r0 -# else -# define PSEUDO_JMP(sym) brlid r15, sym; addk r0, r0, r0 -# endif - # if defined IS_IN_libpthread -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# error Unsupported library # endif -#if !defined NOT_IN_libc || defined IS_IN_libpthread -# ifndef __ASSEMBLER__ +# if !defined NOT_IN_libc || defined IS_IN_libpthread extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# if !defined PIC -# define SINGLE_THREAD_P(reg) lwi reg, r0, __local_multiple_threads; -# else -# define SINGLE_THREAD_P(reg) \ - mfs reg, rpc; \ - addik reg, reg, _GLOBAL_OFFSET_TABLE_+8; \ - lwi reg, reg, __local_multiple_threads@GOT; \ - lwi reg, reg, 0; -# endif -# endif +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - lwi reg, r0, MULTIPLE_THREADS_OFFSET(reg) -# endif # endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION (1) #endif + +#define RTLD_SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h index 1750f059a..57b50042b 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h @@ -1,5 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. +/* Copyright (C) 2003-2017 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,165 +22,18 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# ifdef __PIC__ -# define PSEUDO_CPLOAD .cpload t9; -# define PSEUDO_ERRJMP move a0, v0; la t9, __syscall_error; jr t9; -# define PSEUDO_SAVEGP sw gp, 32(sp); cfi_rel_offset (gp, 32); -# define PSEUDO_LOADGP lw gp, 32(sp); -# else -# define PSEUDO_CPLOAD -# define PSEUDO_ERRJMP move a0, v0; j __syscall_error; -# define PSEUDO_SAVEGP -# define PSEUDO_LOADGP -# endif - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .align 2; \ - L(pseudo_start): \ - cfi_startproc; \ - 99: PSEUDO_ERRJMP \ - .type __##syscall_name##_nocancel, @function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - .set noreorder; \ - PSEUDO_CPLOAD \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - .set reorder; \ - bne a3, zero, 99b; \ - ret; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name) \ - .set noreorder; \ - PSEUDO_CPLOAD \ - .set reorder; \ - SINGLE_THREAD_P(v1); \ - bne zero, v1, L(pseudo_cancel); \ - .set noreorder; \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - .set reorder; \ - bne a3, zero, 99b; \ - ret; \ - L(pseudo_cancel): \ - SAVESTK_##args; \ - sw ra, 28(sp); \ - cfi_rel_offset (ra, 28); \ - PSEUDO_SAVEGP \ - PUSHARGS_##args; /* save syscall args */ \ - CENABLE; \ - PSEUDO_LOADGP \ - sw v0, 44(sp); /* save mask */ \ - POPARGS_##args; /* restore syscall args */ \ - .set noreorder; \ - li v0, SYS_ify (syscall_name); \ - syscall; \ - .set reorder; \ - sw v0, 36(sp); /* save syscall result */ \ - sw a3, 40(sp); /* save syscall error flag */ \ - lw a0, 44(sp); /* pass mask as arg1 */ \ - CDISABLE; \ - PSEUDO_LOADGP \ - lw v0, 36(sp); /* restore syscall result */ \ - lw a3, 40(sp); /* restore syscall error flag */ \ - lw ra, 28(sp); /* restore return address */ \ - .set noreorder; \ - bne a3, zero, 99b; \ - RESTORESTK; \ - L(pseudo_end): \ - .set reorder; - -# undef PSEUDO_END -# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym - -# define PUSHARGS_0 /* nothing to do */ -# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp); cfi_rel_offset (a0, 0); -# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp); cfi_rel_offset (a1, 4); -# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp); cfi_rel_offset (a2, 8); -# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp); cfi_rel_offset (a3, 12); -# define PUSHARGS_5 PUSHARGS_4 /* handled by SAVESTK_## */ -# define PUSHARGS_6 PUSHARGS_5 -# define PUSHARGS_7 PUSHARGS_6 - -# define POPARGS_0 /* nothing to do */ -# define POPARGS_1 POPARGS_0 lw a0, 0(sp); -# define POPARGS_2 POPARGS_1 lw a1, 4(sp); -# define POPARGS_3 POPARGS_2 lw a2, 8(sp); -# define POPARGS_4 POPARGS_3 lw a3, 12(sp); -# define POPARGS_5 POPARGS_4 /* args already in new stackframe */ -# define POPARGS_6 POPARGS_5 -# define POPARGS_7 POPARGS_6 - - -# define STKSPACE 48 -# define SAVESTK_0 subu sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE) -# define SAVESTK_1 SAVESTK_0 -# define SAVESTK_2 SAVESTK_1 -# define SAVESTK_3 SAVESTK_2 -# define SAVESTK_4 SAVESTK_3 -# define SAVESTK_5 lw t0, 16(sp); \ - SAVESTK_0; \ - sw t0, 16(sp) - -# define SAVESTK_6 lw t0, 16(sp); \ - lw t1, 20(sp); \ - SAVESTK_0; \ - sw t0, 16(sp); \ - sw t1, 20(sp) - -# define SAVESTK_7 lw t0, 16(sp); \ - lw t1, 20(sp); \ - lw t2, 24(sp); \ - SAVESTK_0; \ - sw t0, 16(sp); \ - sw t1, 20(sp); \ - sw t2, 24(sp) - -# define RESTORESTK addu sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE) - - -# ifdef __PIC__ -/* We use jalr rather than jal. This means that the assembler will not - automatically restore $gp (in case libc has multiple GOTs) so we must - do it manually - which we have to do anyway since we don't use .cprestore. - It also shuts up the assembler warning about not using .cprestore. */ -# define PSEUDO_JMP(sym) la t9, sym; jalr t9; -# else -# define PSEUDO_JMP(sym) jal sym; -# endif - -# ifdef IS_IN_libpthread -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) -# elif defined IS_IN_librt -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) \ == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - READ_THREAD_POINTER(reg); \ - lw reg, MULTIPLE_THREADS_OFFSET(reg) -#endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P 1 # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/sysdep-cancel.h index a0f4de5c8..fd3af9aec 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/sysdep-cancel.h @@ -25,171 +25,12 @@ # include <pthreadP.h> #endif - - -#define PUSHARGS_0 -#define PUSHARGS_1 smw.adm $r0, [$sp], $r0, #0; \ - cfi_adjust_cfa_offset(4); \ - cfi_rel_offset(r0,0); \ - addi $sp, $sp, -4; \ - cfi_adjust_cfa_offset(4); -#define PUSHARGS_2 smw.adm $r0, [$sp], $r1, #0; \ - cfi_adjust_cfa_offset(8); \ - cfi_rel_offset(r1, 4); \ - cfi_rel_offset(r0, 0); -#define PUSHARGS_3 smw.adm $r0, [$sp], $r2, #0; \ - cfi_adjust_cfa_offset(12); \ - cfi_rel_offset(r2, 8); \ - cfi_rel_offset(r1, 4); \ - cfi_rel_offset(r0, 0); \ - addi $sp, $sp, -4; \ - cfi_adjust_cfa_offset(4); -#define PUSHARGS_4 smw.adm $r0, [$sp], $r3, #0; \ - cfi_adjust_cfa_offset(16); \ - cfi_rel_offset(r3, 12); \ - cfi_rel_offset(r2, 8); \ - cfi_rel_offset(r1, 4); \ - cfi_rel_offset(r0, 0); -#define PUSHARGS_5 smw.adm $r0, [$sp], $r4, #0; \ - cfi_adjust_cfa_offset(20); \ - cfi_rel_offset(r4, 16); \ - cfi_rel_offset(r3, 12); \ - cfi_rel_offset(r2, 8); \ - cfi_rel_offset(r1, 4); \ - cfi_rel_offset(r0, 0); \ - addi $sp, $sp, -4; \ - cfi_adjust_cfa_offset(4); -#define PUSHARGS_6 smw.adm $r0, [$sp], $r5, #0; \ - cfi_adjust_cfa_offset(24); \ - cfi_rel_offset(r5, 20); \ - cfi_rel_offset(r4, 16); \ - cfi_rel_offset(r3, 12); \ - cfi_rel_offset(r2, 8); \ - cfi_rel_offset(r1, 4); \ - cfi_rel_offset(r0, 0); - -#define POPARGS2_0 -#define POPARGS2_1 addi $sp, $sp, 4; \ - cfi_adjust_cfa_offset(-4); \ - lmw.bim $r0, [$sp], $r0, #0; \ - cfi_adjust_cfa_offset(-4); \ - cfi_restore(r0); -#define POPARGS2_2 lmw.bim $r0, [$sp], $r1, #0; \ - cfi_adjust_cfa_offset(-8); \ - cfi_restore(r0); \ - cfi_restore(r1); -#define POPARGS2_3 addi $sp, $sp, 4; \ - cfi_adjust_cfa_offset(-4); \ - lmw.bim $r0, [$sp], $r2, #0; \ - cfi_adjust_cfa_offset(-12); \ - cfi_restore(r0); \ - cfi_restore(r1); \ - cfi_restore(r2); -#define POPARGS2_4 lmw.bim $r0, [$sp], $r3, #0; \ - cfi_adjust_cfa_offset(-16); \ - cfi_restore(r0); \ - cfi_restore(r1); \ - cfi_restore(r2); \ - cfi_restore(r3); -#define POPARGS2_5 addi $sp, $sp, 4; \ - cfi_adjust_cfa_offset(-4); \ - lmw.bim $r0, [$sp], $r4, #0; \ - cfi_adjust_cfa_offset(-20); \ - cfi_restore(r0); \ - cfi_restore(r1); \ - cfi_restore(r2); \ - cfi_restore(r3); \ - cfi_restore(r4); -#define POPARGS2_6 lmw.bim $r0, [$sp], $r5, #0; \ - cfi_adjust_cfa_offset(-24); \ - cfi_restore(r0); \ - cfi_restore(r1); \ - cfi_restore(r2); \ - cfi_restore(r3); \ - cfi_restore(r4); \ - cfi_restore(r5); - #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -/* NOTE: We do mark syscalls with unwind annotations, for the benefit of - cancellation; but they're really only accurate at the point of the - syscall. The ARM unwind directives are not rich enough without adding - a custom personality function. */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .align 2; \ - ENTRY (__##syscall_name##_nocancel); \ - __do_syscall(syscall_name); \ - PSEUDO_RET; \ - ret; \ - END (__##syscall_name##_nocancel); \ - ENTRY (name); \ - smw.adm $r6,[$sp],$r6,0x2; \ - cfi_adjust_cfa_offset(8); \ - cfi_offset(r6,-8); \ - cfi_offset(lp,-4); \ - SINGLE_THREAD_P ($r15); \ - bgtz $r15, .Lpseudo_cancel; \ - __do_syscall(syscall_name); \ - j 50f; \ - .Lpseudo_cancel: \ - PUSHARGS_##args; /* save syscall args etc. around CENABLE. */ \ - CENABLE ($r5); \ - mov55 $r6, $r0; /* put mask in safe place. */ \ - POPARGS2_##args; \ - __do_syscall(syscall_name); /* do the call. */ \ - push $r0; \ - cfi_adjust_cfa_offset(4); \ - cfi_rel_offset(r0, 0); \ - addi $sp, $sp, -4; \ - cfi_adjust_cfa_offset(4); \ - mov55 $r0, $r6; /* save syscall return value. */\ - CDISABLE($r5); \ - addi $sp, $sp, 4; \ - cfi_adjust_cfa_offset(-4); \ - pop $r0; /* retrieve return value. */ \ - cfi_adjust_cfa_offset(-4); \ - cfi_restore(r0); \ -50: \ - lmw.bim $r6,[$sp],$r6, 0x2; \ - cfi_adjust_cfa_offset(-8); \ - cfi_restore(lp); \ - cfi_restore(r6); \ - PSEUDO_RET; -# ifndef __ASSEMBLER__ -//# if defined IS_IN_libpthread || !defined NOT_IN_libc -//extern int __local_multiple_threads attribute_hidden; -//# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -//# else -/* There is no __local_multiple_threads for librt */ -# define SINGLE_THREAD_P __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ +# define SINGLE_THREAD_P __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -//# endif -# else -# define SINGLE_THREAD_P(reg) \ - addi reg, $r25, MULTIPLE_THREADS_OFFSET; \ - lw reg, [reg]; -# define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P(x) -# endif - - -# ifdef IS_IN_libpthread -# define CENABLE(reg) jmp(reg, __pthread_enable_asynccancel) -# define CDISABLE(reg) jmp(reg, __pthread_disable_asynccancel) -# define __local_multiple_threads __pthread_multiple_threads -# elif !defined NOT_IN_libc -# define CENABLE(reg) jmp(reg, __libc_enable_asynccancel) -# define CDISABLE(reg) jmp(reg, __libc_disable_asynccancel) -# define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE(reg) jmp(reg, __librt_enable_asynccancel) -# define CDISABLE(reg) jmp(reg, __librt_disable_asynccancel) -# else -# error Unsupported library -# endif -#elif !defined __ASSEMBLER__ +#else /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -197,77 +38,7 @@ #endif - - - - - - -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif - - - -#ifdef PIC -#define PSEUDO_RET \ - .pic \ - .align 2; \ - bgez $r0, 1f; \ - sltsi $r1, $r0, -4096; \ - bgtz $r1, 1f; \ - PIC_jmp_err \ - nop; \ - 1: -#else /* PIC*/ -#define PSEUDO_RET \ - .align 2; \ - bgez $r0, 1f; \ - sltsi $r1, $r0, -4096; \ - bgtz $r1, 1f; \ - j SYSCALL_ERROR; \ - 1: -#endif -#ifdef PIC -#define jmp(reg, symble) PIC_jmpr(reg, symble) -/* reg: available register */ -#define PIC_jmp_err \ - smw.adm $sp,[$sp],$sp,#0x6; \ - mfusr $r15, $PC; \ - sethi $gp, hi20(_GLOBAL_OFFSET_TABLE_ + 4); \ - ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_ + 8); \ - add $gp, $r15, $gp; \ - sethi $r15, hi20(SYSCALL_ERROR@PLT); \ - ori $r15, $r15, lo12(SYSCALL_ERROR@PLT); \ - add $r15, $r15, $gp; \ - jral $r15; \ - lmw.bim $sp,[$sp],$sp,#0x6; \ - ret; - -#define PIC_jmp(reg, symble) \ - mfusr $r15, $PC; \ - sethi reg, hi20(_GLOBAL_OFFSET_TABLE_ + 4); \ - ori reg, reg, lo12(_GLOBAL_OFFSET_TABLE_ + 8); \ - add reg, $r15, reg; \ - sethi $r15, hi20(symble@PLT); \ - ori $r15, $r15, lo12(symble@PLT); \ - add $r15, $r15, reg; \ - jr $r15; - - -#define PIC_jmpr(reg, symble) \ - mfusr $r15, $PC; \ - sethi reg, hi20(_GLOBAL_OFFSET_TABLE_ + 4); \ - ori reg, reg, lo12(_GLOBAL_OFFSET_TABLE_ + 8); \ - add reg, $r15, reg; \ - sethi $r15, hi20(symble@PLT); \ - ori $r15, $r15, lo12(symble@PLT); \ - add $r15, $r15, reg; \ - jral $r15; - -#else -#define jmp(reg, symble) jal symble -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h index 25382dd19..a0c4799e5 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h @@ -1,6 +1,5 @@ /* Assembler macros with cancellation support, Nios II version. Copyright (C) 2003-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -24,117 +23,18 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -#ifdef __ASSEMBLER__ -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .type __##syscall_name##_nocancel, @function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - cfi_startproc; \ - DO_CALL (syscall_name, args); \ - ret; \ - cfi_endproc; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name) \ - SINGLE_THREAD_P(r2); \ - bne r2, zero, pseudo_cancel; \ - DO_CALL (syscall_name, args); \ - ret; \ - pseudo_cancel: \ - SAVESTK_##args; /* save syscall args and adjust stack */ \ - SAVEREG(ra, 0); /* save return address */ \ - SAVEREG(r22, 4); /* save GOT pointer */ \ - nextpc r22; \ -1: movhi r2, %hiadj(_gp_got - 1b); \ - addi r2, r2, %lo(_gp_got - 1b); \ - add r22, r22, r2; \ - CENABLE; \ - callr r3; \ - stw r2, 8(sp); /* save mask */ \ - LOADARGS_##args; \ - movi r2, SYS_ify(syscall_name); \ - trap; \ - stw r2, 12(sp); /* save syscall result */ \ - stw r7, 16(sp); /* save syscall error flag */ \ - ldw r4, 8(sp); /* pass mask as argument 1 */ \ - CDISABLE; \ - callr r3; \ - ldw r7, 16(sp); /* restore syscall error flag */ \ - ldw r2, 12(sp); /* restore syscall result */ \ - ldw ra, 0(sp); /* restore return address */ \ - ldw r22, 4(sp); /* restore GOT pointer */ \ - RESTORESTK_##args; \ - - -# undef PSEUDO_END -# define PSEUDO_END(sym) \ - END (sym) - -#define SAVEREG(REG, LOC) stw REG, LOC(sp); cfi_rel_offset (REG, LOC) -#define SAVESTK(X) subi sp, sp, X; cfi_adjust_cfa_offset(X) -#define SAVESTK_0 SAVESTK(20) -#define SAVEARG_1 SAVEREG(r4, 20) -#define SAVESTK_1 SAVESTK(24); SAVEARG_1 -#define SAVEARG_2 SAVEREG(r5, 24); SAVEARG_1 -#define SAVESTK_2 SAVESTK(28); SAVEARG_2 -#define SAVEARG_3 SAVEREG(r6, 28); SAVEARG_2 -#define SAVESTK_3 SAVESTK(32); SAVEARG_3 -#define SAVEARG_4 SAVEREG(r7, 32); SAVEARG_3 -#define SAVESTK_4 SAVESTK(36); SAVEARG_4 -#define SAVESTK_5 SAVESTK_4 -#define SAVESTK_6 SAVESTK_5 - -#define LOADARGS_0 -#define LOADARGS_1 ldw r4, 20(sp) -#define LOADARGS_2 LOADARGS_1; ldw r5, 24(sp) -#define LOADARGS_3 LOADARGS_2; ldw r6, 28(sp) -#define LOADARGS_4 LOADARGS_3; ldw r7, 32(sp) -#define LOADARGS_5 LOADARGS_4; ldw r8, 36(sp) -#define LOADARGS_6 LOADARGS_5; ldw r9, 40(sp) - -#define RESTORESTK(X) addi sp, sp, X; cfi_adjust_cfa_offset(-X) -#define RESTORESTK_0 RESTORESTK(20) -#define RESTORESTK_1 RESTORESTK(24) -#define RESTORESTK_2 RESTORESTK(28) -#define RESTORESTK_3 RESTORESTK(32) -#define RESTORESTK_4 RESTORESTK(36) -#define RESTORESTK_5 RESTORESTK(36) -#define RESTORESTK_6 RESTORESTK(36) - -# endif - -# ifdef IS_IN_libpthread -# define CENABLE ldw r3, %call(__pthread_enable_asynccancel)(r22) -# define CDISABLE ldw r3, %call(__pthread_disable_asynccancel)(r22) -# elif defined IS_IN_librt -# define CENABLE ldw r3, %call(__librt_enable_asynccancel)(r22) -# define CDISABLE ldw r3, %call(__librt_disable_asynccancel)(r22) -# elif !defined NOT_IN_libc -# define CENABLE ldw r3, %call(__libc_enable_asynccancel)(r22) -# define CDISABLE ldw r3, %call(__libc_disable_asynccancel)(r22) -# else -# error Unsupported library -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) \ == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - ldw reg, MULTIPLE_THREADS_OFFSET(r23) -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P 1 # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/or1k/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/or1k/sysdep-cancel.h index 286fa0cce..f7e70514a 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/or1k/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/or1k/sysdep-cancel.h @@ -1,5 +1,4 @@ /* Copyright (C) 2014 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,94 +22,17 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ -ENTRY(__##syscall_name##_nocancel); \ -L(pseudo_nocancel): \ - DO_CALL(syscall_name); \ - l.j L(pseudo_finish); \ - l.nop; \ -END(__##syscall_name##_nocancel); \ -ENTRY(name); \ - SINGLE_THREAD_P(r13); \ - l.sfeq r13,r0; \ - l.bnf L(pseudo_nocancel); \ - l.nop; \ - /* Reserve the same amount of stack space, effectivly disregarding \ - * how many args we're supposed to push. This makes the code easier. */ \ - l.addi r1,r1,-28; \ - cfi_adjust_cfa_offset(28); \ - PUSHARGS_##args; /* CENABLE is a function call, save args for syscall. */ \ - CENABLE; \ - l.sw 24(r1),r11; \ - POPARGS_##args; \ - DO_CALL(syscall_name); \ - l.lwz r3,24(r1); /* pass return value from CENABLE to CDISABLE. */ \ - l.sw 24(r1),r11; /* save syscall return value for after CDISABLE. */ \ - CDISABLE; \ - l.lwz r11,24(r1); /* restore syscall return value. */ \ - cfi_adjust_cfa_offset(-28); \ - l.addi r1,r1,28; \ -L(pseudo_finish): \ - /* if -4096 < ret < 0 holds, it's an error */ \ - l.sfgeui r11,0xf001; \ - l.bf L(pseudo_end); \ - l.nop - -# undef PSEUDO_END -# define PSEUDO_END(name) \ -L(pseudo_end): \ - l.j SYSCALL_ERROR_NAME; \ - l.ori r3,r11,0; \ - END(name) - -# define PUSHARGS_0 /* nothing to do */ -# define PUSHARGS_1 PUSHARGS_0 l.sw 0(r1),r3; -# define PUSHARGS_2 PUSHARGS_1 l.sw 4(r1),r4; -# define PUSHARGS_3 PUSHARGS_2 l.sw 8(r1),r5; -# define PUSHARGS_4 PUSHARGS_3 l.sw 12(r1),r6; -# define PUSHARGS_5 PUSHARGS_4 l.sw 16(r1),r7; -# define PUSHARGS_6 PUSHARGS_5 l.sw 20(r1),r8; - -# define POPARGS_0 /* nothing to do */ -# define POPARGS_1 POPARGS_0 l.lwz r3,0(r1); -# define POPARGS_2 POPARGS_1 l.lwz r4,4(r1); -# define POPARGS_3 POPARGS_2 l.lwz r5,8(r1); -# define POPARGS_4 POPARGS_3 l.lwz r6,12(r1); -# define POPARGS_5 POPARGS_4 l.lwz r7,16(r1); -# define POPARGS_6 POPARGS_5 l.lwz r8,20(r1); - -# define PSEUDO_JMP(sym) l.jal sym; l.nop; - -# ifdef IS_IN_libpthread -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) -# elif defined IS_IN_librt -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -/* It's not super nice to have "r10" hardcoded here */ -# define SINGLE_THREAD_P(reg) l.lwz reg, MULTIPLE_THREADS_OFFSET(r10) -#endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P 1 # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h index c163dcdba..2247801b2 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h @@ -1,6 +1,5 @@ /* Cancellable system call stubs. Linux/PowerPC version. Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. Contributed by Franz Sirl <franz.sirl-ker...@lauterbach.com>, 2003. The GNU C Library is free software; you can redistribute it and/or @@ -25,94 +24,17 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ - ENTRY (name) \ - SINGLE_THREAD_P; \ - bne- .Lpseudo_cancel; \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (SYS_ify (syscall_name)); \ - PSEUDO_RET; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - .Lpseudo_cancel: \ - stwu 1,-48(1); \ - cfi_adjust_cfa_offset (48); \ - mflr 9; \ - stw 9,52(1); \ - cfi_offset (lr, 4); \ - DOCARGS_##args; /* save syscall args around CENABLE. */ \ - CENABLE; \ - stw 3,16(1); /* store CENABLE return value (MASK). */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - DO_CALL (SYS_ify (syscall_name)); \ - mfcr 0; /* save CR/R3 around CDISABLE. */ \ - stw 3,8(1); \ - stw 0,12(1); \ - lwz 3,16(1); /* pass MASK to CDISABLE. */ \ - CDISABLE; \ - lwz 4,52(1); \ - lwz 0,12(1); /* restore CR/R3. */ \ - lwz 3,8(1); \ - mtlr 4; \ - mtcr 0; \ - addi 1,1,48; - -# define DOCARGS_0 -# define UNDOCARGS_0 - -# define DOCARGS_1 stw 3,20(1); DOCARGS_0 -# define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0 - -# define DOCARGS_2 stw 4,24(1); DOCARGS_1 -# define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1 - -# define DOCARGS_3 stw 5,28(1); DOCARGS_2 -# define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2 - -# define DOCARGS_4 stw 6,32(1); DOCARGS_3 -# define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3 - -# define DOCARGS_5 stw 7,36(1); DOCARGS_4 -# define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4 - -# define DOCARGS_6 stw 8,40(1); DOCARGS_5 -# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5 - -# ifdef IS_IN_libpthread -# define CENABLE bl __pthread_enable_asynccancel@local -# define CDISABLE bl __pthread_disable_asynccancel@local -# elif !defined NOT_IN_libc -# define CENABLE bl __libc_enable_asynccancel@local -# define CDISABLE bl __libc_disable_asynccancel@local -# elif defined IS_IN_librt -# define CENABLE bl __librt_enable_asynccancel@local -# define CDISABLE bl __librt_disable_asynccancel@local -# else -# error Unsupported library -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - lwz 10,MULTIPLE_THREADS_OFFSET(2); \ - cmpwi 10,0 -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h index f64c24f90..ec583acf9 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h @@ -1,5 +1,4 @@ /* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,146 +22,17 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# define _IMM12 #-12 -# define _IMM16 #-16 -# define _IMP16 #16 -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name); \ - .Lpseudo_start: \ - SINGLE_THREAD_P; \ - bf .Lpseudo_cancel; \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - mov r0,r1; \ - mov _IMM12,r2; \ - shad r2,r1; \ - not r1,r1; \ - tst r1,r1; \ - bt .Lsyscall_error; \ - bra .Lpseudo_end; \ - nop; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - .Lpseudo_cancel: \ - sts.l pr,@-r15; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (pr, 0); \ - add _IMM16,r15; \ - cfi_adjust_cfa_offset (16); \ - SAVE_ARGS_##args; \ - CENABLE; \ - LOAD_ARGS_##args; \ - add _IMP16,r15; \ - cfi_adjust_cfa_offset (-16); \ - lds.l @r15+,pr; \ - cfi_adjust_cfa_offset (-4); \ - cfi_restore (pr); \ - DO_CALL(syscall_name, args); \ - SYSCALL_INST_PAD; \ - sts.l pr,@-r15; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (pr, 0); \ - mov.l r0,@-r15; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (r0, 0); \ - CDISABLE; \ - mov.l @r15+,r0; \ - cfi_adjust_cfa_offset (-4); \ - lds.l @r15+,pr; \ - cfi_adjust_cfa_offset (-4); \ - cfi_restore (pr); \ - mov r0,r1; \ - mov _IMM12,r2; \ - shad r2,r1; \ - not r1,r1; \ - tst r1,r1; \ - bf .Lpseudo_end; \ - .Lsyscall_error: \ - SYSCALL_ERROR_HANDLER; \ - .Lpseudo_end: - -# undef PSEUDO_END -# define PSEUDO_END(sym) \ - END (sym) - -# define SAVE_ARGS_0 /* Nothing. */ -# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15); cfi_offset (r4,-4) -# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15); cfi_offset (r5,-8) -# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15); cfi_offset (r6,-12) -# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15); cfi_offset (r7,-16) -# define SAVE_ARGS_5 SAVE_ARGS_4 -# define SAVE_ARGS_6 SAVE_ARGS_5 - -# define LOAD_ARGS_0 /* Nothing. */ -# define LOAD_ARGS_1 LOAD_ARGS_0; mov.l @(0,r15),r4 -# define LOAD_ARGS_2 LOAD_ARGS_1; mov.l @(4,r15),r5 -# define LOAD_ARGS_3 LOAD_ARGS_2; mov.l @(8,r15),r6 -# define LOAD_ARGS_4 LOAD_ARGS_3; mov.l @(12,r15),r7 -# define LOAD_ARGS_5 LOAD_ARGS_4 -# define LOAD_ARGS_6 LOAD_ARGS_5 - -# ifdef IS_IN_libpthread -# define __local_enable_asynccancel __pthread_enable_asynccancel -# define __local_disable_asynccancel __pthread_disable_asynccancel -# elif !defined NOT_IN_libc -# define __local_enable_asynccancel __libc_enable_asynccancel -# define __local_disable_asynccancel __libc_disable_asynccancel -# elif defined IS_IN_librt -# define __local_enable_asynccancel __librt_enable_asynccancel -# define __local_disable_asynccancel __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -# define CENABLE \ - mov.l 1f,r0; \ - bsrf r0; \ - nop; \ - 0: bra 2f; \ - mov r0,r2; \ - .align 2; \ - 1: .long __local_enable_asynccancel - 0b; \ - 2: - -# define CDISABLE \ - mov.l 1f,r0; \ - bsrf r0; \ - mov r2,r4; \ - 0: bra 2f; \ - nop; \ - .align 2; \ - 1: .long __local_disable_asynccancel - 0b; \ - 2: - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - stc gbr,r0; \ - mov.w 0f,r1; \ - sub r1,r0; \ - mov.l @(MULTIPLE_THREADS_OFFSET,r0),r0; \ - bra 1f; \ - tst r0,r0; \ - 0: .word TLS_PRE_TCB_SIZE; \ - 1: - -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ # define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h index b61ca7b52..0bf58bbbc 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h @@ -1,5 +1,4 @@ /* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. Contributed by Jakub Jelinek <ja...@redhat.com>, 2002. The GNU C Library is free software; you can redistribute it and/or @@ -24,88 +23,17 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - .globl __syscall_error; \ -ENTRY(name) \ - ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\ - cmp %g1, 0; \ - bne 1f; \ -.type __##syscall_name##_nocancel,@function; \ -.globl __##syscall_name##_nocancel; \ -__##syscall_name##_nocancel: \ - mov SYS_ify(syscall_name), %g1; \ - ta 0x10; \ - bcc 8f; \ - mov %o7, %g1; \ - call __syscall_error; \ - mov %g1, %o7; \ -8: jmpl %o7 + 8, %g0; \ - nop; \ -.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\ -1: save %sp, -96, %sp; \ - cfi_def_cfa_register(%fp); \ - cfi_window_save; \ - cfi_register(%o7, %i7); \ - CENABLE; \ - nop; \ - mov %o0, %l0; \ - COPY_ARGS_##args \ - mov SYS_ify(syscall_name), %g1; \ - ta 0x10; \ - bcc 1f; \ - mov %o0, %l1; \ - CDISABLE; \ - mov %l0, %o0; \ - call __syscall_error; \ - mov %l1, %o0; \ - b 2f; \ - mov -1, %l1; \ -1: CDISABLE; \ - mov %l0, %o0; \ -2: jmpl %i7 + 8, %g0; \ - restore %g0, %l1, %o0; - - -# ifdef IS_IN_libpthread -# define CENABLE call __pthread_enable_asynccancel -# define CDISABLE call __pthread_disable_asynccancel -# elif !defined NOT_IN_libc -# define CENABLE call __libc_enable_asynccancel -# define CDISABLE call __libc_disable_asynccancel -# elif defined IS_IN_librt -# define CENABLE call __librt_enable_asynccancel -# define CDISABLE call __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -#define COPY_ARGS_0 /* Nothing */ -#define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0; -#define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1; -#define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2; -#define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3; -#define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4; -#define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5; - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1 -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h index 6e8041738..d731c61dd 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h @@ -1,5 +1,4 @@ -/* Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. +/* Copyright (C) 2002-2017 Free Software Foundation, Inc. Contributed by Jakub Jelinek <ja...@redhat.com>, 2002. The GNU C Library is free software; you can redistribute it and/or @@ -24,87 +23,31 @@ #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -/* The code to disable cancellation depends on the fact that the called - functions are special. They don't modify registers other than %rax - and %r11 if they return. Therefore we don't have to preserve other - registers around these calls. */ -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P; \ - jne L(pseudo_cancel); \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - cmpq $-4095, %rax; \ - jae SYSCALL_ERROR_LABEL; \ - ret; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - L(pseudo_cancel): \ - /* We always have to align the stack before calling a function. */ \ - subq $8, %rsp; cfi_adjust_cfa_offset (8); \ - CENABLE \ - /* The return value from CENABLE is argument for CDISABLE. */ \ - movq %rax, (%rsp); \ - DO_CALL (syscall_name, args); \ - movq (%rsp), %rdi; \ - /* Save %rax since it's the error code from the syscall. */ \ - movq %rax, %rdx; \ - CDISABLE \ - movq %rdx, %rax; \ - addq $8,%rsp; cfi_adjust_cfa_offset (-8); \ - cmpq $-4095, %rax; \ - jae SYSCALL_ERROR_LABEL; \ - L(pseudo_end): - - # ifdef IS_IN_libpthread -# define CENABLE call __pthread_enable_asynccancel; -# define CDISABLE call __pthread_disable_asynccancel; # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE call __libc_enable_asynccancel; -# define CDISABLE call __libc_disable_asynccancel; # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE call __librt_enable_asynccancel; -# define CDISABLE call __librt_disable_asynccancel; -# else -# error Unsupported library # endif # if defined IS_IN_libpthread || !defined NOT_IN_libc -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads(%rip) -# endif # else -# ifndef __ASSEMBLER__ # define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P cmpl $0, %fs:MULTIPLE_THREADS_OFFSET -# endif - # endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ # define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h index db1cfdc04..181412c0c 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h @@ -1,5 +1,4 @@ /* Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -17,142 +16,25 @@ #include <sysdep.h> #include <tls.h> -/* #include <pt-machine.h> */ #ifndef __ASSEMBLER__ # include <pthreadP.h> #endif #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -#ifdef __ASSEMBLER__ -#if defined(__XTENSA_WINDOWED_ABI__) -/* CENABLE/CDISABLE in PSEUDO below use call8, stack frame size must be - * at least 32. - */ -#if FRAMESIZE < 32 -#undef FRAMESIZE -#define FRAMESIZE 32 -#endif - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P(a15); \ - bnez a15, .Lpseudo_cancel; \ - DO_CALL (syscall_name, args); \ - bgez a2, .Lpseudo_done; \ - movi a4, -4095; \ - blt a2, a4, .Lpseudo_done; \ - j SYSCALL_ERROR_LABEL; \ - .Lpseudo_done: \ - retw; \ - .Lpseudo_cancel: \ - /* The syscall args are in a2...a7; no need to save */ \ - CENABLE; \ - /* The return value is in a10 and preserved across the syscall */ \ - DO_CALL (syscall_name, args); \ - CDISABLE; \ - bgez a2, .Lpseudo_end; \ - movi a4, -4095; \ - blt a2, a4, .Lpseudo_end; \ - j SYSCALL_ERROR_LABEL; \ - .Lpseudo_end: - -# define CENABLE movi a8, CENABLE_FUNC; \ - callx8 a8 -# define CDISABLE movi a8, CDISABLE_FUNC; \ - callx8 a8 -#elif defined(__XTENSA_CALL0_ABI__) - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P(a10); \ - bnez a10, .Lpseudo_cancel; \ - DO_CALL (syscall_name, args); \ - bgez a2, .Lpseudo_done; \ - movi a4, -4095; \ - blt a2, a4, .Lpseudo_done; \ - j SYSCALL_ERROR_LABEL; \ - .Lpseudo_done: \ - ret; \ - .Lpseudo_cancel: \ - addi a1, a1, -32; \ - /* The syscall args are in a2...a7; save them */ \ - s32i a0, a1, 0; \ - s32i a2, a1, 4; \ - s32i a3, a1, 8; \ - s32i a4, a1, 12; \ - s32i a5, a1, 16; \ - s32i a6, a1, 20; \ - s32i a7, a1, 24; \ - CENABLE; \ - /* Move return value to a10 preserved across the syscall */ \ - mov a10, a2; \ - l32i a2, a1, 4; \ - l32i a3, a1, 8; \ - l32i a4, a1, 12; \ - l32i a5, a1, 16; \ - l32i a6, a1, 20; \ - l32i a7, a1, 24; \ - DO_CALL (syscall_name, args); \ - s32i a2, a1, 4; \ - mov a2, a10; \ - CDISABLE; \ - l32i a2, a1, 4; \ - l32i a0, a1, 0; \ - addi a1, a1, 32; \ - bgez a2, .Lpseudo_end; \ - movi a4, -4095; \ - blt a2, a4, .Lpseudo_end; \ - j SYSCALL_ERROR_LABEL; \ - .Lpseudo_end: - -# define CENABLE movi a0, CENABLE_FUNC; \ - callx0 a0 -# define CDISABLE movi a0, CDISABLE_FUNC; \ - callx0 a0 -#else -#error Unsupported Xtensa ABI -#endif -#endif - # ifdef IS_IN_libpthread -# define CENABLE_FUNC __pthread_enable_asynccancel -# define CDISABLE_FUNC __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif !defined NOT_IN_libc -# define CENABLE_FUNC __libc_enable_asynccancel -# define CDISABLE_FUNC __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif defined IS_IN_librt -# define CENABLE_FUNC __librt_enable_asynccancel -# define CDISABLE_FUNC __librt_disable_asynccancel -# else -# error Unsupported library # endif # if defined IS_IN_libpthread || !defined NOT_IN_libc -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P(reg) movi reg, __local_multiple_threads; \ - l32i reg, reg, 0; -# endif - +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - rur reg, threadptr; \ - l32i reg, reg, MULTIPLE_THREADS_OFFSET; -# endif # endif #else @@ -163,9 +45,6 @@ extern int __local_multiple_threads attribute_hidden; #endif - -#ifndef __ASSEMBLER__ # define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif -- 2.11.0
_______________________________________________ devel mailing list devel@uclibc-ng.org https://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel