about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2019-09-18 16:51:23 -0700
committerAlistair Francis <alistair.francis@wdc.com>2019-10-01 14:56:06 -0700
commit69fd157a3dedf6c924c19738961083e80422258d (patch)
treed92171b4993e3ae4291a00d46da71c8096c9205a
parentaa706e13f4bfdf32a27c498902edf4f6006e433e (diff)
downloadglibc-69fd157a3dedf6c924c19738961083e80422258d.tar.gz
glibc-69fd157a3dedf6c924c19738961083e80422258d.tar.xz
glibc-69fd157a3dedf6c924c19738961083e80422258d.zip
time: Add padding for the timespec if required
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.
-rw-r--r--ChangeLog5
-rw-r--r--time/bits/types/struct_timespec.h13
2 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 17ff0ade2c..23dc785f30 100644
--- 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>
 
diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index 5b77c52b4f..d11c69cfd3 100644
--- a/time/bits/types/struct_timespec.h
+++ b/time/bits/types/struct_timespec.h
@@ -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