abstract
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@604 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
5a25b79546
commit
b34054e916
13 changed files with 90 additions and 47 deletions
35
src/abstract/time.c
Normal file
35
src/abstract/time.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
long MwTimeGetTick(void) {
|
||||
return GetTickCount();
|
||||
}
|
||||
|
||||
void MwTimeSleep(int ms) {
|
||||
Sleep(ms);
|
||||
}
|
||||
#else
|
||||
long MwTimeGetTick(void) {
|
||||
struct timespec ts;
|
||||
long n = 0;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
n += ts.tv_nsec / 1000 / 1000;
|
||||
n += ts.tv_sec * 1000;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void MwTimeSleep(int ms) {
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = ms / 1000;
|
||||
ts.tv_nsec = (ms % 1000) * 1000 * 1000;
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue