[PATCH] y2038: Export struct __timespec64 (as ./bits/types/struct___timespec64.h)
Lukasz Majewski
lukma@denx.de
Wed Nov 11 15:50:58 GMT 2020
After this change the struct __timespec64 would be available as exported
(installed) header file. As a result - in-glibc copy could be removed
and just one instance would be used.
After this change it was also necessary to adjust #include paths for
struct___timespec64.h
Build tests:
./src/scripts/build-many-glibcs.py glibcs
---
A few questions regarding the above patch:
1. Is this approach acceptable?
2. I have had a question (posted to glibc-help) regarding the way headers are
exported/installed in glibc:
https://sourceware.org/pipermail/libc-help/2020-November/005549.html
3. Which approach shall be taken:
-- The one which adjusts struct_timespec.h with __USE_TIME_BITS64, so still
the struct timespec is used - as presented in:
https://github.com/lmajewski/y2038_glibc/commit/cc68c0498f82697e6f87418e148a19ded2d5aec7#diff-8297a1191cc06a8a7af6fc6ac33af4bef2d7d72efd901d1634d910b56631e0c7R13
or
-- The approach presented here - struct___timespec64.h is exported and
struct timespec is aliased (via #define) to struct __timespec64
It would be crucial to have the consensus sooner than latter as it determines
the work needed to provide patch enabling Y2038 support to glibc.
---
include/bits/types/struct___timespec64.h | 1 +
include/mqueue.h | 2 +-
include/signal.h | 2 +-
include/sys/select.h | 2 +-
include/sys/stat.h | 2 +-
include/time.h | 2 +-
inet/net-internal.h | 2 +-
login/logwtmp.c | 2 +-
nscd/nscd_helper.c | 2 +-
sysdeps/unix/sysv/linux/include/sys/sem.h | 2 +-
time/Makefile | 3 ++-
{include => time/bits/types}/struct___timespec64.h | 4 ++--
time/bits/types/struct_timespec.h | 5 +++++
13 files changed, 19 insertions(+), 12 deletions(-)
create mode 100644 include/bits/types/struct___timespec64.h
rename {include => time/bits/types}/struct___timespec64.h (92%)
diff --git a/include/bits/types/struct___timespec64.h b/include/bits/types/struct___timespec64.h
new file mode 100644
index 0000000000..5904500b5e
--- /dev/null
+++ b/include/bits/types/struct___timespec64.h
@@ -0,0 +1 @@
+#include <time/bits/types/struct___timespec64.h>
diff --git a/include/mqueue.h b/include/mqueue.h
index 98e4596c22..d2796ee086 100644
--- a/include/mqueue.h
+++ b/include/mqueue.h
@@ -10,7 +10,7 @@ extern __typeof (mq_timedreceive) __mq_timedreceive __nonnull ((2, 5));
hidden_proto (__mq_timedreceive)
hidden_proto (mq_setattr)
# endif
-#include <struct___timespec64.h>
+#include <bits/types/struct___timespec64.h>
#if __TIMESIZE == 64
# define __mq_timedsend_time64 __mq_timedsend
# define __mq_timedreceive_time64 __mq_timedreceive
diff --git a/include/signal.h b/include/signal.h
index 2a278697c1..545410c7d7 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -41,7 +41,7 @@ libc_hidden_proto (__sigwaitinfo)
#if __TIMESIZE == 64
# define __sigtimedwait64 __sigtimedwait
#else
-# include <struct___timespec64.h>
+# include <bits/types/struct___timespec64.h>
extern int __sigtimedwait64 (const sigset_t *__set, siginfo_t *__info,
const struct __timespec64 *__timeout);
libc_hidden_proto (__sigtimedwait64)
diff --git a/include/sys/select.h b/include/sys/select.h
index ec073deeba..ea25c7c181 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -7,7 +7,7 @@
# define __pselect64 __pselect
# define __select64 __select
#else
-# include <struct___timespec64.h>
+# include <bits/types/struct___timespec64.h>
# include <struct___timeval64.h>
extern int __pselect64 (int __nfds, fd_set *__readfds,
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 108cb0c9bf..8e6cc5ec74 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -3,7 +3,7 @@
#ifndef _ISOMAC
# include <xstatver.h>
-# include <struct___timespec64.h>
+# include <bits/types/struct___timespec64.h>
# include <struct_stat_time64.h>
# include <stdbool.h>
diff --git a/include/time.h b/include/time.h
index caf2af5e74..89170a1d3f 100644
--- a/include/time.h
+++ b/include/time.h
@@ -3,7 +3,7 @@
#ifndef _ISOMAC
# include <bits/types/struct_timeval.h>
-# include <struct___timespec64.h>
+# include <bits/types/struct___timespec64.h>
# include <struct___timeval64.h>
# include <bits/types/locale_t.h>
# include <stdbool.h>
diff --git a/inet/net-internal.h b/inet/net-internal.h
index 50c7e1c482..6bbc02fd79 100644
--- a/inet/net-internal.h
+++ b/inet/net-internal.h
@@ -24,7 +24,7 @@
#include <stdint.h>
#include <sys/time.h>
#include <libc-diag.h>
-#include <struct___timespec64.h>
+#include <bits/types/struct___timespec64.h>
int __inet6_scopeid_pton (const struct in6_addr *address,
const char *scope, uint32_t *result);
diff --git a/login/logwtmp.c b/login/logwtmp.c
index 050219c153..96066ea560 100644
--- a/login/logwtmp.c
+++ b/login/logwtmp.c
@@ -21,7 +21,7 @@
#include <time.h>
#include <unistd.h>
#include <utmp.h>
-#include <struct___timespec64.h>
+#include <bits/types/struct___timespec64.h>
void
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index 41c7937fcd..f40bcc7d7e 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -37,7 +37,7 @@
#include <not-cancel.h>
#include <kernel-features.h>
#include <nss.h>
-#include <struct___timespec64.h>
+#include <bits/types/struct___timespec64.h>
#include "nscd-client.h"
diff --git a/sysdeps/unix/sysv/linux/include/sys/sem.h b/sysdeps/unix/sysv/linux/include/sys/sem.h
index f369c6b6d3..41bc82fe55 100644
--- a/sysdeps/unix/sysv/linux/include/sys/sem.h
+++ b/sysdeps/unix/sysv/linux/include/sys/sem.h
@@ -9,7 +9,7 @@ __typeof__ (semtimedop) __semtimedop attribute_hidden;
# define __semctl64 __semctl
# define __semtimedop64 __semtimedop
#else
-# include <struct___timespec64.h>
+# include <bits/types/struct___timespec64.h>
extern int __semctl64 (int semid, int semnum, int cmd, ...);
libc_hidden_proto (__semctl64);
diff --git a/time/Makefile b/time/Makefile
index f27a75a115..4d0a10a193 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -27,7 +27,8 @@ headers := time.h sys/time.h sys/timeb.h bits/time.h \
bits/types/struct_itimerspec.h \
bits/types/struct_timespec.h bits/types/struct_timeval.h \
bits/types/struct_tm.h bits/types/timer_t.h \
- bits/types/time_t.h bits/types/struct_timeb.h
+ bits/types/time_t.h bits/types/struct_timeb.h \
+ bits/types/struct___timespec64.h
routines := offtime asctime clock ctime ctime_r difftime \
gmtime localtime mktime time \
diff --git a/include/struct___timespec64.h b/time/bits/types/struct___timespec64.h
similarity index 92%
rename from include/struct___timespec64.h
rename to time/bits/types/struct___timespec64.h
index 9abb25c8f7..ea164f9c41 100644
--- a/include/struct___timespec64.h
+++ b/time/bits/types/struct___timespec64.h
@@ -4,7 +4,7 @@
#if __TIMESIZE == 64
# define __timespec64 timespec
#else
-#include <endian.h>
+#include <bits/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
@@ -15,7 +15,7 @@
struct __timespec64
{
__time64_t tv_sec; /* Seconds */
-# if BYTE_ORDER == BIG_ENDIAN
+# if __BYTE_ORDER == __BIG_ENDIAN
__int32_t :32; /* Padding */
__int32_t tv_nsec; /* Nanoseconds */
# else
diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index d11c69cfd3..bf0ee6c410 100644
--- a/time/bits/types/struct_timespec.h
+++ b/time/bits/types/struct_timespec.h
@@ -4,6 +4,7 @@
#include <bits/types.h>
#include <bits/endian.h>
+#include <bits/types/time_t.h>
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
@@ -25,4 +26,8 @@ struct timespec
#endif
};
+# if __TIMESIZE == 32 && defined __USE_TIME_BITS64
+# include <bits/types/struct___timespec64.h>
+# define timespec __timespec64
+# endif
#endif
--
2.20.1
More information about the Libc-alpha
mailing list