This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 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: Fri, 27 Sep 2019 16:41:33 -0700
- Subject: [PATCH v2 2/2] time: Add padding for the timespec if required
- Ironport-sdr: fsS4z3W6uTi6gSJrs+E5yrij1cEOSZPFVwwQhfVYUQKXmZqq6JNuIY8J8Dv5iFtolACzciRGPY HGFEkILJ13a2eTrsc5OHiX2dOrSxCpTm0r0Y9EFk/pOMk0Kmfr9rkjXtsCCCi29i3DhhtytvA3 gtEWNkfMXKM/pj8/XTz4dmzonxErMYegUnx6lGf5XlBKdK2EWDnGo5up2D/rhhapPSKrGvaDjO HLuHlnrHFMW4LkThCVj7laWjjyC7fiwHBmIe+tiC4W+/k1nssupRTNsENl0WlcVAEMTzjY263j gIM=
- Ironport-sdr: B+ByoAo2GRSFawpkHwL4HttZpl7j3thY21LiwR5MU5FV4ZEsAcGrdPUdSU6bIwl8ReHgIX9k4X VPZUcoV6zz7QATlS1dAeuS49mlLLxOp4Oh97H6fT0SfxD8AWbxmy8Q5D1Dai3iShvNlNv+nA8T mai1ScsiopkQTkAz3ifnu5HYBiSyrXNiM2KRVRHFAD5O9pZo6LZSPgW3eKnDtvzrIWBovRcbwe Jl5jzi3xd8yDbtbG/Fe5nz9QrHgp8yZ+BRuPL2OTfKgZQZS5SWzJ7jnghMyoMfyLf6OviKG2S+ k5ES0cGfWGOGzNm9HUqsfJNi
- Ironport-sdr: VGqzRl1L9PX8spdvTP9WSuhZfdvvp33UUpaMxAIz0STxbu5w7c42cHGGRftQnQ1sOek8a3MNhL dqYhlkl+jcy10Cb8CzHuucny2tdTEzZUSz58U5vppvZeEHyLmSzh+BEJd+tbtoSZVypzVA8NhY 9RMj2I50whkDRhfQYc4yCCoP72RlsmQTc1/rQ9oeGxjGEDCCLvKHBbt4Av52+1uhfwZNvQDA2/ HrmJmB4J5lFOpApUbAunvi1V4cJjC30C0kkDTG1yWJiSQzPKo+xV/OdOlH6q54qsvIrljW47TZ Tp4=
- References: <20190927234133.1046-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.
---
v2:
- Fix style issues
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..d11c69cfd32 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