[RFC,v2,2/2] sys/types.h: struct timespec: Use snseconds_t for tv_nsec
Commit Message
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(-)
@@ -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
};