29 lines
558 B
C
29 lines
558 B
C
#include "components/kcp/ikcp_util.h"
|
|
|
|
#include <unistd.h>
|
|
#include <sys/time.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/types.h>
|
|
|
|
static inline __attribute__((always_inline)) void itimeofday(long* sec, long* usec)
|
|
{
|
|
struct timeval time;
|
|
gettimeofday(&time, NULL);
|
|
if (sec) *sec = time.tv_sec;
|
|
if (usec) *usec = time.tv_usec;
|
|
}
|
|
|
|
// get clock in millisecond 64
|
|
IINT64 iclock64(void)
|
|
{
|
|
long s, u;
|
|
IINT64 value;
|
|
itimeofday(&s, &u);
|
|
value = ((IINT64)s) * 1000 + (u / 1000);
|
|
return value;
|
|
}
|
|
|
|
IUINT32 iclock()
|
|
{
|
|
return (IUINT32)(iclock64() & 0xfffffffful);
|
|
} |