Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
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#endif
14
15#include "n_common.h"
16
17#include <time.h>
18#include <limits.h>
19
20#ifdef __windows__
21#include <windows.h>
22#else
23#include <sys/time.h>
24#endif
25
32typedef struct N_TIME {
34 time_t delta;
35#ifdef __windows__
37 LARGE_INTEGER freq;
39 LARGE_INTEGER startTime;
41 LARGE_INTEGER currentTime;
42#else
44 struct timeval startTime;
46 struct timeval currentTime;
47#endif
48} N_TIME;
49
50#if defined __windows__
51void u_sleep(__int64 usec);
52#else
53void u_sleep(unsigned int usec);
54#endif
55
56/* for the 'press a key to continue' */
57void PAUSE(void);
58
59/* Init or restart from zero any N_TIME HiTimer */
60int start_HiTimer(N_TIME* timer);
61
62/* Poll any N_TIME HiTimer, returning usec */
63time_t get_usec(N_TIME* timer);
64
65/* Poll any N_TIME HiTimer, returning msec */
66time_t get_msec(N_TIME* timer);
67
68/* Poll any N_TIME HiTimer, returning sec */
69time_t get_sec(N_TIME* timer);
70
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* #ifndef __COMMON_FOR_C_IMPLEMENTATION__ */
struct timeval startTime
start time
Definition n_time.h:44
time_t delta
time since last poll
Definition n_time.h:34
struct timeval currentTime
start time
Definition n_time.h:46
void u_sleep(unsigned int usec)
wrapper around usleep for API consistency
Definition n_time.c:35
int start_HiTimer(N_TIME *timer)
Initialize or restart from zero any N_TIME HiTimer.
Definition n_time.c:67
time_t get_usec(N_TIME *timer)
Poll any N_TIME HiTimer, returning usec, and moving currentTime to startTime.
Definition n_time.c:89
time_t get_msec(N_TIME *timer)
Poll any N_TIME HiTimer, returning msec, and moving currentTime to startTime.
Definition n_time.c:109
time_t get_sec(N_TIME *timer)
Poll any N_TIME HiTimer, returning sec, and moving currentTime to startTime.
Definition n_time.c:129
void PAUSE(void)
make a pause in a terminal
Definition n_time.c:43
Timing Structure.
Definition n_time.h:32
Common headers and low-level functions & define.