add jtk.time module
This commit is contained in:
parent
09875f5d49
commit
977b7cbf37
@ -4,12 +4,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <GL/glx.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static Display * g_display;
|
||||
static XVisualInfo * g_vi;
|
||||
static XSetWindowAttributes g_swa;
|
||||
static GLXContext g_context;
|
||||
|
||||
/**************************************************************************
|
||||
* Init
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* Initialize the Jtk subsystem.
|
||||
*
|
||||
@ -56,6 +61,26 @@ bool jtk_init()
|
||||
return true;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Time
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* Get system time in microseconds.
|
||||
*
|
||||
* @return System time in microseconds.
|
||||
*/
|
||||
uint64_t jtk_us_time()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (uint64_t)tv.tv_sec * 1000000u + (uint64_t)tv.tv_usec;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Window
|
||||
*************************************************************************/
|
||||
|
||||
static Bool wait_for_notify(Display * display, XEvent * event, XPointer arg)
|
||||
{
|
||||
return (event->type == MapNotify) && (event->xmap.window == (Window)arg);
|
||||
|
@ -2,4 +2,5 @@ module jtk;
|
||||
|
||||
public import jtk.event;
|
||||
public import jtk.init;
|
||||
public import jtk.time;
|
||||
public import jtk.window;
|
||||
|
13
src/jtk/time.d
Normal file
13
src/jtk/time.d
Normal file
@ -0,0 +1,13 @@
|
||||
module jtk.time;
|
||||
|
||||
private extern(C) ulong jtk_us_time();
|
||||
|
||||
ulong us_time()
|
||||
{
|
||||
return jtk_us_time();
|
||||
}
|
||||
|
||||
ulong ms_time()
|
||||
{
|
||||
return us_time() / 1000u;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user