unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file
@ 2020-02-14  9:17 Lukasz Majewski
  2020-02-14  9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-14  9:17 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Alistair Francis, Alistair Francis, GNU C Library,
	Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
	Carlos O'Donell, Andreas Schwab, Vineet Gupta,
	Lukasz Majewski

The struct __timespec64's definition has been moved from ./include/time.h to
./include/bits/types/struct___timespec64.h.

This change would prevent from polluting other glibc namespaces (when
headers are modified to support 64 bit time on architectures with
__WORDSIZE==32).

Now it is possible to just include definition of this particular structure
when needed.

---
Changes for v2:
- New patch - as suggested by Andreas Schwab
---
 include/bits/types/struct___timespec64.h | 26 ++++++++++++++++++++++++
 include/time.h                           | 24 +---------------------
 2 files changed, 27 insertions(+), 23 deletions(-)
 create mode 100644 include/bits/types/struct___timespec64.h

diff --git a/include/bits/types/struct___timespec64.h b/include/bits/types/struct___timespec64.h
new file mode 100644
index 0000000000..0c60f144c8
--- /dev/null
+++ b/include/bits/types/struct___timespec64.h
@@ -0,0 +1,26 @@
+#ifndef _TIMESPEC64_H
+#define _TIMESPEC64_H 1
+# if __TIMESIZE == 64
+#  define __timespec64 timespec
+# else
+# include <endian.h>
+/* The glibc Y2038-proof struct __timespec64 structure for a time value.
+   To keep things Posix-ish, we keep the nanoseconds field a 32-bit
+   signed long, but since the Linux field is a 64-bit signed int, we
+   pad our tv_nsec with a 32-bit unnamed bit-field padding.
+
+   As a general rule the Linux kernel is ignoring upper 32 bits of
+   tv_nsec field.  */
+struct __timespec64
+{
+  __time64_t tv_sec;         /* Seconds */
+#  if BYTE_ORDER == BIG_ENDIAN
+  __int32_t :32;             /* Padding */
+  __int32_t tv_nsec;         /* Nanoseconds */
+#  else
+  __int32_t tv_nsec;         /* Nanoseconds */
+  __int32_t :32;             /* Padding */
+#  endif
+};
+# endif
+#endif
diff --git a/include/time.h b/include/time.h
index bd0b74dbcc..5931f4854c 100644
--- a/include/time.h
+++ b/include/time.h
@@ -3,11 +3,11 @@
 
 #ifndef _ISOMAC
 # include <bits/types/struct_timeval.h>
+# include <bits/types/struct___timespec64.h>
 # include <bits/types/locale_t.h>
 # include <stdbool.h>
 # include <time/mktime-internal.h>
 # include <sys/time.h>
-# include <endian.h>
 # include <time-clockid.h>
 # include <sys/time.h>
 
@@ -61,28 +61,6 @@ extern void __tzset_parse_tz (const char *tz) attribute_hidden;
 extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
   __THROW attribute_hidden;
 
-#if __TIMESIZE == 64
-# define __timespec64 timespec
-#else
-/* The glibc Y2038-proof struct __timespec64 structure for a time value.
-   To keep things Posix-ish, we keep the nanoseconds field a 32-bit
-   signed long, but since the Linux field is a 64-bit signed int, we
-   pad our tv_nsec with a 32-bit unnamed bit-field padding.
-
-   As a general rule the Linux kernel is ignoring upper 32 bits of
-   tv_nsec field.  */
-struct __timespec64
-{
-  __time64_t tv_sec;         /* Seconds */
-# if BYTE_ORDER == BIG_ENDIAN
-  __int32_t :32;             /* Padding */
-  __int32_t tv_nsec;         /* Nanoseconds */
-# else
-  __int32_t tv_nsec;         /* Nanoseconds */
-  __int32_t :32;             /* Padding */
-# endif
-};
-#endif
 
 #if __TIMESIZE == 64
 # define __itimerspec64 itimerspec
-- 
2.20.1


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

end of thread, other threads:[~2020-03-04 11:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14  9:17 [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2020-02-14  9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
2020-02-24  9:15   ` Lukasz Majewski
2020-02-14  9:17 ` [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation Lukasz Majewski
2020-02-24  9:16   ` Lukasz Majewski
2020-02-24  9:17 ` [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2020-03-04 10:12   ` Andreas Schwab
2020-03-04 11:07     ` Lukasz Majewski

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).