diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-11 20:34:37 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-11 20:34:37 +0000 |
commit | 75747606d38495414110fcabaac1a7606b89601a (patch) | |
tree | 524aa92f35b9c5e632c2b670787efc762897105b /psycopg/win32_support.c | |
parent | ee4887b4c5b5a0afca1d85dd05a58b29c9dae224 (diff) | |
parent | 32e81a27b5a4c07a9fb935091d971eece63bbca2 (diff) | |
download | psycopg2-75747606d38495414110fcabaac1a7606b89601a.tar.gz |
Merge branch 'pull-507'
Diffstat (limited to 'psycopg/win32_support.c')
-rw-r--r-- | psycopg/win32_support.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/psycopg/win32_support.c b/psycopg/win32_support.c index d508b22..7a9c8b8 100644 --- a/psycopg/win32_support.c +++ b/psycopg/win32_support.c @@ -35,7 +35,7 @@ src/port/gettimeofday.c in PostgreSQL core */ /* FILETIME of Jan 1 1970 00:00:00. */ -static const unsigned __int64 epoch = 116444736000000000ULL; +static const unsigned __int64 epoch = ((unsigned __int64) 116444736000000000ULL); /* * timezone information is stored outside the kernel so tzp isn't used anymore. @@ -44,7 +44,7 @@ static const unsigned __int64 epoch = 116444736000000000ULL; * elapsed_time(). */ int -gettimeofday(struct timeval * tp, struct timezone * tzp) +gettimeofday(struct timeval * tp, void * tzp) { FILETIME file_time; SYSTEMTIME system_time; @@ -60,17 +60,30 @@ gettimeofday(struct timeval * tp, struct timezone * tzp) return 0; } + +/* timeradd missing on MS VC */ +void +timeradd(struct timeval *a, struct timeval *b, struct timeval *c) +{ + c->tv_sec = a->tv_sec + b->tv_sec; + c->tv_usec = a->tv_usec + b->tv_usec; + if(c->tv_usec >= 1000000L) { + c->tv_usec -= 1000000L; + c->tv_sec += 1; + } +} #endif /* !defined(__MINGW32__) */ -/* timersub is missing on mingw */ +/* timersub is missing on mingw & MS VC */ void timersub(struct timeval *a, struct timeval *b, struct timeval *c) { c->tv_sec = a->tv_sec - b->tv_sec; c->tv_usec = a->tv_usec - b->tv_usec; - if (tv_usec < 0) { + if (c->tv_usec < 0) { c->tv_usec += 1000000; c->tv_sec -= 1; } } + #endif /* defined(_WIN32) */ |