y2038: Export struct __timespec64 (as ./bits/types/struct___timespec64.h)
Commit Message
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%)
Comments
On Nov 11 2020, Lukasz Majewski wrote:
> @@ -25,4 +26,8 @@ struct timespec
> #endif
> };
>
> +# if __TIMESIZE == 32 && defined __USE_TIME_BITS64
> +# include <bits/types/struct___timespec64.h>
> +# define timespec __timespec64
I don't think the implementation is allowed to define that macro.
Andreas.
Hi Andreas,
> On Nov 11 2020, Lukasz Majewski wrote:
>
> > @@ -25,4 +26,8 @@ struct timespec
> > #endif
> > };
> >
> > +# if __TIMESIZE == 32 && defined __USE_TIME_BITS64
> > +# include <bits/types/struct___timespec64.h>
> > +# define timespec __timespec64
>
> I don't think the implementation is allowed to define that macro.
This one shall be added when __USE_TIME_BITS64 is defined and enabled
in the glibc. This would be done in the patch, which adds y2038 support.
I've added it here to show my idea on exporting struct __timespec64 and
using it afterwards in Y2038 code.
I'm just wondering if # define timespec __timespec64 will not clash
with POSIX... (build-many-glibc.py and make check seems to be correct).
>
> Andreas.
>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
new file mode 100644
@@ -0,0 +1 @@
+#include <time/bits/types/struct___timespec64.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
@@ -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)
@@ -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,
@@ -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>
@@ -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>
@@ -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);
@@ -21,7 +21,7 @@
#include <time.h>
#include <unistd.h>
#include <utmp.h>
-#include <struct___timespec64.h>
+#include <bits/types/struct___timespec64.h>
void
@@ -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"
@@ -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);
@@ -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 \
similarity index 92%
rename from include/struct___timespec64.h
rename to 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
@@ -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