-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplatform.h
More file actions
33 lines (26 loc) · 824 Bytes
/
platform.h
File metadata and controls
33 lines (26 loc) · 824 Bytes
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
#pragma once
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <libusb-1.0/libusb.h>
typedef unsigned char uchar;
#define crash(format, ...) do { \
fprintf(stderr, "%s:%u:%s | errno: %d | " format "\n", __FILE__, __LINE__, __FUNCTION__, errno, ##__VA_ARGS__); \
_Exit(1); \
} while(0);
#define FALSE 0
#define TRUE 1
#define INLINE inline
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define FOR_RANGE(variable, limit) for(size_t variable = 0; variable < limit; ++variable)
static inline double timef(void) {
struct timespec tTime;
if(clock_gettime(CLOCK_MONOTONIC_RAW, &tTime)) return NAN;
return (double)tTime.tv_sec + (double)tTime.tv_nsec * 1.0e-9;
}