From 16a97296c05ec9d5bb4ffeae9dce90fc63f578ed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 18:41:15 -0700 Subject: Make Emacs functions such as Fatom 'static' by default. This makes it easier for human readers (and static analyzers) to see whether these functions can be called from other modules. DEFUN now defines a static function. To make the function external so that it can be used in other C modules, use the new macro DEFUE. * lisp.h (DEFINE_FUNC): New macro, with the old contents of DEFUN. (DEFUN): Rewrite in terms of DEFINE_FUNC. It now generates a static function definition. Use DEFUE if you want an extern one. (DEFUE, INFUN): New macros. (Funibyte_char_to_multibyte, Fsyntax_table_p, Finit_image_library): (Feval_region, Fbacktrace, Ffetch_bytecode, Fswitch_to_buffer): (Ffile_executable_p, Fmake_symbolic_link, Fcommand_execute): (Fget_process, Fdocumentation_property, Fbyte_code, Ffile_attributes): Remove decls, since these functions are now static. (Funintern, Fget_internal_run_time): New decls, since these functions were already external. * alloc.c, buffer.c, callint.c, callproc.c, casefiddle.c, casetab.c: * ccl.c, character.c, chartab.c, cmds.c, coding.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, floatfns.c: * fns.c, font.c, fontset.c, frame.c, image.c, indent.c: * keyboard.c, keymap.c, lread.c: * macros.c, marker.c, menu.c, minibuf.c, print.c, process.c, search.c: * syntax.c, term.c, terminal.c, textprop.c, undo.c: * window.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xsettings.c: Mark functions with DEFUE instead of DEFUN, if they are used in other modules. * buffer.c (Fset_buffer_major_mode, Fdelete_overlay): New forward decls for now-static functions. * buffer.h (Fdelete_overlay): Remove decl. * callproc.c (Fgetenv_internal): Mark as internal. * composite.c (Fremove_list_of_text_properties): Remove decl. (Fcomposition_get_gstring): New forward static decl. * composite.h (Fcomposite_get_gstring): Remove decl. * dired.c (Ffile_attributes): New forward static decl. * doc.c (Fdocumntation_property): New forward static decl. * eval.c (Ffetch_bytecode): New forward static decl. (Funintern): Remove extern decl; now in .h file where it belongs. * fileio.c (Fmake_symbolic_link): New forward static decl. * image.c (Finit_image_library): New forward static decl. * insdel.c (Fcombine_after_change_execute): Make forward decl static. * intervals.h (Fprevious_property_change): (Fremove_list_of_text_properties): Remove decls. * keyboard.c (Fthis_command_keys): Remove decl. (Fcommand_execute): New forward static decl. * keymap.c (Flookup_key): New forward static decl. (Fcopy_keymap): Now static. * keymap.h (Flookup_key): Remove decl. * process.c (Fget_process): New forward static decl. (Fprocess_datagram_address): Mark as internal. * syntax.c (Fsyntax_table_p): New forward static decl. (skip_chars): Remove duplicate decl. * textprop.c (Fprevious_property_change): New forward static decl. * window.c (Fset_window_fringes, Fset_window_scroll_bars): Now internal. (Fset_window_margins, Fset_window_vscroll): New forward static decls. * window.h (Fset_window_vscroll, Fset_window_margins): Remove decls. --- src/eval.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 0f9e012b823..d6d62aa4afb 100644 --- a/src/eval.c +++ b/src/eval.c @@ -126,6 +126,7 @@ static Lisp_Object funcall_lambda (Lisp_Object, size_t, Lisp_Object *); static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN; static int interactive_p (int); static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); +INFUN (Ffetch_bytecode, 1); void init_eval_once (void) @@ -339,7 +340,7 @@ usage: (cond CLAUSES...) */) return val; } -DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, +DEFUE ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, doc: /* Eval BODY forms sequentially and return value of last one. usage: (progn BODY...) */) (Lisp_Object args) @@ -504,7 +505,7 @@ usage: (function ARG) */) } -DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, +DEFUE ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, doc: /* Return t if the containing function was run directly by user input. This means that the function was called with `call-interactively' \(which includes being called as the binding of a key) @@ -1310,7 +1311,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) _longjmp (catch->jmp, 1); } -DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, +DEFUE ("throw", Fthrow, Sthrow, 2, 2, 0, doc: /* Throw to the catch for TAG and return VALUE from it. Both TAG and VALUE are evalled. */) (register Lisp_Object tag, Lisp_Object value) @@ -1648,7 +1649,7 @@ static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object, static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data); -DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, +DEFUE ("signal", Fsignal, Ssignal, 2, 2, 0, doc: /* Signal an error. Args are ERROR-SYMBOL and associated DATA. This function does not return. @@ -2032,7 +2033,7 @@ error (const char *m, ...) va_end (ap); } -DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, +DEFUE ("commandp", Fcommandp, Scommandp, 1, 2, 0, doc: /* Non-nil if FUNCTION makes provisions for interactive calling. This means it contains a description for how to read arguments to give it. The value is nil for an invalid function or a symbol with no function @@ -2213,7 +2214,7 @@ do_autoload (Lisp_Object fundef, Lisp_Object funname) } -DEFUN ("eval", Feval, Seval, 1, 2, 0, +DEFUE ("eval", Feval, Seval, 1, 2, 0, doc: /* Evaluate FORM and return its value. If LEXICAL is t, evaluate using lexical scoping. */) (Lisp_Object form, Lisp_Object lexical) @@ -2449,7 +2450,7 @@ eval_sub (Lisp_Object form) return val; } -DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, +DEFUE ("apply", Fapply, Sapply, 2, MANY, 0, doc: /* Call FUNCTION with our remaining args, using our last arg as list of args. Then return the value FUNCTION returns. Thus, (apply '+ 1 2 '(3 4)) returns 10. @@ -2544,7 +2545,7 @@ funcall_nil (size_t nargs, Lisp_Object *args) return Qnil; } -DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0, +DEFUE ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0, doc: /* Run each hook in HOOKS. Each argument should be a symbol, a hook variable. These symbols are processed in the order specified. @@ -2573,7 +2574,7 @@ usage: (run-hooks &rest HOOKS) */) return Qnil; } -DEFUN ("run-hook-with-args", Frun_hook_with_args, +DEFUE ("run-hook-with-args", Frun_hook_with_args, Srun_hook_with_args, 1, MANY, 0, doc: /* Run HOOK with the specified arguments ARGS. HOOK should be a symbol, a hook variable. If HOOK has a non-nil @@ -2619,7 +2620,7 @@ funcall_not (size_t nargs, Lisp_Object *args) return NILP (Ffuncall (nargs, args)) ? Qt : Qnil; } -DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, +DEFUE ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, Srun_hook_with_args_until_failure, 1, MANY, 0, doc: /* Run HOOK with the specified arguments ARGS. HOOK should be a symbol, a hook variable. If HOOK has a non-nil @@ -2906,7 +2907,7 @@ call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, /* The caller should GCPRO all the elements of ARGS. */ -DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, +DEFUE ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, doc: /* Non-nil if OBJECT is a function. */) (Lisp_Object object) { @@ -2939,7 +2940,7 @@ DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, return Qnil; } -DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, +DEFUE ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, doc: /* Call first argument as a function, passing remaining arguments to it. Return the value that function returns. Thus, (funcall 'cons 'x 'y) returns (x . y). @@ -3647,8 +3648,6 @@ mark_backtrace (void) } } -EXFUN (Funintern, 2); - void syms_of_eval (void) { -- cgit v1.2.1 From 955cbe7b1720f09b2991b7d981147d9cc79d52e3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 20:39:45 -0700 Subject: Declare Lisp_Object Q* variables to be 'static' if not exproted. This makes it easier for human readers (and static analyzers) to see whether these variables are used from other modules. * alloc.c, buffer.c, bytecode.c, callint.c, casetab.c, category.c: * ccl.c, character.c, charset.c, cmds.c, coding.c, composite.c: * data.c, dbusbind.c, dired.c, editfns.c, eval.c, fileio.c, fns.c: * font.c, frame.c, fringe.c, ftfont.c, image.c, keyboard.c, keymap.c: * lread.c, macros.c, minibuf.c, print.c, process.c, search.c: * sound.c, syntax.c, textprop.c, window.c, xdisp.c, xfaces.c, xfns.c: * xmenu.c, xselect.c: Declare Q* vars static if they are not used in other modules. * ccl.h, character.h, charset.h, coding.h, composite.h, font.h: * frame.h, intervals.h, keyboard.h, lisp.h, process.h, syntax.h: Remove decls of unexported vars. * keyboard.h (EVENT_HEAD_UNMODIFIED): Remove now-unused macro. --- src/eval.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index d6d62aa4afb..cefdf784faf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -66,12 +66,13 @@ int gcpro_level; Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun; Lisp_Object Qinhibit_quit; -Lisp_Object Qand_rest, Qand_optional; -Lisp_Object Qdebug_on_error; -Lisp_Object Qdeclare; +Lisp_Object Qand_rest; +static Lisp_Object Qand_optional; +static Lisp_Object Qdebug_on_error; +static Lisp_Object Qdeclare; Lisp_Object Qinternal_interpreter_environment, Qclosure; -Lisp_Object Qdebug; +static Lisp_Object Qdebug; /* This holds either the symbol `run-hooks' or nil. It is nil at an early stage of startup, and when Emacs -- cgit v1.2.1 From 244ed9077fe7ccebbc15c7157cb45832f46a46d3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 21:39:49 -0700 Subject: alloc.c: Import and export fewer symbols, and remove unused items. * lisp.h (suppress_checking, die): Declare only if ENABLE_CHECKING is defined. (suppress_checking): Add EXTERNALLY_VISIBLE attribute, so that it's not optimized away by whole-program optimization. (message_enable_multibyte, free_misc): Remove. (catchlist, handlerlist, mark_backtrace): Declare only if BYTE_MARK_STACK. (mark_byte_stack): Likewise, fixing a ifdef-vs-if typo. * alloc.c (pure): Export only if VIRT_ADDR_VARIES is defined. (message_enable_multibyte): Remove decl. (free_misc, interval_free_list, float_block, float_block_index): (n_float_blocks, float_free_list, cons_block, cons_block_index): (cons_free_list, last_marked_index): Now static. (suppress_checking, die): Define only if ENABLE_CHECKING is defined. * eval.c (catchlist, handlerlist): Export only if BYTE_MARK_STACK. (mark_backtrace): Define only if BYTE_MARK_STACK. * xdisp.c (message_enable_multibyte): Now static. --- src/eval.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index cefdf784faf..dddedc77286 100644 --- a/src/eval.c +++ b/src/eval.c @@ -57,8 +57,23 @@ struct backtrace }; struct backtrace *backtrace_list; + +#if !BYTE_MARK_STACK +static +#endif struct catchtag *catchlist; +/* Chain of condition handlers currently in effect. + The elements of this chain are contained in the stack frames + of Fcondition_case and internal_condition_case. + When an error is signaled (by calling Fsignal, below), + this chain is searched for an element that applies. */ + +#if !BYTE_MARK_STACK +static +#endif +struct handler *handlerlist; + #ifdef DEBUG_GCPRO /* Count levels of GCPRO to detect failure to UNGCPRO. */ int gcpro_level; @@ -1345,14 +1360,6 @@ usage: (unwind-protect BODYFORM UNWINDFORMS...) */) return unbind_to (count, val); } -/* Chain of condition handlers currently in effect. - The elements of this chain are contained in the stack frames - of Fcondition_case and internal_condition_case. - When an error is signaled (by calling Fsignal, below), - this chain is searched for an element that applies. */ - -struct handler *handlerlist; - DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0, doc: /* Regain control when an error is signaled. Executes BODYFORM and returns its value if no error happens. @@ -3629,6 +3636,7 @@ If NFRAMES is more than the number of frames, the value is nil. */) } +#if BYTE_MARK_STACK void mark_backtrace (void) { @@ -3648,6 +3656,7 @@ mark_backtrace (void) mark_object (backlist->args[i]); } } +#endif void syms_of_eval (void) -- cgit v1.2.1 From 57a96f5c91758efc0acf2c343dc876d0e0926018 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 15:53:58 -0700 Subject: * eval.c: Make symbols static if they're not exported. (backtrace_list, lisp_eval_depth, when_entered_debugger): Now static. * lisp.h (backtrace_list): Remove decl. --- src/eval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index dddedc77286..ef5eb6bdaaf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -56,7 +56,7 @@ struct backtrace char debug_on_exit : 1; }; -struct backtrace *backtrace_list; +static struct backtrace *backtrace_list; #if !BYTE_MARK_STACK static @@ -116,7 +116,7 @@ struct specbinding *specpdl_ptr; /* Depth in Lisp evaluations and function calls. */ -EMACS_INT lisp_eval_depth; +static EMACS_INT lisp_eval_depth; /* The value of num_nonmacro_input_events as of the last time we started to enter the debugger. If we decide to enter the debugger @@ -125,7 +125,7 @@ EMACS_INT lisp_eval_depth; signal the error instead of entering an infinite loop of debugger invocations. */ -int when_entered_debugger; +static int when_entered_debugger; /* The function from which the last `signal' was called. Set in Fsignal. */ -- cgit v1.2.1 From a7ca3326c4740ed3ed118b794d35d235de49f346 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 22:04:02 -0700 Subject: Undo the DEFUN->DEFUE change. --- src/eval.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index ef5eb6bdaaf..4d0786fc0d4 100644 --- a/src/eval.c +++ b/src/eval.c @@ -356,7 +356,7 @@ usage: (cond CLAUSES...) */) return val; } -DEFUE ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, +DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, doc: /* Eval BODY forms sequentially and return value of last one. usage: (progn BODY...) */) (Lisp_Object args) @@ -521,7 +521,7 @@ usage: (function ARG) */) } -DEFUE ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, +DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, doc: /* Return t if the containing function was run directly by user input. This means that the function was called with `call-interactively' \(which includes being called as the binding of a key) @@ -1327,7 +1327,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) _longjmp (catch->jmp, 1); } -DEFUE ("throw", Fthrow, Sthrow, 2, 2, 0, +DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, doc: /* Throw to the catch for TAG and return VALUE from it. Both TAG and VALUE are evalled. */) (register Lisp_Object tag, Lisp_Object value) @@ -1657,7 +1657,7 @@ static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object, static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data); -DEFUE ("signal", Fsignal, Ssignal, 2, 2, 0, +DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, doc: /* Signal an error. Args are ERROR-SYMBOL and associated DATA. This function does not return. @@ -2041,7 +2041,7 @@ error (const char *m, ...) va_end (ap); } -DEFUE ("commandp", Fcommandp, Scommandp, 1, 2, 0, +DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, doc: /* Non-nil if FUNCTION makes provisions for interactive calling. This means it contains a description for how to read arguments to give it. The value is nil for an invalid function or a symbol with no function @@ -2222,7 +2222,7 @@ do_autoload (Lisp_Object fundef, Lisp_Object funname) } -DEFUE ("eval", Feval, Seval, 1, 2, 0, +DEFUN ("eval", Feval, Seval, 1, 2, 0, doc: /* Evaluate FORM and return its value. If LEXICAL is t, evaluate using lexical scoping. */) (Lisp_Object form, Lisp_Object lexical) @@ -2458,7 +2458,7 @@ eval_sub (Lisp_Object form) return val; } -DEFUE ("apply", Fapply, Sapply, 2, MANY, 0, +DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, doc: /* Call FUNCTION with our remaining args, using our last arg as list of args. Then return the value FUNCTION returns. Thus, (apply '+ 1 2 '(3 4)) returns 10. @@ -2553,7 +2553,7 @@ funcall_nil (size_t nargs, Lisp_Object *args) return Qnil; } -DEFUE ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0, +DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0, doc: /* Run each hook in HOOKS. Each argument should be a symbol, a hook variable. These symbols are processed in the order specified. @@ -2582,7 +2582,7 @@ usage: (run-hooks &rest HOOKS) */) return Qnil; } -DEFUE ("run-hook-with-args", Frun_hook_with_args, +DEFUN ("run-hook-with-args", Frun_hook_with_args, Srun_hook_with_args, 1, MANY, 0, doc: /* Run HOOK with the specified arguments ARGS. HOOK should be a symbol, a hook variable. If HOOK has a non-nil @@ -2628,7 +2628,7 @@ funcall_not (size_t nargs, Lisp_Object *args) return NILP (Ffuncall (nargs, args)) ? Qt : Qnil; } -DEFUE ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, +DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, Srun_hook_with_args_until_failure, 1, MANY, 0, doc: /* Run HOOK with the specified arguments ARGS. HOOK should be a symbol, a hook variable. If HOOK has a non-nil @@ -2915,7 +2915,7 @@ call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, /* The caller should GCPRO all the elements of ARGS. */ -DEFUE ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, +DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, doc: /* Non-nil if OBJECT is a function. */) (Lisp_Object object) { @@ -2948,7 +2948,7 @@ DEFUE ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, return Qnil; } -DEFUE ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, +DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, doc: /* Call first argument as a function, passing remaining arguments to it. Return the value that function returns. Thus, (funcall 'cons 'x 'y) returns (x . y). -- cgit v1.2.1 From cd64ea1d0df393beb93d1bdf19bd3990e3378f85 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 14 Apr 2011 12:34:42 -0700 Subject: * lisp.h (INFUN): Remove. Suggested by Dan Nicolaescu in . All uses spelled out. --- src/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 4d0786fc0d4..c068f5f3fbf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -142,7 +142,7 @@ static Lisp_Object funcall_lambda (Lisp_Object, size_t, Lisp_Object *); static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN; static int interactive_p (int); static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); -INFUN (Ffetch_bytecode, 1); +static Lisp_Object Ffetch_bytecode (Lisp_Object); void init_eval_once (void) -- cgit v1.2.1