]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
time: Add padding for the timespec if required
authorAlistair Francis <alistair.francis@wdc.com>
Wed, 18 Sep 2019 23:51:23 +0000 (16:51 -0700)
committerAlistair Francis <alistair.francis@wdc.com>
Tue, 1 Oct 2019 21:56:06 +0000 (14:56 -0700)
If we are running on a 32-bit system with a 64-bit time_t we need to
ensure there is padding around the tv_nsec variable. This is requried as
the timespec is #defined to the __timespec64 struct.

* time/bits/types/struct_timespec.h: Add padding for the timespec if
required.

ChangeLog
time/bits/types/struct_timespec.h

index 17ff0ade2cd8e0aa44d76826920d7e2520a57cfc..23dc785f30e99ce2338439da21a1bf984191c4d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-01  Alistair Francis  <alistair.francis@wdc.com>
+
+        * time/bits/types/struct_timespec.h: Add padding for the timespec if
+       required.
+
 2019-10-01  Zack Weinberg  <zackw@panix.com>
            Alistair Francis <alistair.francis@wdc.com>
 
index 5b77c52b4f005701b1b91ded0b4edbe3520b1eb1..d11c69cfd320581285eb12941e69382c2c6544b7 100644 (file)
@@ -3,13 +3,26 @@
 #define _STRUCT_TIMESPEC 1
 
 #include <bits/types.h>
+#include <bits/endian.h>
 
 /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
    has nanoseconds instead of microseconds.  */
 struct timespec
 {
   __time_t tv_sec;             /* Seconds.  */
+#if __WORDSIZE == 64 \
+  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
+  || __TIMESIZE == 32
   __syscall_slong_t tv_nsec;   /* Nanoseconds.  */
+#else
+# if __BYTE_ORDER == __BIG_ENDIAN
+  int: 32;           /* Padding.  */
+  long int tv_nsec;  /* Nanoseconds.  */
+# else
+  long int tv_nsec;  /* Nanoseconds.  */
+  int: 32;           /* Padding.  */
+# endif
+#endif
 };
 
 #endif