summaryrefslogtreecommitdiff
path: root/mysys/my_getsystime.c
diff options
context:
space:
mode:
authorunknown <miguel@hegel.local>2004-05-05 02:59:17 -0300
committerunknown <miguel@hegel.local>2004-05-05 02:59:17 -0300
commitbddee0c170454f54c1f87299d88d3aa9e44a3872 (patch)
treeacaa682ecb4e7413232120ad5965cc6adc2f410c /mysys/my_getsystime.c
parentaf847c22af26e1cc308eeab08d35942741809408 (diff)
downloadmariadb-git-bddee0c170454f54c1f87299d88d3aa9e44a3872.tar.gz
Windows fixes for VC++ compiler compability
myisam/myisam_ftdump.c: VC++ compiler compability fix mysys/my_getsystime.c: Applied Sergei's code for Windows (still subject to changes by him) sql/handler.cc: VC++ compiler compability fix sql/item_geofunc.cc: Removed non-used variable sql/item_strfunc.cc: VC++ compiler compability fix sql/opt_range.cc: VC++ compiler compability fix sql/sql_insert.cc: VC++ compiler compability fix sql/sql_lex.cc: VC++ compiler compability fix sql/sql_parse.cc: VC++ compiler compability fix sql/sql_prepare.cc: VC++ compiler compability fix sql/sql_union.cc: Removed non-used variable and VC++ compiler compability fix
Diffstat (limited to 'mysys/my_getsystime.c')
-rw-r--r--mysys/my_getsystime.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c
index bdaa232d560..c07dd8eb32e 100644
--- a/mysys/my_getsystime.c
+++ b/mysys/my_getsystime.c
@@ -30,11 +30,26 @@ ulonglong my_getsystime()
clock_gettime(CLOCK_REALTIME, &tp);
return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100;
#elif defined(__WIN__)
- /* TODO: use GetSystemTimeAsFileTime here or
- QueryPerformanceCounter/QueryPerformanceFrequency */
- struct _timeb tb;
- _ftime(&tb);
- return (ulonglong)tb.time*10000000+(ulonglong)tb.millitm*10000;
+#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
+ static __int64 offset=0, freq;
+ LARGE_INTEGER t_cnt;
+ if (!offset)
+ {
+ /* strictly speaking there should be a mutex to protect
+ initialization section. But my_getsystime() is called from
+ UUID() code, and UUID() calls are serialized with a mutex anyway
+ */
+ LARGE_INTEGER li;
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ li.LowPart=ft.dwLowDateTime;
+ li.HighPart=ft.dwHighDateTime;
+ offset=li.QuadPart-OFFSET_TO_EPOC;
+ QueryPerformanceFrequency(&li);
+ freq=li.QuadPart;
+ }
+ QueryPerformanceCounter(&t_cnt);
+ return t_cnt.QuadPart/freq*10000000+t_cnt.QuadPart%freq*10000000/freq+offset;
#elif defined(__NETWARE__)
NXTime_t tm;
NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm);