1 /*******************************************************************************
2 * mtime.h: high rezolution time management functions
4 *******************************************************************************
5 * This header provides portable high precision time management functions,
6 * which should be the only ones used in other segments of the program, since
7 * functions like gettimeofday() and ftime() are not always supported.
8 * Most functions are declared as inline or as macros since they are only
9 * interfaces to system calls and have to be called frequently.
10 * 'm' stands for 'micro', since maximum resolution is the microsecond.
11 * Functions prototyped are implemented in interface/mtime.c.
12 *******************************************************************************
15 * this header includes inline functions
16 *******************************************************************************/
18 /*******************************************************************************
19 * mtime_t: high precision date or time interval
20 *******************************************************************************
21 * Store an high precision date or time interval. The maximum precision is the
22 * micro-second, and a 64 bits integer is used to avoid any overflow (maximum
23 * time interval is then 292271 years, which should be length enough for any
24 * video). Date are stored as a time interval since a common date.
25 * Note that date and time intervals can be manipulated using regular arithmetic
26 * operators, and that no special functions are required.
27 *******************************************************************************/
30 /*******************************************************************************
31 * LAST_MDATE: date which will never happen
32 *******************************************************************************
33 * This date can be used as a 'never' date, to mark missing events in a function
34 * supposed to return a date, such as nothing to display in a function
35 * returning the date of the first image to be displayed. It can be used in
36 * comparaison with other values: all existing dates will be earlier.
37 *******************************************************************************/
38 #define LAST_MDATE ((mtime_t)((u64)(-1)/2))
40 /*******************************************************************************
41 * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
42 *******************************************************************************
43 * This values is the maximal possible size of the string returned by the
44 * mstrtime() function, including '-' and the final '\0'. It should be used to
45 * allocate the buffer.
46 *******************************************************************************/
47 #define MSTRTIME_MAX_SIZE 22
49 /*******************************************************************************
51 *******************************************************************************/
52 char * mstrtime ( char *psz_buffer, mtime_t date );
53 mtime_t mdate ( void );
54 void mwait ( mtime_t date );
55 void msleep ( mtime_t delay );