Skip to contentSkip to conversation

time_t.3type: reference _TIME_BITS (time64)

PATCH In review Sam James 2 participants 4 messages Oct 13, 2022 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

Sam James

author
#0 lore raw

PATCH v3 1/2 time_t.3type: reference _TIME_BITS (time64)

Just like we do with _FILE_OFFSET_BITS in off_t.3type.

Reference: https://wiki.gentoo.org/wiki/Project:Toolchain/time64_migration
Reference: https://sourceware.org/pipermail/libc-alpha/2022-January/134985.html

---
 man3type/time_t.3type | 6 ++++++
 1 file changed, 6 insertions(+)
man3type/time_t.3type +6 -0
index d40dd0c0d..9b8f07356 100644
@@ -70,6 +70,12 @@ POSIX.1-2001 and later.
 POSIX.1-2001 and later.
 .PD
 .SH NOTES
+On some architectures,
+the width of
+.I time_t
+can be controlled with the feature test macro
+.BR _TIME_BITS .
+.PP
 .TP
 .I time_t
 The following headers also provide
Signature · 1 line
2.38.0
author
#1 lore raw

PATCH v3 2/2 feature_test_macros.7: document _TIME_BITS (time64)

Some notes:
* glibc is the only libc I'm aware of implementing _TIME_BITS for time64 compatibility. It was introduced in glibc-2.34;

* musl libc made a hard switch in 1.2.0, see https://musl.libc.org/time64.html;

* Using _TIME_BITS=64 with glibc requires _FILE_OFFSET_BITS=64 (which is used for Large File Support)! Extraordinary claims require (some) evidence, so see
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/features-time64.h;h=84d56ee3ff2ecfa0d2499385623f30606f84a1bf.

Reference: https://wiki.gentoo.org/wiki/Project:Toolchain/time64_migration
Reference: https://sourceware.org/pipermail/libc-alpha/2022-January/134985.html

---
 man7/feature_test_macros.7 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
man7/feature_test_macros.7 +15 -0
index cdd962f7f..bcd6e6ae9 100644
@@ -412,6 +412,17 @@ large files with only a recompilation being required.)
 64-bit systems naturally permit file sizes greater than 2 Gigabytes,
 and on those systems this macro has no effect.
 .TP
+.B _TIME_BITS
+Defining this macro with the value 64
+changes the width of
+.BR time_t (3type)
+to 64-bit which allows handling of timestamps beyond
+2038.
+It is closely related to
+.B _FILE_OFFSET_BITS
+and depending on implementation, may require it set.
+This macro is available as of glibc 2.34.
+.TP
 .BR _BSD_SOURCE " (deprecated since glibc 2.20)"
 Defining this macro with any value causes header files to expose
 BSD-derived definitions.
@@ -854,6 +865,10 @@ main(int argc, char *argv[])
     printf("_FILE_OFFSET_BITS defined: %d\en", _FILE_OFFSET_BITS);
 #endif
 
+#ifdef _TIME_BITS
+    printf("_TIME_BITS defined: %d\en", _TIME_BITS);
+#endif
+
 #ifdef _BSD_SOURCE
     printf("_BSD_SOURCE defined\en");
 #endif
Signature · 1 line
2.38.0
#2 lore raw

Re: [PATCH v3 2/2] feature_test_macros.7: document _TIME_BITS (time64)

Quoted 6 lines · Sam James

Some notes:
* glibc is the only libc I'm aware of implementing _TIME_BITS for time64 compatibility. It was introduced in glibc-2.34;

* musl libc made a hard switch in 1.2.0, see https://musl.libc.org/time64.html;

Quoted 7 lines

* Using _TIME_BITS=64 with glibc requires _FILE_OFFSET_BITS=64 (which is used for Large File Support)! Extraordinary claims require (some) evidence, so see
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/features-time64.h;h=84d56ee3ff2ecfa0d2499385623f30606f84a1bf.

Reference: https://wiki.gentoo.org/wiki/Project:Toolchain/time64_migration
Reference: https://sourceware.org/pipermail/libc-alpha/2022-January/134985.html

Patch applied.

Thanks,
Alex

Quoted 37 lines
---
  man7/feature_test_macros.7 | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
man7/feature_test_macros.7 +15 -0
index cdd962f7f..bcd6e6ae9 100644
@@ -412,6 +412,17 @@ large files with only a recompilation being required.)
  64-bit systems naturally permit file sizes greater than 2 Gigabytes,
  and on those systems this macro has no effect.
  .TP
+.B _TIME_BITS
+Defining this macro with the value 64
+changes the width of
+.BR time_t (3type)
+to 64-bit which allows handling of timestamps beyond
+2038.
+It is closely related to
+.B _FILE_OFFSET_BITS
+and depending on implementation, may require it set.
+This macro is available as of glibc 2.34.
+.TP
  .BR _BSD_SOURCE " (deprecated since glibc 2.20)"
  Defining this macro with any value causes header files to expose
  BSD-derived definitions.
@@ -854,6 +865,10 @@ main(int argc, char *argv[])
      printf("_FILE_OFFSET_BITS defined: %d\en", _FILE_OFFSET_BITS);
  #endif
 
+#ifdef _TIME_BITS
+    printf("_TIME_BITS defined: %d\en", _TIME_BITS);
+#endif
+
  #ifdef _BSD_SOURCE
      printf("_BSD_SOURCE defined\en");
  #endif
Signature · 1 line
<http://www.alejandro-colomar.es/>
#3 lore raw
In reply to Sam James
Quoted 5 lines · Sam James

Just like we do with _FILE_OFFSET_BITS in off_t.3type.

Reference: https://wiki.gentoo.org/wiki/Project:Toolchain/time64_migration
Reference: https://sourceware.org/pipermail/libc-alpha/2022-January/134985.html

Patch applied.

Thanks,
Alex

Quoted 9 lines
---
  man3type/time_t.3type | 6 ++++++
  1 file changed, 6 insertions(+)
man3type/time_t.3type +0 -0
index d40dd0c0d..9b8f07356 100644

man3type/time_t.3type POSIX.1-2001 and later. · line 78

Quoted 9 lines
man3type/time_t.3type +6 -0
@@ -70,6 +70,12 @@ POSIX.1-2001 and later.
  POSIX.1-2001 and later.
  .PD
  .SH NOTES
+On some architectures,
+the width of
+.I time_t
+can be controlled with the feature test macro
+.BR _TIME_BITS .
+.PP

This .PP was unnecessary, so I removed it. Both PP and TP are paragraphing macros. TP does what PP does and more. See groff_man(7).

Quoted 3 lines
man3type/time_t.3type +0 -0
  .TP
  .I time_t
  The following headers also provide
Signature · 1 line
<http://www.alejandro-colomar.es/>