Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_time.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
26#ifndef __TIME_C_IMPLEMENTATION__
27#define __TIME_C_IMPLEMENTATION__
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "n_common.h"
34
35#include <time.h>
36#include <limits.h>
37#include "nilorea/n_windows.h"
38#ifndef __windows__
39#include <sys/time.h>
40#endif
41
48typedef struct N_TIME {
50 time_t delta;
51#ifdef __windows__
53 LARGE_INTEGER freq;
55 LARGE_INTEGER startTime;
57 LARGE_INTEGER currentTime;
58#else
60 struct timeval startTime;
62 struct timeval currentTime;
63#endif
64} N_TIME;
65
67#if defined __windows__
68void u_sleep(__int64 usec);
69#else
70void u_sleep(unsigned int usec);
71#endif
72
74void PAUSE(void);
75
77int start_HiTimer(N_TIME* timer);
78
80time_t get_usec(N_TIME* timer);
81
83time_t get_msec(N_TIME* timer);
84
86time_t get_sec(N_TIME* timer);
87
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* #ifndef __COMMON_FOR_C_IMPLEMENTATION__ */
struct timeval startTime
start time
Definition n_time.h:60
time_t delta
time since last poll
Definition n_time.h:50
struct timeval currentTime
current time
Definition n_time.h:62
void u_sleep(unsigned int usec)
sleep for the given number of microseconds
Definition n_time.c:53
int start_HiTimer(N_TIME *timer)
Init or restart from zero any N_TIME HiTimer.
Definition n_time.c:84
time_t get_usec(N_TIME *timer)
Poll any N_TIME HiTimer, returning usec.
Definition n_time.c:106
time_t get_msec(N_TIME *timer)
Poll any N_TIME HiTimer, returning msec.
Definition n_time.c:127
time_t get_sec(N_TIME *timer)
Poll any N_TIME HiTimer, returning sec.
Definition n_time.c:148
void PAUSE(void)
for the 'press a key to continue'
Definition n_time.c:61
Timing Structure.
Definition n_time.h:48
Common headers and low-level functions & define.