public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@wdc.com>
To: libc-alpha@sourceware.org
Cc: alistair23@gmail.com, Alistair Francis <alistair.francis@wdc.com>
Subject: [PATCH 2/2] time: Add padding for the timespec if required
Date: Wed, 25 Sep 2019 00:33:00 -0000	[thread overview]
Message-ID: <20190925002903.15928-2-alistair.francis@wdc.com> (raw)
In-Reply-To: <20190925002903.15928-1-alistair.francis@wdc.com>

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

  reply	other threads:[~2019-09-25  0:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25  0:33 [PATCH 1/2] Split up endian.h to minimize exposure of BYTE_ORDER Alistair Francis
2019-09-25  0:33 ` Alistair Francis [this message]
2019-09-25  0:57   ` [PATCH 2/2] time: Add padding for the timespec if required Joseph Myers
2019-09-25  1:02     ` Alistair Francis
2019-09-25  9:50       ` Lukasz Majewski
2019-09-25 16:24         ` Joseph Myers
2019-09-25 20:05           ` Lukasz Majewski
2019-09-25  7:34 ` [PATCH 1/2] Split up endian.h to minimize exposure of BYTE_ORDER Andreas Schwab
2019-09-25 22:54   ` Alistair Francis
2019-09-26  7:02     ` Andreas Schwab
2019-09-27  0:56       ` Alistair Francis
2019-09-27 15:38         ` Joseph Myers
2019-09-27 21:40           ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190925002903.15928-2-alistair.francis@wdc.com \
    --to=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).