All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
@ 2026-02-20  9:08 Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 01/20] lib/cobalt: Introduce cond.h Florian Bezdeka
                   ` (20 more replies)
  0 siblings, 21 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Hi all,

The current time64_t / y2038 support switched libcobalt to time64_t
only, removing the interfaces for the native time_t type.

With that series applied both worlds can live together in one libcobalt
build which should hopefully increase the backward compatibility a bit.

All time64_t services have been moved into a separate compile unit that
can be compiled twice now, if necessary. Unaffected environments like
x86_64 won't do that. It's not necessary as the native type is already
64 bit.

The most tricky part where the __RT(), __STD() and __WRAP() macros.
That has been solved by redirects on linker level.

To: Xenomai <xenomai@lists.linux.dev>
Cc: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
Florian Bezdeka (20):
      lib/cobalt: Introduce cond.h
      lib/cobalt: Introduce mutex.h
      lib/cobalt: Introduce mq.h
      lib/cobalt: Introduce rtdm.h
      lib/cobalt: Introduce wrappers_time64.c
      lib/cobalt: clock: Move all time64 related services to wrappers_time64.c
      lib/cobalt: cond: Move all time64 related services to wrappers_time64.c
      lib/cobalt: mq: Move all time64 related services to wrappers_time64.c
      lib/cobalt: mutex: Move all time64 related services to wrappers_time64.c
      lib/cobalt: mutex: Provide time64 variant of pthread_timedmutex_lock_interruptible_np
      lib/cobalt: rtdm: Move all time64 related services to wrappers_time64.c
      lib/cobalt: select: Move select services into wrappers_time64.c
      lib/cobalt: semaphore: Move time64 related services to wrappers_time64.c
      lib/cobalt: signal: Move time64 related services to wrappers_time64.c
      lib/cobalt: timer: Move all time64 related services to wrappers_time64.c
      lib/cobalt: timerfd: Move time64 related services to wrappers_time64.c
      lib/cobalt: Move XN_USE_TIME64_SYSCALL to wrappers_time64.c
      lib/cobalt: Finally build the native time_t interfaces on top
      lib/cobalt: thread: Cleanup and reorder includes
      scripts/xeno-config: Allow disabling the y2038 / time64_t support

 include/cobalt/pthread.h      |   16 +-
 include/cobalt/wrappers.h     |   13 +-
 lib/cobalt/Makefile.am        |   27 +-
 lib/cobalt/clock.c            |  309 +-----------
 lib/cobalt/cond.c             |  154 +-----
 lib/cobalt/cond.h             |   78 +++
 lib/cobalt/internal.h         |    5 -
 lib/cobalt/mq.c               |  151 +-----
 lib/cobalt/mq.h               |   34 ++
 lib/cobalt/mutex.c            |  211 +-------
 lib/cobalt/mutex.h            |   90 ++++
 lib/cobalt/rtdm.c             |  105 +---
 lib/cobalt/rtdm.h             |   32 ++
 lib/cobalt/select.c           |  108 ----
 lib/cobalt/semaphore.c        |   67 +--
 lib/cobalt/signal.c           |   26 +-
 lib/cobalt/thread.c           |    8 +-
 lib/cobalt/timer.c            |  121 +----
 lib/cobalt/timerfd.c          |   39 --
 lib/cobalt/wrappers_time64.c  | 1089 +++++++++++++++++++++++++++++++++++++++++
 scripts/xeno-config-cobalt.in |    5 +
 21 files changed, 1407 insertions(+), 1281 deletions(-)
---
base-commit: 363115d15682076ea0766a55c3c5b1eed87e1225
change-id: 20260219-wip-flo-fix-time64-32bit-native-8e5d8b7c7ca8

Best regards,
-- 
Florian Bezdeka <florian.bezdeka@siemens.com>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/20] lib/cobalt: Introduce cond.h
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20 14:33   ` Jan Kiszka
  2026-02-20  9:08 ` [PATCH 02/20] lib/cobalt: Introduce mutex.h Florian Bezdeka
                   ` (19 subsequent siblings)
  20 siblings, 1 reply; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Some code will be re-used later by the time64_t compile unit. Move that
code into cond.h, so code duplication is avoided.

No modifications to the code itself.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/Makefile.am |  1 +
 lib/cobalt/cond.c      | 67 ++-----------------------------------------
 lib/cobalt/cond.h      | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 65 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index ed7e503899f4852388fb3bf204bfe91936009d74..b1098413fbf3a8f6a5f0a85d6aceb9916b14149a 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -1,6 +1,7 @@
 pkgconfigdir = $(libdir)/pkgconfig
 
 noinst_HEADERS =	\
+	cond.h		\
 	current.h	\
 	umm.h		\
 	internal.h
diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
index 2d11f768edc0fe4e89944a96333d2dd76d174172..7be7fca01f53930f8504945206b2ee6ba6be1ba5 100644
--- a/lib/cobalt/cond.c
+++ b/lib/cobalt/cond.c
@@ -20,6 +20,8 @@
 #include <string.h>
 #include <pthread.h>
 #include <asm/xenomai/syscall.h>
+
+#include "cond.h"
 #include "current.h"
 #include "internal.h"
 
@@ -147,32 +149,6 @@ COBALT_IMPL(int, pthread_cond_init, (pthread_cond_t *cond,
 	return 0;
 }
 
-static int __attribute__((cold))
-	cobalt_cond_autoinit_type(const pthread_cond_t *cond)
-{
-	static const pthread_cond_t cond_initializer =
-		PTHREAD_COND_INITIALIZER;
-
-	return memcmp(cond, &cond_initializer, sizeof(cond_initializer)) == 0 ?
-		0 : -1;
-}
-
-static int __attribute__((cold))
-	cobalt_cond_doautoinit(union cobalt_cond_union *ucond)
-{
-	if (cobalt_cond_autoinit_type(&ucond->native_cond) < 0)
-		return EINVAL;
-
-	return __COBALT(pthread_cond_init(&ucond->native_cond, NULL));
-}
-
-static inline int cobalt_cond_autoinit(union cobalt_cond_union *ucond)
-{
-	if (ucond->shadow_cond.magic != COBALT_COND_MAGIC)
-		return cobalt_cond_doautoinit(ucond);
-	return 0;
-}
-
 /**
  * @fn int pthread_cond_destroy(pthread_cond_t *cond)
  * @brief Destroy a condition variable
@@ -208,45 +184,6 @@ COBALT_IMPL(int, pthread_cond_destroy, (pthread_cond_t *cond))
 	return -XENOMAI_SYSCALL1( sc_cobalt_cond_destroy, _cond);
 }
 
-struct cobalt_cond_cleanup_t {
-	struct cobalt_cond_shadow *cond;
-	struct cobalt_mutex_shadow *mutex;
-	unsigned count;
-	int err;
-};
-
-static void __pthread_cond_cleanup(void *data)
-{
-	struct cobalt_cond_cleanup_t *c = (struct cobalt_cond_cleanup_t *)data;
-	xnhandle_t cur = cobalt_get_current();
-	int err;
-
-	/* if we still own the mutex, cond_wait_prologue wasn't called yet */
-	if (xnsynch_fast_owner_check(mutex_get_ownerp(c->mutex), cur) == 0)
-		return;
-
-	do {
-		err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue,
-				       c->cond, c->mutex);
-	} while (err == -EINTR);
-
-	c->mutex->lockcnt = c->count;
-}
-
-static inline int do_sc_cond_wait_prologue(struct cobalt_cond_shadow *cnd,
-					   struct cobalt_mutex_shadow *mx,
-					   int *err, int timed,
-					   const struct timespec *abstime)
-{
-#ifdef __USE_TIME_BITS64
-	long sc_nr = sc_cobalt_cond_wait_prologue64;
-#else
-	long sc_nr = sc_cobalt_cond_wait_prologue;
-#endif
-
-	return XENOMAI_SYSCALL5(sc_nr, cnd, mx, err, timed, abstime);
-}
-
 /**
  * Wait on a condition variable.
  *
diff --git a/lib/cobalt/cond.h b/lib/cobalt/cond.h
new file mode 100644
index 0000000000000000000000000000000000000000..fbb7a02149ddfa0858def5e8741d5b044afc17b7
--- /dev/null
+++ b/lib/cobalt/cond.h
@@ -0,0 +1,78 @@
+#ifndef _LIB_COBALT_COND_H
+#define _LIB_COBALT_COND_H
+
+#include "current.h"
+#include "internal.h"
+
+#include <asm/xenomai/syscall.h>
+#include <cobalt/uapi/cond.h>
+
+#include <string.h>
+#include <pthread.h>
+
+struct cobalt_cond_cleanup_t {
+	struct cobalt_cond_shadow *cond;
+	struct cobalt_mutex_shadow *mutex;
+	unsigned count;
+	int err;
+};
+
+static int __attribute__((cold))
+cobalt_cond_autoinit_type(const pthread_cond_t *cond)
+{
+	static const pthread_cond_t cond_initializer = PTHREAD_COND_INITIALIZER;
+
+	return memcmp(cond, &cond_initializer, sizeof(cond_initializer)) == 0 ?
+		       0 :
+		       -1;
+}
+
+static int __attribute__((cold))
+cobalt_cond_doautoinit(union cobalt_cond_union *ucond)
+{
+	if (cobalt_cond_autoinit_type(&ucond->native_cond) < 0)
+		return EINVAL;
+
+	return __COBALT(pthread_cond_init(&ucond->native_cond, NULL));
+}
+
+static inline int cobalt_cond_autoinit(union cobalt_cond_union *ucond)
+{
+	if (ucond->shadow_cond.magic != COBALT_COND_MAGIC)
+		return cobalt_cond_doautoinit(ucond);
+	return 0;
+}
+
+static void __pthread_cond_cleanup(void *data)
+{
+	struct cobalt_cond_cleanup_t *c = (struct cobalt_cond_cleanup_t *)data;
+	xnhandle_t cur = cobalt_get_current();
+	int err;
+
+	/* if we still own the mutex, cond_wait_prologue wasn't called yet */
+	if (xnsynch_fast_owner_check(mutex_get_ownerp(c->mutex), cur) == 0)
+		return;
+
+	do {
+		err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue, c->cond,
+				       c->mutex);
+	} while (err == -EINTR);
+
+	c->mutex->lockcnt = c->count;
+}
+
+static inline int do_sc_cond_wait_prologue(struct cobalt_cond_shadow *cnd,
+					   struct cobalt_mutex_shadow *mx,
+					   int *err, int timed,
+					   const struct timespec *abstime)
+{
+#ifdef __USE_TIME_BITS64
+	long sc_nr = sc_cobalt_cond_wait_prologue64;
+#else
+	long sc_nr = sc_cobalt_cond_wait_prologue;
+#endif
+
+	return XENOMAI_SYSCALL5(sc_nr, cnd, mx, err, timed, abstime);
+}
+
+#endif //_LIB_COBALT_COND_H

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 02/20] lib/cobalt: Introduce mutex.h
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 01/20] lib/cobalt: Introduce cond.h Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 03/20] lib/cobalt: Introduce mq.h Florian Bezdeka
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

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 <florian.bezdeka@siemens.com>
---
 lib/cobalt/Makefile.am |  1 +
 lib/cobalt/mutex.c     | 82 ++-------------------------------------------
 lib/cobalt/mutex.h     | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 79 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index b1098413fbf3a8f6a5f0a85d6aceb9916b14149a..d913ca02128cd588327c2a728a01fb84d9cee538 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -3,6 +3,7 @@ pkgconfigdir = $(libdir)/pkgconfig
 noinst_HEADERS =	\
 	cond.h		\
 	current.h	\
+	mutex.h		\
 	umm.h		\
 	internal.h
 
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 62cdb462d7b92b177cc44777e07f69459fb6d195..390305cddc94985ebed354c895783e24652c1025 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -20,8 +20,10 @@
 #include <string.h>
 #include <pthread.h>
 #include <asm/xenomai/syscall.h>
+
 #include "current.h"
 #include "internal.h"
+#include "mutex.h"
 
 /**
  * @ingroup cobalt_api
@@ -61,7 +63,7 @@
 
 static pthread_mutexattr_t cobalt_default_mutexattr;
 static union cobalt_mutex_union cobalt_autoinit_mutex_union;
-static pthread_mutex_t *const cobalt_autoinit_mutex =
+pthread_mutex_t *const cobalt_autoinit_mutex =
 	&cobalt_autoinit_mutex_union.native_mutex;
 
 void cobalt_mutex_init(void)
@@ -167,84 +169,6 @@ COBALT_IMPL(int, pthread_mutex_init, (pthread_mutex_t *mutex,
 	return err;
 }
 
-/**
- * Test if a mutex structure contains a valid autoinitializer.
- *
- * @return the mutex type on success,
- * @return -1 if not in supported autoinitializer state
- */
-static int __attribute__((cold))
-	cobalt_mutex_autoinit_type(const pthread_mutex_t *mutex)
-{
-	static const pthread_mutex_t mutex_initializers[] = {
-#if HAVE_DECL_PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-		PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
-#endif
-#if HAVE_DECL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-		PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-#endif
-		PTHREAD_MUTEX_INITIALIZER
-	};
-	static const int mutex_types[] = {
-#if HAVE_DECL_PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-		PTHREAD_MUTEX_ERRORCHECK_NP,
-#endif
-#if HAVE_DECL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-		PTHREAD_MUTEX_RECURSIVE_NP,
-#endif
-		PTHREAD_MUTEX_DEFAULT
-	};
-	int i;
-
-	for (i = ARRAY_SIZE(mutex_types); i > 0; --i) {
-		if (memcmp(mutex, &mutex_initializers[i - 1],
-				sizeof(mutex_initializers[0])) == 0)
-			return mutex_types[i - 1];
-	}
-	return -1;
-}
-
-static int __attribute__((cold))
-	cobalt_mutex_doautoinit(union cobalt_mutex_union *umutex)
-{
-	struct cobalt_mutex_shadow *_mutex = &umutex->shadow_mutex;
-	int err __attribute__((unused));
-	pthread_mutexattr_t mattr;
-	int ret = 0, type;
-
-	type = cobalt_mutex_autoinit_type(&umutex->native_mutex);
-	if (type < 0)
-		return EINVAL;
-
-	pthread_mutexattr_init(&mattr);
-	pthread_mutexattr_settype(&mattr, type);
-	err = __COBALT(pthread_mutex_lock(cobalt_autoinit_mutex));
-	if (err) {
-		ret = err;
-		goto out;
-	}
-	if (_mutex->magic != COBALT_MUTEX_MAGIC)
-		ret = __COBALT(pthread_mutex_init(&umutex->native_mutex,
-			&mattr));
-	err = __COBALT(pthread_mutex_unlock(cobalt_autoinit_mutex));
-	if (err) {
-		if (ret == 0)
-			ret = err;
-	}
-
-  out:
-	pthread_mutexattr_destroy(&mattr);
-
-	return ret;
-}
-
-static inline int cobalt_mutex_autoinit(union cobalt_mutex_union *umutex)
-{
-	if (umutex->shadow_mutex.magic != COBALT_MUTEX_MAGIC)
-		return cobalt_mutex_doautoinit(umutex);
-	return 0;
-}
-
 /**
  * Destroy a mutex.
  *
diff --git a/lib/cobalt/mutex.h b/lib/cobalt/mutex.h
new file mode 100644
index 0000000000000000000000000000000000000000..2f8eac7d20521517a524770d62e0db52a4113649
--- /dev/null
+++ b/lib/cobalt/mutex.h
@@ -0,0 +1,90 @@
+
+#ifndef _LIB_COBALT_MUTEX_H
+#define _LIB_COBALT_MUTEX_H
+
+#include <boilerplate/ancillaries.h>
+#include <cobalt/uapi/mutex.h>
+
+#include <pthread.h>
+
+extern pthread_mutex_t *const cobalt_autoinit_mutex;
+
+/**
+ * Test if a mutex structure contains a valid autoinitializer.
+ *
+ * @return the mutex type on success,
+ * @return -1 if not in supported autoinitializer state
+ */
+static int __attribute__((cold))
+cobalt_mutex_autoinit_type(const pthread_mutex_t *mutex)
+{
+	static const pthread_mutex_t mutex_initializers[] = {
+#if HAVE_DECL_PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
+		PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
+#endif
+#if HAVE_DECL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+		PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+#endif
+		PTHREAD_MUTEX_INITIALIZER
+	};
+	static const int mutex_types[] = {
+#if HAVE_DECL_PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
+		PTHREAD_MUTEX_ERRORCHECK_NP,
+#endif
+#if HAVE_DECL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+		PTHREAD_MUTEX_RECURSIVE_NP,
+#endif
+		PTHREAD_MUTEX_DEFAULT
+	};
+	int i;
+
+	for (i = ARRAY_SIZE(mutex_types); i > 0; --i) {
+		if (memcmp(mutex, &mutex_initializers[i - 1],
+			   sizeof(mutex_initializers[0])) == 0)
+			return mutex_types[i - 1];
+	}
+	return -1;
+}
+
+static int __attribute__((cold))
+cobalt_mutex_doautoinit(union cobalt_mutex_union *umutex)
+{
+	struct cobalt_mutex_shadow *_mutex = &umutex->shadow_mutex;
+	int err __attribute__((unused));
+	pthread_mutexattr_t mattr;
+	int ret = 0, type;
+
+	type = cobalt_mutex_autoinit_type(&umutex->native_mutex);
+	if (type < 0)
+		return EINVAL;
+
+	pthread_mutexattr_init(&mattr);
+	pthread_mutexattr_settype(&mattr, type);
+	err = __COBALT(pthread_mutex_lock(cobalt_autoinit_mutex));
+	if (err) {
+		ret = err;
+		goto out;
+	}
+	if (_mutex->magic != COBALT_MUTEX_MAGIC)
+		ret = __COBALT(
+			pthread_mutex_init(&umutex->native_mutex, &mattr));
+	err = __COBALT(pthread_mutex_unlock(cobalt_autoinit_mutex));
+	if (err) {
+		if (ret == 0)
+			ret = err;
+	}
+
+out:
+	pthread_mutexattr_destroy(&mattr);
+
+	return ret;
+}
+
+static inline int cobalt_mutex_autoinit(union cobalt_mutex_union *umutex)
+{
+	if (umutex->shadow_mutex.magic != COBALT_MUTEX_MAGIC)
+		return cobalt_mutex_doautoinit(umutex);
+	return 0;
+}
+
+#endif //_LIB_COBALT_MUTEX_H

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 03/20] lib/cobalt: Introduce mq.h
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 01/20] lib/cobalt: Introduce cond.h Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 02/20] lib/cobalt: Introduce mutex.h Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 04/20] lib/cobalt: Introduce rtdm.h Florian Bezdeka
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

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 <florian.bezdeka@siemens.com>
---
 lib/cobalt/Makefile.am |  1 +
 lib/cobalt/mq.c        | 30 ++++--------------------------
 lib/cobalt/mq.h        | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index d913ca02128cd588327c2a728a01fb84d9cee538..262c9bedb3fbe8edee96353f5a3e6b631c31e81d 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -4,6 +4,7 @@ noinst_HEADERS =	\
 	cond.h		\
 	current.h	\
 	mutex.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..f8627c67456dcd4d0716c37051a528243efa33a3
--- /dev/null
+++ b/lib/cobalt/mq.h
@@ -0,0 +1,34 @@
+
+#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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 04/20] lib/cobalt: Introduce rtdm.h
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (2 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 03/20] lib/cobalt: Introduce mq.h Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c Florian Bezdeka
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

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 <florian.bezdeka@siemens.com>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (3 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 04/20] lib/cobalt: Introduce rtdm.h Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20 14:36   ` Jan Kiszka
  2026-02-20  9:08 ` [PATCH 06/20] lib/cobalt: clock: Move all time64 related services to wrappers_time64.c Florian Bezdeka
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

All COBALT_IMPL_TIME64() services will be moved afterwards - step by
step - into the newly introduced wrappers_time64.c. At the end that
should allow us to compile libcobalt with time64_t support leaving
the native time_t services in place.

