From ccc200d454c712f6e8bfadb4b7c3ee58086d8f2b Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Fri, 14 Jul 2017 19:37:28 +0200 Subject: rt: convert mq_timedsend/mq_timedreceive to use cancel.h macros --- 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 ++++++++++++++++ 7 files changed, 41 insertions(+), 103 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 (limited to 'librt') 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 +#include #include -#ifdef __NR_mq_timedreceive - -#include #include -#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 +#include #include -#ifdef __NR_mq_timedsend - -#include #include -#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 -#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 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#include +#include +#include + +#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 -#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 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#include +#include +#include + +#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) -- cgit v1.2.3