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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
27#ifndef __TIME_C_IMPLEMENTATION__
28#define __TIME_C_IMPLEMENTATION__
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "n_common.h"
35
36#include <time.h>
37#include <limits.h>
38#include "nilorea/n_windows.h"
39#ifndef __windows__
40#include <sys/time.h>
41#endif
42
49typedef struct N_TIME {
51 time_t delta;
52#ifdef __windows__
54 LARGE_INTEGER freq;
56 LARGE_INTEGER startTime;
58 LARGE_INTEGER currentTime;
59#else
61 struct timeval startTime;
63 struct timeval currentTime;
64#endif
65} N_TIME;
66
68#if defined __windows__
69void u_sleep(__int64 usec);
70#else
71void u_sleep(unsigned int usec);
72#endif
73
75void PAUSE(void);
76
78int start_HiTimer(N_TIME* timer);
79
81time_t get_usec(N_TIME* timer);
82
84time_t get_msec(N_TIME* timer);
85
87time_t get_sec(N_TIME* timer);
88
93#ifdef __cplusplus
94}
95#endif
96
97#endif /* #ifndef __COMMON_FOR_C_IMPLEMENTATION__ */
struct timeval startTime
start time
Definition n_time.h:61
time_t delta
time since last poll
Definition n_time.h:51
struct timeval currentTime
current time
Definition n_time.h:63
void u_sleep(unsigned int usec)
sleep for the given number of microseconds
Definition n_time.c:54
int start_HiTimer(N_TIME *timer)
Init or restart from zero any N_TIME HiTimer.
Definition n_time.c:85
time_t get_usec(N_TIME *timer)
Poll any N_TIME HiTimer, returning usec.
Definition n_time.c:107
time_t get_msec(N_TIME *timer)
Poll any N_TIME HiTimer, returning msec.
Definition n_time.c:128
time_t get_sec(N_TIME *timer)
Poll any N_TIME HiTimer, returning sec.
Definition n_time.c:149
void PAUSE(void)
for the 'press a key to continue'
Definition n_time.c:62
Timing Structure.
Definition n_time.h:49
Common headers and low-level functions & define.