Currently, all native time_t services are replaced by the 64 bit
variants. That is OK as long as applications are rebuild after
libcobalt, but we try to remove this limitation now.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/Makefile.am       | 3 ++-
 lib/cobalt/wrappers_time64.c | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index f461e570ed42a0d5cbc43eabb373c3c9edd83bad..17e203f9015fe2bb5306609e4d51c62f3a725780 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -43,7 +43,8 @@ libcobalt_la_SOURCES =		\
 	timerfd.c		\
 	trace.c			\
 	umm.c			\
-	wrappers.c
+	wrappers.c		\
+	wrappers_time64.c
 
 libcobalt_la_CPPFLAGS =			\
 	@XENO_COBALT_CFLAGS@		\
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
new file mode 100644
index 0000000000000000000000000000000000000000..4c4e0db0650b49f46cbd6d9ecf7cd656bb04bbe4
--- /dev/null
+++ b/lib/cobalt/wrappers_time64.c
@@ -0,0 +1,6 @@
+/*
+ * Magic ahead:
+ * This file is compiled twice in case y2038/time64_t support is necessary
+ * and requested. The first time with time64_t and a second time with native
+ * time_t.
+ */

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 06/20] lib/cobalt: clock: Move all time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (4 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 07/20] lib/cobalt: cond: " Florian Bezdeka
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement with some minor adjustments to the doxygen headers.
All services should remain in the cobalt_api_time group.

Some comments have been changed from /* to /** to reflect the doxygen
style. I think those doc information was not properly processed in the
past.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/clock.c           | 309 +---------------------------------------
 lib/cobalt/wrappers_time64.c | 327 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 328 insertions(+), 308 deletions(-)

diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index 65abf5eacf5185e944915fecc44ff7760202ab19..9551bd5f1a5be21eaec1f5c611396f545eb84eb2 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -20,9 +20,7 @@
 #include <errno.h>
 #include <pthread.h>
 #include <unistd.h>
-#include <time.h>
-#include <sys/time.h>
-#include <asm/xenomai/syscall.h>
+
 #include "internal.h"
 
 /**
@@ -65,284 +63,6 @@
  *@{
  */
 
-/**
- * Get the resolution of the specified clock.
- *
- * This service returns, at the address @a res, if it is not @a NULL, the
- * resolution of the clock @a clock_id.
- *
- * For both CLOCK_REALTIME and CLOCK_MONOTONIC, this resolution is the duration
- * of one system clock tick. No other clock is supported.
- *
- * @param clock_id clock identifier, either CLOCK_REALTIME or CLOCK_MONOTONIC;
- *
- * @param tp the address where the resolution of the specified clock will be
- * stored on success.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EINVAL, @a clock_id is invalid;
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html">
- * Specification.</a>
- *
- * @apitags{unrestricted}
- */
-COBALT_IMPL_TIME64(int, clock_getres, __clock_getres64,
-		   (clockid_t clock_id, struct timespec *tp))
-{
-	int ret;
-
-#ifdef __USE_TIME_BITS64
-	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_getres64, clock_id, tp);
-#else
-	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_getres, clock_id, tp);
-#endif
-
-	if (ret) {
-		errno = ret;
-		return -1;
-	}
-
-	return 0;
-}
-
-static int __do_clock_gettime(clockid_t clock_id, struct timespec *tp)
-{
-#ifdef __USE_TIME_BITS64
-	return -XENOMAI_SYSCALL2(sc_cobalt_clock_gettime64, clock_id, tp);
-#else
-	return -XENOMAI_SYSCALL2(sc_cobalt_clock_gettime, clock_id, tp);
-#endif
-}
-
-/**
- * Read the specified clock.
- *
- * This service returns, at the address @a tp the current value of the clock @a
- * clock_id. If @a clock_id is:
- * - CLOCK_REALTIME, the clock value represents the amount of time since the
- *   Epoch, with a precision of one system clock tick;
- * - CLOCK_MONOTONIC or CLOCK_MONOTONIC_RAW, the clock value is given
- *   by an architecture-dependent high resolution counter, with a
- *   precision independent from the system clock tick duration.
- * - CLOCK_HOST_REALTIME, the clock value as seen by the host, typically
- *   Linux. Resolution and precision depend on the host, but it is guaranteed
- *   that both, host and Cobalt, see the same information.
- *
- * @param clock_id clock identifier, either CLOCK_REALTIME, CLOCK_MONOTONIC,
- *        or CLOCK_HOST_REALTIME;
- *
- * @param tp the address where the value of the specified clock will be stored.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EINVAL, @a clock_id is invalid.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_gettime.html">
- * Specification.</a>
- *
- * @apitags{unrestricted}
- */
-COBALT_IMPL_TIME64(int, clock_gettime, __clock_gettime64,
-		   (clockid_t clock_id, struct timespec *tp))
-{
-	int ret;
-
-	switch (clock_id) {
-	case CLOCK_REALTIME:
-	case CLOCK_HOST_REALTIME:
-		ret = __cobalt_vdso_gettime(CLOCK_REALTIME, tp);
-		break;
-	case CLOCK_MONOTONIC:
-	case CLOCK_MONOTONIC_RAW:
-		ret = __cobalt_vdso_gettime(clock_id, tp);
-		break;
-	default:
-		ret = __do_clock_gettime(clock_id, tp);
-	}
-
-	if (ret) {
-		errno = ret;
-		return -1;
-	}
-
-	return 0;
-}
-
-/**
- * Set the specified clock.
- *
- * Set the CLOCK_REALTIME or Cobalt-specific clocks.
- *
- * @param clock_id the id of the clock to be set. CLOCK_REALTIME,
- * and Cobalt-specific clocks are supported.
- *
- * @param tp the address of a struct timespec specifying the new date.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EINVAL, @a clock_id is undefined;
- * - EINVAL, the date specified by @a tp is invalid.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_settime.html">
- * Specification.</a>
- *
- * @note Setting CLOCK_REALTIME may cause the caller to switch to
- * secondary mode.
- *
- * @apitags{unrestricted, switch-secondary}
- */
-COBALT_IMPL_TIME64(int, clock_settime, __clock_settime64,
-		   (clockid_t clock_id, const struct timespec *tp))
-{
-	int ret;
-
-	if (clock_id == CLOCK_REALTIME)
-		return __STD(clock_settime(CLOCK_REALTIME, tp));
-
-#ifdef __USE_TIME_BITS64
-	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_settime64, clock_id, tp);
-#else
-	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_settime, clock_id, tp);
-#endif
-	if (ret) {
-		errno = ret;
-		return -1;
-	}
-
-	return 0;
-}
-
-/* @apitags{unrestricted} */
-
-COBALT_IMPL_TIME64(int, clock_adjtime, __clock_adjtime64,
-		   (clockid_t clock_id, struct timex *tx))
-{
-	int ret;
-
-#ifdef XN_USE_TIME64_SYSCALL
-	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_adjtime64, clock_id, tx);
-#else
-	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_adjtime, clock_id, tx);
-#endif
-
-	if (ret < 0) {
-		errno = ret;
-		return -1;
-	}
-
-	return ret;
-}
-
-/**
- * Sleep some amount of time.
- *
- * This service suspends the calling thread until the wakeup time specified by
- * @a rqtp, or a signal is delivered to the caller. If the flag TIMER_ABSTIME is
- * set in the @a flags argument, the wakeup time is specified as an absolute
- * value of the clock @a clock_id. If the flag TIMER_ABSTIME is not set, the
- * wakeup time is specified as a time interval.
- *
- * If this service is interrupted by a signal, the flag TIMER_ABSTIME is not
- * set, and @a rmtp is not @a NULL, the time remaining until the specified
- * wakeup time is returned at the address @a rmtp.
- *
- * The resolution of this service is one system clock tick.
- *
- * @param clock_id clock identifier, either CLOCK_REALTIME or CLOCK_MONOTONIC.
- *
- * @param flags one of:
- * - 0 meaning that the wakeup time @a rqtp is a time interval;
- * - TIMER_ABSTIME, meaning that the wakeup time is an absolute value of the
- *   clock @a clock_id.
- *
- * @param rqtp address of the wakeup time.
- *
- * @param rmtp address where the remaining time before wakeup will be stored if
- * the service is interrupted by a signal.
- *
- * @return 0 on success;
- * @return an error number if:
- * - EPERM, the caller context is invalid;
- * - ENOTSUP, the specified clock is unsupported;
- * - EINVAL, the specified wakeup time is invalid;
- * - EINTR, this service was interrupted by a signal.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_nanosleep.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-COBALT_IMPL_TIME64(int, clock_nanosleep, __clock_nanosleep_time64,
-		   (clockid_t clock_id, int flags, const struct timespec *rqtp,
-		    struct timespec *rmtp))
-{
-	int ret, oldtype;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-#ifdef __USE_TIME_BITS64
-	ret = -XENOMAI_SYSCALL4(sc_cobalt_clock_nanosleep64,
-				clock_id, flags, rqtp, rmtp);
-#else
-	ret = -XENOMAI_SYSCALL4(sc_cobalt_clock_nanosleep,
-				clock_id, flags, rqtp, rmtp);
-#endif
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	return ret;
-}
-
-/**
- * Sleep some amount of time.
- *
- * This service suspends the calling thread until the wakeup time specified by
- * @a rqtp, or a signal is delivered. The wakeup time is specified as a time
- * interval.
- *
- * If this service is interrupted by a signal and @a rmtp is not @a NULL, the
- * time remaining until the specified wakeup time is returned at the address @a
- * rmtp.
- *
- * The resolution of this service is one system clock tick.
- *
- * @param rqtp address of the wakeup time.
- *
- * @param rmtp address where the remaining time before wakeup will be stored if
- * the service is interrupted by a signal.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EPERM, the caller context is invalid;
- * - EINVAL, the specified wakeup time is invalid;
- * - EINTR, this service was interrupted by a signal.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/nanosleep.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-COBALT_IMPL_TIME64(int, nanosleep, __nanosleep64,
-		   (const struct timespec *rqtp, struct timespec *rmtp))
-{
-	int ret;
-
-	ret = __WRAP(clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp));
-	if (ret) {
-		errno = ret;
-		return -1;
-	}
-
-	return 0;
-}
-
 /* @apitags{thread-unrestricted, switch-primary} */
 
 COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
@@ -376,31 +96,4 @@ COBALT_IMPL(int, usleep, (useconds_t usec))
 	return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, &rqt, NULL));
 }
 
-/* @apitags{unrestricted} */
-
-COBALT_IMPL_TIME64(int, gettimeofday, __gettimeofday64,
-		   (struct timeval *tv, struct timezone *tz))
-{
-	struct timespec ts;
-	int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
-	if (ret == 0) {
-		tv->tv_sec = ts.tv_sec;
-		tv->tv_usec = ts.tv_nsec / 1000;
-	}
-	return ret;
-}
-
-/* @apitags{unrestricted} */
-
-COBALT_IMPL_TIME64(time_t, time, __time64, (time_t *t))
-{
-	struct timespec ts;
-	int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
-	if (ret)
-		return (time_t)-1;
-
-	if (t)
-		*t = ts.tv_sec;
-	return ts.tv_sec;
-}
 /** @} */
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 4c4e0db0650b49f46cbd6d9ecf7cd656bb04bbe4..b50599b066f7e1141422e059dd9912307242d0af 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -4,3 +4,330 @@
  * and requested. The first time with time64_t and a second time with native
  * time_t.
  */
+
+#include "internal.h"
+
+#include <asm/xenomai/syscall.h>
+#include <cobalt/uapi/syscall.h>
+
+#include <errno.h>
+#include <pthread.h>
+#include <sys/time.h>
+#include <time.h>
+
+/**
+ * Get the resolution of the specified clock.
+ * @ingroup cobalt_api_time
+ *
+ * This service returns, at the address @a res, if it is not @a NULL, the
+ * resolution of the clock @a clock_id.
+ *
+ * For both CLOCK_REALTIME and CLOCK_MONOTONIC, this resolution is the duration
+ * of one system clock tick. No other clock is supported.
+ *
+ * @param clock_id clock identifier, either CLOCK_REALTIME or CLOCK_MONOTONIC;
+ *
+ * @param tp the address where the resolution of the specified clock will be
+ * stored on success.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a clock_id is invalid;
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html">
+ * Specification.</a>
+ *
+ * @apitags{unrestricted}
+ */
+COBALT_IMPL_TIME64(int, clock_getres, __clock_getres64,
+		   (clockid_t clock_id, struct timespec *tp))
+{
+	int ret;
+
+#ifdef __USE_TIME_BITS64
+	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_getres64, clock_id, tp);
+#else
+	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_getres, clock_id, tp);
+#endif
+
+	if (ret) {
+		errno = ret;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int __do_clock_gettime(clockid_t clock_id, struct timespec *tp)
+{
+#ifdef __USE_TIME_BITS64
+	return -XENOMAI_SYSCALL2(sc_cobalt_clock_gettime64, clock_id, tp);
+#else
+	return -XENOMAI_SYSCALL2(sc_cobalt_clock_gettime, clock_id, tp);
+#endif
+}
+
+/**
+ * Read the specified clock.
+ * @ingroup cobalt_api_time
+ *
+ * This service returns, at the address @a tp the current value of the clock @a
+ * clock_id. If @a clock_id is:
+ * - CLOCK_REALTIME, the clock value represents the amount of time since the
+ *   Epoch, with a precision of one system clock tick;
+ * - CLOCK_MONOTONIC or CLOCK_MONOTONIC_RAW, the clock value is given
+ *   by an architecture-dependent high resolution counter, with a
+ *   precision independent from the system clock tick duration.
+ * - CLOCK_HOST_REALTIME, the clock value as seen by the host, typically
+ *   Linux. Resolution and precision depend on the host, but it is guaranteed
+ *   that both, host and Cobalt, see the same information.
+ *
+ * @param clock_id clock identifier, either CLOCK_REALTIME, CLOCK_MONOTONIC,
+ *        or CLOCK_HOST_REALTIME;
+ *
+ * @param tp the address where the value of the specified clock will be stored.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a clock_id is invalid.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_gettime.html">
+ * Specification.</a>
+ *
+ * @apitags{unrestricted}
+ */
+COBALT_IMPL_TIME64(int, clock_gettime, __clock_gettime64,
+		   (clockid_t clock_id, struct timespec *tp))
+{
+	int ret;
+
+	switch (clock_id) {
+	case CLOCK_REALTIME:
+	case CLOCK_HOST_REALTIME:
+		ret = __cobalt_vdso_gettime(CLOCK_REALTIME, tp);
+		break;
+	case CLOCK_MONOTONIC:
+	case CLOCK_MONOTONIC_RAW:
+		ret = __cobalt_vdso_gettime(clock_id, tp);
+		break;
+	default:
+		ret = __do_clock_gettime(clock_id, tp);
+	}
+
+	if (ret) {
+		errno = ret;
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Set the specified clock.
+ * @ingroup cobalt_api_time
+ *
+ * Set the CLOCK_REALTIME or Cobalt-specific clocks.
+ *
+ * @param clock_id the id of the clock to be set. CLOCK_REALTIME,
+ * and Cobalt-specific clocks are supported.
+ *
+ * @param tp the address of a struct timespec specifying the new date.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a clock_id is undefined;
+ * - EINVAL, the date specified by @a tp is invalid.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_settime.html">
+ * Specification.</a>
+ *
+ * @note Setting CLOCK_REALTIME may cause the caller to switch to
+ * secondary mode.
+ *
+ * @apitags{unrestricted, switch-secondary}
+ */
+COBALT_IMPL_TIME64(int, clock_settime, __clock_settime64,
+		   (clockid_t clock_id, const struct timespec *tp))
+{
+	int ret;
+
+	if (clock_id == CLOCK_REALTIME)
+		return __STD(clock_settime(CLOCK_REALTIME, tp));
+
+#ifdef __USE_TIME_BITS64
+	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_settime64, clock_id, tp);
+#else
+	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_settime, clock_id, tp);
+#endif
+	if (ret) {
+		errno = ret;
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * @ingroup cobalt_api_time
+ * @apitags{unrestricted}
+ */
+COBALT_IMPL_TIME64(int, clock_adjtime, __clock_adjtime64,
+		   (clockid_t clock_id, struct timex *tx))
+{
+	int ret;
+
+#ifdef XN_USE_TIME64_SYSCALL
+	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_adjtime64, clock_id, tx);
+#else
+	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_adjtime, clock_id, tx);
+#endif
+
+	if (ret < 0) {
+		errno = ret;
+		return -1;
+	}
+
+	return ret;
+}
+
+/**
+ * Sleep some amount of time.
+ * @ingroup cobalt_api_time
+ *
+ * This service suspends the calling thread until the wakeup time specified by
+ * @a rqtp, or a signal is delivered to the caller. If the flag TIMER_ABSTIME is
+ * set in the @a flags argument, the wakeup time is specified as an absolute
+ * value of the clock @a clock_id. If the flag TIMER_ABSTIME is not set, the
+ * wakeup time is specified as a time interval.
+ *
+ * If this service is interrupted by a signal, the flag TIMER_ABSTIME is not
+ * set, and @a rmtp is not @a NULL, the time remaining until the specified
+ * wakeup time is returned at the address @a rmtp.
+ *
+ * The resolution of this service is one system clock tick.
+ *
+ * @param clock_id clock identifier, either CLOCK_REALTIME or CLOCK_MONOTONIC.
+ *
+ * @param flags one of:
+ * - 0 meaning that the wakeup time @a rqtp is a time interval;
+ * - TIMER_ABSTIME, meaning that the wakeup time is an absolute value of the
+ *   clock @a clock_id.
+ *
+ * @param rqtp address of the wakeup time.
+ *
+ * @param rmtp address where the remaining time before wakeup will be stored if
+ * the service is interrupted by a signal.
+ *
+ * @return 0 on success;
+ * @return an error number if:
+ * - EPERM, the caller context is invalid;
+ * - ENOTSUP, the specified clock is unsupported;
+ * - EINVAL, the specified wakeup time is invalid;
+ * - EINTR, this service was interrupted by a signal.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/clock_nanosleep.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+COBALT_IMPL_TIME64(int, clock_nanosleep, __clock_nanosleep_time64,
+		   (clockid_t clock_id, int flags, const struct timespec *rqtp,
+		    struct timespec *rmtp))
+{
+	int ret, oldtype;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+#ifdef __USE_TIME_BITS64
+	ret = -XENOMAI_SYSCALL4(sc_cobalt_clock_nanosleep64, clock_id, flags,
+				rqtp, rmtp);
+#else
+	ret = -XENOMAI_SYSCALL4(sc_cobalt_clock_nanosleep, clock_id, flags,
+				rqtp, rmtp);
+#endif
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	return ret;
+}
+
+/**
+ * Sleep some amount of time.
+ * @ingroup cobalt_api_time
+ *
+ * This service suspends the calling thread until the wakeup time specified by
+ * @a rqtp, or a signal is delivered. The wakeup time is specified as a time
+ * interval.
+ *
+ * If this service is interrupted by a signal and @a rmtp is not @a NULL, the
+ * time remaining until the specified wakeup time is returned at the address @a
+ * rmtp.
+ *
+ * The resolution of this service is one system clock tick.
+ *
+ * @param rqtp address of the wakeup time.
+ *
+ * @param rmtp address where the remaining time before wakeup will be stored if
+ * the service is interrupted by a signal.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EPERM, the caller context is invalid;
+ * - EINVAL, the specified wakeup time is invalid;
+ * - EINTR, this service was interrupted by a signal.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/nanosleep.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+COBALT_IMPL_TIME64(int, nanosleep, __nanosleep64,
+		   (const struct timespec *rqtp, struct timespec *rmtp))
+{
+	int ret;
+
+	ret = __WRAP(clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp));
+	if (ret) {
+		errno = ret;
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * @apitags{unrestricted}
+ * @ingroup cobalt_api_time
+ */
+COBALT_IMPL_TIME64(int, gettimeofday, __gettimeofday64,
+		   (struct timeval *tv, struct timezone *tz))
+{
+	struct timespec ts;
+	int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
+	if (ret == 0) {
+		tv->tv_sec = ts.tv_sec;
+		tv->tv_usec = ts.tv_nsec / 1000;
+	}
+	return ret;
+}
+
+/**
+ * @apitags{unrestricted}
+ * @ingroup cobalt_api_time
+ */
+COBALT_IMPL_TIME64(time_t, time, __time64, (time_t *t))
+{
+	struct timespec ts;
+	int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
+	if (ret)
+		return (time_t)-1;
+
+	if (t)
+		*t = ts.tv_sec;
+	return ts.tv_sec;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/20] lib/cobalt: cond: Move all time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (5 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 06/20] lib/cobalt: clock: Move all time64 related services to wrappers_time64.c Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 08/20] lib/cobalt: mq: " Florian Bezdeka
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement with some minor adjustments to the doxygen headers.
All services should remain in the cobalt_api_cond group.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/cond.c            | 87 ------------------------------------------
 lib/cobalt/wrappers_time64.c | 90 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 87 deletions(-)

diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
index 7be7fca01f53930f8504945206b2ee6ba6be1ba5..fb700f4500a6f1e7a0331954f7a5f5a8a3bf1052 100644
--- a/lib/cobalt/cond.c
+++ b/lib/cobalt/cond.c
@@ -282,93 +282,6 @@ COBALT_IMPL(int, pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mute
 	return -err ?: -c.err;
 }
 
-/**
- * Wait a bounded time on a condition variable.
- *
- * This service is equivalent to pthread_cond_wait(), except that the calling
- * thread remains blocked on the condition variable @a cnd only until the
- * timeout specified by @a abstime expires.
- *
- * The timeout @a abstime is expressed as an absolute value of the @a clock
- * attribute passed to pthread_cond_init(). By default, @a CLOCK_REALTIME is
- * used.
- *
- * @param cond the condition variable to wait for;
- *
- * @param mutex the mutex associated with @a cnd;
- *
- * @param abstime the timeout, expressed as an absolute value of the clock
- * attribute passed to pthread_cond_init().
- *
- * @return 0 on success,
- * @return an error number if:
- * - EPERM, the caller context is invalid;
- * - EPERM, the specified condition variable is not process-shared and does not
- *   belong to the current process;
- * - EINVAL, the specified condition variable, mutex or timeout is invalid;
- * - EINVAL, another thread is currently blocked on @a cnd using another mutex
- *   than @a mx;
- * - EPERM, the specified mutex is not owned by the caller;
- * - ETIMEDOUT, the specified timeout expired.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_cond_timedwait.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-COBALT_IMPL_TIME64(int, pthread_cond_timedwait, __pthread_cond_timedwait64,
-		   (pthread_cond_t *cond, pthread_mutex_t *mutex,
-		    const struct timespec *abstime))
-{
-	struct cobalt_cond_shadow *_cnd = &((union cobalt_cond_union *)cond)->shadow_cond;
-	struct cobalt_mutex_shadow *_mx =
-		&((union cobalt_mutex_union *)mutex)->shadow_mutex;
-	struct cobalt_cond_cleanup_t c = {
-		.cond = _cnd,
-		.mutex = _mx,
-	};
-	int err, oldtype;
-
-	if (_mx->magic != COBALT_MUTEX_MAGIC)
-		return EINVAL;
-
-	err = cobalt_cond_autoinit((union cobalt_cond_union *)cond);
-	if (err)
-		return err;
-
-	if (_mx->attr.type == PTHREAD_MUTEX_ERRORCHECK) {
-		xnhandle_t cur = cobalt_get_current();
-
-		if (cur == XN_NO_HANDLE)
-			return EPERM;
-
-		if (xnsynch_fast_owner_check(mutex_get_ownerp(_mx), cur))
-			return EPERM;
-	}
-
-	c.count = _mx->lockcnt;
-
-	pthread_cleanup_push(&__pthread_cond_cleanup, &c);
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-	err = do_sc_cond_wait_prologue(_cnd, _mx, &c.err, 1, abstime);
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	pthread_cleanup_pop(0);
-
-	while (err == -EINTR) {
-		err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue, _cnd, _mx);
-		pthread_testcancel();
-	}
-
-	_mx->lockcnt = c.count;
-
-	return -err ?: -c.err;
-}
-
 /**
  * Signal a condition variable.
  *
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index b50599b066f7e1141422e059dd9912307242d0af..8e70e0bb351d9fe18a68495383ed5a6a77dd5c18 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -5,6 +5,7 @@
  * time_t.
  */
 
+#include "cond.h"
 #include "internal.h"
 
 #include <asm/xenomai/syscall.h>
@@ -331,3 +332,92 @@ COBALT_IMPL_TIME64(time_t, time, __time64, (time_t *t))
 		*t = ts.tv_sec;
 	return ts.tv_sec;
 }
+
+/**
+ * Wait a bounded time on a condition variable.
+ * @ingroup cobalt_api_cond
+ *
+ * This service is equivalent to pthread_cond_wait(), except that the calling
+ * thread remains blocked on the condition variable @a cnd only until the
+ * timeout specified by @a abstime expires.
+ *
+ * The timeout @a abstime is expressed as an absolute value of the @a clock
+ * attribute passed to pthread_cond_init(). By default, @a CLOCK_REALTIME is
+ * used.
+ *
+ * @param cond the condition variable to wait for;
+ *
+ * @param mutex the mutex associated with @a cnd;
+ *
+ * @param abstime the timeout, expressed as an absolute value of the clock
+ * attribute passed to pthread_cond_init().
+ *
+ * @return 0 on success,
+ * @return an error number if:
+ * - EPERM, the caller context is invalid;
+ * - EPERM, the specified condition variable is not process-shared and does not
+ *   belong to the current process;
+ * - EINVAL, the specified condition variable, mutex or timeout is invalid;
+ * - EINVAL, another thread is currently blocked on @a cnd using another mutex
+ *   than @a mx;
+ * - EPERM, the specified mutex is not owned by the caller;
+ * - ETIMEDOUT, the specified timeout expired.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_cond_timedwait.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+COBALT_IMPL_TIME64(int, pthread_cond_timedwait, __pthread_cond_timedwait64,
+		   (pthread_cond_t *cond, pthread_mutex_t *mutex,
+		    const struct timespec *abstime))
+{
+	struct cobalt_cond_shadow *_cnd =
+		&((union cobalt_cond_union *)cond)->shadow_cond;
+	struct cobalt_mutex_shadow *_mx =
+		&((union cobalt_mutex_union *)mutex)->shadow_mutex;
+	struct cobalt_cond_cleanup_t c = {
+		.cond = _cnd,
+		.mutex = _mx,
+	};
+	int err, oldtype;
+
+	if (_mx->magic != COBALT_MUTEX_MAGIC)
+		return EINVAL;
+
+	err = cobalt_cond_autoinit((union cobalt_cond_union *)cond);
+	if (err)
+		return err;
+
+	if (_mx->attr.type == PTHREAD_MUTEX_ERRORCHECK) {
+		xnhandle_t cur = cobalt_get_current();
+
+		if (cur == XN_NO_HANDLE)
+			return EPERM;
+
+		if (xnsynch_fast_owner_check(mutex_get_ownerp(_mx), cur))
+			return EPERM;
+	}
+
+	c.count = _mx->lockcnt;
+
+	pthread_cleanup_push(&__pthread_cond_cleanup, &c);
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+	err = do_sc_cond_wait_prologue(_cnd, _mx, &c.err, 1, abstime);
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	pthread_cleanup_pop(0);
+
+	while (err == -EINTR) {
+		err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue, _cnd, _mx);
+		pthread_testcancel();
+	}
+
+	_mx->lockcnt = c.count;
+
+	return -err ?: -c.err;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 08/20] lib/cobalt: mq: Move all time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (6 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 07/20] lib/cobalt: cond: " Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 09/20] lib/cobalt: mutex: " Florian Bezdeka
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement with some minor adjustments to the doxygen headers.
All services should remain in the cobalt_api_mq group.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/mq.c              | 121 -----------------------------------------
 lib/cobalt/wrappers_time64.c | 125 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 125 insertions(+), 121 deletions(-)

diff --git a/lib/cobalt/mq.c b/lib/cobalt/mq.c
index 72d419d6cfac0097ba7ed61941e7b8a92e3bc673..0997d396d06e08407741f4b5d6b373284f219f97 100644
--- a/lib/cobalt/mq.c
+++ b/lib/cobalt/mq.c
@@ -345,64 +345,6 @@ COBALT_IMPL(int, mq_send, (mqd_t q, const char *buffer, size_t len, unsigned pri
 	return -1;
 }
 
-/**
- * Attempt, during a bounded time, to send a message to a message queue.
- *
- * This service is equivalent to mq_send(), except that if the message queue is
- * full and the flag @a O_NONBLOCK is not set for the descriptor @a fd, the
- * calling thread is only suspended until the timeout specified by @a
- * abs_timeout expires.
- *
- * @param q message queue descriptor;
- *
- * @param buffer pointer to the message to be sent;
- *
- * @param len length of the message;
- *
- * @param prio priority of the message;
- *
- * @param timeout the timeout, expressed as an absolute value of the
- * CLOCK_REALTIME clock.
- *
- * @return 0 and send a message on success;
- * @return -1 with no message sent and @a errno set if:
- * - EBADF, @a fd is not a valid message queue descriptor open for writing;
- * - EMSGSIZE, the message length exceeds the @a mq_msgsize attribute of the
- *   message queue;
- * - EAGAIN, the flag O_NONBLOCK is set for the descriptor @a fd and the message
- *   queue is full;
- * - EPERM, the caller context is invalid;
- * - ETIMEDOUT, the specified timeout expired;
- * - EINTR, the service was interrupted by a signal.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_timedsend.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-COBALT_IMPL_TIME64(int, mq_timedsend, __mq_timedsend_time64,
-		   (mqd_t q, const char *buffer, size_t len, unsigned prio,
-		    const struct timespec *timeout))
-{
-	int err, oldtype;
-
-	if (timeout == NULL)
-		return -EFAULT;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-	err = __do_mq_timesend(q, buffer, len, prio, timeout);
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	if (!err)
-		return 0;
-
-	errno = -err;
-	return -1;
-}
-
 /**
  * Receive a message from a message queue.
  *
@@ -461,69 +403,6 @@ COBALT_IMPL(ssize_t, mq_receive, (mqd_t q, char *buffer, size_t len, unsigned *p
 	return -1;
 }
 
-/**
- * Attempt, during a bounded time, to receive a message from a message queue.
- *
- * This service is equivalent to mq_receive(), except that if the flag @a
- * O_NONBLOCK is not set for the descriptor @a fd and the message queue is
- * empty, the calling thread is only suspended until the timeout @a abs_timeout
- * expires.
- *
- * @param q the queue descriptor;
- *
- * @param buffer the address where the received message will be stored on
- * success;
- *
- * @param len @a buffer length;
- *
- * @param prio address where the priority of the received message will be
- * stored on success.
- *
- * @param timeout the timeout, expressed as an absolute value of the
- * CLOCK_REALTIME clock.
- *
- * @return the message length, and copy a message at the address @a buffer on
- * success;
- * @return -1 with no message unqueued and @a errno set if:
- * - EBADF, @a fd is not a valid descriptor open for reading;
- * - EMSGSIZE, the length @a len is lesser than the message queue @a mq_msgsize
- *   attribute;
- * - EAGAIN, the queue is empty, and the flag @a O_NONBLOCK is set for the
- *   descriptor @a fd;
- * - EPERM, the caller context is invalid;
- * - EINTR, the service was interrupted by a signal;
- * - ETIMEDOUT, the specified timeout expired.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_timedreceive.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-COBALT_IMPL_TIME64(ssize_t, mq_timedreceive, __mq_timedreceive_time64,
-		   (mqd_t q, char *__restrict__ buffer, size_t len,
-		    unsigned *__restrict__ prio,
-		    const struct timespec *__restrict__ timeout))
-{
-	ssize_t rlen = (ssize_t) len;
-	int err, oldtype;
-
-	if (timeout == NULL)
-		return -EFAULT;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-	err = __do_mq_timedreceive(q, buffer, &rlen, prio, timeout);
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	if (!err)
-		return rlen;
-
-	errno = -err;
-	return -1;
-}
-
 /**
  * @brief Enable notification on message arrival
  *
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 8e70e0bb351d9fe18a68495383ed5a6a77dd5c18..46463560593a05a206e8b60b531c62ca21e209e0 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -7,11 +7,13 @@
 
 #include "cond.h"
 #include "internal.h"
+#include "mq.h"
 
 #include <asm/xenomai/syscall.h>
 #include <cobalt/uapi/syscall.h>
 
 #include <errno.h>
+#include <mqueue.h>
 #include <pthread.h>
 #include <sys/time.h>
 #include <time.h>
@@ -421,3 +423,126 @@ COBALT_IMPL_TIME64(int, pthread_cond_timedwait, __pthread_cond_timedwait64,
 
 	return -err ?: -c.err;
 }
+
+/**
+ * Attempt, during a bounded time, to send a message to a message queue.
+ * @ingroup cobalt_api_mq
+ *
+ * This service is equivalent to mq_send(), except that if the message queue is
+ * full and the flag @a O_NONBLOCK is not set for the descriptor @a fd, the
+ * calling thread is only suspended until the timeout specified by @a
+ * abs_timeout expires.
+ *
+ * @param q message queue descriptor;
+ *
+ * @param buffer pointer to the message to be sent;
+ *
+ * @param len length of the message;
+ *
+ * @param prio priority of the message;
+ *
+ * @param timeout the timeout, expressed as an absolute value of the
+ * CLOCK_REALTIME clock.
+ *
+ * @return 0 and send a message on success;
+ * @return -1 with no message sent and @a errno set if:
+ * - EBADF, @a fd is not a valid message queue descriptor open for writing;
+ * - EMSGSIZE, the message length exceeds the @a mq_msgsize attribute of the
+ *   message queue;
+ * - EAGAIN, the flag O_NONBLOCK is set for the descriptor @a fd and the message
+ *   queue is full;
+ * - EPERM, the caller context is invalid;
+ * - ETIMEDOUT, the specified timeout expired;
+ * - EINTR, the service was interrupted by a signal.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_timedsend.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+COBALT_IMPL_TIME64(int, mq_timedsend, __mq_timedsend_time64,
+		   (mqd_t q, const char *buffer, size_t len, unsigned prio,
+		    const struct timespec *timeout))
+{
+	int err, oldtype;
+
+	if (timeout == NULL)
+		return -EFAULT;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+	err = __do_mq_timesend(q, buffer, len, prio, timeout);
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	if (!err)
+		return 0;
+
+	errno = -err;
+	return -1;
+}
+
+/**
+ * Attempt, during a bounded time, to receive a message from a message queue.
+ * @ingroup cobalt_api_mq
+ *
+ * This service is equivalent to mq_receive(), except that if the flag @a
+ * O_NONBLOCK is not set for the descriptor @a fd and the message queue is
+ * empty, the calling thread is only suspended until the timeout @a abs_timeout
+ * expires.
+ *
+ * @param q the queue descriptor;
+ *
+ * @param buffer the address where the received message will be stored on
+ * success;
+ *
+ * @param len @a buffer length;
+ *
+ * @param prio address where the priority of the received message will be
+ * stored on success.
+ *
+ * @param timeout the timeout, expressed as an absolute value of the
+ * CLOCK_REALTIME clock.
+ *
+ * @return the message length, and copy a message at the address @a buffer on
+ * success;
+ * @return -1 with no message unqueued and @a errno set if:
+ * - EBADF, @a fd is not a valid descriptor open for reading;
+ * - EMSGSIZE, the length @a len is lesser than the message queue @a mq_msgsize
+ *   attribute;
+ * - EAGAIN, the queue is empty, and the flag @a O_NONBLOCK is set for the
+ *   descriptor @a fd;
+ * - EPERM, the caller context is invalid;
+ * - EINTR, the service was interrupted by a signal;
+ * - ETIMEDOUT, the specified timeout expired.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_timedreceive.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+COBALT_IMPL_TIME64(ssize_t, mq_timedreceive, __mq_timedreceive_time64,
+		   (mqd_t q, char *__restrict__ buffer, size_t len,
+		    unsigned *__restrict__ prio,
+		    const struct timespec *__restrict__ timeout))
+{
+	ssize_t rlen = (ssize_t) len;
+	int err, oldtype;
+
+	if (timeout == NULL)
+		return -EFAULT;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+	err = __do_mq_timedreceive(q, buffer, &rlen, prio, timeout);
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	if (!err)
+		return rlen;
+
+	errno = -err;
+	return -1;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 09/20] lib/cobalt: mutex: Move all time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (7 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 08/20] lib/cobalt: mq: " Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 10/20] lib/cobalt: mutex: Provide time64 variant of pthread_timedmutex_lock_interruptible_np Florian Bezdeka
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement with some minor adjustments to the doxygen headers.
All services should remain in the cobalt_api_mutex group.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/mutex.c           | 131 ++-----------------------------------------
 lib/cobalt/wrappers_time64.c | 126 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 130 insertions(+), 127 deletions(-)

diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 390305cddc94985ebed354c895783e24652c1025..edc4e46c065d2dd3695b74923f6758c512ce6909 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -16,15 +16,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
-#include <errno.h>
-#include <string.h>
-#include <pthread.h>
-#include <asm/xenomai/syscall.h>
-
 #include "current.h"
 #include "internal.h"
 #include "mutex.h"
 
+#include <asm/xenomai/syscall.h>
+
+#include <pthread.h>
+
 /**
  * @ingroup cobalt_api
  * @defgroup cobalt_api_mutex Mutual exclusion
@@ -328,128 +327,6 @@ int pthread_mutex_lock_interruptible_np(pthread_mutex_t *mutex)
 	return __pthread_mutex_lock(mutex);
 }
 
-/**
- * Attempt, during a bounded time, to lock a mutex.
- *
- * This service is equivalent to pthread_mutex_lock(), except that if the mutex
- * @a mx is locked by another thread than the current one, this service only
- * suspends the current thread until the timeout specified by @a to expires.
- *
- * @param mutex the mutex to be locked;
- *
- * @param to the timeout, expressed as an absolute value of the CLOCK_REALTIME
- * clock.
- *
- * @return 0 on success;
- * @return an error number if:
- * - EPERM, the caller is not allowed to perform the operation;
- * - EINVAL, the mutex @a mx is invalid;
- * - EPERM, the mutex is not process-shared and does not belong to the current
- *   process;
- * - ETIMEDOUT, the mutex could not be locked and the specified timeout
- *   expired;
- * - EDEADLK, the mutex is of the @a PTHREAD_MUTEX_ERRORCHECK type and the mutex
- *   was already locked by the current thread;
- * - EAGAIN, the mutex is of the @a PTHREAD_MUTEX_RECURSIVE type and the maximum
- *   number of recursive locks has been exceeded.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutex_timedlock.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-static int __pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *to)
-{
-	struct cobalt_mutex_shadow *_mutex =
-		&((union cobalt_mutex_union *)mutex)->shadow_mutex;
-	struct xnthread_user_window *u_window;
-	int status, ret, lazy_protect = 0;
-	xnhandle_t cur;
-
-	cur = cobalt_get_current();
-	if (cur == XN_NO_HANDLE)
-		return EPERM;
-
-	ret = cobalt_mutex_autoinit((union cobalt_mutex_union *)mutex);
-	if (ret)
-		return ret;
-
-	/* See __cobalt_pthread_mutex_lock() */
-	status = cobalt_get_current_mode();
-	if ((status & (XNRELAX|XNWEAK|XNDEBUG)) == 0) {
-		if (_mutex->attr.protocol == PTHREAD_PRIO_PROTECT)
-			goto protect;
-fast_path:
-		ret = xnsynch_fast_acquire(mutex_get_ownerp(_mutex), cur);
-		if (ret == 0) {
-			_mutex->lockcnt = 1;
-			return 0;
-		}
-	} else {
-slow_path:
-		ret = xnsynch_fast_owner_check(mutex_get_ownerp(_mutex), cur);
-		if (ret == 0)
-			ret = -EBUSY;
-	}
-
-	if (ret == -EBUSY) {
-		if (lazy_protect)
-			u_window->pp_pending = XN_NO_HANDLE;
-			
-		switch(_mutex->attr.type) {
-		case PTHREAD_MUTEX_NORMAL:
-			break;
-
-		case PTHREAD_MUTEX_ERRORCHECK:
-			return EDEADLK;
-
-		case PTHREAD_MUTEX_RECURSIVE:
-			if (_mutex->lockcnt == UINT32_MAX)
-				return EAGAIN;
-
-			++_mutex->lockcnt;
-			return 0;
-		}
-	}
-
-#ifdef __USE_TIME_BITS64
-	ret = XENOMAI_SYSCALL2(sc_cobalt_mutex_timedlock64, _mutex, to);
-#else
-	ret = XENOMAI_SYSCALL2(sc_cobalt_mutex_timedlock, _mutex, to);
-#endif
-
-	if (ret == 0)
-		_mutex->lockcnt = 1;
-	return -ret;
-protect:	
-	u_window = cobalt_get_current_window();
-	/*
-	 * Can't nest lazy ceiling requests, have to take the slow
-	 * path when this happens.
-	 */
-	if (u_window->pp_pending != XN_NO_HANDLE)
-		goto slow_path;
-	u_window->pp_pending = _mutex->handle;
-	lazy_protect = 1;
-	goto fast_path;
-}
-
-COBALT_IMPL_TIME64(int, pthread_mutex_timedlock, __pthread_mutex_timedlock64,
-		   (pthread_mutex_t *mutex, const struct timespec *to))
-{
-	int ret;
-	do
-		ret = __pthread_mutex_timedlock(mutex, to);
-	while (ret == EINTR);
-	return ret;
-}
-
-int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex, const struct timespec *to)
-{
-	return __pthread_mutex_timedlock(mutex, to);
-}
-
 /**
  * Attempt to lock a mutex.
  *
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 46463560593a05a206e8b60b531c62ca21e209e0..8f37e310eb19f783199681fc167883b72ebdfa1f 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -7,6 +7,7 @@
 
 #include "cond.h"
 #include "internal.h"
+#include "mutex.h"
 #include "mq.h"
 
 #include <asm/xenomai/syscall.h>
@@ -546,3 +547,128 @@ COBALT_IMPL_TIME64(ssize_t, mq_timedreceive, __mq_timedreceive_time64,
 	errno = -err;
 	return -1;
 }
+
+/**
+ * Attempt, during a bounded time, to lock a mutex.
+ * @ingroup cobalt_api_mutex
+ *
+ * This service is equivalent to pthread_mutex_lock(), except that if the mutex
+ * @a mx is locked by another thread than the current one, this service only
+ * suspends the current thread until the timeout specified by @a to expires.
+ *
+ * @param mutex the mutex to be locked;
+ *
+ * @param to the timeout, expressed as an absolute value of the CLOCK_REALTIME
+ * clock.
+ *
+ * @return 0 on success;
+ * @return an error number if:
+ * - EPERM, the caller is not allowed to perform the operation;
+ * - EINVAL, the mutex @a mx is invalid;
+ * - EPERM, the mutex is not process-shared and does not belong to the current
+ *   process;
+ * - ETIMEDOUT, the mutex could not be locked and the specified timeout
+ *   expired;
+ * - EDEADLK, the mutex is of the @a PTHREAD_MUTEX_ERRORCHECK type and the mutex
+ *   was already locked by the current thread;
+ * - EAGAIN, the mutex is of the @a PTHREAD_MUTEX_RECURSIVE type and the maximum
+ *   number of recursive locks has been exceeded.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutex_timedlock.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+static int __pthread_mutex_timedlock(pthread_mutex_t *mutex,
+				     const struct timespec *to)
+{
+	struct cobalt_mutex_shadow *_mutex =
+		&((union cobalt_mutex_union *)mutex)->shadow_mutex;
+	struct xnthread_user_window *u_window;
+	int status, ret, lazy_protect = 0;
+	xnhandle_t cur;
+
+	cur = cobalt_get_current();
+	if (cur == XN_NO_HANDLE)
+		return EPERM;
+
+	ret = cobalt_mutex_autoinit((union cobalt_mutex_union *)mutex);
+	if (ret)
+		return ret;
+
+	/* See __cobalt_pthread_mutex_lock() */
+	status = cobalt_get_current_mode();
+	if ((status & (XNRELAX | XNWEAK | XNDEBUG)) == 0) {
+		if (_mutex->attr.protocol == PTHREAD_PRIO_PROTECT)
+			goto protect;
+	fast_path:
+		ret = xnsynch_fast_acquire(mutex_get_ownerp(_mutex), cur);
+		if (ret == 0) {
+			_mutex->lockcnt = 1;
+			return 0;
+		}
+	} else {
+	slow_path:
+		ret = xnsynch_fast_owner_check(mutex_get_ownerp(_mutex), cur);
+		if (ret == 0)
+			ret = -EBUSY;
+	}
+
+	if (ret == -EBUSY) {
+		if (lazy_protect)
+			u_window->pp_pending = XN_NO_HANDLE;
+
+		switch (_mutex->attr.type) {
+		case PTHREAD_MUTEX_NORMAL:
+			break;
+
+		case PTHREAD_MUTEX_ERRORCHECK:
+			return EDEADLK;
+
+		case PTHREAD_MUTEX_RECURSIVE:
+			if (_mutex->lockcnt == UINT32_MAX)
+				return EAGAIN;
+
+			++_mutex->lockcnt;
+			return 0;
+		}
+	}
+
+#ifdef __USE_TIME_BITS64
+	ret = XENOMAI_SYSCALL2(sc_cobalt_mutex_timedlock64, _mutex, to);
+#else
+	ret = XENOMAI_SYSCALL2(sc_cobalt_mutex_timedlock, _mutex, to);
+#endif
+
+	if (ret == 0)
+		_mutex->lockcnt = 1;
+	return -ret;
+protect:
+	u_window = cobalt_get_current_window();
+	/*
+	 * Can't nest lazy ceiling requests, have to take the slow
+	 * path when this happens.
+	 */
+	if (u_window->pp_pending != XN_NO_HANDLE)
+		goto slow_path;
+	u_window->pp_pending = _mutex->handle;
+	lazy_protect = 1;
+	goto fast_path;
+}
+
+COBALT_IMPL_TIME64(int, pthread_mutex_timedlock, __pthread_mutex_timedlock64,
+		   (pthread_mutex_t * mutex, const struct timespec *to))
+{
+	int ret;
+	do
+		ret = __pthread_mutex_timedlock(mutex, to);
+	while (ret == EINTR);
+	return ret;
+}
+
+int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex,
+					     const struct timespec *to)
+{
+	return __pthread_mutex_timedlock(mutex, to);
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 10/20] lib/cobalt: mutex: Provide time64 variant of pthread_timedmutex_lock_interruptible_np
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (8 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 09/20] lib/cobalt: mutex: " Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 11/20] lib/cobalt: rtdm: Move all time64 related services to wrappers_time64.c Florian Bezdeka
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

