Home | History | Annotate | Line # | Download | only in man3
      1  1.1  christos =pod
      2  1.1  christos 
      3  1.1  christos =head1 NAME
      4  1.1  christos 
      5  1.1  christos OSSL_TIME, OSSL_TIME_SECOND, OSSL_TIME_MS, OSSL_TIME_US,
      6  1.1  christos ossl_time_infinite, ossl_time_zero, ossl_time_now,
      7  1.1  christos ossl_ticks2time, ossl_time2ticks, ossl_seconds2time, ossl_time2seconds,
      8  1.1  christos ossl_ms2time, ossl_us2time, ossl_time2ms, ossl_time2us,
      9  1.1  christos ossl_time_to_timeval, ossl_time_from_timeval,
     10  1.1  christos ossl_time_to_time_t, ossl_time_from_time_t,
     11  1.1  christos ossl_time_compare, ossl_time_is_zero, ossl_time_is_infinite,
     12  1.1  christos ossl_time_add, ossl_time_subtract,
     13  1.1  christos ossl_time_multiply, ossl_time_divide, ossl_time_muldiv,
     14  1.1  christos ossl_time_abs_difference, ossl_time_max,
     15  1.1  christos ossl_time_min - times and durations
     16  1.1  christos 
     17  1.1  christos =head1 SYNOPSIS
     18  1.1  christos 
     19  1.1  christos  #include "internal/time.h"
     20  1.1  christos 
     21  1.1  christos  typedef struct OSSL_TIME;
     22  1.1  christos 
     23  1.1  christos  #define OSSL_TIME_SECOND   /* Ticks per second */
     24  1.1  christos  #define OSSL_TIME_MS       /* Ticks per millisecond */
     25  1.1  christos  #define OSSL_TIME_US       /* Ticks per microsecond */
     26  1.1  christos 
     27  1.1  christos  OSSL_TIME ossl_ticks2time(uint64_t);
     28  1.1  christos  uint64_t ossl_time2ticks(OSSL_TIME t);
     29  1.1  christos  OSSL_TIME ossl_seconds2time(uint64_t);
     30  1.1  christos  uint64_t ossl_time2seconds(OSSL_TIME t);
     31  1.1  christos  OSSL_TIME ossl_ms2time(uint64_t);
     32  1.1  christos  uint64_t ossl_time2ms(OSSL_TIME t);
     33  1.1  christos  OSSL_TIME ossl_us2time(uint64_t);
     34  1.1  christos  uint64_t ossl_time2us(OSSL_TIME t);
     35  1.1  christos 
     36  1.1  christos  OSSL_TIME ossl_time_zero(void);
     37  1.1  christos  OSSL_TIME ossl_time_infinite(void);
     38  1.1  christos  OSSL_TIME ossl_time_now(void);
     39  1.1  christos 
     40  1.1  christos  struct timeval ossl_time_to_timeval(OSSL_TIME t);
     41  1.1  christos  OSSL_TIME ossl_time_from_timeval(struct timeval tv);
     42  1.1  christos  time_t ossl_time_to_time_t(OSSL_TIME t);
     43  1.1  christos  OSSL_TIME ossl_time_from_time_t(time_t t);
     44  1.1  christos 
     45  1.1  christos  int ossl_time_compare(OSSL_TIME a, OSSL_TIME b);
     46  1.1  christos  int ossl_time_is_zero(OSSL_TIME t);
     47  1.1  christos  int ossl_time_is_infinite(OSSL_TIME t);
     48  1.1  christos 
     49  1.1  christos  OSSL_TIME ossl_time_add(OSSL_TIME a, OSSL_TIME b);
     50  1.1  christos  OSSL_TIME ossl_time_subtract(OSSL_TIME a, OSSL_TIME b);
     51  1.1  christos  OSSL_TIME ossl_time_multiply(OSSL_TIME a, uint64_t b);
     52  1.1  christos  OSSL_TIME ossl_time_divide(OSSL_TIME a, uint64_t b);
     53  1.1  christos  OSSL_TIME ossl_time_muldiv(OSSL_TIME a, uint64_t b, uint64_t c);
     54  1.1  christos  OSSL_TIME ossl_time_abs_difference(OSSL_TIME a, OSSL_TIME b);
     55  1.1  christos  OSSL_TIME ossl_time_max(OSSL_TIME a, OSSL_TIME b);
     56  1.1  christos  OSSL_TIME ossl_time_min(OSSL_TIME a, OSSL_TIME b);
     57  1.1  christos 
     58  1.1  christos =head1 DESCRIPTION
     59  1.1  christos 
     60  1.1  christos These functions allow the current time to be obtained and for basic
     61  1.1  christos arithmetic operations to be safely performed with times and durations.
     62  1.1  christos 
     63  1.1  christos B<OSSL_TIME> can represent a duration, or a point in time. Where it is
     64  1.1  christos used to represent a point in time, it does so by expressing a duration
     65  1.1  christos relative to some reference Epoch.  The OSSL_TIME structure itself does
     66  1.1  christos not contain information about the Epoch used; thus, interpretation of
     67  1.1  christos an OSSL_TIME requires that the Epoch it is to be interpreted relative
     68  1.1  christos to is contextually understood.
     69  1.1  christos 
     70  1.1  christos B<OSSL_TIME_SECOND> is an integer that indicates the precision of an
     71  1.1  christos B<OSSL_TIME>.  Specifically, it is the number of counts per second that
     72  1.1  christos a time can represent.  The accuracy is independent of this and is system
     73  1.1  christos dependent.
     74  1.1  christos 
     75  1.1  christos B<ossl_ticks2time> converts an integral number of counts to a time.
     76  1.1  christos 
     77  1.1  christos B<ossl_time2ticks> converts a time to an integral number of counts.
     78  1.1  christos 
     79  1.1  christos B<ossl_seconds2time>, B<ossl_ms2time> and B<ossl_us2time> convert an
     80  1.1  christos integral number of seconds, milliseconds and microseconds respectively
     81  1.1  christos to a time.  These functions are implemented as macros.
     82  1.1  christos 
     83  1.1  christos B<ossl_time2seconds>, B<ossl_time2ms> and B<ossl_time2us> convert a
     84  1.1  christos time to an integral number of second, milliseconds and microseconds
     85  1.1  christos respectively.  These functions truncates any fractional seconds and are
     86  1.1  christos implemented as macros.
     87  1.1  christos 
     88  1.1  christos B<ossl_time_zero> returns the smallest representable B<OSSL_TIME>.
     89  1.1  christos This value represents the time Epoch and it is returned when an underflow
     90  1.1  christos would otherwise occur.
     91  1.1  christos 
     92  1.1  christos B<ossl_time_infinite> returns the largest representable B<OSSL_TIME>.
     93  1.1  christos This value is returned when an overflow would otherwise occur.
     94  1.1  christos 
     95  1.1  christos B<ossl_time_now> returns the current time relative to an Epoch which
     96  1.1  christos is undefined but unchanging for at least the duration of program
     97  1.1  christos execution.  The time returned is monotonic and need not represent
     98  1.1  christos wall-clock time.  The time returned by this function is useful for
     99  1.1  christos scheduling timeouts, deadlines and recurring events, but due to its
    100  1.1  christos undefined Epoch and monotonic nature, is not suitable for other uses.
    101  1.1  christos 
    102  1.1  christos B<ossl_time_to_timeval> converts a time to a I<struct timeval>.
    103  1.1  christos 
    104  1.1  christos B<ossl_time_from_timeval> converts a I<struct timeval> to a time.
    105  1.1  christos 
    106  1.1  christos B<ossl_time_to_time_t> converts a time to a I<time_t>.
    107  1.1  christos 
    108  1.1  christos B<ossl_time_from_time_t> converts a I<time_t> to a time.
    109  1.1  christos 
    110  1.1  christos B<ossl_time_compare> compares I<a> with I<b> and returns -1 if I<a>
    111  1.1  christos is smaller than I<b>, 0 if they are equal and +1 if I<a> is
    112  1.1  christos larger than I<b>.
    113  1.1  christos 
    114  1.1  christos B<ossl_time_is_zero> returns 1 if the time I<t> is zero and 0 otherwise.
    115  1.1  christos 
    116  1.1  christos B<ossl_time_is_infinite> returns 1 if the time I<t> is infinite and 0 otherwise.
    117  1.1  christos 
    118  1.1  christos B<ossl_time_add> performs a saturating addition of the two times,
    119  1.1  christos returning I<a> + I<b>.
    120  1.1  christos If the summation would overflow B<OSSL_TIME_INFINITY> is returned.
    121  1.1  christos 
    122  1.1  christos B<ossl_time_subtract> performs a saturating subtraction of the two items,
    123  1.1  christos returning I<a> - I<b>.
    124  1.1  christos If the difference would be negative,  B<0> is returned.
    125  1.1  christos 
    126  1.1  christos B<ossl_time_multiply> performs a saturating multiplication of a time value by a
    127  1.1  christos given integer multiplier returning I<a> &#xD7; I<b>.
    128  1.1  christos 
    129  1.1  christos B<ossl_time_divide> performs division of a time value by a given integer
    130  1.1  christos divisor returning &#x230A;I<a> &#xF7; I<b>&#x230B;.
    131  1.1  christos 
    132  1.1  christos B<ossl_time_muldiv> performs a fused multiplication and division operation.
    133  1.1  christos The result is equal to &#x230A;I<a> &#xD7; I<b> &#xF7; I<c>&#x230B;.
    134  1.1  christos 
    135  1.1  christos B<ossl_time_abs_difference> returns the magnitude of the difference between two
    136  1.1  christos time values.
    137  1.1  christos 
    138  1.1  christos B<ossl_time_min> returns the lesser of two time values.
    139  1.1  christos 
    140  1.1  christos B<ossl_time_max> returns the greater of two time values.
    141  1.1  christos 
    142  1.1  christos =head1 NOTES
    143  1.1  christos 
    144  1.1  christos The largest representable duration is guaranteed to be at least 500 years.
    145  1.1  christos 
    146  1.1  christos =head1 RETURN VALUES
    147  1.1  christos 
    148  1.1  christos B<ossl_time_now> returns the current time, or the time of the Epoch on error.
    149  1.1  christos 
    150  1.1  christos B<ossl_time_zero> returns the time of the Epoch.
    151  1.1  christos 
    152  1.1  christos B<ossl_time_infinite> returns the last representable time.
    153  1.1  christos 
    154  1.1  christos B<ossl_ticks2time>, B<ossl_seconds2time>, B<ossl_ms2time> and B<ossl_us2time>
    155  1.1  christos return the duration specified in ticks, seconds, milliseconds and microseconds
    156  1.1  christos respectively.
    157  1.1  christos 
    158  1.1  christos B<ossl_time2ticks>, B<ossl_time2seconds>, B<ossl_time2ms> and B<ossl_time2us>
    159  1.1  christos return the number of ticks, seconds, microseconds and microseconds respectively
    160  1.1  christos that the time object represents.
    161  1.1  christos 
    162  1.1  christos B<ossl_time_to_timeval>, B<ossl_time_from_timeval>, B<ossl_time_to_time_t> and
    163  1.1  christos B<ossl_time_from_time_t> all return the converted time.
    164  1.1  christos 
    165  1.1  christos B<ossl_time_compare> returns -1, 0 or 1 depending on the comparison.
    166  1.1  christos 
    167  1.1  christos B<ossl_time_is_zero> and B<ossl_time_is_infinite> return 1 if the condition
    168  1.1  christos is true and 0 otherwise.
    169  1.1  christos 
    170  1.1  christos B<ossl_time_add> returns the summation of the two times or
    171  1.1  christos the last representable time on overflow.
    172  1.1  christos 
    173  1.1  christos B<ossl_time_subtract> returns the difference of the two times or the
    174  1.1  christos time of the Epoch on underflow.
    175  1.1  christos 
    176  1.1  christos B<ossl_time_multiply> returns the result of multiplying the given time by the
    177  1.1  christos given integral multiplier, or B<OSSL_TIME_INFINITY> on overflow.
    178  1.1  christos 
    179  1.1  christos B<ossl_time_divide> returns the result of dividing the given time by the given
    180  1.1  christos integral divisor.
    181  1.1  christos 
    182  1.1  christos B<ossl_time_muldiv> returns the fused multiplication and division of the given
    183  1.1  christos time and the two integral values.
    184  1.1  christos 
    185  1.1  christos B<ossl_time_abs_difference> returns the magnitude of the difference between the
    186  1.1  christos input time values.
    187  1.1  christos 
    188  1.1  christos B<ossl_time_min> and B<ossl_time_max> choose and return one of the input values.
    189  1.1  christos 
    190  1.1  christos =head1 HISTORY
    191  1.1  christos 
    192  1.1  christos This functionality was added in OpenSSL 3.2.
    193  1.1  christos 
    194  1.1  christos =head1 COPYRIGHT
    195  1.1  christos 
    196  1.1  christos Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
    197  1.1  christos 
    198  1.1  christos Licensed under the Apache License 2.0 (the "License").  You may not use this
    199  1.1  christos file except in compliance with the License.  You can obtain a copy in the file
    200  1.1  christos LICENSE in the source distribution or at
    201  1.1  christos L<https://www.openssl.org/source/license.html>.
    202  1.1  christos 
    203  1.1  christos =cut
    204