diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | libguile/Makefile.am | 24 | ||||
-rw-r--r-- | libguile/procs.h | 68 | ||||
-rw-r--r-- | libguile/snarf.h | 32 |
4 files changed, 43 insertions, 82 deletions
diff --git a/.gitignore b/.gitignore index 43545aedb..7644deacd 100644 --- a/.gitignore +++ b/.gitignore @@ -74,5 +74,4 @@ libguile/stack-limit-calibration.scm cscope.out cscope.files *.log -/libguile/snarf-gsubr.h INSTALL diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 885de72c4..9b05f01be 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -77,21 +77,6 @@ scmconfig.h: ${top_builddir}/config.h gen-scmconfig$(EXEEXT) rm -f scmconfig.h mv scmconfig.h.tmp scmconfig.h -# Generate aliases for `SCM_DEFINE_GSUBR'. Since there's a lot of -# them, it's an efficient compression method. -snarf-gsubr.h: - ( echo "/* Automatically generated, do not edit. */" ; \ - for req in `seq 0 16`; do \ - for opt in `seq 0 16`; do \ - for rst in 0 1; do \ - echo "#ifndef SCM_DEFINE_SUBR_req$${req}_opt$${opt}_rst$${rst}" ; \ - echo "# define SCM_DEFINE_SUBR_req$${req}_opt$${opt}_rst$${rst} SCM_DEFINE_GSUBR" ; \ - echo "#endif" ; \ - done ; \ - done ; \ - done ) > "$@.tmp" - mv "$@.tmp" "$@" - guile_filter_doc_snarfage_SOURCES = c-tokenize.c ## Override default rule; this should be compiled for BUILD host. @@ -181,8 +166,8 @@ DOT_DOC_FILES = alist.doc arbiters.doc async.doc backtrace.doc \ EXTRA_DOT_DOC_FILES = @EXTRA_DOT_DOC_FILES@ -BUILT_SOURCES = cpp_err_symbols.c cpp_sig_symbols.c libpath.h \ - version.h scmconfig.h snarf-gsubr.h \ +BUILT_SOURCES = cpp_err_symbols.c cpp_sig_symbols.c libpath.h \ + version.h scmconfig.h \ $(DOT_X_FILES) $(EXTRA_DOT_X_FILES) EXTRA_libguile_la_SOURCES = _scm.h \ @@ -239,7 +224,7 @@ modinclude_HEADERS = __scm.h alist.h arbiters.h async.h backtrace.h \ pthread-threads.h null-threads.h throw.h unif.h values.h \ variable.h vectors.h vports.h weaks.h -nodist_modinclude_HEADERS = version.h scmconfig.h snarf-gsubr.h +nodist_modinclude_HEADERS = version.h scmconfig.h bin_SCRIPTS = guile-snarf @@ -424,8 +409,7 @@ MOSTLYCLEANFILES = \ cpp_err_symbols_here cpp_err_symbols_diff cpp_err_symbols_new \ cpp_sig_symbols_here cpp_sig_symbols_diff cpp_sig_symbols_new \ version.h version.h.tmp \ - scmconfig.h scmconfig.h.tmp snarf-gsubr.h snarf-gsubr.h.tmp \ - stack-limit-calibration.scm + scmconfig.h scmconfig.h.tmp stack-limit-calibration.scm CLEANFILES = libpath.h *.x *.doc guile-procedures.txt guile-procedures.texi guile.texi diff --git a/libguile/procs.h b/libguile/procs.h index e2dec99d0..18857c62e 100644 --- a/libguile/procs.h +++ b/libguile/procs.h @@ -39,37 +39,43 @@ #define SCM_SET_SUBR_GENERIC(x, g) (*((SCM *) SCM_CELL_WORD_2 (x)) = (g)) #define SCM_SET_SUBR_GENERIC_LOC(x, g) (SCM_SET_CELL_WORD_2 (x, (scm_t_bits) g)) -/* Return the subr type corresponding to the given arity. If the arity - doesn't match that of a subr (e.g., too many arguments), then -1 is - returned. This has to be in sync with `create_gsubr ()'. */ -#define SCM_SUBR_ARITY_TO_TYPE(req, opt, rest) \ - ((rest) == 0 \ - ? ((opt) == 0 \ - ? ((req) == 0 \ - ? scm_tc7_subr_0 \ - : ((req) == 1 \ - ? scm_tc7_subr_1 \ - : ((req) == 2 \ - ? scm_tc7_subr_2 \ - : ((req) == 3 \ - ? scm_tc7_subr_3 \ - : -1)))) \ - : ((opt) == 1 \ - ? ((req) == 0 \ - ? scm_tc7_subr_1o \ - : ((req) == 1 \ - ? scm_tc7_subr_2o \ - : -1)) \ - : -1)) \ - : ((rest) == 1 \ - ? ((opt) == 0 \ - ? ((req) == 0 \ - ? scm_tc7_lsubr \ - : ((req) == 2 \ - ? scm_tc7_lsubr_2 \ - : -1)) \ - : -1) \ - : -1)) +/* Return the most suitable subr type for a subr with REQ required arguments, + OPT optional arguments, and REST (0 or 1) arguments. This has to be in + sync with `create_gsubr ()'. */ +#define SCM_SUBR_ARITY_TO_TYPE(req, opt, rest) \ + ((rest) == 0 \ + ? ((opt) == 0 \ + ? ((req) == 0 \ + ? scm_tc7_subr_0 \ + : ((req) == 1 \ + ? scm_tc7_subr_1 \ + : ((req) == 2 \ + ? scm_tc7_subr_2 \ + : ((req) == 3 \ + ? scm_tc7_subr_3 \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))))) \ + : ((opt) == 1 \ + ? ((req) == 0 \ + ? scm_tc7_subr_1o \ + : ((req) == 1 \ + ? scm_tc7_subr_2o \ + : scm_tc7_gsubr | \ + (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) \ + : scm_tc7_gsubr | \ + (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) \ + : ((rest) == 1 \ + ? ((opt) == 0 \ + ? ((req) == 0 \ + ? scm_tc7_lsubr \ + : ((req) == 2 \ + ? scm_tc7_lsubr_2 \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U)) \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) diff --git a/libguile/snarf.h b/libguile/snarf.h index 451323c1b..c3113e1a7 100644 --- a/libguile/snarf.h +++ b/libguile/snarf.h @@ -97,8 +97,8 @@ SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) #ifdef SCM_SUPPORT_STATIC_ALLOCATION -/* Regular "subrs", i.e., few arguments. */ -#define SCM_DEFINE_SUBR(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ +/* Static subr allocation. */ +#define SCM_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ SCM_SYMBOL (scm_i_paste (FNAME, __name), PRIMNAME); \ SCM_SNARF_HERE( \ static const char scm_i_paste (s_, FNAME) [] = PRIMNAME; \ @@ -116,34 +116,6 @@ SCM_SNARF_INIT( \ ) \ SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) -/* XXX: Eventually, we could statically allocate gsubrs as well. */ - -/* These are the subrs whose arity makes it possible to define them as "raw - subrs" (as opposed to "gsubrs"). This has to be consistent with - `SCM_SUBR_ARITY_TO_TYPE ()' and `create_gsubr ()'. */ -#define SCM_DEFINE_SUBR_req0_opt0_rst0 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req1_opt0_rst0 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req0_opt1_rst0 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req1_opt1_rst0 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req2_opt0_rst0 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req3_opt0_rst0 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req0_opt0_rst1 SCM_DEFINE_SUBR -#define SCM_DEFINE_SUBR_req2_opt0_rst1 SCM_DEFINE_SUBR - -/* For any other combination of required/optional/rest arguments, use - `SCM_DEFINE_GSUBR (). */ -#include "libguile/snarf-gsubr.h" - -/* The generic subr definition macro. This macro dispatches to either - `SCM_DEFINE_SUBR ()' or `SCM_DEFINE_GSUBR ()' depending on the arity of - the subr being defined. */ -#define SCM_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ - SCM_DEFINE_SUBR_req ## REQ ## _opt ## OPT ## _rst ## VAR \ - (FNAME, PRIMNAME, \ - REQ, OPT, VAR, \ - ARGLIST, DOCSTRING) - - #else /* !SCM_SUPPORT_STATIC_ALLOCATION */ /* Always use the generic subr case. */ |