That service / function was forgotten when introducing the time64_t
services. This is a non-posix / non portable (np) mutex function, so
not marked with COBALT_{IMPL,DECL}_TIME64() as no wrapping is taking
place.

Provide a time64_t variant in case time64_t support has been requested.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/pthread.h     | 16 +++++++++++++++-
 lib/cobalt/wrappers_time64.c |  8 ++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index fed7dd2d8ecee155cd58d2d07cbd6077b6c7612a..b6a6d7a58b0fb44abcdb11e9666b78a9e6b48667 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -173,7 +173,21 @@ int pthread_attr_setpersonality_ex(pthread_attr_ex_t *attr_ex,
 
 int pthread_mutex_lock_interruptible_np(pthread_mutex_t *mutex);
 
-int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex, const struct timespec *to);
+int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex,
+					     const struct timespec *to);
+
+#if __USE_TIME_BITS64 && __TIMESIZE == 32
+int pthread_timedmutex_lock_interruptible_np_time64(pthread_mutex_t *mutex,
+						    const struct timespec *to);
+#ifdef __REDIRECT
+int __REDIRECT(pthread_timedmutex_lock_interruptible_np,
+	       (pthread_mutex_t * mutex, const struct timespec *to),
+	       pthread_timedmutex_lock_interruptible_np_time64);
+#else
+#define pthread_timedmutex_lock_interruptible_np                               \
+	pthread_timedmutex_lock_interruptible_np_time64
+#endif
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 8f37e310eb19f783199681fc167883b72ebdfa1f..fbd644bef485b4ec9d319373ffa702bc1927a75d 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -667,8 +667,16 @@ COBALT_IMPL_TIME64(int, pthread_mutex_timedlock, __pthread_mutex_timedlock64,
 	return ret;
 }
 
+#if __USE_TIME_BITS64 && __TIMESIZE == 32
+int pthread_timedmutex_lock_interruptible_np_time64(pthread_mutex_t *mutex,
+						    const struct timespec *to)
+{
+	return __pthread_mutex_timedlock(mutex, to);
+}
+#else
 int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex,
 					     const struct timespec *to)
 {
 	return __pthread_mutex_timedlock(mutex, to);
 }
+#endif

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 11/20] lib/cobalt: rtdm: Move all time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (9 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 10/20] lib/cobalt: mutex: Provide time64 variant of pthread_timedmutex_lock_interruptible_np Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c Florian Bezdeka
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement only.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/rtdm.c            | 71 ------------------------------------------
 lib/cobalt/wrappers_time64.c | 74 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 71 deletions(-)

diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c
index ec950e15db921b32458d746d300ff6c542a8b23b..df7aa7eb69904f0953be2d324f29d60913916a4a 100644
--- a/lib/cobalt/rtdm.c
+++ b/lib/cobalt/rtdm.c
@@ -169,24 +169,6 @@ COBALT_IMPL(int, fcntl, (int fd, int cmd, ...))
 	return __STD(fcntl(fd, cmd, arg));
 }
 
-COBALT_IMPL_TIME64(int, ioctl, __ioctl_time64,
-		   (int fd, unsigned int request, ...))
-{
-	va_list ap;
-	void *arg;
-	int ret;
-
-	va_start(ap, request);
-	arg = va_arg(ap, void *);
-	va_end(ap);
-
-	ret = do_ioctl(fd, request, arg);
-	if (ret != -EADV && ret != -ENOSYS)
-		return set_errno(ret);
-
-	return __STD(ioctl(fd, request, arg));
-}
-
 COBALT_IMPL(ssize_t, read, (int fd, void *buf, size_t nbyte))
 {
 	int ret, oldtype;
@@ -243,29 +225,6 @@ COBALT_IMPL(ssize_t, recvmsg, (int fd, struct msghdr *msg, int flags))
 	return __STD(recvmsg(fd, msg, flags));
 }
 
-COBALT_IMPL_TIME64(int, recvmmsg, __recvmmsg64,
-		   (int fd, struct mmsghdr *msgvec, unsigned int vlen,
-		    unsigned int flags, struct timespec *timeout))
-{
-	int ret, oldtype;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-#ifdef __USE_TIME_BITS64
-	ret = XENOMAI_SYSCALL5(sc_cobalt_recvmmsg64, fd, msgvec,
-				vlen, flags, timeout);
-#else
-	ret = XENOMAI_SYSCALL5(sc_cobalt_recvmmsg, fd, msgvec, vlen, flags, timeout);
-#endif
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	if (ret != -EADV && ret != -ENOSYS)
-		return set_errno(ret);
-
-	return __STD(recvmmsg(fd, msgvec, vlen, flags, timeout));
-}
-
 static ssize_t do_sendmsg(int fd, const struct msghdr *msg, int flags)
 {
 	int ret, oldtype;
@@ -408,36 +367,6 @@ COBALT_IMPL(ssize_t, send, (int fd, const void *buf, size_t len, int flags))
 	return __STD(send(fd, buf, len, flags));
 }
 
-COBALT_IMPL_TIME64(int, getsockopt, __getsockopt64,
-		   (int fd, int level, int optname, void *optval,
-		    socklen_t *optlen))
-{
-	struct _rtdm_getsockopt_args args = { level, optname, optval, optlen };
-	int ret;
-
-	ret = do_ioctl(fd, _RTIOC_GETSOCKOPT, &args);
-	if (ret != -EADV && ret != -ENOSYS)
-		return set_errno(ret);
-
-	return __STD(getsockopt(fd, level, optname, optval, optlen));
-}
-
-COBALT_IMPL_TIME64(int, setsockopt, __setsockopt64,
-		   (int fd, int level, int optname, const void *optval,
-		    socklen_t optlen))
-{
-	struct _rtdm_setsockopt_args args = {
-		level, optname, (void *)optval, optlen
-	};
-	int ret;
-
-	ret = do_ioctl(fd, _RTIOC_SETSOCKOPT, &args);
-	if (ret != -EADV && ret != -ENOSYS)
-		return set_errno(ret);
-
-	return __STD(setsockopt(fd, level, optname, optval, optlen));
-}
-
 COBALT_IMPL(int, bind, (int fd, const struct sockaddr *my_addr, socklen_t addrlen))
 {
 	struct _rtdm_setsockaddr_args args = { my_addr, addrlen };
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index fbd644bef485b4ec9d319373ffa702bc1927a75d..ded0232824fade9b2f656c03ac3e5515fb5f8b38 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -9,13 +9,16 @@
 #include "internal.h"
 #include "mutex.h"
 #include "mq.h"
+#include "rtdm.h"
 
 #include <asm/xenomai/syscall.h>
 #include <cobalt/uapi/syscall.h>
+#include <rtdm/rtdm.h>
 
 #include <errno.h>
 #include <mqueue.h>
 #include <pthread.h>
+#include <sys/socket.h>
 #include <sys/time.h>
 #include <time.h>
 
@@ -680,3 +683,74 @@ int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex,
 	return __pthread_mutex_timedlock(mutex, to);
 }
 #endif
