From 3c71ec8ad293ef4e84920340c1bd30a00388b9c3 Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Mon, 18 Nov 2002 11:27:51 +0000 Subject: [PATCH] Make use of GCC's __attribute__((regparm)) to simplify calling the error functions. --- src/c/character.d | 33 +++++++++++++----------- src/c/pathname.d | 2 ++ src/h/external.h | 65 +++++++++++++++++++++++------------------------ 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/c/character.d b/src/c/character.d index d3d68f7b7..51e85ad9d 100644 --- a/src/c/character.d +++ b/src/c/character.d @@ -318,31 +318,26 @@ char_compare(cl_object x, cl_object y) cl_object cl_character(cl_object x) -{ - return1(coerce_to_character(x)); -} - -cl_object -coerce_to_character(cl_object x) { switch (type_of(x)) { case t_character: - return x; + break; case t_symbol: x = x->symbol.name; case t_string: if (x->string.fillp == 1) - return(CODE_CHAR(x->string.self[0])); + x = CODE_CHAR(x->string.self[0]); default: FEtype_error_character(x); } + @(return x) } cl_object cl_char_code(cl_object c) { /* INV: char_code() checks the type of `c' */ - return1(MAKE_FIXNUM(char_code(c))); + @(return MAKE_FIXNUM(char_code(c))) } cl_object @@ -350,12 +345,20 @@ cl_code_char(cl_object c) { cl_fixnum fc; - /* INV: fixnnint() checks the type of `c' */ - if (type_of(c) == t_bignum) - return1(Cnil); - if ((fc = fixnnint(c)) >= CHAR_CODE_LIMIT) - return1(Cnil); - return1(CODE_CHAR(fc)); + switch (type_of(c)) { + case t_fixnum: + fc = fix(c); + if (fc < CHAR_CODE_LIMIT && fc >= 0) { + c = CODE_CHAR(fc); + break; + } + case t_bignum: + c = Cnil; + break; + default: + FEtype_error_integer(c); + } + @(return c) } cl_object diff --git a/src/c/pathname.d b/src/c/pathname.d index b46456a52..d1bf62e79 100644 --- a/src/c/pathname.d +++ b/src/c/pathname.d @@ -612,6 +612,8 @@ M: push_string(buffer, y); /* INV: pathname.version is always @':unspecific' or Cnil */ N: + /* INV: namestring() must return a simple string which can + * be used by a C function */ return(copy_simple_string(cl_token)); } diff --git a/src/h/external.h b/src/h/external.h index 23d0c2d50..d0656c08d 100644 --- a/src/h/external.h +++ b/src/h/external.h @@ -217,7 +217,6 @@ extern bool char_eq(cl_object x, cl_object y); extern int char_cmp(cl_object x, cl_object y); extern bool char_equal(cl_object x, cl_object y); extern int char_compare(cl_object x, cl_object y); -extern cl_object coerce_to_character(cl_object x); extern short digit_weight(int w, int r); extern void init_character(void); extern void init_character_function(void); @@ -245,9 +244,9 @@ extern float object_to_float(cl_object x); extern double object_to_double(cl_object x); extern int aref_bv(cl_object x, cl_index index); extern int aset_bv(cl_object x, cl_index index, int value); -extern void cl_throw(cl_object tag) __attribute__((noreturn)); -extern void cl_return_from(cl_object block_id, cl_object block_name) __attribute__((noreturn)); -extern void cl_go(cl_object tag_id, cl_object label) __attribute__((noreturn)); +extern void cl_throw(cl_object tag) __attribute__((noreturn,regparm(2))); +extern void cl_return_from(cl_object block_id, cl_object block_name) __attribute__((noreturn,regparm(2))); +extern void cl_go(cl_object tag_id, cl_object label) __attribute__((noreturn,regparm(2))); extern void cl_parse_key(cl_va_list args, int nkey, cl_object *keys, cl_object *vars, cl_object *rest, bool allow_other_keys); extern cl_object cl_grab_rest_args(cl_va_list args); extern void check_other_key(cl_object l, int n, ...); @@ -300,26 +299,26 @@ extern cl_object cl_error _ARGS((int narg, cl_object eformat, ...)); extern cl_object cl_cerror _ARGS((int narg, cl_object cformat, cl_object eformat, ...)); extern cl_object null_string; -extern void internal_error(const char *s) __attribute__((noreturn)); +extern void internal_error(const char *s) __attribute__((noreturn,regparm(2))); extern void cs_overflow(void) __attribute__((noreturn)); -extern void error(const char *s) __attribute__((noreturn)); +extern void error(const char *s) __attribute__((noreturn,regparm(2))); extern void terminal_interrupt(bool correctable); extern void FEcondition(int narg, cl_object name, ...) __attribute__((noreturn)); extern void FEprogram_error(const char *s, int narg, ...) __attribute__((noreturn)); extern void FEcontrol_error(const char *s, int narg, ...) __attribute__((noreturn)); extern void FEerror(char *s, int narg, ...) __attribute__((noreturn)); -extern void FEcannot_open(cl_object fn) __attribute__((noreturn)); -extern void FEwrong_type_argument(cl_object type, cl_object value) __attribute__((noreturn)); -extern void FEtoo_few_arguments(int narg) __attribute__((noreturn)); -extern void FEtoo_many_arguments(int narg) __attribute__((noreturn)); -extern void FEunbound_variable(cl_object sym) __attribute__((noreturn)); -extern void FEinvalid_macro_call(cl_object obj) __attribute__((noreturn)); -extern void FEinvalid_variable(char *s, cl_object obj) __attribute__((noreturn)); -extern void FEassignment_to_constant(cl_object v) __attribute__((noreturn)); -extern void FEundefined_function(cl_object fname) __attribute__((noreturn)); -extern void FEinvalid_function(cl_object obj) __attribute__((noreturn)); +extern void FEcannot_open(cl_object fn) __attribute__((noreturn,regparm(2))); +extern void FEwrong_type_argument(cl_object type, cl_object value) __attribute__((noreturn,regparm(2))); +extern void FEtoo_few_arguments(int narg) __attribute__((noreturn,regparm(2))); +extern void FEtoo_many_arguments(int narg) __attribute__((noreturn,regparm(2))); +extern void FEunbound_variable(cl_object sym) __attribute__((noreturn,regparm(2))); +extern void FEinvalid_macro_call(cl_object obj) __attribute__((noreturn,regparm(2))); +extern void FEinvalid_variable(char *s, cl_object obj) __attribute__((noreturn,regparm(2))); +extern void FEassignment_to_constant(cl_object v) __attribute__((noreturn,regparm(2))); +extern void FEundefined_function(cl_object fname) __attribute__((noreturn,regparm(2))); +extern void FEinvalid_function(cl_object obj) __attribute__((noreturn,regparm(2))); extern cl_object CEerror(char *err_str, int narg, ...); -extern void check_arg_failed(int narg, int req) __attribute__((noreturn)); +extern void check_arg_failed(int narg, int req) __attribute__((noreturn,regparm(2))); extern void illegal_index(cl_object x, cl_object i); extern void FEtype_error_symbol(cl_object obj); extern void not_a_variable(cl_object obj); @@ -375,7 +374,7 @@ extern cl_object cl_file_position _ARGS((int narg, cl_object file_stream, ...)); extern bool input_stream_p(cl_object strm); extern bool output_stream_p(cl_object strm); extern cl_object stream_element_type(cl_object strm); -extern void closed_stream(cl_object strm) __attribute__ ((noreturn)); +extern void closed_stream(cl_object strm) __attribute__ ((noreturn,regparm(2))); extern cl_object open_stream(cl_object fn, enum smmode smm, cl_object if_exists, cl_object if_does_not_exist); extern void close_stream(cl_object strm, bool abort_flag); extern cl_object make_two_way_stream(cl_object istrm, cl_object ostrm); @@ -1174,7 +1173,7 @@ extern cl_object si_reset_stack_limits(); extern void bds_overflow(void) __attribute__((noreturn)); extern void bds_unwind(bds_ptr new_bds_top); extern int frs_overflow(void) __attribute__((noreturn)); -extern void unwind(frame_ptr fr) __attribute__((noreturn)); +extern void unwind(frame_ptr fr) __attribute__((noreturn,regparm(2))); extern frame_ptr frs_sch(cl_object frame_id); extern frame_ptr frs_sch_catch(cl_object frame_id); extern cl_object new_frame_id(void); @@ -1388,20 +1387,20 @@ extern cl_object cl_type_of(cl_object x); extern void init_typespec(void); extern void init_typespec_function(void); -extern void FEtype_error_character(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_cons(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_number(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_real(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_float(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_integer(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_list(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_proper_list(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_plist(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_alist(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_stream(cl_object x) __attribute__((noreturn)); -extern void FEcircular_list(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_index(cl_object x) __attribute__((noreturn)); -extern void FEtype_error_string(cl_object x) __attribute__((noreturn)); +extern void FEtype_error_character(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_cons(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_number(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_real(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_float(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_integer(cl_object x) __attribute__((noreturn,regparm(1))); +extern void FEtype_error_list(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_proper_list(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_plist(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_alist(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_stream(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEcircular_list(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_index(cl_object x) __attribute__((noreturn,regparm(2))); +extern void FEtype_error_string(cl_object x) __attribute__((noreturn,regparm(2))); /* unixfsys.c */