[PATCH v2 02/20] lib/cobalt: Introduce mq.h
Florian Bezdeka <[email protected]>
| Newsgroups | dev.linux.lists.xenomai |
|---|---|
| Message-ID | <20260302-wip-flo-fix-time64-32bit-native-v2-2-7caefce29bcd@siemens.com> |
Some code will be re-used later by the time64_t compile unit. Move that code into mutex.h, so code duplication is avoided. No modifications to the code itself. Signed-off-by: Florian Bezdeka <[email protected]> --- lib/cobalt/Makefile.am | 1 + lib/cobalt/mq.c | 30 ++++-------------------------- lib/cobalt/mq.h | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am index b1098413fbf3a8f6a5f0a85d6aceb9916b14149a..aa4ba2b92020e661d4906844ddee62aecc30de07 100644 --- a/lib/cobalt/Makefile.am +++ b/lib/cobalt/Makefile.am @@ -3,6 +3,7 @@ pkgconfigdir = $(libdir)/pkgconfig noinst_HEADERS = \ cond.h \ current.h \ + mq.h \ umm.h \ internal.h diff --git a/lib/cobalt/mq.c b/lib/cobalt/mq.c index 88e6e9fbf57a6cc0094d34d3bc9aa0852e82d96c..72d419d6cfac0097ba7ed61941e7b8a92e3bc673 100644 --- a/lib/cobalt/mq.c +++ b/lib/cobalt/mq.c @@ -16,13 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include "mq.h" + +#include <asm/xenomai/syscall.h> + #include <errno.h> #include <stdarg.h> #include <unistd.h> #include <fcntl.h> #include <pthread.h> #include <mqueue.h> -#include <asm/xenomai/syscall.h> /** * @ingroup cobalt_api @@ -288,18 +291,6 @@ COBALT_IMPL(int, mq_setattr, (mqd_t mqd, return -1; } -static inline int __do_mq_timesend(mqd_t q, const char *buffer, size_t len, - unsigned int prio, const struct timespec *to) -{ -#ifdef __USE_TIME_BITS64 - long sc_nr = sc_cobalt_mq_timedsend64; -#else - long sc_nr = sc_cobalt_mq_timedsend; -#endif - - return XENOMAI_SYSCALL5(sc_nr, q, buffer, len, prio, to); -} - /** * Send a message to a message queue. * @@ -412,19 +403,6 @@ COBALT_IMPL_TIME64(int, mq_timedsend, __mq_timedsend_time64, return -1; } -static inline int __do_mq_timedreceive(mqd_t q, char *buffer, ssize_t *len, - unsigned int *prio, - const struct timespec *timeout) -{ -#ifdef __USE_TIME_BITS64 - long sc_nr = sc_cobalt_mq_timedreceive64; -#else - long sc_nr = sc_cobalt_mq_timedreceive; -#endif - - return XENOMAI_SYSCALL5(sc_nr, q, buffer, len, prio, timeout); -} - /** * Receive a message from a message queue. * diff --git a/lib/cobalt/mq.h b/lib/cobalt/mq.h new file mode 100644 index 0000000000000000000000000000000000000000..82d18f6fbb1b635bacaaf49356e86a8901c65e9a --- /dev/null +++ b/lib/cobalt/mq.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.0-or-later */ + +/* + * Copyright (C) 2026 Florian Bezdeka <[email protected]>. + */ + +#ifndef _LIB_COBALT_MQ_H +#define _LIB_COBALT_MQ_H + +#include <asm/xenomai/syscall.h> + +#include <mqueue.h> + +static inline int __do_mq_timedreceive(mqd_t q, char *buffer, ssize_t *len, + unsigned int *prio, + const struct timespec *timeout) +{ +#ifdef __USE_TIME_BITS64 + long sc_nr = sc_cobalt_mq_timedreceive64; +#else + long sc_nr = sc_cobalt_mq_timedreceive; +#endif + + return XENOMAI_SYSCALL5(sc_nr, q, buffer, len, prio, timeout); +} + +static inline int __do_mq_timesend(mqd_t q, const char *buffer, size_t len, + unsigned int prio, const struct timespec *to) +{ +#ifdef __USE_TIME_BITS64 + long sc_nr = sc_cobalt_mq_timedsend64; +#else + long sc_nr = sc_cobalt_mq_timedsend; +#endif + + return XENOMAI_SYSCALL5(sc_nr, q, buffer, len, prio, to); +} + +#endif //_LIB_COBALT_MQ_H -- 2.53.0