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.
This commit is contained in:
parent
152dfe5867
commit
b519f2b626
@ -542,8 +542,8 @@ uint32 String::numchars()
|
||||
int String::charpos(longlong i,uint32 offset)
|
||||
{
|
||||
if (i <= 0)
|
||||
return i;
|
||||
return str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
|
||||
return (int)i;
|
||||
return (int)str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,(size_t)i);
|
||||
}
|
||||
|
||||
int String::strstr(const String &s,uint32 offset)
|
||||
|
@ -75,37 +75,11 @@ typedef volatile LONG my_pthread_once_t;
|
||||
#define MY_PTHREAD_ONCE_INPROGRESS 1
|
||||
#define MY_PTHREAD_ONCE_DONE 2
|
||||
|
||||
/*
|
||||
Struct and macros to be used in combination with the
|
||||
windows implementation of pthread_cond_timedwait
|
||||
*/
|
||||
|
||||
/*
|
||||
Declare a union to make sure FILETIME is properly aligned
|
||||
so it can be used directly as a 64 bit value. The value
|
||||
stored is in 100ns units.
|
||||
*/
|
||||
union ft64 {
|
||||
FILETIME ft;
|
||||
__int64 i64;
|
||||
};
|
||||
|
||||
struct timespec {
|
||||
union ft64 tv;
|
||||
/* The max timeout value in millisecond for pthread_cond_timedwait */
|
||||
long max_timeout_msec;
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
#define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \
|
||||
(ABSTIME).tv.i64= (TIME)+(__int64)(NSEC)/100; \
|
||||
(ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
|
||||
} while(0)
|
||||
|
||||
#define set_timespec_nsec(ABSTIME,NSEC) do { \
|
||||
union ft64 tv; \
|
||||
GetSystemTimeAsFileTime(&tv.ft); \
|
||||
set_timespec_time_nsec((ABSTIME), tv.i64, (NSEC)); \
|
||||
} while(0)
|
||||
|
||||
void win_pthread_init(void);
|
||||
int win_pthread_setspecific(void *A,void *B,uint length);
|
||||
|
@ -15,6 +15,7 @@ insert t1 values (20101211010203.45678);
|
||||
insert t1 values (20101211030405.789e0);
|
||||
insert t1 values (99991231235959e1);
|
||||
select * from t1;
|
||||
--replace_regex /121000/121094/ /457000/457031/ /789000/789062/
|
||||
select truncate(a, 6) from t1; # Field::val_real()
|
||||
select a DIV 1 from t1; # Field::val_int()
|
||||
select group_concat(distinct a) from t1; # Field::cmp()
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -4602,7 +4602,7 @@ int Field_timestamp::store(double nr)
|
||||
|
||||
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
|
||||
if (nr < 0 || nr > LONGLONG_MAX)
|
||||
nr= LONGLONG_MAX;
|
||||
nr= (double)LONGLONG_MAX;
|
||||
tmp= number_to_datetime((longlong) floor(nr),
|
||||
&l_time, (thd->variables.sql_mode &
|
||||
MODE_NO_ZERO_DATE) |
|
||||
@ -5075,7 +5075,7 @@ int Field_temporal::store(double nr)
|
||||
Lazy_string_double str(nr);
|
||||
|
||||
if (nr < 0 || nr > LONGLONG_MAX)
|
||||
nr= LONGLONG_MAX;
|
||||
nr= (double)LONGLONG_MAX;
|
||||
longlong tmp= number_to_datetime((longlong) floor(nr), <ime,
|
||||
(TIME_FUZZY_DATE |
|
||||
(thd->variables.sql_mode &
|
||||
|
@ -100,7 +100,7 @@ bool Item_func_sec_to_time::sec_to_time(my_decimal *seconds, MYSQL_TIME *ltime)
|
||||
my_decimal_mul(E_DEC_FATAL_ERROR, &tmp, &sub_seconds,
|
||||
&time_second_part_factor);
|
||||
(void) decimal2longlong(&tmp, &full_seconds);
|
||||
ltime->second_part= full_seconds;
|
||||
ltime->second_part= (ulong)full_seconds;
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -2915,7 +2915,7 @@ bool sys_var_timestamp::check(THD *thd, set_var *var)
|
||||
if (val < 0 || val > MY_TIME_T_MAX)
|
||||
{
|
||||
char buf[64];
|
||||
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", llstr(val, buf));
|
||||
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", llstr((longlong)val, buf));
|
||||
return TRUE;
|
||||
}
|
||||
var->save_result.ulonglong_value= hrtime_from_time(val);
|
||||
|
@ -580,8 +580,8 @@ uint32 String::numchars()
|
||||
int String::charpos(longlong i,uint32 offset)
|
||||
{
|
||||
if (i <= 0)
|
||||
return i;
|
||||
return str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
|
||||
return (int)i;
|
||||
return (int)str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,(size_t)i);
|
||||
}
|
||||
|
||||
int String::strstr(const String &s,uint32 offset)
|
||||
|
@ -607,7 +607,7 @@ void tablockman_init(TABLOCKMAN *lm, loid_to_tlo_func *func, uint timeout)
|
||||
lm->loid_to_tlo= func;
|
||||
lm->lock_timeout= timeout;
|
||||
pthread_mutex_init(& lm->pool_mutex, MY_MUTEX_INIT_FAST);
|
||||
my_getsystime(); /* ensure that my_getsystime() is initialized */
|
||||
my_interval_timer(); /* ensure that my_interval_timer() is initialized */
|
||||
}
|
||||
|
||||
void tablockman_destroy(TABLOCKMAN *lm)
|
||||
|
@ -369,8 +369,7 @@ xtPublic xtBool xt_fs_stat(XTThreadPtr self, char *path, off_t *size, struct tim
|
||||
CloseHandle(fh);
|
||||
if (size)
|
||||
*size = (off_t) info.nFileSizeLow | (((off_t) info.nFileSizeHigh) << 32);
|
||||
if (mod_time)
|
||||
mod_time->tv.ft = info.ftLastWriteTime;
|
||||
memset(mod_time, 0, sizeof(*mod_time));
|
||||
#else
|
||||
struct stat sb;
|
||||
|
||||
|
@ -396,48 +396,7 @@ xtPublic int xt_p_cond_wait(xt_cond_type *cond, xt_mutex_type *mutex)
|
||||
|
||||
xtPublic int xt_p_cond_timedwait(xt_cond_type *cond, xt_mutex_type *mt, struct timespec *abstime)
|
||||
{
|
||||
pthread_mutex_t *mutex = &mt->mt_cs;
|
||||
int result;
|
||||
long timeout;
|
||||
union ft64 now;
|
||||
|
||||
if (abstime != NULL) {
|
||||
GetSystemTimeAsFileTime(&now.ft);
|
||||
|
||||
timeout = (long)((abstime->tv.i64 - now.i64) / 10000);
|
||||
if (timeout < 0)
|
||||
timeout = 0L;
|
||||
if (timeout > abstime->max_timeout_msec)
|
||||
timeout = abstime->max_timeout_msec;
|
||||
}
|
||||
else
|
||||
timeout= INFINITE;
|
||||
|
||||
WaitForSingleObject(cond->broadcast_block_event, INFINITE);
|
||||
|
||||
EnterCriticalSection(&cond->lock_waiting);
|
||||
cond->waiting++;
|
||||
LeaveCriticalSection(&cond->lock_waiting);
|
||||
|
||||
LeaveCriticalSection(mutex);
|
||||
|
||||
result= WaitForMultipleObjects(2, cond->events, FALSE, timeout);
|
||||
|
||||
EnterCriticalSection(&cond->lock_waiting);
|
||||
cond->waiting--;
|
||||
|
||||
if (cond->waiting == 0) {
|
||||
/* The last waiter must reset the broadcast
|
||||
* state (whther there was a broadcast or not)!
|
||||
*/
|
||||
ResetEvent(cond->events[xt_cond_type::BROADCAST]);
|
||||
SetEvent(cond->broadcast_block_event);
|
||||
}
|
||||
LeaveCriticalSection(&cond->lock_waiting);
|
||||
|
||||
EnterCriticalSection(mutex);
|
||||
|
||||
return result == WAIT_TIMEOUT ? ETIMEDOUT : 0;
|
||||
return pthread_cond_timedwait(cond, &mt->mt_cs, abstime);
|
||||
}
|
||||
|
||||
xtPublic int xt_p_join(pthread_t thread, void **value)
|
||||
|
@ -54,6 +54,9 @@ void xt_db_exit_thread(XTThreadPtr self);
|
||||
|
||||
static void thr_accumulate_statistics(XTThreadPtr self);
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <my_sys.h>
|
||||
#endif
|
||||
/*
|
||||
* -----------------------------------------------------------------------
|
||||
* THREAD GLOBALS
|
||||
@ -1962,18 +1965,7 @@ xtPublic xtBool xt_timed_wait_cond(XTThreadPtr self, xt_cond_type *cond, xt_mute
|
||||
XTThreadPtr me = self ? self : xt_get_self();
|
||||
|
||||
#ifdef XT_WIN
|
||||
union ft64 now;
|
||||
|
||||
GetSystemTimeAsFileTime(&now.ft);
|
||||
|
||||
/* System time is measured in 100ns units.
|
||||
* This calculation will be reversed by the Windows implementation
|
||||
* of pthread_cond_timedwait(), in order to extract the
|
||||
* milli-second timeout!
|
||||
*/
|
||||
abstime.tv.i64 = now.i64 + (milli_sec * 10000);
|
||||
|
||||
abstime.max_timeout_msec = milli_sec;
|
||||
set_timespec_nsec(abstime, 1000000ULL* milli_sec);
|
||||
#else
|
||||
struct timeval now;
|
||||
u_llong micro_sec;
|
||||
|
Loading…
x
Reference in New Issue
Block a user