This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] y2038: linux: Provide __mq_timedsend_time64 implementation
- From: Andreas Schwab <schwab at suse dot de>
- To: Lukasz Majewski <lukma at denx dot de>
- Cc: Joseph Myers <joseph at codesourcery dot com>, Paul Eggert <eggert at cs dot ucla dot edu>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Alistair Francis <alistair23 at gmail dot com>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Siddhesh Poyarekar <siddhesh at gotplt dot org>, Florian Weimer <fweimer at redhat dot com>, Florian Weimer <fw at deneb dot enyo dot de>, Zack Weinberg <zackw at panix dot com>, Carlos O'Donell <carlos at redhat dot com>
- Date: Wed, 12 Feb 2020 14:56:29 +0100
- Subject: Re: [PATCH 1/2] y2038: linux: Provide __mq_timedsend_time64 implementation
- References: <20200211165256.21848-1-lukma@denx.de> <mvmmu9pcade.fsf@suse.de> <20200212101835.2f33c2eb@jawa> <mvma75ocdkq.fsf@suse.de> <20200212113736.509a7537@jawa> <mvm5zgcccfv.fsf@suse.de> <20200212123109.3623f3d2@jawa> <mvm1rr0c9j8.fsf@suse.de> <20200212141937.1a291d02@jawa>
On Feb 12 2020, Lukasz Majewski wrote:
> I've added the struct __timespec64 definition to
> ./include/bits/struct/timespec.h
>
>
> and I had build errors on ./include/time.h which uses struct
> __timespec64 massively.
> It requires explicit adding of #include
> <include/bits/struct/timespec.h> or <bits/struct/timespec.h>
This works for me:
diff --git a/include/bits/types/struct_timespec.h b/include/bits/types/struct_timespec.h
index c27417cfd5..de1cf44311 100644
--- a/include/bits/types/struct_timespec.h
+++ b/include/bits/types/struct_timespec.h
@@ -1 +1,30 @@
+#ifndef _STRUCT_TIMESPEC
#include <time/bits/types/struct_timespec.h>
+
+#ifndef _ISOMAC
+# include <endian.h>
+# 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
+#endif
+
+#endif
diff --git a/include/time.h b/include/time.h
index 73f66277ac..f806bd8f0f 100644
--- a/include/time.h
+++ b/include/time.h
@@ -6,7 +6,6 @@
# include <bits/types/locale_t.h>
# include <stdbool.h>
# include <time/mktime-internal.h>
-# include <endian.h>
# include <time-clockid.h>
# include <sys/time.h>
@@ -60,29 +59,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
#else
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."