unify os dependent time code in one file - rm win_time.c
This commit is contained in:
parent
5000e0d57a
commit
40aa445ee8
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
noinst_LTLIBRARIES = libmisc.la
|
||||
|
||||
EXTRA_DIST = win_time.c
|
||||
|
||||
libmisc_la_SOURCES = \
|
||||
getopt_long_bsd.c \
|
||||
getopt_bsd.h \
|
||||
|
|
|
|||
|
|
@ -21,6 +21,37 @@ Copyright 1990 Regents of the University of California. All rights reserved.
|
|||
*/
|
||||
#undef BOOLEAN
|
||||
#include <windows.h>
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
#include <winsock2.h>
|
||||
#include <stdint.h> // portable: uint64_t MSVC: __int64
|
||||
|
||||
/*/ MSVC defines this in winsock2.h!?
|
||||
typedef struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
} timeval;
|
||||
*/
|
||||
int gettimeofday(struct timeval * tp, void * unused)
|
||||
{
|
||||
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
|
||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
||||
// until 00:00:00 January 1, 1970
|
||||
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
|
||||
|
||||
SYSTEMTIME system_time;
|
||||
FILETIME file_time;
|
||||
uint64_t time;
|
||||
|
||||
GetSystemTime( &system_time );
|
||||
SystemTimeToFileTime( &system_time, &file_time );
|
||||
time = ((uint64_t)file_time.dwLowDateTime ) ;
|
||||
time += ((uint64_t)file_time.dwHighDateTime) << 32;
|
||||
|
||||
tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
|
||||
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
//#include "ngspice/ngspice.h"
|
||||
#include <Windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <stdint.h> // portable: uint64_t MSVC: __int64
|
||||
|
||||
/*/ MSVC defines this in winsock2.h!?
|
||||
typedef struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
} timeval;
|
||||
*/
|
||||
int gettimeofday(struct timeval * tp, void * unused)
|
||||
{
|
||||
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
|
||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
||||
// until 00:00:00 January 1, 1970
|
||||
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
|
||||
|
||||
SYSTEMTIME system_time;
|
||||
FILETIME file_time;
|
||||
uint64_t time;
|
||||
|
||||
GetSystemTime( &system_time );
|
||||
SystemTimeToFileTime( &system_time, &file_time );
|
||||
time = ((uint64_t)file_time.dwLowDateTime ) ;
|
||||
time += ((uint64_t)file_time.dwHighDateTime) << 32;
|
||||
|
||||
tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
|
||||
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1466,7 +1466,6 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3
|
|||
<ClCompile Include="..\src\misc\string.c" />
|
||||
<ClCompile Include="..\src\misc\tilde.c" />
|
||||
<ClCompile Include="..\src\misc\util.c" />
|
||||
<ClCompile Include="..\src\misc\win_time.c" />
|
||||
<ClCompile Include="..\src\misc\wlist.c" />
|
||||
<ClCompile Include="..\src\ngspice.c" />
|
||||
<ClCompile Include="..\src\osdi\osdiacld.c" />
|
||||
|
|
|
|||
|
|
@ -1687,7 +1687,6 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3
|
|||
<ClCompile Include="..\src\misc\string.c" />
|
||||
<ClCompile Include="..\src\misc\tilde.c" />
|
||||
<ClCompile Include="..\src\misc\util.c" />
|
||||
<ClCompile Include="..\src\misc\win_time.c" />
|
||||
<ClCompile Include="..\src\misc\wlist.c" />
|
||||
<ClCompile Include="..\src\ngspice.c" />
|
||||
<ClCompile Include="..\src\osdi\osdiacld.c" />
|
||||
|
|
|
|||
|
|
@ -1702,7 +1702,6 @@
|
|||
<ClCompile Include="..\src\misc\string.c" />
|
||||
<ClCompile Include="..\src\misc\tilde.c" />
|
||||
<ClCompile Include="..\src\misc\util.c" />
|
||||
<ClCompile Include="..\src\misc\win_time.c" />
|
||||
<ClCompile Include="..\src\misc\wlist.c" />
|
||||
<ClCompile Include="..\src\ngspice.c" />
|
||||
<ClCompile Include="..\src\osdi\osdiacld.c" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue