public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [RFC] y2038: test: Add _Static_assert() check when __USE_TIME_BITS64 is defined
@ 2020-12-09 14:53 Lukasz Majewski
  2020-12-10  0:42 ` Paul Eggert
  0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Majewski @ 2020-12-09 14:53 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Alistair Francis, Arnd Bergmann, Alistair Francis, GNU C Library,
	Florian Weimer, Carlos O'Donell, Stepan Golosunov,
	Andreas Schwab, Zack Weinberg, Siddhesh Poyarekar,
	Lukasz Majewski

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


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

end of thread, other threads:[~2020-12-15 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 14:53 [RFC] y2038: test: Add _Static_assert() check when __USE_TIME_BITS64 is defined Lukasz Majewski
2020-12-10  0:42 ` Paul Eggert
2020-12-13 11:48   ` Lukasz Majewski
2020-12-15 18:54     ` Paul Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).