All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] timespec.3type: tv_nsec is impl-def-type, glibc llong not a bug
@ 2023-01-28 14:17 наб
  2023-01-28 14:17 ` [PATCH 2/3] clock_getres.2, clock_getcpuclockid.3, pthread_getcpuclockid.3: fix tv_nsec formatting наб
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: наб @ 2023-01-28 14:17 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

[-- Attachment #1: Type: text/plain, Size: 2818 bytes --]

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>
---
This is in many ways a followup to the patchset that originally added
the BUGS sexion to timespec.3type, root msgid of
  <ec1dcc655184f6cdaae40ff8b7970b750434e4ef.1638123425.git.nabijaczleweli@nabijaczleweli.xyz>

For ease of reference, n3066:
  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3066.pdf
and the relevant part of n3091 (screenshot, it's a .doc):
  https://cohost.org/nabijaczleweli/post/922578-pog-pog

2/3 and 3/3 only span the pages that matched git grep -l tv_nsec,
but that should be most of the relevant ones

 man3type/timespec.3type | 46 +++++++++++++----------------------------
 1 file changed, 14 insertions(+), 32 deletions(-)

diff --git a/man3type/timespec.3type b/man3type/timespec.3type
index 7cd80ce86..ca5533814 100644
--- a/man3type/timespec.3type
+++ b/man3type/timespec.3type
@@ -16,14 +16,27 @@ Standard C library
 .PP
 .B struct timespec {
 .BR "    time_t  tv_sec;" "   /* Seconds */"
-.BR "    long    tv_nsec;" "  /* Nanoseconds [" 0 ", " 999999999 "] */"
+.BR "    /*\(da*/   tv_nsec;" "  /* Nanoseconds [" 0 ", " 999999999 "] */"
 .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 safely be down-cast to any concrete 32-bit integer type for processing.
 .SH STANDARDS
 C11 and later;
 POSIX.1-2001 and later.
+Prior to C23
+.I tv_nsec
+was
+.IR long .
 .SH NOTES
 The following headers also provide this type:
 .IR <aio.h> ,
@@ -33,37 +46,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),
-- 
2.30.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-02-05 16:09 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28 14:17 [PATCH 1/3] timespec.3type: tv_nsec is impl-def-type, glibc llong not a bug наб
2023-01-28 14:17 ` [PATCH 2/3] clock_getres.2, clock_getcpuclockid.3, pthread_getcpuclockid.3: fix tv_nsec formatting наб
2023-01-28 14:17 ` [PATCH 3/3] man2/clock_getres.2, man2/clock_nanosleep.2, man2/nanosleep.2, man2/timer_settime.2, man2/timerfd_create.2, man2/utimensat.2, man3/mq_send.3, man3/pthread_tryjoin_np.3, man3/sem_wait.3: standardise on "range [0, 999999999]" for tv_nsec наб
2023-01-29 15:48 ` [PATCH 1/3] timespec.3type: tv_nsec is impl-def-type, glibc llong not a bug Alejandro Colomar
2023-01-29 16:29   ` наб
2023-01-29 16:31     ` [PATCH v2 " наб
2023-01-29 16:41       ` Alejandro Colomar
2023-01-30  2:05         ` наб
2023-01-30 12:56           ` Alejandro Colomar
2023-01-29 16:31     ` [PATCH v2 2/3] clock_getres.2, clock_getcpuclockid.3, pthread_getcpuclockid.3: fix tv_nsec formatting наб
2023-01-29 16:31     ` [PATCH v2 3/3] man2/clock_getres.2, man2/clock_nanosleep.2, man2/nanosleep.2, man2/timer_settime.2, man2/timerfd_create.2, man2/utimensat.2, man3/mq_send.3, man3/pthread_tryjoin_np.3, man3/sem_wait.3: standardise on "range [0, 999\(aq999\(aq999]" for tv_nsec наб
2023-01-30  7:08   ` [PATCH 1/3] timespec.3type: tv_nsec is impl-def-type, glibc llong not a bug Jakub Wilk
2023-01-30 13:15     ` Alejandro Colomar
2023-01-30 13:50       ` G. Branden Robinson
2023-01-30 13:54         ` Alejandro Colomar
2023-01-30 19:47           ` Brian Inglis
2023-01-30 18:38       ` [PATCH v3 " наб
2023-02-05 15:39         ` Alejandro Colomar
2023-02-05 15:49           ` наб
2023-02-05 16:09             ` Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.