diff options
author | наб <nabijaczleweli@nabijaczleweli.xyz> | 2023-01-30 19:38:35 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2023-02-05 17:07:09 +0100 |
commit | 734db27a2a4b1c3c39430910aaf426771704369b (patch) | |
tree | db6109461c6866a165635f10376ed31f7f69cc62 /man3type | |
parent | 9c7080027acecc01ee7c18641ec5be53f43cb3dc (diff) |
timespec.3type: tv_nsec is impl-def-type, glibc llong not a bug
n3091 accepts n3066, making it part of the next working draft and C23:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3091.doc
Update timespec.3type appropriately, largely mirroring my paper.
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man3type')
-rw-r--r-- | man3type/timespec.3type | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/man3type/timespec.3type b/man3type/timespec.3type index 7cd80ce86..c3c69cfd2 100644 --- a/man3type/timespec.3type +++ b/man3type/timespec.3type @@ -15,15 +15,30 @@ Standard C library .B #include <time.h> .PP .B struct timespec { -.BR " time_t tv_sec;" " /* Seconds */" -.BR " long tv_nsec;" " /* Nanoseconds [" 0 ", " 999999999 "] */" +.BR " time_t tv_sec;" " /* Seconds */" +.RB " /* ... */" " tv_nsec;" \ +" /* Nanoseconds [" 0 ", " 999\[aq]999\[aq]999 "] */" .B }; .EE .SH DESCRIPTION Describes times in seconds and nanoseconds. +.PP +.I tv_nsec +is of an implementation-defined signed type capable of holding the specified range. +Under glibc, this is usually +.IR long , +and +.I long long +on X32. +It can be safely down-cast to any concrete 32-bit integer type for processing. .SH STANDARDS C11 and later; POSIX.1-2001 and later. +.SH VERSIONS +Prior to C23, +.I tv_nsec +was +.IR long . .SH NOTES The following headers also provide this type: .IR <aio.h> , @@ -33,37 +48,6 @@ The following headers also provide this type: .IR <sys/select.h> , and .IR <sys/stat.h> . -.SH BUGS -Under glibc, -.I tv_nsec -is the -.I syscall -long, -though this affects only fringe architectures like X32, -which is ILP32, but uses the LP64 AMD64 syscall ABI. -In reality, the field ends up being defined as: -.PP -.in +4n -.EX -#if __x86_64__ && __ILP32__ /* == x32 */ - long long tv_nsec; -#else - long tv_nsec; -#endif -.EE -.in -.PP -This is a long-standing and long-enshrined glibc bug -.UR https://sourceware.org/bugzilla/show_bug.cgi?id=16437 -.I #16437 -.UE , -and an incompatible extension to the standards; -however, as even a 32-bit -.I long -can hold the entire -.I tv_nsec -range, -it's always safe to forcibly down-cast it to the standard type. .SH SEE ALSO .BR clock_gettime (2), .BR clock_nanosleep (2), |