Skip to content

Commit

Permalink
🎨 no more m_bool
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Feb 17, 2024
1 parent 373c31f commit 40579af
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
34 changes: 0 additions & 34 deletions include/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#define container_of(ptr, type, member) \
((type *)((char *)(ptr)-offsetof(type, member)))

#define GW_ERROR -1
#define GW_OK 1
#define MEM_STEP 16
#define SIZEOF_MEM (0x1 << MEM_STEP)
#define SIZEOF_REG (0x1 << 14)
Expand All @@ -44,10 +42,6 @@
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

#define CHECK_b(f) \
do { \
if (!f) return GW_ERROR; \
} while (0)
#define CHECK_B(f) \
do { \
if (!f) return false; \
Expand All @@ -56,41 +50,13 @@
do { \
if (!f) return NULL; \
} while (0)
#define CHECK_BB(f) \
do { \
if (f < 0) return GW_ERROR; \
} while (0)
#define CHECK_OB(f) \
do { \
if (!f) return GW_ERROR; \
} while (0)
#define CHECK_BO(f) \
do { \
if (f < 0) return NULL; \
} while (0)
#define CHECK_OO(f) \
do { \
if (!f) return NULL; \
} while (0)

#define DECL_B(decl, f, exp) \
decl f exp; \
if (!f) return false
#define DECL_O(decl, f, exp) \
decl f exp; \
if (!f) return NULL
#define DECL_BB(decl, f, exp) \
decl f exp; \
if (f < 0) return GW_ERROR
#define DECL_OB(decl, f, exp) \
decl f exp; \
if (!f) return GW_ERROR
#define DECL_BO(decl, f, exp) \
decl f exp; \
if (f < 0) return NULL
#define DECL_OO(decl, f, exp) \
decl f exp; \
if (!f) return NULL

#include <stdio.h>
#include <math.h>
Expand Down
1 change: 0 additions & 1 deletion include/gwcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
typedef intptr_t m_int;
typedef uintptr_t m_uint;
typedef unsigned char m_bit;
typedef int m_bool;
typedef float m_float;
typedef char * m_str;
typedef struct { m_float x, y, z; } m_vec3;
Expand Down
3 changes: 2 additions & 1 deletion src/gwion_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ ANN2(2)
static int gw_vasprintf(MemPool mp, char **str, const char *fmt, va_list args) {
char * base = *str;
const size_t base_len = base ? strlen(base) : 0;
DECL_BB(const int, size, = fmtlen(fmt, args));
const int size = fmtlen(fmt, args));
if (size < 0) return -1;
char *ret = mp_malloc2(mp, base_len + size + 1);
if (base) strcpy(ret, base);
const int final_len = vsprintf(ret + base_len, fmt, args);
Expand Down
2 changes: 1 addition & 1 deletion src/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ANN Vector vector_copy(MemPool p, const Vector v) {
ANN m_int vector_find(const Vector v, const vtype data) {
for (vtype i = VLEN(v) + 1; --i;)
if (VPTR(v, i - 1) == (vtype)data) return (m_int)(i - 1);
return GW_ERROR;
return -1;
}

ANN void vector_rem(const Vector v, const vtype index) {
Expand Down

0 comments on commit 40579af

Please sign in to comment.