diff mbox series

[RFC,v2,2/2] sys/types.h: struct timespec: Use snseconds_t for tv_nsec

Message ID 20211207220535.19228-1-alx.manpages@gmail.com
State New
Headers show
Series sys/types.h: Define new types: [s]nseconds_t | expand

Commit Message

Alejandro Colomar Dec. 7, 2021, 10:05 p.m. UTC
The timespec(3) structure uses long for tv_nsec,
except if __x86_64__ && __ILP32__,
in which case it uses long long.
Let's use a stable type that can be relied upon by users,
for example for creating pointers.

Link: linux-man <https://lore.kernel.org/linux-man/ec1dcc655184f6cdaae40ff8b7970b750434e4ef.1638123425.git.nabijaczleweli@nabijaczleweli.xyz/T/>
Link: glibc <https://sourceware.org/pipermail/libc-alpha/2021-December/133702.html>
Cc: наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: Jakub Wilk <jwilk@jwilk.net>
Cc: Zack Weinberg <zackw@panix.com>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Cc: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: Joseph Myers <joseph@codesourcery.com>
Cc: Rich Felker <dalias@libc.org>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 time/bits/types/struct_timespec.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index 489e81136d..33dda4db2a 100644
--- a/time/bits/types/struct_timespec.h
+++ b/time/bits/types/struct_timespec.h
@@ -18,14 +18,14 @@  struct timespec
 #if __WORDSIZE == 64 \
   || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
   || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
-  __syscall_slong_t tv_nsec;	/* Nanoseconds.  */
+  __snseconds_t tv_nsec;  /* Nanoseconds.  */
 #else
 # if __BYTE_ORDER == __BIG_ENDIAN
-  int: 32;           /* Padding.  */
-  long int tv_nsec;  /* Nanoseconds.  */
+  int: 32;                /* Padding.  */
+  __snseconds_t tv_nsec;  /* Nanoseconds.  */
 # else
-  long int tv_nsec;  /* Nanoseconds.  */
-  int: 32;           /* Padding.  */
+  __snseconds_t tv_nsec;  /* Nanoseconds.  */
+  int: 32;                /* Padding.  */
 # endif
 #endif
 };