milsko/src/abstract/time.c
NishiOwO b34054e916 abstract
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@604 b9cfdab3-6d41-4d17-bbe4-086880011989
2025-11-05 04:29:01 +00:00

35 lines
493 B
C

/* $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