]> git.saurik.com Git - minimal.git/blob - minimal.h
6e26870727f8b277bfcb2e518d8e88242dc1a2ff
[minimal.git] / minimal.h
1 #define _assert(expr) \
2 do if (!(expr)) { \
3 fprintf(stderr, "%s(%u): _assert(%u:%s)\n", __FILE__, __LINE__, errno, #expr); \
4 exit(1); \
5 } while (false)
6
7 #define _syscall(expr) \
8 do if ((long) (expr) != -1) \
9 break; \
10 else switch (errno) { \
11 case EINTR: \
12 continue; \
13 default: \
14 _assert(false); \
15 } while (true)
16
17 #define _forever \
18 for (;;)
19
20 #define _trace() \
21 printf("_trace(%s:%u)\n", __FILE__, __LINE__)
22
23 #define _not(type) \
24 ((type) ~ (type) 0)
25
26 #include <stdio.h>
27 #include <stdbool.h>
28 #include <stdlib.h>
29 #include <stdint.h>