xref: /aosp_15_r20/external/curl/lib/timeval.h (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker #ifndef HEADER_CURL_TIMEVAL_H
2*6236dae4SAndroid Build Coastguard Worker #define HEADER_CURL_TIMEVAL_H
3*6236dae4SAndroid Build Coastguard Worker /***************************************************************************
4*6236dae4SAndroid Build Coastguard Worker  *                                  _   _ ____  _
5*6236dae4SAndroid Build Coastguard Worker  *  Project                     ___| | | |  _ \| |
6*6236dae4SAndroid Build Coastguard Worker  *                             / __| | | | |_) | |
7*6236dae4SAndroid Build Coastguard Worker  *                            | (__| |_| |  _ <| |___
8*6236dae4SAndroid Build Coastguard Worker  *                             \___|\___/|_| \_\_____|
9*6236dae4SAndroid Build Coastguard Worker  *
10*6236dae4SAndroid Build Coastguard Worker  * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
11*6236dae4SAndroid Build Coastguard Worker  *
12*6236dae4SAndroid Build Coastguard Worker  * This software is licensed as described in the file COPYING, which
13*6236dae4SAndroid Build Coastguard Worker  * you should have received as part of this distribution. The terms
14*6236dae4SAndroid Build Coastguard Worker  * are also available at https://curl.se/docs/copyright.html.
15*6236dae4SAndroid Build Coastguard Worker  *
16*6236dae4SAndroid Build Coastguard Worker  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17*6236dae4SAndroid Build Coastguard Worker  * copies of the Software, and permit persons to whom the Software is
18*6236dae4SAndroid Build Coastguard Worker  * furnished to do so, under the terms of the COPYING file.
19*6236dae4SAndroid Build Coastguard Worker  *
20*6236dae4SAndroid Build Coastguard Worker  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21*6236dae4SAndroid Build Coastguard Worker  * KIND, either express or implied.
22*6236dae4SAndroid Build Coastguard Worker  *
23*6236dae4SAndroid Build Coastguard Worker  * SPDX-License-Identifier: curl
24*6236dae4SAndroid Build Coastguard Worker  *
25*6236dae4SAndroid Build Coastguard Worker  ***************************************************************************/
26*6236dae4SAndroid Build Coastguard Worker 
27*6236dae4SAndroid Build Coastguard Worker #include "curl_setup.h"
28*6236dae4SAndroid Build Coastguard Worker 
29*6236dae4SAndroid Build Coastguard Worker #include "timediff.h"
30*6236dae4SAndroid Build Coastguard Worker 
31*6236dae4SAndroid Build Coastguard Worker struct curltime {
32*6236dae4SAndroid Build Coastguard Worker   time_t tv_sec; /* seconds */
33*6236dae4SAndroid Build Coastguard Worker   int tv_usec;   /* microseconds */
34*6236dae4SAndroid Build Coastguard Worker };
35*6236dae4SAndroid Build Coastguard Worker 
36*6236dae4SAndroid Build Coastguard Worker struct curltime Curl_now(void);
37*6236dae4SAndroid Build Coastguard Worker 
38*6236dae4SAndroid Build Coastguard Worker /*
39*6236dae4SAndroid Build Coastguard Worker  * Make sure that the first argument (newer) is the more recent time and older
40*6236dae4SAndroid Build Coastguard Worker  * is the older time, as otherwise you get a weird negative time-diff back...
41*6236dae4SAndroid Build Coastguard Worker  *
42*6236dae4SAndroid Build Coastguard Worker  * Returns: the time difference in number of milliseconds.
43*6236dae4SAndroid Build Coastguard Worker  */
44*6236dae4SAndroid Build Coastguard Worker timediff_t Curl_timediff(struct curltime newer, struct curltime older);
45*6236dae4SAndroid Build Coastguard Worker 
46*6236dae4SAndroid Build Coastguard Worker /*
47*6236dae4SAndroid Build Coastguard Worker  * Make sure that the first argument (newer) is the more recent time and older
48*6236dae4SAndroid Build Coastguard Worker  * is the older time, as otherwise you get a weird negative time-diff back...
49*6236dae4SAndroid Build Coastguard Worker  *
50*6236dae4SAndroid Build Coastguard Worker  * Returns: the time difference in number of milliseconds, rounded up.
51*6236dae4SAndroid Build Coastguard Worker  */
52*6236dae4SAndroid Build Coastguard Worker timediff_t Curl_timediff_ceil(struct curltime newer, struct curltime older);
53*6236dae4SAndroid Build Coastguard Worker 
54*6236dae4SAndroid Build Coastguard Worker /*
55*6236dae4SAndroid Build Coastguard Worker  * Make sure that the first argument (newer) is the more recent time and older
56*6236dae4SAndroid Build Coastguard Worker  * is the older time, as otherwise you get a weird negative time-diff back...
57*6236dae4SAndroid Build Coastguard Worker  *
58*6236dae4SAndroid Build Coastguard Worker  * Returns: the time difference in number of microseconds.
59*6236dae4SAndroid Build Coastguard Worker  */
60*6236dae4SAndroid Build Coastguard Worker timediff_t Curl_timediff_us(struct curltime newer, struct curltime older);
61*6236dae4SAndroid Build Coastguard Worker 
62*6236dae4SAndroid Build Coastguard Worker #endif /* HEADER_CURL_TIMEVAL_H */
63