Skip to contentSkip to conversation

time_t.3type: reference _TIME_BITS

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

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Sam James

author
#0 lore raw

PATCH v2 1/2 time_t.3type: reference _TIME_BITS

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 v2 2/2 feature_test_macros.7: document _TIME_BITS

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 | 13 +++++++++++++
 1 file changed, 13 insertions(+)
man7/feature_test_macros.7 +13 -0
index cdd962f7f..d33041001 100644
@@ -412,6 +412,15 @@ 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.
+.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 +863,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 v2 2/2] feature_test_macros.7: document _TIME_BITS

Hi Sam,

Quoted 12 lines · Sam James

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 | 13 +++++++++++++
  1 file changed, 13 insertions(+)
man7/feature_test_macros.7 +0 -0
index cdd962f7f..d33041001 100644

man7/feature_test_macros.7 large files with only a recompilation being required.) · line 420

Quoted 9 lines
man7/feature_test_macros.7 +6 -0
@@ -412,6 +412,15 @@ 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

Please use semantic newlines. See man-pages(7):

Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase bound‐ aries. This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences, clauses, or phrases.

That is: 's/2038. /2038.\n/'

man7/feature_test_macros.7 large files with only a recompilation being required.) · line 422

Quoted 2 lines
man7/feature_test_macros.7 +2 -0
+.B _FILE_OFFSET_BITS
+and depending on implementation, may require it set.

Am I understanding this right? _FILE_OFFSET_BITS is required to be set for _TIME_BITS to be also set (in some archs)? Could you please link directly to a source for that in the commit log? They are somewhat related, but I'm quite surprised that something to do with file sizes interferes at all with something to do with time.

Thanks,

Alex

Quoted 15 lines
man7/feature_test_macros.7 +5 -0
+.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 +863,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/>
author
#3 lore raw

Re: [PATCH v2 2/2] feature_test_macros.7: document _TIME_BITS

Quoted 30 lines · Alejandro Colomar

Hi Sam,

Quoted 11 lines · Sam James

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 | 13 +++++++++++++
 1 file changed, 13 insertions(+)
man7/feature_test_macros.7 +0 -0
index cdd962f7f..d33041001 100644

man7/feature_test_macros.7 large files with only a recompilation being required.) · line 420

Quoted 9 lines
man7/feature_test_macros.7 +6 -0
@@ -412,6 +412,15 @@ 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

Please use semantic newlines. See man-pages(7):

Quoted 10 lines

Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase bound‐ aries. This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences, clauses, or phrases.

Mea culpa -- let me read that over again :)

Quoted 7 lines

That is: 's/2038. /2038.\n/'

man7/feature_test_macros.7 large files with only a recompilation being required.) · line 422

Quoted 2 lines
man7/feature_test_macros.7 +2 -0
+.B _FILE_OFFSET_BITS
+and depending on implementation, may require it set.

Am I understanding this right? _FILE_OFFSET_BITS is required to be set for _TIME_BITS to be also set (in some archs)? Could you please link directly to a source for that in the commit log? They are somewhat related, but I'm quite surprised that something to do with file sizes interferes at all with something to do with time.

Yes, it's shocking, but true!

I'll add a reference -- but it's in /usr/include/features-time64.h:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/features-time64.h

Best,
sam

#4 lore raw

Re: [PATCH v2 2/2] feature_test_macros.7: document _TIME_BITS

Quoted 7 lines · Sam James
Quoted 2 lines

Am I understanding this right? _FILE_OFFSET_BITS is required to be set for _TIME_BITS to be also set (in some archs)? Could you please link directly to a source for that in the commit log? They are somewhat related, but I'm quite surprised that something to do with file sizes interferes at all with something to do with time.

Yes, it's shocking, but true!

I'll add a reference -- but it's in /usr/include/features-time64.h:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/features-time64.h

O.O Yes, it seems to also be in the glibc documentation. Weird.

Cheers,

Alex

Signature · 1 line
<http://www.alejandro-colomar.es/>
author
#5 lore raw

Re: [PATCH v2 2/2] feature_test_macros.7: document _TIME_BITS

Quoted 13 lines · Alejandro Colomar
Quoted 5 lines · Sam James
Quoted 2 lines

Am I understanding this right? _FILE_OFFSET_BITS is required to be set for _TIME_BITS to be also set (in some archs)? Could you please link directly to a source for that in the commit log? They are somewhat related, but I'm quite surprised that something to do with file sizes interferes at all with something to do with time.

Yes, it's shocking, but true!
I'll add a reference -- but it's in /usr/include/features-time64.h:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/features-time64.h

O.O Yes, it seems to also be in the glibc documentation. Weird.

You can imagine my surprise when I only hit this when something failed to compile with the #error...

#6 lore raw

Re: [PATCH v2 2/2] feature_test_macros.7: document _TIME_BITS

In reply to Sam James
Quoted 14 lines · Sam James
Quoted 13 lines

Please use semantic newlines. See man-pages(7):

Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase bound‐ aries. This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences, clauses, or phrases.

Quoted 1 line

Mea culpa -- let me read that over again :)

If you're curious, here you'll find a bit more about it:
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit?id=6ff6f43d68164f99a8c3fb66f4525d145571310c>

Cheers,

Alex

Signature · 1 line
<http://www.alejandro-colomar.es/>