diff options
| author | Oleksandr Shulgin <oleksandr.shulgin@zalando.de> | 2015-06-04 11:00:08 +0200 |
|---|---|---|
| committer | Oleksandr Shulgin <oleksandr.shulgin@zalando.de> | 2015-06-04 11:00:08 +0200 |
| commit | 50df864f8c63144bad281a1de1d6d38d4a06d4aa (patch) | |
| tree | c5530a447c5e956edaad821c30f83701535cc446 /psycopg/win32_support.c | |
| parent | f14521f8cb567c98814d392ba7ec196b4a7df77c (diff) | |
| download | psycopg2-50df864f8c63144bad281a1de1d6d38d4a06d4aa.tar.gz | |
Add timersub for Win32. Fix gettimeofday on MinGW.
Diffstat (limited to 'psycopg/win32_support.c')
| -rw-r--r-- | psycopg/win32_support.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/psycopg/win32_support.c b/psycopg/win32_support.c index 8a760b9..d508b22 100644 --- a/psycopg/win32_support.c +++ b/psycopg/win32_support.c @@ -29,6 +29,8 @@ #include "psycopg/win32_support.h" #ifdef _WIN32 + +#ifndef __MINGW32__ /* millisecond-precision port of gettimeofday for Win32, taken from src/port/gettimeofday.c in PostgreSQL core */ @@ -58,4 +60,17 @@ gettimeofday(struct timeval * tp, struct timezone * tzp) return 0; } -#endif /* _WIN32 */ +#endif /* !defined(__MINGW32__) */ + +/* timersub is missing on mingw */ +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) { + c->tv_usec += 1000000; + c->tv_sec -= 1; + } +} +#endif /* defined(_WIN32) */ |
