OpenSSL 1.0.1 update
[tomato.git] / release / src / router / transmission / third-party / libnatpmp / wingettimeofday.c
blob5b1b8a63a25c2a4767e6c717660b3cdbdd52b800
1 /* $Id: wingettimeofday.c,v 1.3 2009/12/19 12:00:00 nanard Exp $ */
2 /* libnatpmp
3 * Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
4 * http://miniupnp.free.fr/libnatpmp.html
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
17 #ifdef WIN32
18 #if defined(_MSC_VER)
19 struct timeval {
20 long tv_sec;
21 long tv_usec;
23 #else
24 #include <sys/time.h>
25 #endif
27 typedef struct _FILETIME {
28 unsigned long dwLowDateTime;
29 unsigned long dwHighDateTime;
30 } FILETIME;
32 void __stdcall GetSystemTimeAsFileTime(FILETIME*);
34 //int gettimeofday(struct timeval* p, void* tz /* IGNORED */);
36 int gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
37 union {
38 long long ns100; /*time since 1 Jan 1601 in 100ns units */
39 FILETIME ft;
40 } _now;
42 if(!p)
43 return -1;
44 GetSystemTimeAsFileTime( &(_now.ft) );
45 p->tv_usec =(long)((_now.ns100 / 10LL) % 1000000LL );
46 p->tv_sec = (long)((_now.ns100-(116444736000000000LL))/10000000LL);
47 return 0;
49 #endif