#include #include #include #define capture __block #define closure Block_copy typedef void (^__defer_block_t)(void); static inline void __defer_exec(__defer_block_t *blk) { (*blk)(); } #define __cat_2(a, b) a##b #define __cat_1(a, b) __cat_2(a, b) #define scope_exit \ __attribute__((cleanup(__defer_exec), unused)) \ __defer_block_t __cat_1(_defer_, __LINE__) = ^ #define auto __auto_type typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; typedef float f32; typedef double f64; typedef intptr_t intptr; typedef uintptr_t uintptr; typedef size_t usize; typedef ptrdiff_t ssize; // Thanks AZMR #define cast(to_type, expr) ((to_type)(expr)) #define chkcast(to_type, from_type, expr) _Generic(expr, from_type: (to_type)(expr)) #define ptrcast(to_type, from_type, expr) _Generic(expr, from_type: (to_type)(uintptr_t)(expr)) #define bitcast(to_type, from_type, expr) (((union { from_type from; to_type to; }){_Generic(expr, from_type: expr)}).to)