.
This commit is contained in:
parent
7aa9c8ee3d
commit
93840bc2ab
1 changed files with 18 additions and 17 deletions
35
src/base.c
35
src/base.c
|
|
@ -2,22 +2,6 @@
|
|||
#include <stddef.h>
|
||||
#include <Block.h>
|
||||
|
||||
#define capture __block
|
||||
#define closure Block_copy
|
||||
|
||||
typedef void (^__defer_block_t)(void);
|
||||
|
||||
static inline void __defer_exec(__defer_block_t *blk) { (*blk)(); }
|
||||
|
||||
#define __concat__2(a, b) a##b
|
||||
#define __concat(a, b) __concat__2(a, b)
|
||||
|
||||
#define scope_exit \
|
||||
__attribute__((cleanup(__defer_exec), unused)) \
|
||||
__defer_block_t __concat(_defer_, __LINE__) = ^
|
||||
|
||||
#define auto __auto_type
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
|
|
@ -37,9 +21,26 @@ typedef intptr_t sptr;
|
|||
typedef uptr ureg;
|
||||
typedef sptr sreg;
|
||||
|
||||
#define auto __auto_type
|
||||
|
||||
// Thanks AZMR
|
||||
// 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)
|
||||
|
||||
|
||||
#define capture __block
|
||||
#define closure Block_copy
|
||||
|
||||
typedef void (^__defer__block)(void);
|
||||
|
||||
static inline void __defer__exec(__defer__block *blk) { (*blk)(); }
|
||||
|
||||
#define __concat__2(a, b) a##b
|
||||
#define __concat(a, b) __concat__2(a, b)
|
||||
|
||||
#define scope_exit \
|
||||
__attribute__((cleanup(__defer__exec), unused)) \
|
||||
__defer__block __concat(_defer_, __LINE__) = ^
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue