[PATCH 18/20] lib/cobalt: Finally build the native time_t interfaces on top

Florian Bezdeka <[email protected]>
Newsgroups dev.linux.lists.xenomai
Message-ID <20260220-wip-flo-fix-time64-32bit-native-v1-18-731c773e72cc@siemens.com>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.