From: Pauli Date: Wed, 11 May 2022 02:50:32 +0000 (+1000) Subject: doc: document the new internal time API X-Git-Tag: openssl-3.2.0-alpha1~2504 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f40251da8a6bd66c36a33fe41e52c87ec14ca64;p=thirdparty%2Fopenssl.git doc: document the new internal time API Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/18274) --- diff --git a/doc/internal/man3/OSSL_TIME.pod b/doc/internal/man3/OSSL_TIME.pod new file mode 100644 index 00000000000..c7091d08328 --- /dev/null +++ b/doc/internal/man3/OSSL_TIME.pod @@ -0,0 +1,96 @@ +=pod + +=head1 NAME + +OSSL_TIME, OSSL_TIME_SECOND, OSSL_TIME_INFINITY, +ossl_time_now, ossl_time_time_to_timeval, ossl_time_compare, +ossl_time_add, ossl_time_subtract +- times and durations + +=head1 SYNOPSIS + + #include "internal/time.h" + + typedef uint64_t OSSL_TIME; + + #define OSSL_TIME_SECOND + #define OSSL_TIME_INFINITY + + OSSL_TIME ossl_time_now(void); + void ossl_time_time_to_timeval(OSSL_TIME t, struct timeval *out); + + int ossl_time_compare(OSSL_TIME a, OSSL_TIME b); + OSSL_TIME ossl_time_add(OSSL_TIME a, OSSL_TIME b); + OSSL_TIME ossl_time_subtract(OSSL_TIME a, OSSL_TIME b); + +=head1 DESCRIPTION + +These functions allow the current time to be obtained and for basic +arithmetic operations to be safely performed with times and durations. + +B can represent a duration, or a point in time. Where it is +used to represent a point in time, it does so by expressing a duration +relative to some reference Epoch. The OSSL_TIME structure itself does +not contain information about the Epoch used; thus, interpretation of +an OSSL_TIME requires that the Epoch it is to be interpreted relative +to is contextually understood. + +B is an integer that indicates the precision of an +B. Specifically, it is the number of counts per second that +a time can represent. The accuracy is independent of this and is system +dependent. + +B is the largest representable B. This value +is returned when an overflow would otherwise occur. + +B returns the current time relative to an Epoch which +is undefined but unchanging for at least the duration of program +execution. The time returned is monotonic and need not represent +wall-clock time. The time returned by this function is useful for +scheduling timeouts, deadlines and recurring events, but due to its +undefined Epoch and monotonic nature, is not suitable for other uses. + +B converts a time to a I. + +B compares I with I and returns -1 if I +is smaller than I, 0 if they are equal and +1 if I is +larger than I. + +B performs a saturating addition of the two times, +returning I + I. +If the summation would overflow B is returned. + +B performs a saturating subtraction of the two items, +returning I - I. +If the difference would be negative, B<0> is returned. + +=head1 NOTES + +The largest representable duration is guaranteed to be at least 500 years. + +=head1 RETURN VALUES + +B returns the current time, or 0 on error. + +B returns -1, 0 or 1 depending on the comparison. + +B returns the summation of the two times or +B on overflow. + +B returns the difference of the two times or the +0 on underflow. + +=head1 HISTORY + +This functionality was added in OpenSSL 3.1. + +=head1 COPYRIGHT + +Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use this +file except in compliance with the License. You can obtain a copy in the file +LICENSE in the source distribution or at +L. + +=cut