safer names for utility macros
This commit is contained in:
+4
-4
@@ -141,7 +141,7 @@ pic_value pic_gc_protect(pic_state *, pic_value);
|
||||
size_t pic_gc_arena_preserve(pic_state *);
|
||||
void pic_gc_arena_restore(pic_state *, size_t);
|
||||
#define pic_void(exec) \
|
||||
pic_void_(GENSYM(ai), exec)
|
||||
pic_void_(PIC_GENSYM(ai), exec)
|
||||
#define pic_void_(ai,exec) do { \
|
||||
size_t ai = pic_gc_arena_preserve(pic); \
|
||||
exec; \
|
||||
@@ -202,7 +202,7 @@ struct pic_lib *pic_open_library(pic_state *, pic_value);
|
||||
struct pic_lib *pic_find_library(pic_state *, pic_value);
|
||||
|
||||
#define pic_deflibrary(pic, spec) \
|
||||
pic_deflibrary_helper_(pic, GENSYM(i), GENSYM(prev_lib), spec)
|
||||
pic_deflibrary_helper_(pic, PIC_GENSYM(i), PIC_GENSYM(prev_lib), spec)
|
||||
#define pic_deflibrary_helper_(pic, i, prev_lib, spec) \
|
||||
for (int i = 0; ! i; ) \
|
||||
for (struct pic_lib *prev_lib; ! i; ) \
|
||||
@@ -212,8 +212,8 @@ void pic_import(pic_state *, pic_value);
|
||||
void pic_import_library(pic_state *, struct pic_lib *);
|
||||
void pic_export(pic_state *, pic_sym);
|
||||
|
||||
noreturn void pic_panic(pic_state *, const char *);
|
||||
noreturn void pic_errorf(pic_state *, const char *, ...);
|
||||
pic_noreturn void pic_panic(pic_state *, const char *);
|
||||
pic_noreturn void pic_errorf(pic_state *, const char *, ...);
|
||||
void pic_warnf(pic_state *, const char *, ...);
|
||||
const char *pic_errmsg(pic_state *);
|
||||
pic_str *pic_get_backtrace(pic_state *);
|
||||
|
||||
@@ -27,7 +27,7 @@ struct pic_error *pic_make_error(pic_state *, pic_sym, const char *, pic_list);
|
||||
/* do not return from try block! */
|
||||
|
||||
#define pic_try \
|
||||
pic_try_(GENSYM(escape))
|
||||
pic_try_(PIC_GENSYM(escape))
|
||||
#define pic_try_(escape) \
|
||||
struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape)); \
|
||||
pic_save_point(pic, escape); \
|
||||
@@ -43,9 +43,9 @@ void pic_push_try(pic_state *, struct pic_escape *);
|
||||
void pic_pop_try(pic_state *);
|
||||
|
||||
pic_value pic_raise_continuable(pic_state *, pic_value);
|
||||
noreturn void pic_raise(pic_state *, pic_value);
|
||||
noreturn void pic_throw(pic_state *, pic_sym, const char *, pic_list);
|
||||
noreturn void pic_error(pic_state *, const char *, pic_list);
|
||||
pic_noreturn void pic_raise(pic_state *, pic_value);
|
||||
pic_noreturn void pic_throw(pic_state *, pic_sym, const char *, pic_list);
|
||||
pic_noreturn void pic_error(pic_state *, const char *, pic_list);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ pic_value pic_list7(pic_state *, pic_value, pic_value, pic_value, pic_value, pic
|
||||
pic_value pic_list_by_array(pic_state *, size_t, pic_value *);
|
||||
pic_value pic_make_list(pic_state *, size_t, pic_value);
|
||||
|
||||
#define pic_for_each(var, list) \
|
||||
pic_for_each_helper_(var, GENSYM(tmp), list)
|
||||
#define pic_for_each_helper_(var, tmp, list) \
|
||||
#define pic_for_each(var, list) \
|
||||
pic_for_each_helper_(var, PIC_GENSYM(tmp), list)
|
||||
#define pic_for_each_helper_(var, tmp, list) \
|
||||
for (pic_value tmp = (list); \
|
||||
pic_nil_p(tmp) ? false : ((var = pic_car(pic, tmp)), true); \
|
||||
tmp = pic_cdr(pic, tmp))
|
||||
|
||||
+14
-13
@@ -11,33 +11,34 @@ extern "C" {
|
||||
|
||||
#if __STDC_VERSION__ >= 201112L
|
||||
# include <stdnoreturn.h>
|
||||
# define pic_noreturn noreturn
|
||||
#elif __GNUC__ || __clang__
|
||||
# define noreturn __attribute__((noreturn))
|
||||
# define pic_noreturn __attribute__((noreturn))
|
||||
#else
|
||||
# define noreturn
|
||||
# define pic_noreturn
|
||||
#endif
|
||||
|
||||
#define FALLTHROUGH ((void)0)
|
||||
#define UNUSED(v) ((void)(v))
|
||||
#define PIC_FALLTHROUGH ((void)0)
|
||||
#define PIC_UNUSED(v) ((void)(v))
|
||||
|
||||
#define GENSYM2_(x,y) G##x##_##y##__
|
||||
#define GENSYM1_(x,y) GENSYM2_(x,y)
|
||||
#define PIC_GENSYM2_(x,y) PIC_G##x##_##y##_
|
||||
#define PIC_GENSYM1_(x,y) PIC_GENSYM2_(x,y)
|
||||
#if defined(__COUNTER__)
|
||||
# define GENSYM(x) GENSYM1_(__COUNTER__,x)
|
||||
# define PIC_GENSYM(x) PIC_GENSYM1_(__COUNTER__,x)
|
||||
#else
|
||||
# define GENSYM(x) GENSYM1_(__LINE__,x)
|
||||
# define PIC_GENSYM(x) PIC_GENSYM1_(__LINE__,x)
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION >= 40500 || __clang__
|
||||
# define UNREACHABLE() (__builtin_unreachable())
|
||||
# define PIC_UNREACHABLE() (__builtin_unreachable())
|
||||
#else
|
||||
# include <assert.h>
|
||||
# define UNREACHABLE() (assert(false))
|
||||
# define PIC_UNREACHABLE() (assert(false))
|
||||
#endif
|
||||
|
||||
#define SWAP(type,a,b) \
|
||||
SWAP_HELPER_(type,GENSYM(tmp),a,b)
|
||||
#define SWAP_HELPER_(type,tmp,a,b) \
|
||||
#define PIC_SWAP(type,a,b) \
|
||||
PIC_SWAP_HELPER_(type, PIC_GENSYM(tmp), a, b)
|
||||
#define PIC_SWAP_HELPER_(type,tmp,a,b) \
|
||||
do { \
|
||||
type tmp = (a); \
|
||||
(a) = (b); \
|
||||
|
||||
@@ -225,7 +225,7 @@ pic_type(pic_value v)
|
||||
return ((struct pic_object *)pic_ptr(v))->tt;
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
PIC_UNREACHABLE();
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
@@ -279,7 +279,7 @@ pic_type_repr(enum pic_tt tt)
|
||||
case PIC_TT_RECORD:
|
||||
return "record";
|
||||
}
|
||||
UNREACHABLE();
|
||||
PIC_UNREACHABLE();
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
||||
Reference in New Issue
Block a user