Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_03 / synfig-core / src / modules / mod_libavcodec / libavformat / os_support.c
1 /*
2  * Various utilities for ffmpeg system
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 #include "avformat.h"
20 #ifdef CONFIG_WIN32
21 #include <sys/types.h>
22 #include <sys/timeb.h>
23 #elif defined(CONFIG_OS2)
24 #include <string.h>
25 #include <sys/time.h>
26 #else
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <sys/time.h>
30 #endif
31 #include <time.h>
32
33 int64_t av_gettime(void)
34 {
35 #ifdef CONFIG_WIN32
36     struct _timeb tb;
37     _ftime(&tb);
38     return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
39 #else
40     struct timeval tv;
41     gettimeofday(&tv,NULL);
42     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
43 #endif
44 }
45
46 #if !defined(HAVE_LOCALTIME_R)
47 struct tm *localtime_r(const time_t *t, struct tm *tp)
48 {
49     struct tm *l;
50     
51     l = localtime(t);
52     if (!l)
53         return 0;
54     *tp = *l;
55     return tp;
56 }
57 #endif /* !defined(HAVE_LOCALTIME_R) */