+
+COBALT_IMPL_TIME64(int, ioctl, __ioctl_time64,
+		   (int fd, unsigned int request, ...))
+{
+	va_list ap;
+	void *arg;
+	int ret;
+
+	va_start(ap, request);
+	arg = va_arg(ap, void *);
+	va_end(ap);
+
+	ret = do_ioctl(fd, request, arg);
+	if (ret != -EADV && ret != -ENOSYS)
+		return set_errno(ret);
+
+	return __STD(ioctl(fd, request, arg));
+}
+
+COBALT_IMPL_TIME64(int, recvmmsg, __recvmmsg64,
+		   (int fd, struct mmsghdr *msgvec, unsigned int vlen,
+		    unsigned int flags, struct timespec *timeout))
+{
+	int ret, oldtype;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+#ifdef __USE_TIME_BITS64
+	ret = XENOMAI_SYSCALL5(sc_cobalt_recvmmsg64, fd, msgvec, vlen, flags,
+			       timeout);
+#else
+	ret = XENOMAI_SYSCALL5(sc_cobalt_recvmmsg, fd, msgvec, vlen, flags,
+			       timeout);
+#endif
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	if (ret != -EADV && ret != -ENOSYS)
+		return set_errno(ret);
+
+	return __STD(recvmmsg(fd, msgvec, vlen, flags, timeout));
+}
+
+COBALT_IMPL_TIME64(int, getsockopt, __getsockopt64,
+		   (int fd, int level, int optname, void *optval,
+		    socklen_t *optlen))
+{
+	struct _rtdm_getsockopt_args args = { level, optname, optval, optlen };
+	int ret;
+
+	ret = do_ioctl(fd, _RTIOC_GETSOCKOPT, &args);
+	if (ret != -EADV && ret != -ENOSYS)
+		return set_errno(ret);
+
+	return __STD(getsockopt(fd, level, optname, optval, optlen));
+}
+
+COBALT_IMPL_TIME64(int, setsockopt, __setsockopt64,
+		   (int fd, int level, int optname, const void *optval,
+		    socklen_t optlen))
+{
+	struct _rtdm_setsockopt_args args = { level, optname, (void *)optval,
+					      optlen };
+	int ret;
+
+	ret = do_ioctl(fd, _RTIOC_SETSOCKOPT, &args);
+	if (ret != -EADV && ret != -ENOSYS)
+		return set_errno(ret);
+
+	return __STD(setsockopt(fd, level, optname, optval, optlen));
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (10 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 11/20] lib/cobalt: rtdm: Move all time64 related services to wrappers_time64.c Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20 14:38   ` Jan Kiszka
  2026-02-20  9:08 ` [PATCH 13/20] lib/cobalt: semaphore: Move time64 related services to wrappers_time64.c Florian Bezdeka
                   ` (8 subsequent siblings)
  20 siblings, 1 reply; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

select.c is no longer needed as everything inside is time64_t affected.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/Makefile.am       |   1 -
 lib/cobalt/select.c          | 108 -------------------------------------------
 lib/cobalt/wrappers_time64.c |  86 ++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 109 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 17e203f9015fe2bb5306609e4d51c62f3a725780..c31f030117dfc3ddf5ae386897fbc8a2435912a8 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -33,7 +33,6 @@ libcobalt_la_SOURCES =		\
 	printf.c		\
 	rtdm.c			\
 	sched.c			\
-	select.c		\
 	semaphore.c		\
 	signal.c		\
 	sigshadow.c		\
diff --git a/lib/cobalt/select.c b/lib/cobalt/select.c
deleted file mode 100644
index 5472e991e126c2f521b346a7cf3c884bbf6f6317..0000000000000000000000000000000000000000
--- a/lib/cobalt/select.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <sys/select.h>
-#include <asm/xenomai/syscall.h>
-
-#if __USE_TIME_BITS64 && __TIMESIZE == 32
-
-#define USEC_PER_SEC	1000000L
-#define NSEC_PER_USEC	1000L
-
-/*
- * The time64 wrapper for select() is a little different:
- * There is no y2038 safe syscall for select() itself, but we have pselect()
- * without signal support.
- */
-static inline int do_select(int __nfds, fd_set *__restrict __readfds,
-			      fd_set *__restrict __writefds,
-			      fd_set *__restrict __exceptfds,
-			      struct timeval *__restrict __timeout)
-{
-	struct timespec to;
-	int err, oldtype;
-
-	if (__timeout) {
-		to.tv_sec =
-			__timeout->tv_sec + (__timeout->tv_usec / USEC_PER_SEC);
-		to.tv_nsec =
-			(__timeout->tv_usec % USEC_PER_SEC) * NSEC_PER_USEC;
-	}
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-	/*
-	 * Note: No sigmask here, we already reached the limit of 5
-	 * syscall parameters
-	 */
-	err = XENOMAI_SYSCALL5(sc_cobalt_pselect64, __nfds, __readfds,
-			       __writefds, __exceptfds, __timeout ? &to : NULL);
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	if (err == -EADV || err == -EPERM || err == -ENOSYS) {
-		err = __STD(__select64(__nfds, __readfds, __writefds,
-				       __exceptfds, __timeout));
-	} else if (__timeout) {
-		__timeout->tv_sec = to.tv_sec;
-		__timeout->tv_usec = to.tv_nsec / 1000;
-	}
-
-	if (err >= 0)
-		return err;
-
-	errno = -err;
-	return -1;
-}
-#else
-static inline int do_select(int __nfds, fd_set *__restrict __readfds,
-			    fd_set *__restrict __writefds,
-			    fd_set *__restrict __exceptfds,
-			    struct timeval *__restrict __timeout)
-{
-	int err, oldtype;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-	err = XENOMAI_SYSCALL5(sc_cobalt_select, __nfds,
-			       __readfds, __writefds, __exceptfds, __timeout);
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	if (err == -EADV || err == -EPERM || err == -ENOSYS)
-		return __STD(select(__nfds, __readfds,
-				    __writefds, __exceptfds, __timeout));
-
-	if (err >= 0)
-		return err;
-
-	errno = -err;
-	return -1;
-}
-#endif
-
-COBALT_IMPL_TIME64(int, select, __select64,
-		   (int __nfds, fd_set *__restrict __readfds,
-		    fd_set *__restrict __writefds,
-		    fd_set *__restrict __exceptfds,
-		    struct timeval *__restrict __timeout))
-{
-	return do_select(__nfds, __readfds, __writefds, __exceptfds, __timeout);
-}
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index ded0232824fade9b2f656c03ac3e5515fb5f8b38..7b634976eb07d7ae143b4567983dbea7f4ddebea 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -754,3 +754,89 @@ COBALT_IMPL_TIME64(int, setsockopt, __setsockopt64,
 
 	return __STD(setsockopt(fd, level, optname, optval, optlen));
 }
+
+#if __USE_TIME_BITS64 && __TIMESIZE == 32
+
+#define USEC_PER_SEC	1000000L
+#define NSEC_PER_USEC	1000L
+
+/*
+ * The time64 wrapper for select() is a little different:
+ * There is no y2038 safe syscall for select() itself, but we have pselect()
+ * without signal support.
+ */
+static inline int do_select(int __nfds, fd_set *__restrict __readfds,
+			      fd_set *__restrict __writefds,
+			      fd_set *__restrict __exceptfds,
+			      struct timeval *__restrict __timeout)
+{
+	struct timespec to;
+	int err, oldtype;
+
+	if (__timeout) {
+		to.tv_sec =
+			__timeout->tv_sec + (__timeout->tv_usec / USEC_PER_SEC);
+		to.tv_nsec =
+			(__timeout->tv_usec % USEC_PER_SEC) * NSEC_PER_USEC;
+	}
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+	/*
+	 * Note: No sigmask here, we already reached the limit of 5
+	 * syscall parameters
+	 */
+	err = XENOMAI_SYSCALL5(sc_cobalt_pselect64, __nfds, __readfds,
+			       __writefds, __exceptfds, __timeout ? &to : NULL);
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	if (err == -EADV || err == -EPERM || err == -ENOSYS) {
+		err = __STD(__select64(__nfds, __readfds, __writefds,
+				       __exceptfds, __timeout));
+	} else if (__timeout) {
+		__timeout->tv_sec = to.tv_sec;
+		__timeout->tv_usec = to.tv_nsec / 1000;
+	}
+
+	if (err >= 0)
+		return err;
+
+	errno = -err;
+	return -1;
+}
+#else
+static inline int do_select(int __nfds, fd_set *__restrict __readfds,
+			    fd_set *__restrict __writefds,
+			    fd_set *__restrict __exceptfds,
+			    struct timeval *__restrict __timeout)
+{
+	int err, oldtype;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+	err = XENOMAI_SYSCALL5(sc_cobalt_select, __nfds,
+			       __readfds, __writefds, __exceptfds, __timeout);
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	if (err == -EADV || err == -EPERM || err == -ENOSYS)
+		return __STD(select(__nfds, __readfds,
+				    __writefds, __exceptfds, __timeout));
+
+	if (err >= 0)
+		return err;
+
+	errno = -err;
+	return -1;
+}
+#endif
+
+COBALT_IMPL_TIME64(int, select, __select64,
+		   (int __nfds, fd_set *__restrict __readfds,
+		    fd_set *__restrict __writefds,
+		    fd_set *__restrict __exceptfds,
+		    struct timeval *__restrict __timeout))
+{
+	return do_select(__nfds, __readfds, __writefds, __exceptfds, __timeout);
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 13/20] lib/cobalt: semaphore: Move time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (11 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 14/20] lib/cobalt: signal: " Florian Bezdeka
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement with some minor adjustments to the doxygen headers.
All services should remain in the cobalt_api_sem group.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/semaphore.c       | 67 +++-----------------------------------------
 lib/cobalt/wrappers_time64.c | 62 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/lib/cobalt/semaphore.c b/lib/cobalt/semaphore.c
index 0c1a245cd40f7e2b0e0c883f317a3bbccde5187d..1fe3581df1cb30748ed780e57cd212827dd0f4c9 100644
--- a/lib/cobalt/semaphore.c
+++ b/lib/cobalt/semaphore.c
@@ -16,14 +16,16 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
+#include "internal.h"
+
+#include <asm/xenomai/syscall.h>
+
 #include <stdlib.h>		/* For malloc & free. */
 #include <stdarg.h>
 #include <errno.h>
 #include <fcntl.h>		/* For O_CREAT. */
 #include <pthread.h>		/* For pthread_setcanceltype. */
 #include <semaphore.h>
-#include <asm/xenomai/syscall.h>
-#include "internal.h"
 
 /**
  * @ingroup cobalt_api
@@ -329,67 +331,6 @@ COBALT_IMPL(int, sem_wait, (sem_t *sem))
 	return 0;
 }
 
-/**
- * @fn int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
- * @brief Attempt to decrement a semaphore with a time limit
- *
- * This service is equivalent to sem_wait(), except that the caller is only
- * blocked until the timeout @a abs_timeout expires.
- *
- * @param sem the semaphore to be decremented;
- *
- * @param abs_timeout the timeout, expressed as an absolute value of
- * the relevant clock for the semaphore, either CLOCK_MONOTONIC if
- * SEM_RAWCLOCK was mentioned via sem_init_np(), or CLOCK_REALTIME
- * otherwise.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EPERM, the caller context is invalid;
- * - EINVAL, the semaphore is invalid or uninitialized;
- * - EINVAL, the specified timeout is invalid;
- * - EPERM, the semaphore @a sm is not process-shared and does not belong to the
- *   current process;
- * - EINTR, the caller was interrupted by a signal while blocked in this
- *   service;
- * - ETIMEDOUT, the semaphore could not be decremented and the
- *   specified timeout expired.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/sem_timedwait.html">
- * Specification.</a>
- *
- * @apitags{xthread-only, switch-primary}
- */
-COBALT_IMPL_TIME64(int, sem_timedwait, __sem_timedwait64,
-		   (sem_t *sem, const struct timespec *abs_timeout))
-{
-	struct cobalt_sem_shadow *_sem = &((union cobalt_sem_union *)sem)->shadow_sem;
-	int ret, oldtype;
-
-	ret = __RT(sem_trywait(sem));
-	if (ret != -1 || errno != EAGAIN)
-		return ret;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-#ifdef __USE_TIME_BITS64
-	ret = XENOMAI_SYSCALL2(sc_cobalt_sem_timedwait64, _sem,
-			       abs_timeout);
-#else
-	ret = XENOMAI_SYSCALL2(sc_cobalt_sem_timedwait, _sem, abs_timeout);
-#endif
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	if (ret) {
-		errno = -ret;
-		return -1;
-	}
-
-	return 0;
-}
-
 /**
  * @fn int sem_getvalue(sem_t sem, int *sval_r)
  * @brief Get the value of a semaphore.
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 7b634976eb07d7ae143b4567983dbea7f4ddebea..1a4a3c463543e078e43eddd9ccd056ad10f69e97 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -840,3 +840,65 @@ COBALT_IMPL_TIME64(int, select, __select64,
 {
 	return do_select(__nfds, __readfds, __writefds, __exceptfds, __timeout);
 }
+
+/**
+ * @fn int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
+ * @brief Attempt to decrement a semaphore with a time limit
+ * @ingroup cobalt_api_sem
+ *
+ * This service is equivalent to sem_wait(), except that the caller is only
+ * blocked until the timeout @a abs_timeout expires.
+ *
+ * @param sem the semaphore to be decremented;
+ *
+ * @param abs_timeout the timeout, expressed as an absolute value of
+ * the relevant clock for the semaphore, either CLOCK_MONOTONIC if
+ * SEM_RAWCLOCK was mentioned via sem_init_np(), or CLOCK_REALTIME
+ * otherwise.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EPERM, the caller context is invalid;
+ * - EINVAL, the semaphore is invalid or uninitialized;
+ * - EINVAL, the specified timeout is invalid;
+ * - EPERM, the semaphore @a sm is not process-shared and does not belong to the
+ *   current process;
+ * - EINTR, the caller was interrupted by a signal while blocked in this
+ *   service;
+ * - ETIMEDOUT, the semaphore could not be decremented and the
+ *   specified timeout expired.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/sem_timedwait.html">
+ * Specification.</a>
+ *
+ * @apitags{xthread-only, switch-primary}
+ */
+COBALT_IMPL_TIME64(int, sem_timedwait, __sem_timedwait64,
+		   (sem_t *sem, const struct timespec *abs_timeout))
+{
+	struct cobalt_sem_shadow *_sem =
+		&((union cobalt_sem_union *)sem)->shadow_sem;
+	int ret, oldtype;
+
+	ret = __RT(sem_trywait(sem));
+	if (ret != -1 || errno != EAGAIN)
+		return ret;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+#ifdef __USE_TIME_BITS64
+	ret = XENOMAI_SYSCALL2(sc_cobalt_sem_timedwait64, _sem, abs_timeout);
+#else
+	ret = XENOMAI_SYSCALL2(sc_cobalt_sem_timedwait, _sem, abs_timeout);
+#endif
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	if (ret) {
+		errno = -ret;
+		return -1;
+	}
+
+	return 0;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 14/20] lib/cobalt: signal: Move time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (12 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 13/20] lib/cobalt: semaphore: Move time64 related services to wrappers_time64.c Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 15/20] lib/cobalt: timer: Move all " Florian Bezdeka
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement only.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/signal.c          | 26 ++------------------------
 lib/cobalt/wrappers_time64.c | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/lib/cobalt/signal.c b/lib/cobalt/signal.c
index 6e40a36803190ad05b7b4a1ce4fab9108b59c56d..b5c0865e95eb571f3bbf67ce29ffc73b9ddf11ef 100644
--- a/lib/cobalt/signal.c
+++ b/lib/cobalt/signal.c
@@ -16,12 +16,13 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
+#include <asm/xenomai/syscall.h>
+
 #include <stdlib.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <pthread.h>
 #include <signal.h>
-#include <asm/xenomai/syscall.h>
 
 COBALT_IMPL(int, sigwait, (const sigset_t *set, int *sig))
 {
@@ -53,29 +54,6 @@ COBALT_IMPL(int, sigwaitinfo, (const sigset_t *set, siginfo_t *si))
 	return ret;
 }
 
-COBALT_IMPL_TIME64(int, sigtimedwait, __sigtimedwait64,
-		   (const sigset_t *set, siginfo_t *si,
-		    const struct timespec *timeout))
-{
-	int ret, oldtype;
-
-	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-#ifdef __USE_TIME_BITS64
-	ret = XENOMAI_SYSCALL3(sc_cobalt_sigtimedwait64, set, si, timeout);
-#else
-	ret = XENOMAI_SYSCALL3(sc_cobalt_sigtimedwait, set, si, timeout);
-#endif
-	if (ret < 0) {
-		errno = -ret;
-		ret = -1;
-	}
-
-	pthread_setcanceltype(oldtype, NULL);
-
-	return ret;
-}
-
 COBALT_IMPL(int, sigpending, (sigset_t *set))
 {
 	int ret;
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 1a4a3c463543e078e43eddd9ccd056ad10f69e97..5219802c408cecde50d4088a8cd692d4354346ab 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -902,3 +902,26 @@ COBALT_IMPL_TIME64(int, sem_timedwait, __sem_timedwait64,
 
 	return 0;
 }
+
+COBALT_IMPL_TIME64(int, sigtimedwait, __sigtimedwait64,
+		   (const sigset_t *set, siginfo_t *si,
+		    const struct timespec *timeout))
+{
+	int ret, oldtype;
+
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+#ifdef __USE_TIME_BITS64
+	ret = XENOMAI_SYSCALL3(sc_cobalt_sigtimedwait64, set, si, timeout);
+#else
+	ret = XENOMAI_SYSCALL3(sc_cobalt_sigtimedwait, set, si, timeout);
+#endif
+	if (ret < 0) {
+		errno = -ret;
+		ret = -1;
+	}
+
+	pthread_setcanceltype(oldtype, NULL);
+
+	return ret;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 15/20] lib/cobalt: timer: Move all time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (13 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 14/20] lib/cobalt: signal: " Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:08 ` [PATCH 16/20] lib/cobalt: timerfd: Move " Florian Bezdeka
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement with some minor adjustments to the doxygen headers.
All services should remain in the cobalt_api_time group.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/timer.c           | 121 ++-----------------------------------------
 lib/cobalt/wrappers_time64.c | 118 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 117 deletions(-)

diff --git a/lib/cobalt/timer.c b/lib/cobalt/timer.c
index a9f91dfc99cc81373ac176c65685f14a545a46c9..0294953f8e69b63e55fe06fe4f7bbbd2b72a1e8d 100644
--- a/lib/cobalt/timer.c
+++ b/lib/cobalt/timer.c
@@ -16,10 +16,12 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
+#include "internal.h"
+
+#include <asm/xenomai/syscall.h>
+
 #include <errno.h>
 #include <time.h>
-#include <asm/xenomai/syscall.h>
-#include "internal.h"
 
 /**
  * @addtogroup cobalt_api_time
@@ -116,121 +118,6 @@ COBALT_IMPL(int, timer_delete, (timer_t timerid))
 	return -1;
 }
 
-/**
- * @fn timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict__ value, struct itimerspec *__restrict__ ovalue)
- * @brief Start or stop a timer
- *
- * This service sets a timer expiration date and reload value of the
- * timer @a timerid. If @a ovalue is not @a NULL, the current
- * expiration date and reload value are stored at the address @a
- * ovalue as with timer_gettime().
- *
- * If the member @a it_value of the @b itimerspec structure at @a
- * value is zero, the timer is stopped, otherwise the timer is
- * started. If the member @a it_interval is not zero, the timer is
- * periodic. The current thread must be a Cobalt thread (created with
- * pthread_create()) and will be notified via signal of timer
- * expirations.
- *
- * When starting the timer, if @a flags is TIMER_ABSTIME, the expiration value
- * is interpreted as an absolute date of the clock passed to the timer_create()
- * service. Otherwise, the expiration value is interpreted as a time interval.
- *
- * Expiration date and reload value are rounded to an integer count of
- * nanoseconds.
- *
- * @param timerid identifier of the timer to be started or stopped;
- *
- * @param flags one of 0 or TIMER_ABSTIME;
- *
- * @param value address where the specified timer expiration date and reload
- * value are read;
- *
- * @param ovalue address where the specified timer previous expiration date and
- * reload value are stored if not @a NULL.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EINVAL, the specified timer identifier, expiration date or reload value is
- *   invalid. For @a timerid to be valid, it must belong to the current process.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/timer_settime.html">
- * Specification.</a>
- *
- * @apitags{xcontext, switch-primary}
- */
-COBALT_IMPL_TIME64(int, timer_settime, __timer_settime64,
-		   (timer_t timerid, int flags,
-		    const struct itimerspec *__restrict__ value,
-		    struct itimerspec *__restrict__ ovalue))
-{
-	int ret;
-
-#ifdef XN_USE_TIME64_SYSCALL
-	long sc_nr = sc_cobalt_timer_settime64;
-#else
-	long sc_nr = sc_cobalt_timer_settime;
-#endif
-
-	ret = -XENOMAI_SYSCALL4(sc_nr, timerid, flags, value, ovalue);
-	if (ret == 0)
-		return 0;
-
-	errno = ret;
-
-	return -1;
-}
-
-/**
- * @fn int timer_gettime(timer_t timerid, struct itimerspec *value)
- * @brief Get timer next expiration date and reload value.
- *
- * This service stores, at the address @a value, the expiration date
- * (member @a it_value) and reload value (member @a it_interval) of
- * the timer @a timerid. The values are returned as time intervals,
- * and as multiples of the system clock tick duration (see note in
- * section @ref cobalt_api_time "Clocks and timers services" for details
- * on the duration of the system clock tick). If the timer was not
- * started, the returned members @a it_value and @a it_interval of @a
- * value are zero.
- *
- * @param timerid timer identifier;
- *
- * @param value address where the timer expiration date and reload value are
- * stored on success.
- *
- * @retval 0 on success;
- * @retval -1 with @a errno set if:
- * - EINVAL, @a timerid is invalid. For @a timerid to be valid, it
- * must belong to the current process.
- *
- * @see
- * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/timer_gettime.html">
- * Specification.</a>
- *
- * @apitags{unrestricted}
- */
-COBALT_IMPL_TIME64(int, timer_gettime, __timer_gettime64,
-		   (timer_t timerid, struct itimerspec *value))
-{
-	int ret;
-
-#ifdef XN_USE_TIME64_SYSCALL
-	long sc_nr = sc_cobalt_timer_gettime64;
-#else
-	long sc_nr = sc_cobalt_timer_gettime;
-#endif
-
-	ret = -XENOMAI_SYSCALL2(sc_nr, timerid, value);
-	if (ret == 0)
-		return 0;
-
-	errno = ret;
-
-	return -1;
-}
-
 /**
  * Get expiration overruns count since the most recent timer expiration
  * signal delivery.
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index 5219802c408cecde50d4088a8cd692d4354346ab..b4714f22ce3d632cf11456838854df9093b83902 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -925,3 +925,121 @@ COBALT_IMPL_TIME64(int, sigtimedwait, __sigtimedwait64,
 
 	return ret;
 }
+
+/**
+ * @fn timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict__ value, struct itimerspec *__restrict__ ovalue)
+ * @brief Start or stop a timer
+ * @ingroup cobalt_api_time
+ *
+ * This service sets a timer expiration date and reload value of the
+ * timer @a timerid. If @a ovalue is not @a NULL, the current
+ * expiration date and reload value are stored at the address @a
+ * ovalue as with timer_gettime().
+ *
+ * If the member @a it_value of the @b itimerspec structure at @a
+ * value is zero, the timer is stopped, otherwise the timer is
+ * started. If the member @a it_interval is not zero, the timer is
+ * periodic. The current thread must be a Cobalt thread (created with
+ * pthread_create()) and will be notified via signal of timer
+ * expirations.
+ *
+ * When starting the timer, if @a flags is TIMER_ABSTIME, the expiration value
+ * is interpreted as an absolute date of the clock passed to the timer_create()
+ * service. Otherwise, the expiration value is interpreted as a time interval.
+ *
+ * Expiration date and reload value are rounded to an integer count of
+ * nanoseconds.
+ *
+ * @param timerid identifier of the timer to be started or stopped;
+ *
+ * @param flags one of 0 or TIMER_ABSTIME;
+ *
+ * @param value address where the specified timer expiration date and reload
+ * value are read;
+ *
+ * @param ovalue address where the specified timer previous expiration date and
+ * reload value are stored if not @a NULL.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, the specified timer identifier, expiration date or reload value is
+ *   invalid. For @a timerid to be valid, it must belong to the current process.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/timer_settime.html">
+ * Specification.</a>
+ *
+ * @apitags{xcontext, switch-primary}
+ */
+COBALT_IMPL_TIME64(int, timer_settime, __timer_settime64,
+		   (timer_t timerid, int flags,
+		    const struct itimerspec *__restrict__ value,
+		    struct itimerspec *__restrict__ ovalue))
+{
+	int ret;
+
+#ifdef XN_USE_TIME64_SYSCALL
+	long sc_nr = sc_cobalt_timer_settime64;
+#else
+	long sc_nr = sc_cobalt_timer_settime;
+#endif
+
+	ret = -XENOMAI_SYSCALL4(sc_nr, timerid, flags, value, ovalue);
+	if (ret == 0)
+		return 0;
+
+	errno = ret;
+
+	return -1;
+}
+
+
+/**
+ * @fn int timer_gettime(timer_t timerid, struct itimerspec *value)
+ * @brief Get timer next expiration date and reload value.
+ * @ingroup cobalt_api_time
+ *
+ * This service stores, at the address @a value, the expiration date
+ * (member @a it_value) and reload value (member @a it_interval) of
+ * the timer @a timerid. The values are returned as time intervals,
+ * and as multiples of the system clock tick duration (see note in
+ * section @ref cobalt_api_time "Clocks and timers services" for details
+ * on the duration of the system clock tick). If the timer was not
+ * started, the returned members @a it_value and @a it_interval of @a
+ * value are zero.
+ *
+ * @param timerid timer identifier;
+ *
+ * @param value address where the timer expiration date and reload value are
+ * stored on success.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a timerid is invalid. For @a timerid to be valid, it
+ * must belong to the current process.
+ *
+ * @see
+ * <a href="http://www.opengroup.org/onlinepubs/000095399/functions/timer_gettime.html">
+ * Specification.</a>
+ *
+ * @apitags{unrestricted}
+ */
+COBALT_IMPL_TIME64(int, timer_gettime, __timer_gettime64,
+		   (timer_t timerid, struct itimerspec *value))
+{
+	int ret;
+
+#ifdef XN_USE_TIME64_SYSCALL
+	long sc_nr = sc_cobalt_timer_gettime64;
+#else
+	long sc_nr = sc_cobalt_timer_gettime;
+#endif
+
+	ret = -XENOMAI_SYSCALL2(sc_nr, timerid, value);
+	if (ret == 0)
+		return 0;
+
+	errno = ret;
+
+	return -1;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 16/20] lib/cobalt: timerfd: Move time64 related services to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (14 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 15/20] lib/cobalt: timer: Move all " Florian Bezdeka
@ 2026-02-20  9:08 ` Florian Bezdeka
  2026-02-20  9:09 ` [PATCH 17/20] lib/cobalt: Move XN_USE_TIME64_SYSCALL " Florian Bezdeka
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:08 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Code movement only.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/timerfd.c         | 39 ---------------------------------------
 lib/cobalt/wrappers_time64.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/lib/cobalt/timerfd.c b/lib/cobalt/timerfd.c
index 70e9a4e0743d503bb4b57d17ed7c77713bebf946..5fa1f1eaa3902293c81600431fb2d97557c671d2 100644
--- a/lib/cobalt/timerfd.c
+++ b/lib/cobalt/timerfd.c
@@ -17,7 +17,6 @@
  */
 
 #include <errno.h>
-#include <unistd.h>
 #include <sys/timerfd.h>
 #include <asm/xenomai/syscall.h>
 #include "internal.h"
@@ -35,41 +34,3 @@ COBALT_IMPL(int, timerfd_create, (int clockid, int flags))
 	return fd;
 }
 
