This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/2] time: Add padding for the timespec if required
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: alistair23 at gmail dot com, Alistair Francis <alistair dot francis at wdc dot com>
- Date: Tue, 24 Sep 2019 17:29:03 -0700
- Subject: [PATCH 2/2] time: Add padding for the timespec if required
- Ironport-sdr: 0PkGYiRTuJFsNEZKGGhXS+AlZPVaQwhoxwQW20xlGb62veNoGzRsTgozMSbZK1+aI0wUFQnP3n 2gwnHVnghWcmStvgPpiU5nHIgpfJHMGSofS85z+lyj3URIkYphSZ3B/XFsfWz8dzxq8VtJ9Jcd 1Qc+AHucDNEzwoK3LLIFtID/XeCP7EWl4PJ1y0tnaeIC3VcK2Q6jGuJ6nLmHOIfVDrnTGK8cbO 7BPGC7miRgRZPBYYIWEFYtauQJ1Cu3IRT0e870Snbjx0CPg8rSWThAge6f65cPDxkQ0bm6CfoT An0=
- Ironport-sdr: ceEgPThRQy9V+xsFv/z5vHAx5giae8FzTddbdBqqhoOGz+KU92Z8g8TQN7htmVVBu5VdKdNNQK pmfvAB8vxzAGP1oNGgRpLLY7vQV/wxmN38sVY6qN4LuRsdn+ttODWgv71oOj4NE9WsXyxZejZ2 uSwc3S2OYQUKvlLfD1zDiRC2lsWDfKRPSKOHSpJpMzeztdDWZI/1HZlHw3+kVSXJgRyyObOeSl RK5lWk9G8Lk/9Uk42HGHmcoRJG5fNr+Zhv1Dk9ZjhJBGFzh/Ya9hcPfdrxqKMdcNLRes5SJf/6 qd1N8/WZvj5u41j1P33ihlRG
- Ironport-sdr: Gz3F3oyU7LCYXVWvqDrRwGs6HX1cjeoUXqa1Uu3ddSjjfosG47Y8Fyw3t6viZfGXSXMRdzokXm gskM0leKWvDiMYouYBJOVz92yp48rYBN2GSr//lEaTeAKZ3p4gOtcv2N5MIBsT1rs40qscV9FG NV0N7Uw0cnYS8X8djQUkm3GjT8brqpgEG8Yzo9aAvNq3v3/IfX6nC9mHB/k5Gp001935SUXaM+ Ejt5FHxeGR8z/vfKTnEqOrSOVF+sI87ZaaJqpA8+RM8KEbf4GokPDCvWlxI1Bm5hn1LagGobVd HME=
- References: <20190925002903.15928-1-alistair.francis@wdc.com>
- Wdcironportexception: Internal
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.
2019-09-20 Alistair Francis <alistair.francis@wdc.com>
* time/bits/types/struct_timespec.h: Add padding for the timespec if
required.
---
This change was tested by running user space tests on RV32.
time/bits/types/struct_timespec.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index 5b77c52b4f0..fd6087955ac 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
--
2.23.0