summaryrefslogtreecommitdiff
path: root/mysys/my_wincond.c
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-05-28 16:57:58 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2011-05-28 16:57:58 +0200
commitb519f2b626ebd1f3243a21dc883cefa6a26460f9 (patch)
treefaad721ece99fc071000e695861e37d45acda0e5 /mysys/my_wincond.c
parent152dfe58678af35769ca3cd66db592d129b4c08b (diff)
downloadmariadb-git-b519f2b626ebd1f3243a21dc883cefa6a26460f9.tar.gz
Fix compile errors and warnings and test errors introduced by microseconds push.
Also, change windows timespec definition to be Unix-ish - simplifies handling a lot.
Diffstat (limited to 'mysys/my_wincond.c')
-rw-r--r--mysys/my_wincond.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c
index b869b22bdea..e181b24cdef 100644
--- a/mysys/my_wincond.c
+++ b/mysys/my_wincond.c
@@ -77,31 +77,22 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
struct timespec *abstime)
{
int result;
- long timeout;
- union ft64 now;
-
+ DWORD timeout;
+ long long timeout_us;
+ my_hrtime_t now;
+ my_hrtime_t then;
if( abstime != NULL )
{
- GetSystemTimeAsFileTime(&now.ft);
-
- /*
- Calculate time left to abstime
- - subtract start time from current time(values are in 100ns units)
- - convert to millisec by dividing with 10000
- */
- timeout= (long)((abstime->tv.i64 - now.i64) / 10000);
-
- /* Don't allow the timeout to be negative */
- if (timeout < 0)
- timeout= 0L;
-
- /*
- Make sure the calucated timeout does not exceed original timeout
- value which could cause "wait for ever" if system time changes
- */
- if (timeout > abstime->max_timeout_msec)
- timeout= abstime->max_timeout_msec;
-
+ now= my_hrtime();
+ then.val= 1000000ULL*abstime->tv_sec + abstime->tv_nsec/1000;
+ timeout_us= then.val - now.val;
+
+ if (timeout_us < 0)
+ timeout= 0;
+ else if (timeout_us > 1000ULL*INFINITE)
+ timeout= INFINITE;
+ else
+ timeout= (DWORD)(timeout_us/1000);
}
else
{