-COBALT_IMPL_TIME64(int, timerfd_settime, __timerfd_settime64,
-		   (int fd, int flags, const struct itimerspec *new_value,
-		    struct itimerspec *old_value))
-{
-	int ret;
-
-#ifdef XN_USE_TIME64_SYSCALL
-	long sc_nr = sc_cobalt_timerfd_settime64;
-#else
-	long sc_nr = sc_cobalt_timerfd_settime;
-#endif
-
-	ret = -XENOMAI_SYSCALL4(sc_nr, fd, flags, new_value, old_value);
-	if (ret == 0)
-		return ret;
-	
-	errno = ret;
-	return -1;
-}
-
-COBALT_IMPL_TIME64(int, timerfd_gettime, __timerfd_gettime64,
-		   (int fd, struct itimerspec *curr_value))
-{
-	int ret;
-
-#ifdef XN_USE_TIME64_SYSCALL
-	long sc_nr = sc_cobalt_timerfd_gettime64;
-#else
-	long sc_nr = sc_cobalt_timerfd_gettime;
-#endif
-
-	ret = -XENOMAI_SYSCALL2(sc_nr, fd, curr_value);
-	if (ret == 0)
-		return ret;
-	
-	errno = ret;
-	return -1;
-}
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index b4714f22ce3d632cf11456838854df9093b83902..bcb954c1f85b93f24ceb59999e57e4c935b2171f 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -1043,3 +1043,42 @@ COBALT_IMPL_TIME64(int, timer_gettime, __timer_gettime64,
 
 	return -1;
 }
+
+COBALT_IMPL_TIME64(int, timerfd_settime, __timerfd_settime64,
+		   (int fd, int flags, const struct itimerspec *new_value,
+		    struct itimerspec *old_value))
+{
+	int ret;
+
+#ifdef XN_USE_TIME64_SYSCALL
+	long sc_nr = sc_cobalt_timerfd_settime64;
+#else
+	long sc_nr = sc_cobalt_timerfd_settime;
+#endif
+
+	ret = -XENOMAI_SYSCALL4(sc_nr, fd, flags, new_value, old_value);
+	if (ret == 0)
+		return ret;
+
+	errno = ret;
+	return -1;
+}
+
+COBALT_IMPL_TIME64(int, timerfd_gettime, __timerfd_gettime64,
+		   (int fd, struct itimerspec *curr_value))
+{
+	int ret;
+
+#ifdef XN_USE_TIME64_SYSCALL
+	long sc_nr = sc_cobalt_timerfd_gettime64;
+#else
+	long sc_nr = sc_cobalt_timerfd_gettime;
+#endif
+
+	ret = -XENOMAI_SYSCALL2(sc_nr, fd, curr_value);
+	if (ret == 0)
+		return ret;
+
+	errno = ret;
+	return -1;
+}

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 17/20] lib/cobalt: Move XN_USE_TIME64_SYSCALL to wrappers_time64.c
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (15 preceding siblings ...)
  2026-02-20  9:08 ` [PATCH 16/20] lib/cobalt: timerfd: Move " Florian Bezdeka
@ 2026-02-20  9:09 ` Florian Bezdeka
  2026-02-20  9:09 ` [PATCH 18/20] lib/cobalt: Finally build the native time_t interfaces on top Florian Bezdeka
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:09 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

The usage of XN_USE_TIME64_SYSCALL is now limited to wrappers_time64.c.
Moving to clean up.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/internal.h        | 5 -----
 lib/cobalt/wrappers_time64.c | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index 049ab3fc4d1047a1cf0ed3bd9a193938be85826a..0703c721758fdc778708cae70a0e9d53c6fb8eef 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -25,11 +25,6 @@
 #include <cobalt/sys/cobalt.h>
 #include "current.h"
 
-#if defined(__USE_TIME_BITS64) || __WORDSIZE == 64 ||                          \
-	(defined(__SYSCALL_WORDSIZE) && __SYSCALL_WORDSIZE == 64)
-#define XN_USE_TIME64_SYSCALL
-#endif
-
 extern void *cobalt_umm_private;
 
 extern void *cobalt_umm_shared;
diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
index bcb954c1f85b93f24ceb59999e57e4c935b2171f..d43812f88be0e5dc411e1df20cf02329eed60b57 100644
--- a/lib/cobalt/wrappers_time64.c
+++ b/lib/cobalt/wrappers_time64.c
@@ -22,6 +22,11 @@
 #include <sys/time.h>
 #include <time.h>
 
+#if defined(__USE_TIME_BITS64) || __WORDSIZE == 64 ||                          \
+	(defined(__SYSCALL_WORDSIZE) && __SYSCALL_WORDSIZE == 64)
+#define XN_USE_TIME64_SYSCALL
+#endif
+
 /**
  * Get the resolution of the specified clock.
  * @ingroup cobalt_api_time

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 18/20] lib/cobalt: Finally build the native time_t interfaces on top
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (16 preceding siblings ...)
  2026-02-20  9:09 ` [PATCH 17/20] lib/cobalt: Move XN_USE_TIME64_SYSCALL " Florian Bezdeka
@ 2026-02-20  9:09 ` Florian Bezdeka
  2026-02-20  9:09 ` [PATCH 19/20] lib/cobalt: thread: Cleanup and reorder includes Florian Bezdeka
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:09 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

libcobalt was by default providing the time64_t based interfaces in
case time64_t (or y2038) support has been enabled.

We now separated all affected services into a separate compile unit
that allows us to build this compile unit twice. Once with and once
without time64_t support. With that we can build the native interfaces
on top.

libcobalt can now provide both interfaces at the same time. That should
improve backward compatibility a bit.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/wrappers.h | 13 ++++++-------
 lib/cobalt/Makefile.am    | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/wrappers.h b/include/cobalt/wrappers.h
index a5645a1d48946c47bb117064589e883a250839a7..6d826eedf25c5f7708c4a88532101904fb60cd80 100644
--- a/include/cobalt/wrappers.h
+++ b/include/cobalt/wrappers.h
@@ -34,13 +34,12 @@
  * Make __RT() and __STD() usable in combination with time64_t related services.
  */
 #define COBALT_IMPL_TIME64(T, FN, FN_64, I)                                    \
-	__typeof__(T) __wrap_##FN_64 I                                         \
-		__attribute__((alias("__cobalt_" __stringify(FN)), weak));     \
-	COBALT_IMPL(T, FN, I)
-#define COBALT_DECL_TIME64(T, FN, A, I)                                        \
-	__typeof__(T) __STD(A) I;                                              \
-	extern T __REDIRECT_NTH(__STD(FN), I, __real_##A);                     \
-	COBALT_DECL(T, FN, I)
+	COBALT_IMPL(T, FN_64, I)
+#define COBALT_DECL_TIME64(T, FN, FN_64, I)                                    \
+	COBALT_DECL(T, FN_64, I);                                              \
+	extern T __REDIRECT_NTH(__STD(FN), I, __real_##FN_64);                 \
+	extern T __REDIRECT_NTH(__RT(FN), I, __cobalt_##FN_64);                \
+	extern T __REDIRECT_NTH(__WRAP(FN), I, __wrap_##FN_64)
 #else
 #define COBALT_IMPL_TIME64(T, FN, FN_64, I) COBALT_IMPL(T, FN, I)
 #define COBALT_DECL_TIME64(T, FN, FN_64, I) COBALT_DECL(T, FN, I)
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index c31f030117dfc3ddf5ae386897fbc8a2435912a8..697c6ab9fcad8625e0fe604ee027309e992042f3 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -62,6 +62,25 @@ libcobaltext_la_CPPFLAGS =		\
 	-I$(top_srcdir)/include		\
 	-U_TIME_BITS -U_FILE_OFFSET_BITS
 
+if CONFIG_XENO_LIBS_TIME64
+# If time64_t has ben requested libcobalt is already providing time64_t
+# interfaces. The native interfaces have to be build on top.
+libcobaltnativetime_la_SOURCES =	\
+	wrappers.c			\
+	wrappers_time64.c
+
+libcobaltnativetime_la_LDFLAGS = @XENO_LIB_LDFLAGS@
+
+libcobaltnativetime_la_CPPFLAGS =	\
+	@XENO_COBALT_CFLAGS@		\
+        -I$(top_srcdir)/include/cobalt	\
+        -I$(top_srcdir)/include		\
+        -U_TIME_BITS -U_FILE_OFFSET_BITS
+
+noinst_LTLIBRARIES += libcobaltnativetime.la
+libcobalt_la_LIBADD += libcobaltnativetime.la
+endif
+
 libmodechk_la_LIBADD = libcobalt.la
 
 libmodechk_la_SOURCES =	\

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 19/20] lib/cobalt: thread: Cleanup and reorder includes
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (17 preceding siblings ...)
  2026-02-20  9:09 ` [PATCH 18/20] lib/cobalt: Finally build the native time_t interfaces on top Florian Bezdeka
@ 2026-02-20  9:09 ` Florian Bezdeka
  2026-02-20  9:09 ` [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support Florian Bezdeka
  2026-02-20  9:28 ` [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Philippe Gerum
  20 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:09 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

Moving to "from private to public" order. Should help us to make sure
headers stay self-contained.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 lib/cobalt/thread.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index e237e7ba1e85166a7b39a62a6a2d35550a1df009..264fd6dda90e9afb82f5d6b7a7294928db6e598e 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -16,15 +16,15 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
-#include <stddef.h>
+#include "internal.h"
+
+#include <asm/xenomai/syscall.h>
+
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
 #include <pthread.h>
-#include <sys/types.h>
 #include <semaphore.h>
-#include <asm/xenomai/syscall.h>
-#include "internal.h"
 
 /**
  * @ingroup cobalt_api

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (18 preceding siblings ...)
  2026-02-20  9:09 ` [PATCH 19/20] lib/cobalt: thread: Cleanup and reorder includes Florian Bezdeka
@ 2026-02-20  9:09 ` Florian Bezdeka
  2026-02-20 14:50   ` Jan Kiszka
  2026-02-20  9:28 ` [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Philippe Gerum
  20 siblings, 1 reply; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20  9:09 UTC (permalink / raw)
  To: Xenomai; +Cc: Jan Kiszka, Florian Bezdeka

xeno-config got a new cmdline option --disable-y2038 that will disable
the time64_t or (year 2038) support inside the application that is
being build against libcobalt.

libcobalt provides both interfaces, so for native time_t and for
time64_t at the same time. By default, the time64_t based interfaces
will be used. If an application does really want to go back to native
time_t --disable-y2038 has to be specified before the --cflags option.

The new parameter is only useful for (old) 32 bit applications.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 scripts/xeno-config-cobalt.in | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index 46b6c11b92fe20e4474e0173a211b18dc5cd7e3b..ecbfefb8f0a9f7ea99864d07e5f717841ef5da4e 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -62,6 +62,7 @@ Options :
         --core
         --info
         --compat
+        --disable-y2038
 EOF
     exit $1
 }
@@ -173,6 +174,9 @@ while test $# -gt 0; do
 	--posix|--cobalt|--vxworks|--psos|--alchemy|--rtdm|--smokey)
 	    skin_list="$skin_list `expr "$1" : '--\(.*\)'`"
 	    ;;
+	--disable-y2038)
+	    disable_y2038=y
+	    ;;
 	--cflags)
 	    do_cflags=y
 	    ;;
@@ -233,6 +237,7 @@ if test x$do_cflags = xy; then
 		;;
 	esac
     done
+    test x$disable_y2038 = xy && cflags="$cflags -U_TIME_BITS -U_FILE_OFFSET_BITS"
     echo $cflags
 fi
 

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
                   ` (19 preceding siblings ...)
  2026-02-20  9:09 ` [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support Florian Bezdeka
@ 2026-02-20  9:28 ` Philippe Gerum
  2026-02-20  9:36   ` Jan Kiszka
  20 siblings, 1 reply; 37+ messages in thread
From: Philippe Gerum @ 2026-02-20  9:28 UTC (permalink / raw)
  To: Florian Bezdeka; +Cc: Xenomai, Jan Kiszka

Florian Bezdeka <florian.bezdeka@siemens.com> writes:

> Hi all,
>
> The current time64_t / y2038 support switched libcobalt to time64_t
> only, removing the interfaces for the native time_t type.
>
> With that series applied both worlds can live together in one libcobalt
> build which should hopefully increase the backward compatibility a bit.
>

Is this series re-enabling time32 in a way?

-- 
Philippe.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20  9:28 ` [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Philippe Gerum
@ 2026-02-20  9:36   ` Jan Kiszka
  2026-02-20 11:12     ` Philippe Gerum
  0 siblings, 1 reply; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20  9:36 UTC (permalink / raw)
  To: Philippe Gerum, Florian Bezdeka; +Cc: Xenomai

On 20.02.26 10:28, Philippe Gerum wrote:
> Florian Bezdeka <florian.bezdeka@siemens.com> writes:
> 
>> Hi all,
>>
>> The current time64_t / y2038 support switched libcobalt to time64_t
>> only, removing the interfaces for the native time_t type.
>>
>> With that series applied both worlds can live together in one libcobalt
>> build which should hopefully increase the backward compatibility a bit.
>>
> 
> Is this series re-enabling time32 in a way?
> 

It's allowing to keep the time32 ABIs around without having to use
--disable-y2038 for configure. It also resolves that we were changing
existing time32-only functions to time64 where glibc actually added a
separate one (see also
https://lore.kernel.org/xenomai/cd03fe98-7237-426d-91c7-c6eae63a617e@siemens.com/T/#u
- which probably needs a rework to align with this series).

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20  9:36   ` Jan Kiszka
@ 2026-02-20 11:12     ` Philippe Gerum
  2026-02-20 11:19       ` Florian Bezdeka
                         ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Philippe Gerum @ 2026-02-20 11:12 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Florian Bezdeka, Xenomai

Jan Kiszka <jan.kiszka@siemens.com> writes:

> On 20.02.26 10:28, Philippe Gerum wrote:
>> Florian Bezdeka <florian.bezdeka@siemens.com> writes:
>> 
>>> Hi all,
>>>
>>> The current time64_t / y2038 support switched libcobalt to time64_t
>>> only, removing the interfaces for the native time_t type.
>>>
>>> With that series applied both worlds can live together in one libcobalt
>>> build which should hopefully increase the backward compatibility a bit.
>>>
>> 
>> Is this series re-enabling time32 in a way?
>> 
>
> It's allowing to keep the time32 ABIs around without having to use
> --disable-y2038 for configure. It also resolves that we were changing
> existing time32-only functions to time64 where glibc actually added a
> separate one (see also
> https://lore.kernel.org/xenomai/cd03fe98-7237-426d-91c7-c6eae63a617e@siemens.com/T/#u
> - which probably needs a rework to align with this series).
>

Ok, so this is merely to keep the legacy applications building over the
latest x3 releases as transparently as possible.

x4 is unlikely to support time32 for much longer though. With the
upcoming support for a POSIX API, we can't make a pledge for a stable
ABI yet - timeouts on syscalls have to be handled differently on the
whole user->kernel path in the evl core services, in order to enable
some of them for POSIX too. I plan to use this change window for phasing
out time32 entirely in the same move, which would simplify the POSIX
implementation significantly compared to x3, not to speak of the fact
that using time32 for new applications in this day and age would be
obviously wrong anyway.

-- 
Philippe.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20 11:12     ` Philippe Gerum
@ 2026-02-20 11:19       ` Florian Bezdeka
  2026-02-20 15:06         ` Philippe Gerum
  2026-02-20 11:20       ` Philippe Gerum
  2026-02-20 11:49       ` Jan Kiszka
  2 siblings, 1 reply; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20 11:19 UTC (permalink / raw)
  To: Philippe Gerum, Jan Kiszka; +Cc: Xenomai

On Fri, 2026-02-20 at 12:12 +0100, Philippe Gerum wrote:
> Jan Kiszka <jan.kiszka@siemens.com> writes:
> 
> > On 20.02.26 10:28, Philippe Gerum wrote:
> > > Florian Bezdeka <florian.bezdeka@siemens.com> writes:
> > > 
> > > > Hi all,
> > > > 
> > > > The current time64_t / y2038 support switched libcobalt to time64_t
> > > > only, removing the interfaces for the native time_t type.
> > > > 
> > > > With that series applied both worlds can live together in one libcobalt
> > > > build which should hopefully increase the backward compatibility a bit.
> > > > 
> > > 
> > > Is this series re-enabling time32 in a way?
> > > 
> > 
> > It's allowing to keep the time32 ABIs around without having to use
> > --disable-y2038 for configure. It also resolves that we were changing
> > existing time32-only functions to time64 where glibc actually added a
> > separate one (see also
> > https://lore.kernel.org/xenomai/cd03fe98-7237-426d-91c7-c6eae63a617e@siemens.com/T/#u
> > - which probably needs a rework to align with this series).
> > 
> 
> Ok, so this is merely to keep the legacy applications building over the
> latest x3 releases as transparently as possible.
> 
> x4 is unlikely to support time32 for much longer though. With the
> upcoming support for a POSIX API, we can't make a pledge for a stable
> ABI yet - timeouts on syscalls have to be handled differently on the
> whole user->kernel path in the evl core services, in order to enable
> some of them for POSIX too. I plan to use this change window for phasing
> out time32 entirely in the same move, which would simplify the POSIX
> implementation significantly compared to x3, not to speak of the fact
> that using time32 for new applications in this day and age would be
> obviously wrong anyway.
> 

I see no problem here. If possible - and that seems to be the case - x4
should not deal with time32 anymore.

A possible update path from x3 to x4 would be:
  - x3 no time64
  - x3 enable time64
  - move to x4

That should be doable.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20 11:12     ` Philippe Gerum
  2026-02-20 11:19       ` Florian Bezdeka
@ 2026-02-20 11:20       ` Philippe Gerum
  2026-02-20 11:49       ` Jan Kiszka
  2 siblings, 0 replies; 37+ messages in thread
From: Philippe Gerum @ 2026-02-20 11:20 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Florian Bezdeka, Xenomai

Philippe Gerum <rpm@xenomai.org> writes:

> some of them for POSIX too. I plan to use this change window for phasing
> out time32 entirely in the same move, which would simplify the POSIX

As in passing requiring glibc >= 2.34 for enabling -D_TIME_BITS=64
-D_FILE_OFFSET_BITS=64, or requiring musl >= 1.2.0 since time64 has been
the default since then. The uClibc situation is still unclear to me ATM
since I saw patches floating around months ago disabling time64 in order
to pass the test suite, maybe this has improved, need to check
again. Anyway, since we cannot do without time64 but we do have
alternatives to uClibc, the choice would be pretty clear if we had to
make one.

-- 
Philippe.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20 11:12     ` Philippe Gerum
  2026-02-20 11:19       ` Florian Bezdeka
  2026-02-20 11:20       ` Philippe Gerum
@ 2026-02-20 11:49       ` Jan Kiszka
  2 siblings, 0 replies; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20 11:49 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: Florian Bezdeka, Xenomai

On 20.02.26 12:12, Philippe Gerum wrote:
> Jan Kiszka <jan.kiszka@siemens.com> writes:
> 
>> On 20.02.26 10:28, Philippe Gerum wrote:
>>> Florian Bezdeka <florian.bezdeka@siemens.com> writes:
>>>
>>>> Hi all,
>>>>
>>>> The current time64_t / y2038 support switched libcobalt to time64_t
>>>> only, removing the interfaces for the native time_t type.
>>>>
>>>> With that series applied both worlds can live together in one libcobalt
>>>> build which should hopefully increase the backward compatibility a bit.
>>>>
>>>
>>> Is this series re-enabling time32 in a way?
>>>
>>
>> It's allowing to keep the time32 ABIs around without having to use
>> --disable-y2038 for configure. It also resolves that we were changing
>> existing time32-only functions to time64 where glibc actually added a
>> separate one (see also
>> https://lore.kernel.org/xenomai/cd03fe98-7237-426d-91c7-c6eae63a617e@siemens.com/T/#u
>> - which probably needs a rework to align with this series).
>>
> 
> Ok, so this is merely to keep the legacy applications building over the
> latest x3 releases as transparently as possible.
> 

...and staying compatible with glibc ABIs.

> x4 is unlikely to support time32 for much longer though. With the
> upcoming support for a POSIX API, we can't make a pledge for a stable
> ABI yet - timeouts on syscalls have to be handled differently on the
> whole user->kernel path in the evl core services, in order to enable
> some of them for POSIX too. I plan to use this change window for phasing
> out time32 entirely in the same move, which would simplify the POSIX
> implementation significantly compared to x3, not to speak of the fact
> that using time32 for new applications in this day and age would be
> obviously wrong anyway.
> 

Of course. Best would be then to not even start exposing the old calls
anymore, rather then bending existing ones to time64.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 01/20] lib/cobalt: Introduce cond.h
  2026-02-20  9:08 ` [PATCH 01/20] lib/cobalt: Introduce cond.h Florian Bezdeka
@ 2026-02-20 14:33   ` Jan Kiszka
  0 siblings, 0 replies; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20 14:33 UTC (permalink / raw)
  To: Florian Bezdeka, Xenomai

On 20.02.26 10:08, Florian Bezdeka wrote:
> Some code will be re-used later by the time64_t compile unit. Move that
> code into cond.h, so code duplication is avoided.
> 
> No modifications to the code itself.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  lib/cobalt/Makefile.am |  1 +
>  lib/cobalt/cond.c      | 67 ++-----------------------------------------
>  lib/cobalt/cond.h      | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+), 65 deletions(-)
> 
> diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
> index ed7e503899f4852388fb3bf204bfe91936009d74..b1098413fbf3a8f6a5f0a85d6aceb9916b14149a 100644
> --- a/lib/cobalt/Makefile.am
> +++ b/lib/cobalt/Makefile.am
> @@ -1,6 +1,7 @@
>  pkgconfigdir = $(libdir)/pkgconfig
>  
>  noinst_HEADERS =	\
> +	cond.h		\
>  	current.h	\
>  	umm.h		\
>  	internal.h
> diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
> index 2d11f768edc0fe4e89944a96333d2dd76d174172..7be7fca01f53930f8504945206b2ee6ba6be1ba5 100644
> --- a/lib/cobalt/cond.c
> +++ b/lib/cobalt/cond.c
> @@ -20,6 +20,8 @@
>  #include <string.h>
>  #include <pthread.h>
>  #include <asm/xenomai/syscall.h>
> +
> +#include "cond.h"
>  #include "current.h"
>  #include "internal.h"
>  
> @@ -147,32 +149,6 @@ COBALT_IMPL(int, pthread_cond_init, (pthread_cond_t *cond,
>  	return 0;
>  }
>  
> -static int __attribute__((cold))
> -	cobalt_cond_autoinit_type(const pthread_cond_t *cond)
> -{
> -	static const pthread_cond_t cond_initializer =
> -		PTHREAD_COND_INITIALIZER;
> -
> -	return memcmp(cond, &cond_initializer, sizeof(cond_initializer)) == 0 ?
> -		0 : -1;
> -}
> -
> -static int __attribute__((cold))
> -	cobalt_cond_doautoinit(union cobalt_cond_union *ucond)
> -{
> -	if (cobalt_cond_autoinit_type(&ucond->native_cond) < 0)
> -		return EINVAL;
> -
> -	return __COBALT(pthread_cond_init(&ucond->native_cond, NULL));
> -}
> -
> -static inline int cobalt_cond_autoinit(union cobalt_cond_union *ucond)
> -{
> -	if (ucond->shadow_cond.magic != COBALT_COND_MAGIC)
> -		return cobalt_cond_doautoinit(ucond);
> -	return 0;
> -}
> -
>  /**
>   * @fn int pthread_cond_destroy(pthread_cond_t *cond)
>   * @brief Destroy a condition variable
> @@ -208,45 +184,6 @@ COBALT_IMPL(int, pthread_cond_destroy, (pthread_cond_t *cond))
>  	return -XENOMAI_SYSCALL1( sc_cobalt_cond_destroy, _cond);
>  }
>  
> -struct cobalt_cond_cleanup_t {
> -	struct cobalt_cond_shadow *cond;
> -	struct cobalt_mutex_shadow *mutex;
> -	unsigned count;
> -	int err;
> -};
> -
> -static void __pthread_cond_cleanup(void *data)
> -{
> -	struct cobalt_cond_cleanup_t *c = (struct cobalt_cond_cleanup_t *)data;
> -	xnhandle_t cur = cobalt_get_current();
> -	int err;
> -
> -	/* if we still own the mutex, cond_wait_prologue wasn't called yet */
> -	if (xnsynch_fast_owner_check(mutex_get_ownerp(c->mutex), cur) == 0)
> -		return;
> -
> -	do {
> -		err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue,
> -				       c->cond, c->mutex);
> -	} while (err == -EINTR);
> -
> -	c->mutex->lockcnt = c->count;
> -}
> -
> -static inline int do_sc_cond_wait_prologue(struct cobalt_cond_shadow *cnd,
> -					   struct cobalt_mutex_shadow *mx,
> -					   int *err, int timed,
> -					   const struct timespec *abstime)
> -{
> -#ifdef __USE_TIME_BITS64
> -	long sc_nr = sc_cobalt_cond_wait_prologue64;
> -#else
> -	long sc_nr = sc_cobalt_cond_wait_prologue;
> -#endif
> -
> -	return XENOMAI_SYSCALL5(sc_nr, cnd, mx, err, timed, abstime);
> -}
> -
>  /**
>   * Wait on a condition variable.
>   *
> diff --git a/lib/cobalt/cond.h b/lib/cobalt/cond.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..fbb7a02149ddfa0858def5e8741d5b044afc17b7
> --- /dev/null
> +++ b/lib/cobalt/cond.h

New file but no copyright header. Likely applies to more patches in this
series.

> @@ -0,0 +1,78 @@
> +#ifndef _LIB_COBALT_COND_H
> +#define _LIB_COBALT_COND_H
> +
> +#include "current.h"
> +#include "internal.h"
> +
> +#include <asm/xenomai/syscall.h>
> +#include <cobalt/uapi/cond.h>
> +
> +#include <string.h>
> +#include <pthread.h>
> +
> +struct cobalt_cond_cleanup_t {
> +	struct cobalt_cond_shadow *cond;
> +	struct cobalt_mutex_shadow *mutex;
> +	unsigned count;
> +	int err;
> +};
> +
> +static int __attribute__((cold))
> +cobalt_cond_autoinit_type(const pthread_cond_t *cond)
> +{
> +	static const pthread_cond_t cond_initializer = PTHREAD_COND_INITIALIZER;
> +
> +	return memcmp(cond, &cond_initializer, sizeof(cond_initializer)) == 0 ?
> +		       0 :
> +		       -1;
> +}
> +
> +static int __attribute__((cold))
> +cobalt_cond_doautoinit(union cobalt_cond_union *ucond)
> +{
> +	if (cobalt_cond_autoinit_type(&ucond->native_cond) < 0)
> +		return EINVAL;
> +
> +	return __COBALT(pthread_cond_init(&ucond->native_cond, NULL));
> +}
> +
> +static inline int cobalt_cond_autoinit(union cobalt_cond_union *ucond)
> +{
> +	if (ucond->shadow_cond.magic != COBALT_COND_MAGIC)
> +		return cobalt_cond_doautoinit(ucond);
> +	return 0;
> +}
> +
> +static void __pthread_cond_cleanup(void *data)
> +{
> +	struct cobalt_cond_cleanup_t *c = (struct cobalt_cond_cleanup_t *)data;
> +	xnhandle_t cur = cobalt_get_current();
> +	int err;
> +
> +	/* if we still own the mutex, cond_wait_prologue wasn't called yet */
> +	if (xnsynch_fast_owner_check(mutex_get_ownerp(c->mutex), cur) == 0)
> +		return;
> +
> +	do {
> +		err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue, c->cond,
> +				       c->mutex);
> +	} while (err == -EINTR);
> +
> +	c->mutex->lockcnt = c->count;
> +}
> +
> +static inline int do_sc_cond_wait_prologue(struct cobalt_cond_shadow *cnd,
> +					   struct cobalt_mutex_shadow *mx,
> +					   int *err, int timed,
> +					   const struct timespec *abstime)
> +{
> +#ifdef __USE_TIME_BITS64
> +	long sc_nr = sc_cobalt_cond_wait_prologue64;
> +#else
> +	long sc_nr = sc_cobalt_cond_wait_prologue;
> +#endif
> +
> +	return XENOMAI_SYSCALL5(sc_nr, cnd, mx, err, timed, abstime);
> +}
> +
> +#endif //_LIB_COBALT_COND_H
> 

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c
  2026-02-20  9:08 ` [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c Florian Bezdeka
@ 2026-02-20 14:36   ` Jan Kiszka
  2026-02-20 14:46     ` Florian Bezdeka
  2026-02-27 11:56     ` Florian Bezdeka
  0 siblings, 2 replies; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20 14:36 UTC (permalink / raw)
  To: Florian Bezdeka, Xenomai

