]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
manual: Add a comparative example of 'clock_nanosleep' use
authorMaciej W. Rozycki <macro@redhat.com>
Fri, 6 Jun 2025 17:14:34 +0000 (18:14 +0100)
committerMaciej W. Rozycki <macro@redhat.com>
Fri, 6 Jun 2025 17:14:34 +0000 (18:14 +0100)
Add an illustrative example of how to express 'nanosleep' in terms of
'clock_nanosleep'.

manual/time.texi

index 697a6287f21f0637f193b7aacdc42e31d71bc682..d003ddb6377940931a66a3aac320506c7cf22d70 100644 (file)
@@ -3241,6 +3241,19 @@ different from @code{nanosleep}, which returns @math{-1} upon failure and
 sets the global variable @code{errno} according to the error encountered
 instead.
 
+Except for the return value convention and the way to communicate an error
+condition the call:
+
+@smallexample
+nanosleep (@var{requested_time}, @var{remaining_time})
+@end smallexample
+
+is analogous to:
+
+@smallexample
+clock_nanosleep (CLOCK_REALTIME, 0, @var{requested_time}, @var{remaining_time})
+@end smallexample
+
 The @var{clock} argument specifies the clock to use.
 @xref{Getting the Time}, for the @code{clockid_t} type and possible values
 of @var{clock}.  Not all clocks listed are supported for use with