man/man2/adjtimex.2: Add include, macro and error for clock_adjtime
PATCH 1/1 man/man2/adjtimex.2: Add include, macro and error for clock_adjtime
GNU libc declares clock_adjtime() when including time.h, and not when just sys/timex.h is included, iff support for GNU features is requested.
Verification:
$ for i in BLAH _GNU_SOURCE; do for j in sys/timex.h time.h; do echo -n "Testing $i and $j ... "; echo -e '#define '"$i"'\n#include <'"$j"'>\nvoid f(){clock_adjtime;}' | gcc -xc - -o /dev/null -c 2>/dev/null && echo OK || echo FAIL; done; done
Testing BLAH and sys/timex.h ... FAIL
Testing BLAH and time.h ... FAIL
Testing _GNU_SOURCE and sys/timex.h ... FAIL
Testing _GNU_SOURCE and time.h ... OK(Test output is from a Fedora 43 system)
The ERANGE error can be verified either via trying to adjust the frequency of a PHC by a value that is outside of [-X,X], where X=cat /sys/class/ptp/ptpX/max_adjustment,
or via checking the kernel source code:
<https://elixir.bootlin.com/linux/v7.2.2/source/drivers/ptp/ptp_clock.c#L164>
--- man/man2/adjtimex.2 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
man/man2/adjtimex.2 +20 -2
@@ -17,9 +17,21 @@ .SH SYNOPSIS .P .BI "int adjtimex(struct timex *" "buf" ); .P -.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); -.P .BI "int ntp_adjtime(struct timex *" buf ); +.P +.BR #include <time.h> +.P +.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); +.fi +.P +.RS -4 +Feature Test Macro Requirements for glibc (see +.BR feature_test_macros (7)): +.RE +.P +.BR clock_adjtime (): +.nf + _GNU_SOURCE .fi .SH DESCRIPTION Linux uses David L.\& Mills' clock adjustment algorithm (see RFC\ 5905).
@@ -534,6 +546,12 @@ .SH ERRORS Under Linux, the .B CAP_SYS_TIME capability is required. +.TP +.B ERANGE +The frequency offset supplied with +.BR clock_adjtime () +is outside of the range clock clk_id supports. +See also /sys/class/ptp/ptpX/max_adjustment when adjusting a PTP hardware clock. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).
Signature · 1 line
2.55.0
Hi Georg,
Quoted 3 lines
Date: 2026-10-25 13:56:56+0100
From: Georg Sauthoff <[email protected]>
Subject: [PATCH v1] man/man2/adjtimex.2: Add include, macro and error forclock_adjtime
Please separate this into two patches, each of which does only one thing. The error seems unrelated to the include.
I've CCed a few people that have worked in this manual page, in case they have feedback (and also libc-alpha@).
Quoted 11 lines
GNU libc declares
clock_adjtime()when includingtime.h, and not when justsys/timex.his included, iff support for GNU features is requested.Verification:
$ for i in BLAH _GNU_SOURCE; do for j in sys/timex.h time.h; do echo -n "Testing $i and $j ... "; echo -e '#define '"$i"'\n#include <'"$j"'>\nvoid f(){clock_adjtime;}' | gcc -xc - -o /dev/null -c 2>/dev/null && echo OK || echo FAIL; done; done Testing BLAH and sys/timex.h ... FAIL Testing BLAH and time.h ... FAIL Testing _GNU_SOURCE and sys/timex.h ... FAIL Testing _GNU_SOURCE and time.h ... OK
Agree. I wonder if this use of a different header is intentional and why.
Quoted 19 lines
(Test output is from a Fedora 43 system)
The ERANGE error can be verified either via trying to adjust the frequency of a PHC by a value that is outside of [-X,X], where X=
cat /sys/class/ptp/ptpX/max_adjustment,
or via checking the kernel source code:<https://elixir.bootlin.com/linux/v7.2.2/source/drivers/ptp/ptp_clock.c#L164>
Signed-off-by Georg Sauthoff <[email protected]>--- man/man2/adjtimex.2 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)man/man2/adjtimex.2 +0
-0
man/man2/adjtimex.2 .SH SYNOPSIS · line 22
Quoted 8 lines
man/man2/adjtimex.2 +2
-2@@ -17,9 +17,21 @@ .SH SYNOPSIS .P .BI "int adjtimex(struct timex *" "buf" ); .P -.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); -.P .BI "int ntp_adjtime(struct timex *" buf ); +.P +.BR #include <time.h>
BR is for alternating bold and roman, so this seems wrong. You probably want just B (see the include above).
BTW, I would use
.B #define _GNU_SOURCE
.B #include <time.h>
and then remove the Feature Test Macro text below.
Have a lovely night!
Alex
Quoted 32 lines
man/man2/adjtimex.2 +18
-0+.P +.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); +.fi +.P +.RS -4 +Feature Test Macro Requirements for glibc (see +.BR feature_test_macros (7)): +.RE +.P +.BR clock_adjtime (): +.nf + _GNU_SOURCE .fi .SH DESCRIPTION Linux uses David L.\& Mills' clock adjustment algorithm (see RFC\ 5905).@@ -534,6 +546,12 @@ .SH ERRORS Under Linux, the .B CAP_SYS_TIME capability is required. +.TP +.B ERANGE +The frequency offset supplied with +.BR clock_adjtime () +is outside of the range clock clk_id supports. +See also /sys/class/ptp/ptpX/max_adjustment when adjusting a PTP hardware clock. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).Signature · 1 line
2.55.0
Signature · 1 line
<https://www.alejandro-colomar.es>
Hello,
Quoted 8 lines · Alejandro Colomar
Hi Georg,
Quoted 3 lines
Date: 2026-10-25 13:56:56+0100
From: Georg Sauthoff <[email protected]>
Subject: [PATCH v1] man/man2/adjtimex.2: Add include, macro and error forclock_adjtimePlease separate this into two patches, each of which does only one thing. The error seems unrelated to the include.
Ok. Yes, it's unrelated. It wasn't my intention to imply that both hunks are related.
I'll split it and send both as version 2.
Quoted 8 lines
Quoted 8 lines
man/man2/adjtimex.2 +0
-0@@ -17,9 +17,21 @@ .SH SYNOPSIS .P .BI "int adjtimex(struct timex *" "buf" ); .P
Quoted 8 lines
man/man2/adjtimex.2 .SH SYNOPSIS · line 22
Quoted 5 lines
man/man2/adjtimex.2 +2
-2-.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); -.P .BI "int ntp_adjtime(struct timex *" buf ); +.P +.BR #include <time.h>BR is for alternating bold and roman, so this seems wrong. You probably want just B (see the include above).
FWIW, I copy and pasted the BR from another man page I picked as template which already references _GNU_SOURCE, cf.
$ grep '^\.BR #include' . -r | wc -l
23Ok, I change it to B. Also for consistency.
Quoted 6 lines
BTW, I would use
.B #define
_GNU_SOURCE
.B #include <time.h>and then remove the Feature Test Macro text below.
Ok, no problem. Again, I just copied that style from another man page:
$ grep '^\.BR feature_test_macros' . -r -A50 | grep '\<_GNU' | wc -l
62The define style seems to be more popular, though:
$ grep '#define _GNU_SOURCE' . -r | wc -l
153Plus special space variant:
$ grep '#define\\~_GNU_SOURCE' . -r | wc -l
2I don't really have a preference between these styles and thus follow your suggestion.
Best regards,
Georg
v2 cover man/man2/adjtimex.2: Fix include+add error
In reply to Georg SauthoffHello,
this series fixes the include instructions for clock_adjtime() and documents another error its invocation may yield.
Changes v1 -> v2:
- split patch into series
- use define-style feature macro instead of extra section
- fix font style macro usage
Best regards,
Georg
Georg Sauthoff (2):
man/man2/adjtimex.2: Add include and macro for clock_adjtime man/man2/adjtimex.2: Add error for clock_adjtime
man/man2/adjtimex.2 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Range-diff against v1:
1: ddd4886f0 ! 1: 1f6278005 man/man2/adjtimex.2: Add include, macro and error for clock_adjtime
@@ Metadata
Author: Georg Sauthoff <[email protected]>
## Commit message ##
- man/man2/adjtimex.2: Add include, macro and error for clock_adjtime
+ man/man2/adjtimex.2: Add include and macro for clock_adjtime
GNU libc declares clock_adjtime() when including time.h, and not when just sys/timex.h is included, iff support for GNU features is requested.
@@ Commit message
(Test output is from a Fedora 43 system)
- The ERANGE error can be verified either via trying to adjust the
- frequency of a PHC by a value that is outside of [-X,X],
- where X=cat /sys/class/ptp/ptpX/max_adjustment,
- or via checking the kernel source code:
-
- <https://elixir.bootlin.com/linux/v7.2.2/source/drivers/ptp/ptp_clock.c#L164>
-
## man/man2/adjtimex.2 ##
@@ man/man2/adjtimex.2: .SH SYNOPSIS
.P
@@ man/man2/adjtimex.2: .SH SYNOPSIS
-.P
.BI "int ntp_adjtime(struct timex *" buf );
+.P
-+.BR #include <time.h>
++.BR #define\~_GNU_SOURCE " // See feature_test_macros(7)"
++.B #include <time.h>
+.P
+.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" );
-+.fi
-+.P
-+.RS -4
-+Feature Test Macro Requirements for glibc (see
-+.BR feature_test_macros (7)):
-+.RE
-+.P
-+.BR clock_adjtime ():
-+.nf
-+ _GNU_SOURCE
.fi
.SH DESCRIPTION
Linux uses David L.\& Mills' clock adjustment algorithm (see RFC\ 5905).
-@@ man/man2/adjtimex.2: .SH ERRORS
- Under Linux, the
- .B CAP_SYS_TIME
- capability is required.
-+.TP
-+.B ERANGE
-+The frequency offset supplied with
-+.BR clock_adjtime ()
-+is outside of the range clock clk_id supports.
-+See also /sys/class/ptp/ptpX/max_adjustment when adjusting a PTP hardware clock.
- .SH ATTRIBUTES
- For an explanation of the terms used in this section, see
- .BR attributes (7).
-: --------- > 2: 578a02146 man/man2/adjtimex.2: Add error for clock_adjtime
Signature · 1 line
2.55.0
PATCH v2 1/2 man/man2/adjtimex.2: Add include and macro for clock_adjtime
GNU libc declares clock_adjtime() when including time.h, and not when just sys/timex.h is included, iff support for GNU features is requested.
Verification:
$ for i in BLAH _GNU_SOURCE; do for j in sys/timex.h time.h; do echo -n "Testing $i and $j ... "; echo -e '#define '"$i"'\n#include <'"$j"'>\nvoid f(){clock_adjtime;}' | gcc -xc - -o /dev/null -c 2>/dev/null && echo OK || echo FAIL; done; done
Testing BLAH and sys/timex.h ... FAIL
Testing BLAH and time.h ... FAIL
Testing _GNU_SOURCE and sys/timex.h ... FAIL
Testing _GNU_SOURCE and time.h ... OK(Test output is from a Fedora 43 system)
--- man/man2/adjtimex.2 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
man/man2/adjtimex.2 +5 -2
@@ -17,9 +17,12 @@ .SH SYNOPSIS .P .BI "int adjtimex(struct timex *" "buf" ); .P -.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); -.P .BI "int ntp_adjtime(struct timex *" buf ); +.P +.BR #define\~_GNU_SOURCE " // See feature_test_macros(7)" +.B #include <time.h> +.P +.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); .fi .SH DESCRIPTION Linux uses David L.\& Mills' clock adjustment algorithm (see RFC\ 5905).
Signature · 1 line
2.55.0
Re: [PATCH v2 1/2] man/man2/adjtimex.2: Add include and macro for clock_adjtime
Hi Georg,
Quoted 14 lines
Date: 2026-10-27 01:37:11+0100
From: Georg Sauthoff <[email protected]>GNU libc declares
clock_adjtime()when includingtime.h, and not when justsys/timex.his included, iff support for GNU features is requested.Verification:
$ for i in BLAH _GNU_SOURCE; do for j in sys/timex.h time.h; do echo -n "Testing $i and $j ... "; echo -e '#define '"$i"'\n#include <'"$j"'>\nvoid f(){clock_adjtime;}' | gcc -xc - -o /dev/null -c 2>/dev/null && echo OK || echo FAIL; done; done Testing BLAH and sys/timex.h ... FAIL Testing BLAH and time.h ... FAIL Testing _GNU_SOURCE and sys/timex.h ... FAIL Testing _GNU_SOURCE and time.h ... OK
Quoted 3 lines
(Test output is from a Fedora 43 system)
Signed-off-by Georg Sauthoff <[email protected]>
Thanks! I've applied the patch.
Have a lovely day!
Alex
Quoted 27 lines
--- man/man2/adjtimex.2 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)man/man2/adjtimex.2 +5
-2@@ -17,9 +17,12 @@ .SH SYNOPSIS .P .BI "int adjtimex(struct timex *" "buf" ); .P -.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); -.P .BI "int ntp_adjtime(struct timex *" buf ); +.P +.BR #define\~_GNU_SOURCE " // See feature_test_macros(7)" +.B #include <time.h> +.P +.BI "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); .fi .SH DESCRIPTION Linux uses David L.\& Mills' clock adjustment algorithm (see RFC\ 5905).Signature · 1 line
2.55.0
Signature · 1 line
<https://www.alejandro-colomar.es>
PATCH v2 2/2 man/man2/adjtimex.2: Add error for clock_adjtime
In reply to Georg SauthoffThe ERANGE error can be verified either via trying to adjust the frequency of a PHC by a value that is outside of [-X,X], where X=cat /sys/class/ptp/ptpX/max_adjustment,
or via checking the kernel source code:
<https://elixir.bootlin.com/linux/v7.2.2/source/drivers/ptp/ptp_clock.c#L164>
--- man/man2/adjtimex.2 | 6 ++++++ 1 file changed, 6 insertions(+)
man/man2/adjtimex.2 +6 -0
@@ -537,6 +537,12 @@ .SH ERRORS Under Linux, the .B CAP_SYS_TIME capability is required. +.TP +.B ERANGE +The frequency offset supplied with +.BR clock_adjtime () +is outside of the range clock clk_id supports. +See also /sys/class/ptp/ptpX/max_adjustment when adjusting a PTP hardware clock. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).
Signature · 1 line
2.55.0
Re: [PATCH v2 2/2] man/man2/adjtimex.2: Add error for clock_adjtime
Hi Georg,
Quoted 11 lines
Date: 2026-10-27 01:37:12+0100
From: Georg Sauthoff <[email protected]>The ERANGE error can be verified either via trying to adjust the frequency of a PHC by a value that is outside of [-X,X], where X=
cat /sys/class/ptp/ptpX/max_adjustment,
or via checking the kernel source code:<https://elixir.bootlin.com/linux/v7.2.2/source/drivers/ptp/ptp_clock.c#L164>
Signed-off-by Georg Sauthoff <[email protected]>
Thanks! I've applied the patch.
Cheers,
Alex
Quoted 25 lines
--- man/man2/adjtimex.2 | 6 ++++++ 1 file changed, 6 insertions(+)man/man2/adjtimex.2 +6
-0@@ -537,6 +537,12 @@ .SH ERRORS Under Linux, the .B CAP_SYS_TIME capability is required. +.TP +.B ERANGE +The frequency offset supplied with +.BR clock_adjtime () +is outside of the range clock clk_id supports. +See also /sys/class/ptp/ptpX/max_adjustment when adjusting a PTP hardware clock. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).Signature · 1 line
2.55.0
Signature · 1 line
<https://www.alejandro-colomar.es>