Remove empty lines in start of header files
[elinks.git] / src / util / time.h
blob40a0680e46749149c06a536927da1e37a928a7d1
1 #ifndef EL__UTIL_TIME_H
2 #define EL__UTIL_TIME_H
4 #ifdef HAVE_SYS_TIME_H
5 #include <sys/time.h>
6 #endif
7 #ifdef HAVE_TIME_H
8 #include <time.h>
9 #endif
11 typedef long milliseconds_T;
12 #define MILLISECONDS_MAX ((milliseconds_T) (LONG_MAX / 1000L))
13 #define ms_max(a, b) ((a) < (b) ? (b) : (a))
14 #define ms_min(a, b) ((a) < (b) ? (a) : (b))
16 /* Is using atol() in this way acceptable? It seems
17 * non-portable to me; time_t might not be a long. -- Miciah */
18 #define str_to_time_t(s) ((time_t) atol(s))
20 /* Redefine a timeval that has all fields signed so calculations
21 * will be simplified on rare systems that define timeval with
22 * unsigned fields. */
23 typedef struct { long sec; long usec; } timeval_T;
25 timeval_T *timeval_from_milliseconds(timeval_T *t, milliseconds_T milliseconds);
26 timeval_T *timeval_from_seconds(timeval_T *t, long seconds);
27 timeval_T *timeval_from_double(timeval_T *t, double x);
29 milliseconds_T sec_to_ms(long sec);
30 milliseconds_T add_ms_to_ms(milliseconds_T a, milliseconds_T b);
31 milliseconds_T mult_ms(milliseconds_T a, long lb);
33 milliseconds_T timeval_to_milliseconds(timeval_T *t);
34 long timeval_to_seconds(timeval_T *t);
36 int timeval_is_positive(timeval_T *t);
37 void timeval_limit_to_zero(timeval_T *t);
38 timeval_T *timeval_now(timeval_T *t);
39 timeval_T *timeval_sub(timeval_T *res, timeval_T *older, timeval_T *newer);
40 timeval_T *timeval_add(timeval_T *res, timeval_T *base, timeval_T *t);
41 int timeval_cmp(timeval_T *t1, timeval_T *t2);
42 timeval_T *timeval_sub_interval(timeval_T *t, timeval_T *interval);
43 timeval_T *timeval_add_interval(timeval_T *t, timeval_T *interval);
44 int timeval_div_off_t(off_t n, timeval_T *t);
46 #define timeval_copy(dst, src) copy_struct(dst, src)
48 #endif