Nilorea Library
C utilities for networking, threading, graphics
n_time.h
Go to the documentation of this file.
1
8#ifndef __TIME_C_IMPLEMENTATION__
9#define __TIME_C_IMPLEMENTATION__
10
11#ifdef __cplusplus
12extern "C"
13{
14#endif
15
16#include "n_common.h"
17
18#include <time.h>
19#include <limits.h>
20
21#ifdef __windows__
22#include <windows.h>
23#else
24#include <sys/time.h>
25#endif
26
33typedef struct N_TIME
34{
36 time_t delta;
37#ifdef __windows__
39 LARGE_INTEGER freq;
41 LARGE_INTEGER startTime;
43 LARGE_INTEGER currentTime;
44#else
46 struct timeval startTime;
48 struct timeval currentTime;
49#endif
50} N_TIME;
51
52#if defined __windows__
53void u_sleep( __int64 usec);
54#else
55void u_sleep( unsigned int usec );
56#endif
57
58/* for the 'press a key to continue' */
59void PAUSE( void );
60
61/* Init or restart from zero any N_TIME HiTimer */
62int start_HiTimer( N_TIME *timer );
63
64/* Poll any N_TIME HiTimer, returning usec */
65time_t get_usec( N_TIME *timer );
66
67/* Poll any N_TIME HiTimer, returning msec */
68time_t get_msec( N_TIME *timer );
69
70/* Poll any N_TIME HiTimer, returning sec */
71time_t get_sec( N_TIME *timer );
72
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* #ifndef __COMMON_FOR_C_IMPLEMENTATION__ */
struct timeval startTime
start time
Definition: n_time.h:46
time_t delta
time since last poll
Definition: n_time.h:36
struct timeval currentTime
start time
Definition: n_time.h:48
void u_sleep(unsigned int usec)
wrapper around usleep for API consistency
Definition: n_time.c:38
int start_HiTimer(N_TIME *timer)
Initialize or restart from zero any N_TIME HiTimer.
Definition: n_time.c:82
time_t get_usec(N_TIME *timer)
Poll any N_TIME HiTimer, returning usec, and moving currentTime to startTime.
Definition: n_time.c:107
time_t get_msec(N_TIME *timer)
Poll any N_TIME HiTimer, returning msec, and moving currentTime to startTime.
Definition: n_time.c:130
time_t get_sec(N_TIME *timer)
Poll any N_TIME HiTimer, returning sec, and moving currentTime to startTime.
Definition: n_time.c:153
void PAUSE(void)
make a pause in a terminal
Definition: n_time.c:49
Timing Structure.
Definition: n_time.h:34
Common headers and low-level hugly functions & define.