]> git.sesse.net Git - vlc/blob - include/mtime.h
6241b30239059b40b25f1739a94795a09c29674a
[vlc] / include / mtime.h
1 /*****************************************************************************
2  * mtime.h: high resolution time management functions
3  * This header provides portable high precision time management functions,
4  * which should be the only ones used in other segments of the program, since
5  * functions like gettimeofday() and ftime() are not always supported.
6  * Most functions are declared as inline or as macros since they are only
7  * interfaces to system calls and have to be called frequently.
8  * 'm' stands for 'micro', since maximum resolution is the microsecond.
9  * Functions prototyped are implemented in interface/mtime.c.
10  *****************************************************************************
11  * Copyright (C) 1996, 1997, 1998, 1999, 2000 VideoLAN
12  * $Id: mtime.h,v 1.14 2003/12/02 01:54:30 rocky Exp $
13  *
14  * Authors: Vincent Seguin <seguin@via.ecp.fr>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  * 
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
29  *****************************************************************************/
30
31 /*****************************************************************************
32  * LAST_MDATE: date which will never happen
33  *****************************************************************************
34  * This date can be used as a 'never' date, to mark missing events in a function
35  * supposed to return a date, such as nothing to display in a function
36  * returning the date of the first image to be displayed. It can be used in
37  * comparaison with other values: all existing dates will be earlier.
38  *****************************************************************************/
39 #define LAST_MDATE ((mtime_t)((uint64_t)(-1)/2))
40
41 /*****************************************************************************
42  * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
43  *****************************************************************************
44  * This values is the maximal possible size of the string returned by the
45  * mstrtime() function, including '-' and the final '\0'. It should be used to
46  * allocate the buffer.
47  *****************************************************************************/
48 #define MSTRTIME_MAX_SIZE 22
49
50 #define msecstotimestr(psz_buffer, msecs) \
51   secstotimestr( psz_buffer, (msecs / (int) 1000) )
52
53 /*****************************************************************************
54  * Prototypes
55  *****************************************************************************/
56 VLC_EXPORT( char *,  mstrtime, ( char *psz_buffer, mtime_t date ) );
57 VLC_EXPORT( mtime_t, mdate,    ( void ) );
58 VLC_EXPORT( void,    mwait,    ( mtime_t date ) );
59 VLC_EXPORT( void,    msleep,   ( mtime_t delay ) );
60 VLC_EXPORT( char *,  secstotimestr, ( char *psz_buffer, int secs ) );
61