summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2017-07-14 19:37:28 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2017-07-28 18:52:28 +0200
commitccc200d454c712f6e8bfadb4b7c3ee58086d8f2b (patch)
tree5a728b045bd4467642af6f49439265b454ade9f9
parent952bb00f0b2eb576b0bf48c4f87018429a42e28d (diff)
rt: convert mq_timedsend/mq_timedreceive to use cancel.h macros
-rw-r--r--include/cancel.h4
-rw-r--r--librt/Makefile.in9
-rw-r--r--librt/mq_receive.c45
-rw-r--r--librt/mq_send.c42
-rw-r--r--librt/mq_timedreceive.S8
-rw-r--r--librt/mq_timedreceive.c16
-rw-r--r--librt/mq_timedsend.S8
-rw-r--r--librt/mq_timedsend.c16
8 files changed, 41 insertions, 107 deletions
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 <wbx@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 <wbx@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)