Update cql.y for newer bison YAZ-720
[yaz-moved-to-github.git] / src / gettimeofday.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5
6 /**
7  * \file gettimeofday.c
8  * \brief Implements wrapper for gettimeofday
9  *
10  */
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include <assert.h>
16 #include <stdlib.h>
17 #include <string.h>
18
19 #ifdef WIN32
20 #include <windows.h>
21 #include <sys/timeb.h>
22 #endif
23 #if HAVE_SYS_TIME_H
24 #include <sys/time.h>
25 #endif
26 #include <yaz/gettimeofday.h>
27
28 int yaz_gettimeofday(struct timeval *tval)
29 {
30 #ifdef WIN32
31     struct _timeb timeb;
32     _ftime(&timeb);
33     tval->tv_sec = timeb.time;
34     tval->tv_usec = timeb.millitm * 1000;
35     return 0;
36 #else
37     return gettimeofday(tval, 0);
38 #endif
39 }
40
41 /*
42  * Local variables:
43  * c-basic-offset: 4
44  * c-file-style: "Stroustrup"
45  * indent-tabs-mode: nil
46  * End:
47  * vim: shiftwidth=4 tabstop=8 expandtab
48  */
49