[PATCH 04/20] lib/cobalt: Introduce rtdm.h
Florian Bezdeka <[email protected]>
| Newsgroups | dev.linux.lists.xenomai |
|---|---|
| Message-ID | <20260220-wip-flo-fix-time64-32bit-native-v1-4-731c773e72cc@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 | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am index 262c9bedb3fbe8edee96353f5a3e6b631c31e81d..f461e570ed42a0d5cbc43eabb373c3c9edd83bad 100644 --- a/lib/cobalt/Makefile.am +++ b/lib/cobalt/Makefile.am @@ -5,6 +5,7 @@ noinst_HEADERS = \ current.h \ mutex.h \ mq.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..f16d79835361a20a754c6532101e60667cafee3c --- /dev/null +++ b/lib/cobalt/rtdm.h @@ -0,0 +1,32 @@ + +#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