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/alloc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 54c4760abab..1396586ba3e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2174,7 +2174,7 @@ compact_small_strings (void) } -DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, +DEFUE ("make-string", Fmake_string, Smake_string, 2, 2, 0, doc: /* Return a newly created string of length LENGTH, with INIT in each element. LENGTH must be an integer. INIT must be an integer that represents a character. */) @@ -2222,7 +2222,7 @@ INIT must be an integer that represents a character. */) } -DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, +DEFUE ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, doc: /* Return a new bool-vector of length LENGTH, using INIT for each element. LENGTH must be a number. INIT matters only in whether it is t or nil. */) (Lisp_Object length, Lisp_Object init) @@ -2610,7 +2610,7 @@ free_cons (struct Lisp_Cons *ptr) cons_free_list = ptr; } -DEFUN ("cons", Fcons, Scons, 2, 2, 0, +DEFUE ("cons", Fcons, Scons, 2, 2, 0, doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) (Lisp_Object car, Lisp_Object cdr) { @@ -2703,7 +2703,7 @@ list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, L } -DEFUN ("list", Flist, Slist, 0, MANY, 0, +DEFUE ("list", Flist, Slist, 0, MANY, 0, doc: /* Return a newly created list with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (list &rest OBJECTS) */) @@ -2721,7 +2721,7 @@ usage: (list &rest OBJECTS) */) } -DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, +DEFUE ("make-list", Fmake_list, Smake_list, 2, 2, 0, doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) (register Lisp_Object length, Lisp_Object init) { @@ -2897,7 +2897,7 @@ allocate_process (void) } -DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, +DEFUE ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, doc: /* Return a newly created vector of length LENGTH, with each element being INIT. See also the function `vector'. */) (register Lisp_Object length, Lisp_Object init) @@ -2919,7 +2919,7 @@ See also the function `vector'. */) } -DEFUN ("vector", Fvector, Svector, 0, MANY, 0, +DEFUE ("vector", Fvector, Svector, 0, MANY, 0, doc: /* Return a newly created vector with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (vector &rest OBJECTS) */) @@ -2938,7 +2938,7 @@ usage: (vector &rest OBJECTS) */) } -DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, +DEFUE ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, doc: /* Create a byte-code object with specified arguments as elements. The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant vector CONSTANTS, maximum stack size DEPTH, (optional) DOCSTRING, @@ -3033,7 +3033,7 @@ init_symbol (void) } -DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, +DEFUE ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, doc: /* Return a newly allocated uninterned symbol whose name is NAME. Its value and function definition are void, and its property list is nil. */) (Lisp_Object name) @@ -3196,7 +3196,7 @@ make_save_value (void *pointer, int integer) return val; } -DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, +DEFUE ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, doc: /* Return a newly allocated marker which does not point at any place. */) (void) { @@ -3925,7 +3925,7 @@ static int max_live, max_zombies; static double avg_live; -DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", +DEFUE ("gc-status", Fgc_status, Sgc_status, 0, 0, "", doc: /* Show information about live and zombie objects. */) (void) { @@ -4740,7 +4740,7 @@ make_pure_vector (EMACS_INT len) } -DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, +DEFUE ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, doc: /* Make a copy of object OBJ in pure storage. Recursively copies contents of vectors and cons cells. Does not copy symbols. Copies strings without text properties. */) @@ -4834,7 +4834,7 @@ inhibit_garbage_collection (void) } -DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", +DEFUE ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", doc: /* Reclaim storage for Lisp objects no longer needed. Garbage collection happens automatically if you cons more than `gc-cons-threshold' bytes of Lisp data since previous garbage collection. -- 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/alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 1396586ba3e..ad3dfa96cd2 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -264,11 +264,12 @@ static size_t stack_copy_size; static int ignore_warnings; -Lisp_Object Qgc_cons_threshold, Qchar_table_extra_slots; +static Lisp_Object Qgc_cons_threshold; +Lisp_Object Qchar_table_extra_slots; /* Hook run after GC has finished. */ -Lisp_Object Qpost_gc_hook; +static Lisp_Object Qpost_gc_hook; static void mark_buffer (Lisp_Object); static void mark_terminals (void); -- 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/alloc.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index ad3dfa96cd2..7803ccdc976 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -212,6 +212,9 @@ static int malloc_hysteresis; remapping on more recent systems because this is less important nowadays than in the days of small memories and timesharing. */ +#ifndef VIRT_ADDR_VARIES +static +#endif EMACS_INT pure[(PURESIZE + sizeof (EMACS_INT) - 1) / sizeof (EMACS_INT)] = {1,}; #define PUREBEG (char *) pure @@ -281,8 +284,7 @@ static struct Lisp_String *allocate_string (void); static void compact_small_strings (void); static void free_large_strings (void); static void sweep_strings (void); - -extern int message_enable_multibyte; +static void free_misc (Lisp_Object); /* When scanning the C stack for live Lisp objects, Emacs keeps track of what memory allocated via lisp_malloc is intended for what @@ -1341,7 +1343,7 @@ static int total_free_intervals, total_intervals; /* List of free intervals. */ -INTERVAL interval_free_list; +static INTERVAL interval_free_list; /* Total number of interval blocks now in use. */ @@ -2460,19 +2462,19 @@ struct float_block /* Current float_block. */ -struct float_block *float_block; +static struct float_block *float_block; /* Index of first unused Lisp_Float in the current float_block. */ -int float_block_index; +static int float_block_index; /* Total number of float blocks now in use. */ -int n_float_blocks; +static int n_float_blocks; /* Free-list of Lisp_Floats. */ -struct Lisp_Float *float_free_list; +static struct Lisp_Float *float_free_list; /* Initialize float allocation. */ @@ -2572,15 +2574,15 @@ struct cons_block /* Current cons_block. */ -struct cons_block *cons_block; +static struct cons_block *cons_block; /* Index of first unused Lisp_Cons in the current block. */ -int cons_block_index; +static int cons_block_index; /* Free-list of Lisp_Cons structures. */ -struct Lisp_Cons *cons_free_list; +static struct Lisp_Cons *cons_free_list; /* Total number of cons blocks now in use. */ @@ -3168,7 +3170,7 @@ allocate_misc (void) /* Free a Lisp_Misc object */ -void +static void free_misc (Lisp_Object misc) { XMISCTYPE (misc) = Lisp_Misc_Free; @@ -5216,7 +5218,7 @@ mark_face_cache (struct face_cache *c) #define LAST_MARKED_SIZE 500 static Lisp_Object last_marked[LAST_MARKED_SIZE]; -int last_marked_index; +static int last_marked_index; /* For debugging--call abort when we cdr down this many links of a list, in mark_object. In debugging, @@ -6108,6 +6110,7 @@ Frames, windows, buffers, and subprocesses count as vectors return Flist (8, consed); } +#ifdef ENABLE_CHECKING int suppress_checking; void @@ -6117,6 +6120,7 @@ die (const char *msg, const char *file, int line) file, line, msg); abort (); } +#endif /* Initialization */ -- 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/alloc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 7803ccdc976..d1d6323f905 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2177,7 +2177,7 @@ compact_small_strings (void) } -DEFUE ("make-string", Fmake_string, Smake_string, 2, 2, 0, +DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, doc: /* Return a newly created string of length LENGTH, with INIT in each element. LENGTH must be an integer. INIT must be an integer that represents a character. */) @@ -2225,7 +2225,7 @@ INIT must be an integer that represents a character. */) } -DEFUE ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, +DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, doc: /* Return a new bool-vector of length LENGTH, using INIT for each element. LENGTH must be a number. INIT matters only in whether it is t or nil. */) (Lisp_Object length, Lisp_Object init) @@ -2613,7 +2613,7 @@ free_cons (struct Lisp_Cons *ptr) cons_free_list = ptr; } -DEFUE ("cons", Fcons, Scons, 2, 2, 0, +DEFUN ("cons", Fcons, Scons, 2, 2, 0, doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) (Lisp_Object car, Lisp_Object cdr) { @@ -2706,7 +2706,7 @@ list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, L } -DEFUE ("list", Flist, Slist, 0, MANY, 0, +DEFUN ("list", Flist, Slist, 0, MANY, 0, doc: /* Return a newly created list with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (list &rest OBJECTS) */) @@ -2724,7 +2724,7 @@ usage: (list &rest OBJECTS) */) } -DEFUE ("make-list", Fmake_list, Smake_list, 2, 2, 0, +DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) (register Lisp_Object length, Lisp_Object init) { @@ -2900,7 +2900,7 @@ allocate_process (void) } -DEFUE ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, +DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, doc: /* Return a newly created vector of length LENGTH, with each element being INIT. See also the function `vector'. */) (register Lisp_Object length, Lisp_Object init) @@ -2922,7 +2922,7 @@ See also the function `vector'. */) } -DEFUE ("vector", Fvector, Svector, 0, MANY, 0, +DEFUN ("vector", Fvector, Svector, 0, MANY, 0, doc: /* Return a newly created vector with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (vector &rest OBJECTS) */) @@ -2941,7 +2941,7 @@ usage: (vector &rest OBJECTS) */) } -DEFUE ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, +DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, doc: /* Create a byte-code object with specified arguments as elements. The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant vector CONSTANTS, maximum stack size DEPTH, (optional) DOCSTRING, @@ -3036,7 +3036,7 @@ init_symbol (void) } -DEFUE ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, +DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, doc: /* Return a newly allocated uninterned symbol whose name is NAME. Its value and function definition are void, and its property list is nil. */) (Lisp_Object name) @@ -3199,7 +3199,7 @@ make_save_value (void *pointer, int integer) return val; } -DEFUE ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, +DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, doc: /* Return a newly allocated marker which does not point at any place. */) (void) { @@ -3928,7 +3928,7 @@ static int max_live, max_zombies; static double avg_live; -DEFUE ("gc-status", Fgc_status, Sgc_status, 0, 0, "", +DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", doc: /* Show information about live and zombie objects. */) (void) { @@ -4743,7 +4743,7 @@ make_pure_vector (EMACS_INT len) } -DEFUE ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, +DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, doc: /* Make a copy of object OBJ in pure storage. Recursively copies contents of vectors and cons cells. Does not copy symbols. Copies strings without text properties. */) @@ -4837,7 +4837,7 @@ inhibit_garbage_collection (void) } -DEFUE ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", +DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", doc: /* Reclaim storage for Lisp objects no longer needed. Garbage collection happens automatically if you cons more than `gc-cons-threshold' bytes of Lisp data since previous garbage collection. -- cgit v1.2.1 From 69003fd8410b1d08ad4364af1eb29a4b795f59bb Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 23:15:53 -0700 Subject: 2011-04-14 Paul Eggert * alloc.c (refill_memory_reserve): Now static if !defined REL_ALLOC || defined SYSTEM_MALLOC. * lisp.h (refill_memory_reserve): Declare only if not static. --- src/alloc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index d1d6323f905..1c793c985eb 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -280,6 +280,9 @@ static void gc_sweep (void); static void mark_glyph_matrix (struct glyph_matrix *); static void mark_face_cache (struct face_cache *); +#if !defined REL_ALLOC || defined SYSTEM_MALLOC +static void refill_memory_reserve (void); +#endif static struct Lisp_String *allocate_string (void); static void compact_small_strings (void); static void free_large_strings (void); -- cgit v1.2.1