]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - src/types.h
Append .zip to ZIP files generated by release script
[dragonblocks_alpha.git] / src / types.h
1 #ifndef _TYPES_H_
2 #define _TYPES_H_
3
4 #include <stdint.h>
5 #include <stdbool.h>
6
7 #define DEFRW(type) \
8         bool read_ ## type(int fd, type *ptr); \
9         bool write_ ## type(int fd, type val);
10
11 #define DEFVEC(type) \
12         typedef struct {type x, y;} v2 ## type; \
13         DEFRW(v2 ## type) \
14         typedef struct {type x, y, z;} v3 ## type; \
15         DEFRW(v3 ## type)
16
17 #define DEFTYP(from, to) \
18         typedef from to; \
19         DEFRW(to) \
20         DEFVEC(to)
21
22 #define DEFTYPES(bits) \
23         DEFTYP(int ## bits ## _t, s ## bits) \
24         DEFTYP(uint ## bits ## _t, u ## bits)
25
26 DEFTYPES(8)
27 DEFTYPES(16)
28 DEFTYPES(32)
29 DEFTYPES(64)
30
31 typedef float f32;
32 typedef double f64;
33
34 DEFTYP(float, f32)
35 DEFTYP(double, f64)
36
37 typedef v2f32 v2f;
38 typedef v3f32 v3f;
39
40 #undef DEFRW
41 #undef DEFVEC
42 #undef DEFTYP
43 #undef DEFTYPES
44
45 #endif