d361ed1e8307fef560994fcd66aed9d45782ec12
[gnulib.git] / lib / gettimeofday.h
1 /* Provide gettimeofday
2    1. for systems that don't have it,
3    2. for some systems where gettimeofday clobbers the static buffer that
4       localtime uses for it's return value.  The gettimeofday function from
5       Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem.
6       The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and
7       2.6.
8
9    Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
10
11    This program is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 2, or (at your option)
14    any later version.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software Foundation,
23    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
24
25 #ifndef GETTIMEOFDAY_H
26 #define GETTIMEOFDAY_H
27
28 #if TIME_WITH_SYS_TIME
29 # include <sys/time.h>
30 # include <time.h>
31 #else
32 # if HAVE_SYS_TIME_H
33 #  include <sys/time.h>
34 # else
35 #  include <time.h>
36 # endif
37 #endif
38
39 #if !HAVE_STRUCT_TIMEVAL
40 struct timeval
41 {
42   time_t tv_sec;
43   suseconds_t tv_usec;
44 };
45 #endif
46
47 #if !HAVE_GETTIMEOFDAY_POSIX_SIGNATURE || GETTIMEOFDAY_CLOBBERS_LOCALTIME
48 # undef gettimeofday
49 # define gettimeofday rpl_gettimeofday
50 extern int gettimeofday (struct timeval *restrict tp, void *restrict tzp);
51 #endif
52
53 #endif /* GETTIMEOFDAY_H */