macosx: Remove unnecessary variable and llabs call
[vlc.git] / compat / gettimeofday.c
blob589338a5a05c6c6c3091c41b718af1806bb7a5bb
1 /*****************************************************************************
2 * gettimeofday.c: gettimeofday() replacement
3 *****************************************************************************
4 * Copyright © 2014 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
25 #ifdef _WIN32
26 #include <winsock2.h>
28 /* FILETIME of Jan 1 1970 00:00:00. */
29 static const unsigned __int64 epoch = 116444736000000000;
32 * timezone information is stored outside the kernel so tzp isn't used anymore.
34 * Note: this function is not for Win32 high precision timing purpose. See
35 * elapsed_time().
37 int gettimeofday(struct timeval * tp, struct timezone * tzp)
39 (void)tzp;
40 FILETIME file_time;
41 SYSTEMTIME system_time;
42 ULARGE_INTEGER ularge;
44 GetSystemTime(&system_time);
45 SystemTimeToFileTime(&system_time, &file_time);
46 ularge.LowPart = file_time.dwLowDateTime;
47 ularge.HighPart = file_time.dwHighDateTime;
49 tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
50 tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
52 return 0;
54 #endif /* _WIN32 */