annotate os_support.c @ 230:9f4f4ca9f7b5 libavformat

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