aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorLibravatar Comrade Martin Miroslavovich Michalec <martin@michalec.dev>2023-11-25 18:59:53 +0000
committerLibravatar Martin Michalec <martin@michalec.dev>2026-11-07 02:12:54 +0000
commit055f35e74601bea2223a1555c15b029ee90a9117 (patch)
treec2bc92f254ad85b9fc545ab30a700757d72902fc /src/utils.h
downloadlab-02-055f35e74601bea2223a1555c15b029ee90a9117.tar.gz
publishHEADmaster
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..8cdbe46
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,40 @@
1#ifndef UTILS_H
2#define UTILS_H
3
4#include <stdint.h>
5
6#define MAX(a, b) ({ \
7 __typeof__ (a) _a = (a); \
8 __typeof__ (b) _b = (b); \
9 _a > _b ? _a : _b; \
10 })
11
12#define MIN(a, b) ({ \
13 __typeof__ (a) _a = (a); \
14 __typeof__ (b) _b = (b); \
15 _a < _b ? _a : _b; \
16 })
17
18#define CLZ(X) __builtin_clz (X)
19#define CTZ(X) __builtin_ctz (X)
20#define FFS(X) __builtin_ffs (X)
21#define POPCOUNT(X) __builtin_popcount (X)
22
23#define PAGEBREAK() puts ("\n ")
24#define NEWLINE() putchar ('\n')
25
26typedef unsigned int uint;
27typedef uint8_t u8;
28typedef uint16_t u16;
29typedef uint64_t u64;
30
31int
32input (const char *message, const char *regex, const char *template, ...);
33
34uint
35log10ui (uint ui);
36
37u16
38rev16 (u16 b);
39
40#endif