Subastra
Loading...
Searching...
No Matches
defs.h
Go to the documentation of this file.
1#ifndef __H__DEFS__
2#define __H__DEFS__
3
4#include <stdbool.h>
5#include <stdint.h>
6#include <stdio.h>
7#include <stdlib.h>
8
9#define PANIC_(msg) \
10 do { \
11 fprintf(stderr, "%s:%d\t\t" msg "\n", __FILE__, __LINE__); \
12 abort(); \
13 } while (0)
14
15#define PANIC(msg, ...) \
16 do { \
17 fprintf(stderr, "%s:%d\t\t" msg "\n", __FILE__, __LINE__, __VA_ARGS__); \
18 abort(); \
19 } while (0)
20
21#define ASSERT__(expr) \
22 do { \
23 if (!(expr)) \
24 PANIC_("not ok!.\tAsserton Failed! " #expr); \
25 else \
26 fprintf(stderr, "# %s:%d\t\tok.\t%s\n", __FILE__, __LINE__, #expr); \
27 } while (0)
28
29#define ASSERT_(expr, msg) \
30 do { \
31 if (!(expr)) \
32 PANIC_("not ok!\tAsserton Failed! " msg); \
33 } while (0)
34
35#define ASSERT(expr, msg, ...) \
36 do { \
37 if (!(expr)) \
38 PANIC("not ok!\tAssertion Failed! " msg, __VA_ARGS__); \
39 } while (0)
40
41// TODO: replace builtins
42#define FLOAT32_INFTY (__builtin_inff())
43#define FLOAT32_NEG_INFTY (-__builtin_inff())
44
45typedef uint32_t u32;
46typedef uint64_t u64;
47typedef int32_t i32;
48typedef uint16_t u16;
49typedef unsigned char byte;
50typedef char i8;
51typedef size_t sz;
52
53#endif
unsigned char byte
Definition defs.h:49
uint64_t u64
Definition defs.h:46
int32_t i32
Definition defs.h:47
size_t sz
Definition defs.h:51
uint16_t u16
Definition defs.h:48
char i8
Definition defs.h:50
uint32_t u32
Definition defs.h:45