=pod =head1 NAME OSSL_TIME, OSSL_TIME_SECOND, OSSL_TIME_MS, OSSL_TIME_US, ossl_time_infinite, ossl_time_zero, ossl_time_now, ossl_ticks2time, ossl_time2ticks, ossl_seconds2time, ossl_time2seconds, ossl_ms2time, ossl_us2time, ossl_time2ms, ossl_time2us, ossl_time_to_timeval, ossl_time_from_timeval, ossl_time_to_time_t, ossl_time_from_time_t, ossl_time_compare, ossl_time_is_zero, ossl_time_is_infinite, ossl_time_add, ossl_time_subtract, ossl_time_multiply, ossl_time_divide, ossl_time_muldiv, ossl_time_abs_difference, ossl_time_max, ossl_time_min - times and durations =head1 SYNOPSIS #include "internal/time.h" typedef struct OSSL_TIME; #define OSSL_TIME_SECOND /* Ticks per second */ #define OSSL_TIME_MS /* Ticks per millisecond */ #define OSSL_TIME_US /* Ticks per microsecond */ OSSL_TIME ossl_ticks2time(uint64_t); uint64_t ossl_time2ticks(OSSL_TIME t); OSSL_TIME ossl_seconds2time(uint64_t); uint64_t ossl_time2seconds(OSSL_TIME t); OSSL_TIME ossl_ms2time(uint64_t); uint64_t ossl_time2ms(OSSL_TIME t); OSSL_TIME ossl_us2time(uint64_t); uint64_t ossl_time2us(OSSL_TIME t); OSSL_TIME ossl_time_zero(void); OSSL_TIME ossl_time_infinite(void); OSSL_TIME ossl_time_now(void); struct timeval ossl_time_to_timeval(OSSL_TIME t); OSSL_TIME ossl_time_from_timeval(struct timeval tv); time_t ossl_time_to_time_t(OSSL_TIME t); OSSL_TIME ossl_time_from_time_t(time_t t); int ossl_time_compare(OSSL_TIME a, OSSL_TIME b); int ossl_time_is_zero(OSSL_TIME t); int ossl_time_is_infinite(OSSL_TIME t); OSSL_TIME ossl_time_add(OSSL_TIME a, OSSL_TIME b); OSSL_TIME ossl_time_subtract(OSSL_TIME a, OSSL_TIME b); OSSL_TIME ossl_time_multiply(OSSL_TIME a, uint64_t b); OSSL_TIME ossl_time_divide(OSSL_TIME a, uint64_t b); OSSL_TIME ossl_time_muldiv(OSSL_TIME a, uint64_t b, uint64_t c); OSSL_TIME ossl_time_abs_difference(OSSL_TIME a, OSSL_TIME b); OSSL_TIME ossl_time_max(OSSL_TIME a, OSSL_TIME b); OSSL_TIME ossl_time_min(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 converts an integral number of counts to a time. B converts a time to an integral number of counts. B, B and B convert an integral number of seconds, milliseconds and microseconds respectively to a time. These functions are implemented as macros. B, B and B convert a time to an integral number of second, milliseconds and microseconds respectively. These functions truncates any fractional seconds and are implemented as macros. B returns the smallest representable B. This value represents the time Epoch and it is returned when an underflow would otherwise occur. B returns 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 converts a I to a time. B converts a time to a I. B converts a I to a time. 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 returns 1 if the time I is zero and 0 otherwise. B returns 1 if the time I is infinite and 0 otherwise. 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. B performs a saturating multiplication of a time value by a given integer multiplier returning I × I. B performs division of a time value by a given integer divisor returning ⌊I ÷ I⌋. B performs a fused multiplication and division operation. The result is equal to ⌊I × I ÷ I⌋. B returns the magnitude of the difference between two time values. B returns the lesser of two time values. B returns the greater of two time values. =head1 NOTES The largest representable duration is guaranteed to be at least 500 years. =head1 RETURN VALUES B returns the current time, or the time of the Epoch on error. B returns the time of the Epoch. B returns the last representable time. B, B, B and B return the duration specified in ticks, seconds, milliseconds and microseconds respectively. B, B, B and B return the number of ticks, seconds, microseconds and microseconds respectively that the time object represents. B, B, B and B all return the converted time. B returns -1, 0 or 1 depending on the comparison. B and B return 1 if the condition is true and 0 otherwise. B returns the summation of the two times or the last representable time on overflow. B returns the difference of the two times or the time of the Epoch on underflow. B returns the result of multiplying the given time by the given integral multiplier, or B on overflow. B returns the result of dividing the given time by the given integral divisor. B returns the fused multiplication and division of the given time and the two integral values. B returns the magnitude of the difference between the input time values. B and B choose and return one of the input values. =head1 HISTORY This functionality was added in OpenSSL 3.2. =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