File: timer.h

package info (click to toggle)
muon-meson 0.5.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,532 kB
  • sloc: ansic: 67,766; python: 4,391; cpp: 1,983; sh: 709; javascript: 570; asm: 226; xml: 67; objc: 36; makefile: 29; modula3: 8; f90: 7
file content (38 lines) | stat: -rw-r--r-- 717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * SPDX-FileCopyrightText: Stone Tickle <lattis@mochiro.moe>
 * SPDX-FileCopyrightText: Vincent Torri <vincent.torri@gmail.com>
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef MUON_PLATFORM_TIMER_H
#define MUON_PLATFORM_TIMER_H

#include <stdint.h>

#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#else
#include <time.h>
#endif

struct timer {
#if defined(_WIN32)
	LARGE_INTEGER freq;
	LARGE_INTEGER start;
#elif defined(CLOCK_MONOTONIC)
	struct timespec start;
#else
	struct timeval start;
#endif
};

void timer_start(struct timer *t);
float timer_read(struct timer *t);
void timer_sleep(uint64_t nanoseconds);

#define SLEEP_TIME 10000000 // 10ms

#endif