Updates for Windows WRT timing and condition vars
[yaz-moved-to-github.git] / src / gettimeofday.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 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 #include <time.h>
24 #include <yaz/gettimeofday.h>
25
26 int yaz_gettimeofday(struct timeval *tval)
27 {
28 #ifdef WIN32
29     struct _timeb timeb;
30     _ftime(&timeb);
31     tval->tv_sec = timeb.time;
32     tval->tv_usec = timeb.millitm * 1000;
33     return 0;
34 #else
35     return gettimeofday(tval, 0);
36 #endif
37 }
38
39 /*
40  * Local variables:
41  * c-basic-offset: 4
42  * c-file-style: "Stroustrup"
43  * indent-tabs-mode: nil
44  * End:
45  * vim: shiftwidth=4 tabstop=8 expandtab
46  */
47