03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
0
|
// util/util.h, version 1.0.1 |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
1
|
// Utility header file from libutil |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
2
|
// Copyright (C) 2021, Jakob Wakeling |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
3
|
// MIT Licence |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
4
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
5
|
#ifndef UTIL_UTIL_H_KP8NS9DC |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
6
|
#define UTIL_UTIL_H_KP8NS9DC |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
7
|
|
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
8
|
#ifdef __cplusplus |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
9
|
extern "C" { |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
10
|
#endif |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
11
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
12
|
#include <assert.h> |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
13
|
#include <float.h> |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
14
|
#include <stdbool.h> |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
15
|
#include <stddef.h> |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
16
|
#include <stdint.h> |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
17
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
18
|
/* Type Definitions */ |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
19
|
typedef uint8_t u8; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
20
|
typedef uint16_t u16; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
21
|
typedef uint32_t u32; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
22
|
typedef uint64_t u64; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
23
|
typedef uintptr_t UINT; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
24
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
25
|
typedef int8_t s8; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
26
|
typedef int16_t s16; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
27
|
typedef int32_t s32; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
28
|
typedef int64_t s64; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
29
|
typedef intptr_t sint; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
30
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
31
|
typedef float f32; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
32
|
typedef double f64; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
33
|
typedef long double f128; |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
34
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
35
|
/* Type Limits */ |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
36
|
#define U8_MIN UINT8_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
37
|
#define U8_MAX UINT8_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
38
|
#define U16_MIN UINT16_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
39
|
#define U16_MAX UINT16_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
40
|
#define U32_MIN UINT32_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
41
|
#define U32_MAX UINT32_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
42
|
#define U64_MIN UINT64_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
43
|
#define U64_MAX UINT64_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
44
|
#define UINT_MIN UINTPTR_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
45
|
#define UINT_MAX UINTPTR_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
46
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
47
|
#define S8_MIN INT8_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
48
|
#define S8_MAX INT8_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
49
|
#define S16_MIN INT16_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
50
|
#define S16_MAX INT16_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
51
|
#define S32_MIN INT32_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
52
|
#define S32_MAX INT32_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
53
|
#define S64_MIN INT64_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
54
|
#define S64_MAX INT64_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
55
|
#define SINT_MIN INTPTR_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
56
|
#define SINT_MAX INTPTR_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
57
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
58
|
#define F32_MIN FLT_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
59
|
#define F32_MAX FLT_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
60
|
#define F64_MIN DBL_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
61
|
#define F64_MAX DBL_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
62
|
#define F128_MIN LDBL_MIN |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
63
|
#define F128_MAX LDBL_MAX |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
64
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
65
|
/* Miscellaneous */ |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
66
|
#define BIT(x) (1 << (x)) |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
67
|
|
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
68
|
#ifdef __cplusplus |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
69
|
} // extern "C" |
03b01d2 |
Jamozed |
2022-03-06 17:10:01 |
70
|
#endif |
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
71
|
|
c01a723 |
Jamozed |
2022-02-05 19:04:03 |
72
|
#endif // UTIL_UTIL_H_KP8NS9DC |
|
|
|
73
|
|