[RFC] y2038: test: Add _Static_assert() check when __USE_TIME_BITS64 is defined
Lukasz Majewski
lukma@denx.de
Wed Dec 9 14:53:31 GMT 2020
This check is added to exported time/time.h file to check in the compile
time if time_t and struct timespec have proper sizes and alignment.
It shall prevent from compiling user programs with -D_TIME_BITS=64 when
time related data structures are not supporting 64 bit time.
---
time/time.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/time/time.h b/time/time.h
index 9a74f01b2f..d293ff3dc5 100644
--- a/time/time.h
+++ b/time/time.h
@@ -446,4 +446,12 @@ extern int getdate_r (const char *__restrict __string,
__END_DECLS
+#define CHECK_TIME64_SIZE(__name, __len) \
+ _Static_assert (sizeof (__name) == __len, "Size of " #__name " != " #__len)
+
+#ifdef __USE_TIME_BITS64
+ CHECK_TIME64_SIZE(time_t, 8);
+ CHECK_TIME64_SIZE(struct timespec, 16);
+#endif
+
#endif /* time.h. */
--
2.20.1
More information about the Libc-alpha
mailing list