[PATCH v2 04/20] lib/cobalt: Introduce rtdm.h
Florian Bezdeka <[email protected]>
| Newsgroups | dev.linux.lists.xenomai |
|---|---|
| Message-ID | <20260302-wip-flo-fix-time64-32bit-native-v2-4-7caefce29bcd@siemens.com> |
Some code will be re-used later by the time64_t compile unit. Move that code into rtdm.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/rtdm.c | 34 ++++++---------------------------- lib/cobalt/rtdm.h | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am index 576fb980f72b342e118bfacb061b5634bda420a2..0a8041dc30efae3eebacd376ac72f4b317f621b3 100644 --- a/lib/cobalt/Makefile.am +++ b/lib/cobalt/Makefile.am @@ -5,6 +5,7 @@ noinst_HEADERS = \ current.h \ mq.h \ mutex.h \ + rtdm.h \ umm.h \ internal.h diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c index 119ba3f83dfd023291ad10b5aad496905db36a47..ec950e15db921b32458d746d300ff6c542a8b23b 100644 --- a/lib/cobalt/rtdm.c +++ b/lib/cobalt/rtdm.c @@ -17,34 +17,25 @@ USA. */ -#include <errno.h> +#include "rtdm.h" + +#include <asm/xenomai/syscall.h> +#include <cobalt/uapi/syscall.h> +#include <rtdm/rtdm.h> + #include <string.h> #include <stdarg.h> #include <pthread.h> #include <fcntl.h> -#include <unistd.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/mman.h> -#include <rtdm/rtdm.h> -#include <cobalt/uapi/syscall.h> -#include <asm/xenomai/syscall.h> /* support for very old c libraries not supporting O_TMPFILE */ #ifndef O_TMPFILE #define O_TMPFILE (020000000 | 0200000) #endif - -static inline int set_errno(int ret) -{ - if (ret >= 0) - return ret; - - errno = -ret; - return -1; -} - static int do_open(const char *path, int oflag, mode_t mode) { int fd, oldtype; @@ -160,19 +151,6 @@ COBALT_IMPL(int, close, (int fd)) return __STD(close(fd)); } -static int do_ioctl(int fd, unsigned int request, void *arg) -{ - int ret, oldtype; - - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); - - ret = XENOMAI_SYSCALL3(sc_cobalt_ioctl, fd, request, arg); - - pthread_setcanceltype(oldtype, NULL); - - return ret; -} - COBALT_IMPL(int, fcntl, (int fd, int cmd, ...)) { va_list ap; diff --git a/lib/cobalt/rtdm.h b/lib/cobalt/rtdm.h new file mode 100644 index 0000000000000000000000000000000000000000..6f3f60ee96d5d474b06b73ee2cb520fa1e846e75 --- /dev/null +++ b/lib/cobalt/rtdm.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.0-or-later */ + +/* + * Copyright (C) 2026 Florian Bezdeka <[email protected]>. + */ + +#ifndef _LIB_COBALT_RTDM_H +#define _LIB_COBALT_RTDM_H + +#include <asm/xenomai/syscall.h> + +#include <errno.h> +#include <pthread.h> + +static int set_errno(int ret) +{ + if (ret >= 0) + return ret; + + errno = -ret; + return -1; +} + +static int do_ioctl(int fd, unsigned int request, void *arg) +{ + int ret, oldtype; + + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); + + ret = XENOMAI_SYSCALL3(sc_cobalt_ioctl, fd, request, arg); + + pthread_setcanceltype(oldtype, NULL); + + return ret; +} + +#endif //_LIB_COBALT_RTDM_H -- 2.53.0