On 20.02.26 10:08, Florian Bezdeka wrote:
> All COBALT_IMPL_TIME64() services will be moved afterwards - step by
> step - into the newly introduced wrappers_time64.c. At the end that
> should allow us to compile libcobalt with time64_t support leaving
> the native time_t services in place.
> 
> Currently, all native time_t services are replaced by the 64 bit
> variants. That is OK as long as applications are rebuild after
> libcobalt, but we try to remove this limitation now.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  lib/cobalt/Makefile.am       | 3 ++-
>  lib/cobalt/wrappers_time64.c | 6 ++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
> index f461e570ed42a0d5cbc43eabb373c3c9edd83bad..17e203f9015fe2bb5306609e4d51c62f3a725780 100644
> --- a/lib/cobalt/Makefile.am
> +++ b/lib/cobalt/Makefile.am
> @@ -43,7 +43,8 @@ libcobalt_la_SOURCES =		\
>  	timerfd.c		\
>  	trace.c			\
>  	umm.c			\
> -	wrappers.c
> +	wrappers.c		\
> +	wrappers_time64.c


So, a should we do a wrapper_off64 for mmap, or put both into the same
one? I don't have a good name for common one yet, though.

>  
>  libcobalt_la_CPPFLAGS =			\
>  	@XENO_COBALT_CFLAGS@		\
> diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..4c4e0db0650b49f46cbd6d9ecf7cd656bb04bbe4
> --- /dev/null
> +++ b/lib/cobalt/wrappers_time64.c
> @@ -0,0 +1,6 @@
> +/*
> + * Magic ahead:
> + * This file is compiled twice in case y2038/time64_t support is necessary
> + * and requested. The first time with time64_t and a second time with native
> + * time_t.
> + */
> 

Header, but still no copyright notices...

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c
  2026-02-20  9:08 ` [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c Florian Bezdeka
@ 2026-02-20 14:38   ` Jan Kiszka
  2026-02-20 14:57     ` Florian Bezdeka
  0 siblings, 1 reply; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20 14:38 UTC (permalink / raw)
  To: Florian Bezdeka, Xenomai

On 20.02.26 10:08, Florian Bezdeka wrote:
> select.c is no longer needed as everything inside is time64_t affected.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  lib/cobalt/Makefile.am       |   1 -
>  lib/cobalt/select.c          | 108 -------------------------------------------
>  lib/cobalt/wrappers_time64.c |  86 ++++++++++++++++++++++++++++++++++
>  3 files changed, 86 insertions(+), 109 deletions(-)
> 
> diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
> index 17e203f9015fe2bb5306609e4d51c62f3a725780..c31f030117dfc3ddf5ae386897fbc8a2435912a8 100644
> --- a/lib/cobalt/Makefile.am
> +++ b/lib/cobalt/Makefile.am
> @@ -33,7 +33,6 @@ libcobalt_la_SOURCES =		\
>  	printf.c		\
>  	rtdm.c			\
>  	sched.c			\
> -	select.c		\
>  	semaphore.c		\
>  	signal.c		\
>  	sigshadow.c		\
> diff --git a/lib/cobalt/select.c b/lib/cobalt/select.c
> deleted file mode 100644
> index 5472e991e126c2f521b346a7cf3c884bbf6f6317..0000000000000000000000000000000000000000
> --- a/lib/cobalt/select.c
> +++ /dev/null
> @@ -1,108 +0,0 @@
> -/*
> - * Copyright (C) 2010 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>

Make sure to not lose copyright notices...

Jan

> - *
> - * This library is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> - *
> - * This library is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * Lesser General Public License for more details.
> -
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this library; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
> - */
> -
> -#include <errno.h>
> -#include <pthread.h>
> -#include <sys/select.h>
> -#include <asm/xenomai/syscall.h>
> -
> -#if __USE_TIME_BITS64 && __TIMESIZE == 32
> -
> -#define USEC_PER_SEC	1000000L
> -#define NSEC_PER_USEC	1000L
> -
> -/*
> - * The time64 wrapper for select() is a little different:
> - * There is no y2038 safe syscall for select() itself, but we have pselect()
> - * without signal support.
> - */
> -static inline int do_select(int __nfds, fd_set *__restrict __readfds,
> -			      fd_set *__restrict __writefds,
> -			      fd_set *__restrict __exceptfds,
> -			      struct timeval *__restrict __timeout)
> -{
> -	struct timespec to;
> -	int err, oldtype;
> -
> -	if (__timeout) {
> -		to.tv_sec =
> -			__timeout->tv_sec + (__timeout->tv_usec / USEC_PER_SEC);
> -		to.tv_nsec =
> -			(__timeout->tv_usec % USEC_PER_SEC) * NSEC_PER_USEC;
> -	}
> -
> -	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
> -
> -	/*
> -	 * Note: No sigmask here, we already reached the limit of 5
> -	 * syscall parameters
> -	 */
> -	err = XENOMAI_SYSCALL5(sc_cobalt_pselect64, __nfds, __readfds,
> -			       __writefds, __exceptfds, __timeout ? &to : NULL);
> -
> -	pthread_setcanceltype(oldtype, NULL);
> -
> -	if (err == -EADV || err == -EPERM || err == -ENOSYS) {
> -		err = __STD(__select64(__nfds, __readfds, __writefds,
> -				       __exceptfds, __timeout));
> -	} else if (__timeout) {
> -		__timeout->tv_sec = to.tv_sec;
> -		__timeout->tv_usec = to.tv_nsec / 1000;
> -	}
> -
> -	if (err >= 0)
> -		return err;
> -
> -	errno = -err;
> -	return -1;
> -}
> -#else
> -static inline int do_select(int __nfds, fd_set *__restrict __readfds,
> -			    fd_set *__restrict __writefds,
> -			    fd_set *__restrict __exceptfds,
> -			    struct timeval *__restrict __timeout)
> -{
> -	int err, oldtype;
> -
> -	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
> -
> -	err = XENOMAI_SYSCALL5(sc_cobalt_select, __nfds,
> -			       __readfds, __writefds, __exceptfds, __timeout);
> -
> -	pthread_setcanceltype(oldtype, NULL);
> -
> -	if (err == -EADV || err == -EPERM || err == -ENOSYS)
> -		return __STD(select(__nfds, __readfds,
> -				    __writefds, __exceptfds, __timeout));
> -
> -	if (err >= 0)
> -		return err;
> -
> -	errno = -err;
> -	return -1;
> -}
> -#endif
> -
> -COBALT_IMPL_TIME64(int, select, __select64,
> -		   (int __nfds, fd_set *__restrict __readfds,
> -		    fd_set *__restrict __writefds,
> -		    fd_set *__restrict __exceptfds,
> -		    struct timeval *__restrict __timeout))
> -{
> -	return do_select(__nfds, __readfds, __writefds, __exceptfds, __timeout);
> -}
> diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
> index ded0232824fade9b2f656c03ac3e5515fb5f8b38..7b634976eb07d7ae143b4567983dbea7f4ddebea 100644
> --- a/lib/cobalt/wrappers_time64.c
> +++ b/lib/cobalt/wrappers_time64.c
> @@ -754,3 +754,89 @@ COBALT_IMPL_TIME64(int, setsockopt, __setsockopt64,
>  
>  	return __STD(setsockopt(fd, level, optname, optval, optlen));
>  }
> +
> +#if __USE_TIME_BITS64 && __TIMESIZE == 32
> +
> +#define USEC_PER_SEC	1000000L
> +#define NSEC_PER_USEC	1000L
> +
> +/*
> + * The time64 wrapper for select() is a little different:
> + * There is no y2038 safe syscall for select() itself, but we have pselect()
> + * without signal support.
> + */
> +static inline int do_select(int __nfds, fd_set *__restrict __readfds,
> +			      fd_set *__restrict __writefds,
> +			      fd_set *__restrict __exceptfds,
> +			      struct timeval *__restrict __timeout)
> +{
> +	struct timespec to;
> +	int err, oldtype;
> +
> +	if (__timeout) {
> +		to.tv_sec =
> +			__timeout->tv_sec + (__timeout->tv_usec / USEC_PER_SEC);
> +		to.tv_nsec =
> +			(__timeout->tv_usec % USEC_PER_SEC) * NSEC_PER_USEC;
> +	}
> +
> +	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
> +
> +	/*
> +	 * Note: No sigmask here, we already reached the limit of 5
> +	 * syscall parameters
> +	 */
> +	err = XENOMAI_SYSCALL5(sc_cobalt_pselect64, __nfds, __readfds,
> +			       __writefds, __exceptfds, __timeout ? &to : NULL);
> +
> +	pthread_setcanceltype(oldtype, NULL);
> +
> +	if (err == -EADV || err == -EPERM || err == -ENOSYS) {
> +		err = __STD(__select64(__nfds, __readfds, __writefds,
> +				       __exceptfds, __timeout));
> +	} else if (__timeout) {
> +		__timeout->tv_sec = to.tv_sec;
> +		__timeout->tv_usec = to.tv_nsec / 1000;
> +	}
> +
> +	if (err >= 0)
> +		return err;
> +
> +	errno = -err;
> +	return -1;
> +}
> +#else
> +static inline int do_select(int __nfds, fd_set *__restrict __readfds,
> +			    fd_set *__restrict __writefds,
> +			    fd_set *__restrict __exceptfds,
> +			    struct timeval *__restrict __timeout)
> +{
> +	int err, oldtype;
> +
> +	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
> +
> +	err = XENOMAI_SYSCALL5(sc_cobalt_select, __nfds,
> +			       __readfds, __writefds, __exceptfds, __timeout);
> +
> +	pthread_setcanceltype(oldtype, NULL);
> +
> +	if (err == -EADV || err == -EPERM || err == -ENOSYS)
> +		return __STD(select(__nfds, __readfds,
> +				    __writefds, __exceptfds, __timeout));
> +
> +	if (err >= 0)
> +		return err;
> +
> +	errno = -err;
> +	return -1;
> +}
> +#endif
> +
> +COBALT_IMPL_TIME64(int, select, __select64,
> +		   (int __nfds, fd_set *__restrict __readfds,
> +		    fd_set *__restrict __writefds,
> +		    fd_set *__restrict __exceptfds,
> +		    struct timeval *__restrict __timeout))
> +{
> +	return do_select(__nfds, __readfds, __writefds, __exceptfds, __timeout);
> +}
> 

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c
  2026-02-20 14:36   ` Jan Kiszka
