diff --git a/contrib/03.callcc/callcc.c b/contrib/03.callcc/callcc.c index e366b8e0..eb519331 100644 --- a/contrib/03.callcc/callcc.c +++ b/contrib/03.callcc/callcc.c @@ -161,7 +161,7 @@ native_stack_extend(pic_state *pic, struct pic_cont *cont) restore_cont(pic, cont); } -noreturn static void +pic_noreturn static void restore_cont(pic_state *pic, struct pic_cont *cont) { char v; @@ -203,7 +203,7 @@ restore_cont(pic_state *pic, struct pic_cont *cont) longjmp(tmp->jmp, 1); } -noreturn static pic_value +pic_noreturn static pic_value cont_call(pic_state *pic) { struct pic_proc *proc; diff --git a/extlib/benz/codegen.c b/extlib/benz/codegen.c index f6183278..e43f19c0 100644 --- a/extlib/benz/codegen.c +++ b/extlib/benz/codegen.c @@ -492,7 +492,7 @@ analyze_if(analyze_state *state, pic_value obj, bool tailpos) pic_errorf(pic, "syntax error"); case 4: if_false = pic_list_ref(pic, obj, 3); - FALLTHROUGH; + PIC_FALLTHROUGH; case 3: if_true = pic_list_ref(pic, obj, 2); } diff --git a/extlib/benz/cont.c b/extlib/benz/cont.c index 4e38e8c6..b1af6eca 100644 --- a/extlib/benz/cont.c +++ b/extlib/benz/cont.c @@ -93,7 +93,7 @@ pic_load_point(pic_state *pic, struct pic_escape *escape) escape->valid = false; } -noreturn static pic_value +static pic_value escape_call(pic_state *pic) { size_t argc; diff --git a/extlib/benz/dict.c b/extlib/benz/dict.c index 81bdea68..ca411551 100644 --- a/extlib/benz/dict.c +++ b/extlib/benz/dict.c @@ -14,7 +14,7 @@ xh_value_hash(const void *key, void *data) pic_value val = *(pic_value *)key; int hash, vtype; - UNUSED(data); + PIC_UNUSED(data); vtype = pic_vtype(val); @@ -96,7 +96,7 @@ pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_value key) void pic_dict_set(pic_state *pic, struct pic_dict *dict, pic_value key, pic_value val) { - UNUSED(pic); + PIC_UNUSED(pic); xh_put_value(&dict->hash, key, &val); } @@ -104,7 +104,7 @@ pic_dict_set(pic_state *pic, struct pic_dict *dict, pic_value key, pic_value val size_t pic_dict_size(pic_state *pic, struct pic_dict *dict) { - UNUSED(pic); + PIC_UNUSED(pic); return dict->hash.count; } @@ -112,7 +112,7 @@ pic_dict_size(pic_state *pic, struct pic_dict *dict) bool pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_value key) { - UNUSED(pic); + PIC_UNUSED(pic); return xh_get_value(&dict->hash, key) != NULL; } diff --git a/extlib/benz/error.c b/extlib/benz/error.c index 3b462969..69c12206 100644 --- a/extlib/benz/error.c +++ b/extlib/benz/error.c @@ -17,7 +17,7 @@ void pic_panic(pic_state *pic, const char *msg) { - UNUSED(pic); + PIC_UNUSED(pic); fprintf(stderr, "abort: %s\n", msg); abort(); @@ -69,7 +69,7 @@ pic_errmsg(pic_state *pic) return pic_str_cstr(str); } -noreturn static pic_value +static pic_value native_exception_handler(pic_state *pic) { pic_value err; @@ -83,7 +83,7 @@ native_exception_handler(pic_state *pic) pic_apply1(pic, cont, pic_false_value()); - UNREACHABLE(); + PIC_UNREACHABLE(); } void @@ -166,7 +166,7 @@ pic_raise_continuable(pic_state *pic, pic_value err) return v; } -noreturn void +void pic_raise(pic_state *pic, pic_value err) { pic_value val; @@ -178,7 +178,7 @@ pic_raise(pic_state *pic, pic_value err) pic_errorf(pic, "error handler returned with ~s on error ~s", val, err); } -noreturn void +void pic_throw(pic_state *pic, pic_sym type, const char *msg, pic_value irrs) { struct pic_error *e; @@ -188,7 +188,7 @@ pic_throw(pic_state *pic, pic_sym type, const char *msg, pic_value irrs) pic_raise(pic, pic_obj_value(e)); } -noreturn void +void pic_error(pic_state *pic, const char *msg, pic_value irrs) { pic_throw(pic, pic_intern_cstr(pic, ""), msg, irrs); @@ -221,7 +221,7 @@ pic_error_with_exception_handler(pic_state *pic) return val; } -noreturn static pic_value +static pic_value pic_error_raise(pic_state *pic) { pic_value v; @@ -241,7 +241,7 @@ pic_error_raise_continuable(pic_state *pic) return pic_raise_continuable(pic, v); } -noreturn static pic_value +static pic_value pic_error_error(pic_state *pic) { const char *str; diff --git a/extlib/benz/file.c b/extlib/benz/file.c index 4a5f57d7..d438c23a 100644 --- a/extlib/benz/file.c +++ b/extlib/benz/file.c @@ -6,7 +6,7 @@ #include "picrin/port.h" #include "picrin/error.h" -static noreturn void +pic_noreturn static void file_error(pic_state *pic, const char *msg) { pic_throw(pic, pic->sFILE, msg, pic_nil_value()); diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index 7768f8b9..633445e8 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -170,7 +170,7 @@ pic_calloc(pic_state *pic, size_t count, size_t size) void pic_free(pic_state *pic, void *ptr) { - UNUSED(pic); + PIC_UNUSED(pic); free(ptr); } diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index 442e06a0..00c1cbe4 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -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 *); diff --git a/extlib/benz/include/picrin/error.h b/extlib/benz/include/picrin/error.h index 784b95f8..e4cc630a 100644 --- a/extlib/benz/include/picrin/error.h +++ b/extlib/benz/include/picrin/error.h @@ -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) } diff --git a/extlib/benz/include/picrin/pair.h b/extlib/benz/include/picrin/pair.h index d489b765..11859482 100644 --- a/extlib/benz/include/picrin/pair.h +++ b/extlib/benz/include/picrin/pair.h @@ -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)) diff --git a/extlib/benz/include/picrin/util.h b/extlib/benz/include/picrin/util.h index d56cd9f6..afa0e037 100644 --- a/extlib/benz/include/picrin/util.h +++ b/extlib/benz/include/picrin/util.h @@ -11,33 +11,34 @@ extern "C" { #if __STDC_VERSION__ >= 201112L # include +# 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 -# 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); \ diff --git a/extlib/benz/include/picrin/value.h b/extlib/benz/include/picrin/value.h index 709fcf77..d21a8418 100644 --- a/extlib/benz/include/picrin/value.h +++ b/extlib/benz/include/picrin/value.h @@ -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 diff --git a/extlib/benz/macro.c b/extlib/benz/macro.c index c7cd243f..eb811253 100644 --- a/extlib/benz/macro.c +++ b/extlib/benz/macro.c @@ -25,7 +25,7 @@ pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym) void pic_put_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym rename) { - UNUSED(pic); + PIC_UNUSED(pic); xh_put_int(&senv->map, sym, &rename); } @@ -35,7 +35,7 @@ pic_find_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym *ren { xh_entry *e; - UNUSED(pic); + PIC_UNUSED(pic); if ((e = xh_get_int(&senv->map, sym)) == NULL) { return false; diff --git a/extlib/benz/proc.c b/extlib/benz/proc.c index 210f157d..2b94201b 100644 --- a/extlib/benz/proc.c +++ b/extlib/benz/proc.c @@ -43,7 +43,7 @@ pic_proc_name(struct pic_proc *proc) case PIC_PROC_KIND_IREP: return proc->u.irep->name; } - UNREACHABLE(); + PIC_UNREACHABLE(); } static pic_value diff --git a/extlib/benz/read.c b/extlib/benz/read.c index be160c0d..46a056f8 100644 --- a/extlib/benz/read.c +++ b/extlib/benz/read.c @@ -18,7 +18,7 @@ static pic_value read(pic_state *pic, struct pic_port *port, int c); static pic_value read_nullable(pic_state *pic, struct pic_port *port, int c); -static noreturn void +pic_noreturn static void read_error(pic_state *pic, const char *msg) { pic_throw(pic, pic->sREAD, msg, pic_nil_value()); @@ -86,8 +86,8 @@ read_comment(pic_state *pic, struct pic_port *port, const char *str) { int c; - UNUSED(pic); - UNUSED(str); + PIC_UNUSED(pic); + PIC_UNUSED(str); do { c = next(port); @@ -102,8 +102,8 @@ read_block_comment(pic_state *pic, struct pic_port *port, const char *str) int x, y; int i = 1; - UNUSED(pic); - UNUSED(str); + PIC_UNUSED(pic); + PIC_UNUSED(str); y = next(port); @@ -124,7 +124,7 @@ read_block_comment(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_datum_comment(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(str); + PIC_UNUSED(str); read(pic, port, next(port)); @@ -157,7 +157,7 @@ read_eval(pic_state *pic, struct pic_port *port, const char *str) { pic_value form; - UNUSED(str); + PIC_UNUSED(str); form = read(pic, port, next(port)); @@ -167,7 +167,7 @@ read_eval(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_quote(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(str); + PIC_UNUSED(str); return pic_list2(pic, pic_sym_value(pic->sQUOTE), read(pic, port, next(port))); } @@ -175,7 +175,7 @@ read_quote(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_quasiquote(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(str); + PIC_UNUSED(str); return pic_list2(pic, pic_sym_value(pic->sQUASIQUOTE), read(pic, port, next(port))); } @@ -183,7 +183,7 @@ read_quasiquote(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_unquote(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(str); + PIC_UNUSED(str); return pic_list2(pic, pic_sym_value(pic->sUNQUOTE), read(pic, port, next(port))); } @@ -191,7 +191,7 @@ read_unquote(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_unquote_splicing(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(str); + PIC_UNUSED(str); return pic_list2(pic, pic_sym_value(pic->sUNQUOTE_SPLICING), read(pic, port, next(port))); } @@ -354,9 +354,9 @@ read_plus(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_true(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(pic); - UNUSED(port); - UNUSED(str); + PIC_UNUSED(pic); + PIC_UNUSED(port); + PIC_UNUSED(str); return pic_true_value(); } @@ -364,9 +364,9 @@ read_true(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_false(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(pic); - UNUSED(port); - UNUSED(str); + PIC_UNUSED(pic); + PIC_UNUSED(port); + PIC_UNUSED(str); return pic_false_value(); } @@ -376,7 +376,7 @@ read_char(pic_state *pic, struct pic_port *port, const char *str) { int c; - UNUSED(str); + PIC_UNUSED(str); c = next(port); @@ -418,7 +418,7 @@ read_string(pic_state *pic, struct pic_port *port, const char *name) size_t size, cnt; pic_str *str; - UNUSED(name); + PIC_UNUSED(name); size = 256; buf = pic_alloc(pic, size); @@ -459,7 +459,7 @@ read_pipe(pic_state *pic, struct pic_port *port, const char *str) size_t i = 0; int c; - UNUSED(str); + PIC_UNUSED(str); size = 256; buf = pic_alloc(pic, size); @@ -504,7 +504,7 @@ read_blob(pic_state *pic, struct pic_port *port, const char *str) unsigned char *dat; pic_blob *blob; - UNUSED(str); + PIC_UNUSED(str); nbits = 0; @@ -631,13 +631,13 @@ read_label_set(pic_state *pic, struct pic_port *port, int i) xh_put_int(&pic->reader->labels, i, &val); tmp = pic_vec_ptr(read(pic, port, c)); - SWAP(pic_value *, tmp->data, pic_vec_ptr(val)->data); - SWAP(size_t, tmp->len, pic_vec_ptr(val)->len); + PIC_SWAP(pic_value *, tmp->data, pic_vec_ptr(val)->data); + PIC_SWAP(size_t, tmp->len, pic_vec_ptr(val)->len); return val; } - FALLTHROUGH; + PIC_FALLTHROUGH; } default: { @@ -655,7 +655,7 @@ read_label_ref(pic_state *pic, struct pic_port *port, int i) { xh_entry *e; - UNUSED(port); + PIC_UNUSED(port); e = xh_get_int(&pic->reader->labels, i); if (! e) { @@ -687,8 +687,8 @@ read_label(pic_state *pic, struct pic_port *port, const char *str) static pic_value read_unmatch(pic_state *pic, struct pic_port *port, const char *str) { - UNUSED(port); - UNUSED(str); + PIC_UNUSED(port); + PIC_UNUSED(str); read_error(pic, "unmatched parenthesis"); } diff --git a/extlib/benz/record.c b/extlib/benz/record.c index 52fbe050..7ba4be29 100644 --- a/extlib/benz/record.c +++ b/extlib/benz/record.c @@ -39,7 +39,7 @@ pic_record_ref(pic_state *pic, struct pic_record *rec, pic_sym slot) void pic_record_set(pic_state *pic, struct pic_record *rec, pic_sym slot, pic_value val) { - UNUSED(pic); + PIC_UNUSED(pic); xh_put_int(&rec->hash, slot, &val); } diff --git a/extlib/benz/var.c b/extlib/benz/var.c index ea9cbff5..84ecda61 100644 --- a/extlib/benz/var.c +++ b/extlib/benz/var.c @@ -73,7 +73,7 @@ var_call(pic_state *pic) return val; } } - UNREACHABLE(); + PIC_UNREACHABLE(); } struct pic_proc * diff --git a/extlib/benz/write.c b/extlib/benz/write.c index fb01addc..dde4b3a7 100644 --- a/extlib/benz/write.c +++ b/extlib/benz/write.c @@ -164,7 +164,7 @@ write_str(pic_state *pic, struct pic_string *str, xFILE *file) size_t i; const char *cstr = pic_str_cstr(str); - UNUSED(pic); + PIC_UNUSED(pic); for (i = 0; i < pic_strlen(str); ++i) { if (cstr[i] == '"' || cstr[i] == '\\') {