@ 2026-02-20 14:46     ` Florian Bezdeka
  2026-02-20 14:47       ` Jan Kiszka
  2026-02-27 11:56     ` Florian Bezdeka
  1 sibling, 1 reply; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20 14:46 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

On Fri, 2026-02-20 at 15:36 +0100, Jan Kiszka wrote:
> On 20.02.26 10:08, Florian Bezdeka wrote:
> > All COBALT_IMPL_TIME64() services will be moved afterwards - step by
> > step - into the newly introduced wrappers_time64.c. At the end that
> > should allow us to compile libcobalt with time64_t support leaving
> > the native time_t services in place.
> > 
> > Currently, all native time_t services are replaced by the 64 bit
> > variants. That is OK as long as applications are rebuild after
> > libcobalt, but we try to remove this limitation now.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  lib/cobalt/Makefile.am       | 3 ++-
> >  lib/cobalt/wrappers_time64.c | 6 ++++++
> >  2 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
> > index f461e570ed42a0d5cbc43eabb373c3c9edd83bad..17e203f9015fe2bb5306609e4d51c62f3a725780 100644
> > --- a/lib/cobalt/Makefile.am
> > +++ b/lib/cobalt/Makefile.am
> > @@ -43,7 +43,8 @@ libcobalt_la_SOURCES =		\
> >  	timerfd.c		\
> >  	trace.c			\
> >  	umm.c			\
> > -	wrappers.c
> > +	wrappers.c		\
> > +	wrappers_time64.c
> 
> 
> So, a should we do a wrapper_off64 for mmap, or put both into the same
> one? I don't have a good name for common one yet, though.

Both should be possible, I think, but testing has to prove that.

> 
> >  
> >  libcobalt_la_CPPFLAGS =			\
> >  	@XENO_COBALT_CFLAGS@		\
> > diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..4c4e0db0650b49f46cbd6d9ecf7cd656bb04bbe4
> > --- /dev/null
> > +++ b/lib/cobalt/wrappers_time64.c
> > @@ -0,0 +1,6 @@
> > +/*
> > + * Magic ahead:
> > + * This file is compiled twice in case y2038/time64_t support is necessary
> > + * and requested. The first time with time64_t and a second time with native
> > + * time_t.
> > + */
> > 
> 
> Header, but still no copyright notices...
> 

Yes, I forgot the license headers / copyright notices because I was not
sure if I should add SDPX headers or the full blown license text...

Any preferences?

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c
  2026-02-20 14:46     ` Florian Bezdeka
@ 2026-02-20 14:47       ` Jan Kiszka
  0 siblings, 0 replies; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20 14:47 UTC (permalink / raw)
  To: Florian Bezdeka, Xenomai

On 20.02.26 15:46, Florian Bezdeka wrote:
> On Fri, 2026-02-20 at 15:36 +0100, Jan Kiszka wrote:
>> On 20.02.26 10:08, Florian Bezdeka wrote:
>>> All COBALT_IMPL_TIME64() services will be moved afterwards - step by
>>> step - into the newly introduced wrappers_time64.c. At the end that
>>> should allow us to compile libcobalt with time64_t support leaving
>>> the native time_t services in place.
>>>
>>> Currently, all native time_t services are replaced by the 64 bit
>>> variants. That is OK as long as applications are rebuild after
>>> libcobalt, but we try to remove this limitation now.
>>>
>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>> ---
>>>  lib/cobalt/Makefile.am       | 3 ++-
>>>  lib/cobalt/wrappers_time64.c | 6 ++++++
>>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
>>> index f461e570ed42a0d5cbc43eabb373c3c9edd83bad..17e203f9015fe2bb5306609e4d51c62f3a725780 100644
>>> --- a/lib/cobalt/Makefile.am
>>> +++ b/lib/cobalt/Makefile.am
>>> @@ -43,7 +43,8 @@ libcobalt_la_SOURCES =		\
>>>  	timerfd.c		\
>>>  	trace.c			\
>>>  	umm.c			\
>>> -	wrappers.c
>>> +	wrappers.c		\
>>> +	wrappers_time64.c
>>
>>
>> So, a should we do a wrapper_off64 for mmap, or put both into the same
>> one? I don't have a good name for common one yet, though.
> 
> Both should be possible, I think, but testing has to prove that.
> 
>>
>>>  
>>>  libcobalt_la_CPPFLAGS =			\
>>>  	@XENO_COBALT_CFLAGS@		\
>>> diff --git a/lib/cobalt/wrappers_time64.c b/lib/cobalt/wrappers_time64.c
>>> new file mode 100644
>>> index 0000000000000000000000000000000000000000..4c4e0db0650b49f46cbd6d9ecf7cd656bb04bbe4
>>> --- /dev/null
>>> +++ b/lib/cobalt/wrappers_time64.c
>>> @@ -0,0 +1,6 @@
>>> +/*
>>> + * Magic ahead:
>>> + * This file is compiled twice in case y2038/time64_t support is necessary
>>> + * and requested. The first time with time64_t and a second time with native
>>> + * time_t.
>>> + */
>>>
>>
>> Header, but still no copyright notices...
>>
> 
> Yes, I forgot the license headers / copyright notices because I was not
> sure if I should add SDPX headers or the full blown license text...
> 
> Any preferences?

When moving existing code, better keep things as they were. SPDX can be
added, but it should not replace old statements.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support
  2026-02-20  9:09 ` [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support Florian Bezdeka
@ 2026-02-20 14:50   ` Jan Kiszka
  2026-02-20 15:05     ` Florian Bezdeka
  0 siblings, 1 reply; 37+ messages in thread
From: Jan Kiszka @ 2026-02-20 14:50 UTC (permalink / raw)
  To: Florian Bezdeka, Xenomai

On 20.02.26 10:09, Florian Bezdeka wrote:
> xeno-config got a new cmdline option --disable-y2038 that will disable
> the time64_t or (year 2038) support inside the application that is
> being build against libcobalt.
> 
> libcobalt provides both interfaces, so for native time_t and for
> time64_t at the same time. By default, the time64_t based interfaces
> will be used. If an application does really want to go back to native
> time_t --disable-y2038 has to be specified before the --cflags option.
> 
> The new parameter is only useful for (old) 32 bit applications.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  scripts/xeno-config-cobalt.in | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
> index 46b6c11b92fe20e4474e0173a211b18dc5cd7e3b..ecbfefb8f0a9f7ea99864d07e5f717841ef5da4e 100644
> --- a/scripts/xeno-config-cobalt.in
> +++ b/scripts/xeno-config-cobalt.in
> @@ -62,6 +62,7 @@ Options :
>          --core
>          --info
>          --compat
> +        --disable-y2038
>  EOF
>      exit $1
>  }
> @@ -173,6 +174,9 @@ while test $# -gt 0; do
>  	--posix|--cobalt|--vxworks|--psos|--alchemy|--rtdm|--smokey)
>  	    skin_list="$skin_list `expr "$1" : '--\(.*\)'`"
>  	    ;;
> +	--disable-y2038)
> +	    disable_y2038=y
> +	    ;;
>  	--cflags)
>  	    do_cflags=y
>  	    ;;
> @@ -233,6 +237,7 @@ if test x$do_cflags = xy; then
>  		;;
>  	esac
>      done
> +    test x$disable_y2038 = xy && cflags="$cflags -U_TIME_BITS -U_FILE_OFFSET_BITS"

I did that undef in my mmap patch as well, but I wonder if - at least
here - we couldn't filter out both defines from the given cflags.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c
  2026-02-20 14:38   ` Jan Kiszka
@ 2026-02-20 14:57     ` Florian Bezdeka
  0 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20 14:57 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

On Fri, 2026-02-20 at 15:38 +0100, Jan Kiszka wrote:
> > diff --git a/lib/cobalt/select.c b/lib/cobalt/select.c
> > deleted file mode 100644
> > index 5472e991e126c2f521b346a7cf3c884bbf6f6317..0000000000000000000000000000000000000000
> > --- a/lib/cobalt/select.c
> > +++ /dev/null
> > @@ -1,108 +0,0 @@
> > -/*
> > - * Copyright (C) 2010 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> 
> Make sure to not lose copyright notices...
> 
> 

That is the only file that gets removed. I will add Gilles' copyright
back to the select() part in wrappers_time64.c as I'm quite sure that
not all time64 services go back to Gilles. I will double check, though.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support
  2026-02-20 14:50   ` Jan Kiszka
@ 2026-02-20 15:05     ` Florian Bezdeka
  0 siblings, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-20 15:05 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

On Fri, 2026-02-20 at 15:50 +0100, Jan Kiszka wrote:
> On 20.02.26 10:09, Florian Bezdeka wrote:
> > xeno-config got a new cmdline option --disable-y2038 that will disable
> > the time64_t or (year 2038) support inside the application that is
> > being build against libcobalt.
> > 
> > libcobalt provides both interfaces, so for native time_t and for
> > time64_t at the same time. By default, the time64_t based interfaces
> > will be used. If an application does really want to go back to native
> > time_t --disable-y2038 has to be specified before the --cflags option.
> > 
> > The new parameter is only useful for (old) 32 bit applications.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  scripts/xeno-config-cobalt.in | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
> > index 46b6c11b92fe20e4474e0173a211b18dc5cd7e3b..ecbfefb8f0a9f7ea99864d07e5f717841ef5da4e 100644
> > --- a/scripts/xeno-config-cobalt.in
> > +++ b/scripts/xeno-config-cobalt.in
> > @@ -62,6 +62,7 @@ Options :
> >          --core
> >          --info
> >          --compat
> > +        --disable-y2038
> >  EOF
> >      exit $1
> >  }
> > @@ -173,6 +174,9 @@ while test $# -gt 0; do
> >  	--posix|--cobalt|--vxworks|--psos|--alchemy|--rtdm|--smokey)
> >  	    skin_list="$skin_list `expr "$1" : '--\(.*\)'`"
> >  	    ;;
> > +	--disable-y2038)
> > +	    disable_y2038=y
> > +	    ;;
> >  	--cflags)
> >  	    do_cflags=y
> >  	    ;;
> > @@ -233,6 +237,7 @@ if test x$do_cflags = xy; then
> >  		;;
> >  	esac
> >      done
> > +    test x$disable_y2038 = xy && cflags="$cflags -U_TIME_BITS -U_FILE_OFFSET_BITS"
> 
> I did that undef in my mmap patch as well, but I wonder if - at least
> here - we couldn't filter out both defines from the given cflags.
> 

In case libcobalt itself was build with time64_t support those flags are
part of all cflags variables. Might be that there is a more elegant way
to remove flags but that didn't come to mind yet...

A different approach might be to skip writing the time64_t enablement
flags into XENO_USER_APP_CFLAGS (configure). Side effect might be that
every (testsuite) application has to enable the support on it's own,
doing all the glibc support checks...

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time
  2026-02-20 11:19       ` Florian Bezdeka
@ 2026-02-20 15:06         ` Philippe Gerum
  0 siblings, 0 replies; 37+ messages in thread
From: Philippe Gerum @ 2026-02-20 15:06 UTC (permalink / raw)
  To: Florian Bezdeka; +Cc: Jan Kiszka, Xenomai

Florian Bezdeka <florian.bezdeka@siemens.com> writes:

> On Fri, 2026-02-20 at 12:12 +0100, Philippe Gerum wrote:
>> Jan Kiszka <jan.kiszka@siemens.com> writes:
>> 
>> > On 20.02.26 10:28, Philippe Gerum wrote:
>> > > Florian Bezdeka <florian.bezdeka@siemens.com> writes:
>> > > 
>> > > > Hi all,
>> > > > 
>> > > > The current time64_t / y2038 support switched libcobalt to time64_t
>> > > > only, removing the interfaces for the native time_t type.
>> > > > 
>> > > > With that series applied both worlds can live together in one libcobalt
>> > > > build which should hopefully increase the backward compatibility a bit.
>> > > > 
>> > > 
>> > > Is this series re-enabling time32 in a way?
>> > > 
>> > 
>> > It's allowing to keep the time32 ABIs around without having to use
>> > --disable-y2038 for configure. It also resolves that we were changing
>> > existing time32-only functions to time64 where glibc actually added a
>> > separate one (see also
>> > https://lore.kernel.org/xenomai/cd03fe98-7237-426d-91c7-c6eae63a617e@siemens.com/T/#u
>> > - which probably needs a rework to align with this series).
>> > 
>> 
>> Ok, so this is merely to keep the legacy applications building over the
>> latest x3 releases as transparently as possible.
>> 
>> x4 is unlikely to support time32 for much longer though. With the
>> upcoming support for a POSIX API, we can't make a pledge for a stable
>> ABI yet - timeouts on syscalls have to be handled differently on the
>> whole user->kernel path in the evl core services, in order to enable
>> some of them for POSIX too. I plan to use this change window for phasing
>> out time32 entirely in the same move, which would simplify the POSIX
>> implementation significantly compared to x3, not to speak of the fact
>> that using time32 for new applications in this day and age would be
>> obviously wrong anyway.
>> 
>
> I see no problem here. If possible - and that seems to be the case - x4
> should not deal with time32 anymore.
>

Yes, moving to time64-only would be straightforward for x4, and would
not even break the ABI. libevl is currently converting time32 requests
to time64 by using bounce buffers for (i)time(r)specs internally, we
only need to drop the latter - which we need to in order to meet a
particular POSIX requirement about deferred timeout handling.

-- 
Philippe.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c
  2026-02-20 14:36   ` Jan Kiszka
  2026-02-20 14:46     ` Florian Bezdeka
@ 2026-02-27 11:56     ` Florian Bezdeka
  1 sibling, 0 replies; 37+ messages in thread
From: Florian Bezdeka @ 2026-02-27 11:56 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

On Fri, 2026-02-20 at 15:36 +0100, Jan Kiszka wrote:
> On 20.02.26 10:08, Florian Bezdeka wrote:
> > All COBALT_IMPL_TIME64() services will be moved afterwards - step by
> > step - into the newly introduced wrappers_time64.c. At the end that
> > should allow us to compile libcobalt with time64_t support leaving
> > the native time_t services in place.
> > 
> > Currently, all native time_t services are replaced by the 64 bit
> > variants. That is OK as long as applications are rebuild after
> > libcobalt, but we try to remove this limitation now.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  lib/cobalt/Makefile.am       | 3 ++-
> >  lib/cobalt/wrappers_time64.c | 6 ++++++
> >  2 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
> > index f461e570ed42a0d5cbc43eabb373c3c9edd83bad..17e203f9015fe2bb5306609e4d51c62f3a725780 100644
> > --- a/lib/cobalt/Makefile.am
> > +++ b/lib/cobalt/Makefile.am
> > @@ -43,7 +43,8 @@ libcobalt_la_SOURCES =		\
> >  	timerfd.c		\
> >  	trace.c			\
> >  	umm.c			\
> > -	wrappers.c
> > +	wrappers.c		\
> > +	wrappers_time64.c
> 
> 
> So, a should we do a wrapper_off64 for mmap, or put both into the same
> one? I don't have a good name for common one yet, though.
> 

Assuming we want to follow the same pattern as we do for the time64
series - both worlds provided within one libcobalt build:

At the end libcobalt has to provide two wrappers / symbols. One for
native and one for off64.

Linker magic (needed for __STD() and __RT() anyway) should do the
necessary routing.

As mmap() already resides in its own compile unit (which is fine, it's
not related to time64_t) we might follow the same implementation
pattern: Compile mmap.c twice, with different flags. Something similar
to the COBALT_IMPL_TIME64() macro would be needed - based on different
glibc / compile flag checks.

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2026-02-27 12:07 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-20  9:08 [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Florian Bezdeka
2026-02-20  9:08 ` [PATCH 01/20] lib/cobalt: Introduce cond.h Florian Bezdeka
2026-02-20 14:33   ` Jan Kiszka
2026-02-20  9:08 ` [PATCH 02/20] lib/cobalt: Introduce mutex.h Florian Bezdeka
2026-02-20  9:08 ` [PATCH 03/20] lib/cobalt: Introduce mq.h Florian Bezdeka
2026-02-20  9:08 ` [PATCH 04/20] lib/cobalt: Introduce rtdm.h Florian Bezdeka
2026-02-20  9:08 ` [PATCH 05/20] lib/cobalt: Introduce wrappers_time64.c Florian Bezdeka
2026-02-20 14:36   ` Jan Kiszka
2026-02-20 14:46     ` Florian Bezdeka
2026-02-20 14:47       ` Jan Kiszka
2026-02-27 11:56     ` Florian Bezdeka
2026-02-20  9:08 ` [PATCH 06/20] lib/cobalt: clock: Move all time64 related services to wrappers_time64.c Florian Bezdeka
2026-02-20  9:08 ` [PATCH 07/20] lib/cobalt: cond: " Florian Bezdeka
2026-02-20  9:08 ` [PATCH 08/20] lib/cobalt: mq: " Florian Bezdeka
2026-02-20  9:08 ` [PATCH 09/20] lib/cobalt: mutex: " Florian Bezdeka
2026-02-20  9:08 ` [PATCH 10/20] lib/cobalt: mutex: Provide time64 variant of pthread_timedmutex_lock_interruptible_np Florian Bezdeka
2026-02-20  9:08 ` [PATCH 11/20] lib/cobalt: rtdm: Move all time64 related services to wrappers_time64.c Florian Bezdeka
2026-02-20  9:08 ` [PATCH 12/20] lib/cobalt: select: Move select services into wrappers_time64.c Florian Bezdeka
2026-02-20 14:38   ` Jan Kiszka
2026-02-20 14:57     ` Florian Bezdeka
2026-02-20  9:08 ` [PATCH 13/20] lib/cobalt: semaphore: Move time64 related services to wrappers_time64.c Florian Bezdeka
2026-02-20  9:08 ` [PATCH 14/20] lib/cobalt: signal: " Florian Bezdeka
2026-02-20  9:08 ` [PATCH 15/20] lib/cobalt: timer: Move all " Florian Bezdeka
2026-02-20  9:08 ` [PATCH 16/20] lib/cobalt: timerfd: Move " Florian Bezdeka
2026-02-20  9:09 ` [PATCH 17/20] lib/cobalt: Move XN_USE_TIME64_SYSCALL " Florian Bezdeka
2026-02-20  9:09 ` [PATCH 18/20] lib/cobalt: Finally build the native time_t interfaces on top Florian Bezdeka
2026-02-20  9:09 ` [PATCH 19/20] lib/cobalt: thread: Cleanup and reorder includes Florian Bezdeka
2026-02-20  9:09 ` [PATCH 20/20] scripts/xeno-config: Allow disabling the y2038 / time64_t support Florian Bezdeka
2026-02-20 14:50   ` Jan Kiszka
2026-02-20 15:05     ` Florian Bezdeka
2026-02-20  9:28 ` [PATCH 00/20] y2038: libcobalt: Allow both, native + time64_t interfaces at the same time Philippe Gerum
2026-02-20  9:36   ` Jan Kiszka
2026-02-20 11:12     ` Philippe Gerum
2026-02-20 11:19       ` Florian Bezdeka
2026-02-20 15:06         ` Philippe Gerum
2026-02-20 11:20       ` Philippe Gerum
2026-02-20 11:49       ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.