From bad98418bf75efc6dd8ac393157413bc6ef769b4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 18 Mar 2013 21:41:53 -0700 Subject: Spelling fixes. --- src/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index b2703c5f961..5e30c1b20ad 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1162,7 +1162,7 @@ lisp_align_free (void *block) #define INTERVAL_BLOCK_SIZE \ ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval)) -/* Intervals are allocated in chunks in form of an interval_block +/* Intervals are allocated in chunks in the form of an interval_block structure. */ struct interval_block -- cgit v1.2.1 From d6723bf7e58e17c889e354bc429f3f134281953a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 21 Mar 2013 11:28:50 -0700 Subject: * alloc.c: Remove redundant static declarations. --- src/alloc.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 5e30c1b20ad..39379bc3bd7 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -323,20 +323,7 @@ static void *min_heap_address, *max_heap_address; static struct mem_node mem_z; #define MEM_NIL &mem_z -static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t); -static void lisp_free (void *); -static void mark_stack (void); -static bool live_vector_p (struct mem_node *, void *); -static bool live_buffer_p (struct mem_node *, void *); -static bool live_string_p (struct mem_node *, void *); -static bool live_cons_p (struct mem_node *, void *); -static bool live_symbol_p (struct mem_node *, void *); -static bool live_float_p (struct mem_node *, void *); -static bool live_misc_p (struct mem_node *, void *); -static void mark_maybe_object (Lisp_Object); -static void mark_memory (void *, void *); #if GC_MARK_STACK || defined GC_MALLOC_CHECK -static void mem_init (void); static struct mem_node *mem_insert (void *, void *, enum mem_type); static void mem_insert_fixup (struct mem_node *); static void mem_rotate_left (struct mem_node *); @@ -346,11 +333,6 @@ static void mem_delete_fixup (struct mem_node *); static struct mem_node *mem_find (void *); #endif - -#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS -static void check_gcpros (void); -#endif - #endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ #ifndef DEADP -- cgit v1.2.1 From 7b1123d824e51d40496c242e7a7f173de8936100 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 21 Mar 2013 13:56:22 -0700 Subject: Use functions and constants to manipulate Lisp_Save_Value objects. This replaces code that used macros and strings and token-pasting. The change makes the C source a bit easier to follow, and shrinks the Emacs executable a bit. * alloc.c: Verify some properties of Lisp_Save_Value's representation. (make_save_value): Change 1st arg from string to enum. All callers changed. (INTX): Remove. (mark_object): Use if, not #if, for GC_MARK_STACK. * lisp.h (SAVE_VALUEP, XSAVE_VALUE, XSAVE_POINTER, XSAVE_INTEGER) (XSAVE_OBJECT): Now functions, not macros. (STRING_BYTES_BOUND): Now just a macro, not a constant too; the constant was never used. (SAVE_SLOT_BITS, SAVE_VALUE_SLOTS, SAVE_TYPE_BITS, SAVE_TYPE_INT_INT) (SAVE_TYPE_INT_INT_INT, SAVE_TYPE_OBJ_OBJ, SAVE_TYPE_OBJ_OBJ_OBJ) (SAVE_TYPE_OBJ_OBJ_OBJ_OBJ, SAVE_TYPE_PTR_INT, SAVE_TYPE_PTR_OBJ) (SAVE_TYPE_PTR_PTR, SAVE_TYPE_PTR_PTR_OBJ, SAVE_TYPE_MEMORY): New constants. (struct Lisp_Save_Value): Replace members area, type0, type1, type2, type3 with a single member save_type. All uses changed. (save_type, set_save_pointer, set_save_integer): New functions. * print.c (PRINTX): Remove. --- src/alloc.c | 95 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 40 insertions(+), 55 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 39379bc3bd7..4245b3069fa 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3326,56 +3326,50 @@ free_misc (Lisp_Object misc) total_free_markers++; } +/* Verify properties of Lisp_Save_Value's representation + that are assumed here and elsewhere. */ + +verify (SAVE_UNUSED == 0); +verify ((SAVE_INTEGER | SAVE_POINTER | SAVE_OBJECT) >> SAVE_SLOT_BITS == 0); + /* Return a Lisp_Save_Value object with the data saved according to - FMT. Format specifiers are `i' for an integer, `p' for a pointer - and `o' for Lisp_Object. Up to 4 objects can be specified. */ + DATA_TYPE. DATA_TYPE should be one of SAVE_TYPE_INT_INT, etc. */ Lisp_Object -make_save_value (const char *fmt, ...) +make_save_value (enum Lisp_Save_Type save_type, ...) { va_list ap; - int len = strlen (fmt); + int i; Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); struct Lisp_Save_Value *p = XSAVE_VALUE (val); - eassert (0 < len && len < 5); - va_start (ap, fmt); - -#define INITX(index) \ - do { \ - if (len <= index) \ - p->type ## index = SAVE_UNUSED; \ - else \ - { \ - if (fmt[index] == 'i') \ - { \ - p->type ## index = SAVE_INTEGER; \ - p->data[index].integer = va_arg (ap, ptrdiff_t); \ - } \ - else if (fmt[index] == 'p') \ - { \ - p->type ## index = SAVE_POINTER; \ - p->data[index].pointer = va_arg (ap, void *); \ - } \ - else if (fmt[index] == 'o') \ - { \ - p->type ## index = SAVE_OBJECT; \ - p->data[index].object = va_arg (ap, Lisp_Object); \ - } \ - else \ - emacs_abort (); \ - } \ - } while (0) + eassert (0 < save_type + && (save_type < 1 << (SAVE_TYPE_BITS - 1) + || save_type == SAVE_TYPE_MEMORY)); + p->save_type = save_type; + va_start (ap, save_type); + save_type &= ~ (1 << (SAVE_TYPE_BITS - 1)); + + for (i = 0; save_type; i++, save_type >>= SAVE_SLOT_BITS) + switch (save_type & ((1 << SAVE_SLOT_BITS) - 1)) + { + case SAVE_POINTER: + p->data[i].pointer = va_arg (ap, void *); + break; - INITX (0); - INITX (1); - INITX (2); - INITX (3); + case SAVE_INTEGER: + p->data[i].integer = va_arg (ap, ptrdiff_t); + break; -#undef INITX + case SAVE_OBJECT: + p->data[i].object = va_arg (ap, Lisp_Object); + break; + + default: + emacs_abort (); + } va_end (ap); - p->area = 0; return val; } @@ -3386,11 +3380,8 @@ make_save_pointer (void *pointer) { Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); struct Lisp_Save_Value *p = XSAVE_VALUE (val); - - p->area = 0; - p->type0 = SAVE_POINTER; + p->save_type = SAVE_POINTER; p->data[0].pointer = pointer; - p->type1 = p->type2 = p->type3 = SAVE_UNUSED; return val; } @@ -5958,12 +5949,11 @@ mark_object (Lisp_Object arg) case Lisp_Misc_Save_Value: XMISCANY (obj)->gcmarkbit = 1; { - register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); - /* If `area' is nonzero, `data[0].pointer' is the address + struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); + /* If `save_type' is zero, `data[0].pointer' is the address of a memory area containing `data[1].integer' potential Lisp_Objects. */ -#if GC_MARK_STACK - if (ptr->area) + if (GC_MARK_STACK && ptr->save_type == SAVE_TYPE_MEMORY) { Lisp_Object *p = ptr->data[0].pointer; ptrdiff_t nelt; @@ -5971,17 +5961,12 @@ mark_object (Lisp_Object arg) mark_maybe_object (*p); } else -#endif /* GC_MARK_STACK */ { /* Find Lisp_Objects in `data[N]' slots and mark them. */ - if (ptr->type0 == SAVE_OBJECT) - mark_object (ptr->data[0].object); - if (ptr->type1 == SAVE_OBJECT) - mark_object (ptr->data[1].object); - if (ptr->type2 == SAVE_OBJECT) - mark_object (ptr->data[2].object); - if (ptr->type3 == SAVE_OBJECT) - mark_object (ptr->data[3].object); + int i; + for (i = 0; i < SAVE_VALUE_SLOTS; i++) + if (save_type (ptr, i) == SAVE_OBJECT) + mark_object (ptr->data[i].object); } } break; -- cgit v1.2.1 From 908589fd28437a9b0995b103e22ce5e4d421eb8a Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 24 Mar 2013 13:59:45 +0100 Subject: Reorder conditions that are written backwards * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are written backwards. * blockinput.h (input_blocked_p): Likewise. * bytecode.c (exec_byte_code): Likewise. * callproc.c (call_process_kill, call_process_cleanup) (Fcall_process): Likewise. * ccl.c (ccl_driver, resolve_symbol_ccl_program) (Fccl_execute_on_string): Likewise. * character.c (string_escape_byte8): Likewise. * charset.c (read_hex): Likewise. * cm.c (calccost): Likewise. * data.c (cons_to_unsigned): Likewise. * dired.c (directory_files_internal, file_name_completion): Likewise. * dispnew.c (scrolling_window, update_frame_1, Fsleep_for) (sit_for): Likewise. * doc.c (Fsubstitute_command_keys): Likewise. * doprnt.c (doprnt): Likewise. * editfns.c (hi_time, decode_time_components, Fformat): Likewise. * emacsgtkfixed.c: Likewise. * fileio.c (file_offset, Fwrite_region): Likewise. * floatfns.c (Fexpt, fmod_float): Likewise. * fns.c (larger_vector, make_hash_table, Fmake_hash_table): Likewise. * font.c (font_intern_prop): Likewise. * frame.c (x_set_alpha): Likewise. * gtkutil.c (get_utf8_string): Likewise. * indent.c (check_display_width): Likewise. * intervals.c (create_root_interval, rotate_right, rotate_left) (split_interval_right, split_interval_left) (adjust_intervals_for_insertion, delete_node) (interval_deletion_adjustment, adjust_intervals_for_deletion) (merge_interval_right, merge_interval_left, copy_intervals) (set_intervals_multibyte_1): Likewise. * keyboard.c (gobble_input, append_tool_bar_item): Likewise. * keymap.c (Fkey_description): Likewise. * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise. * lread.c (openp, read_integer, read1, string_to_number): Likewise. * menu.c (ensure_menu_items): Likewise. * minibuf.c (read_minibuf_noninteractive): Likewise. * print.c (printchar, strout): Likewise. * process.c (create_process, Faccept_process_output) (wait_reading_process_output, read_process_output, send_process) (wait_reading_process_output): Likewise. * profiler.c (make_log, handle_profiler_signal): Likewise. * regex.c (re_exec): Likewise. * regex.h: Likewise. * search.c (looking_at_1, Freplace_match): Likewise. * sysdep.c (get_child_status, procfs_ttyname) (procfs_get_total_memory): Likewise. * systime.h (EMACS_TIME_VALID_P): Likewise. * term.c (dissociate_if_controlling_tty): Likewise. * window.c (get_phys_cursor_glyph): Likewise. * xdisp.c (init_iterator, redisplay_internal, redisplay_window) (try_window_reusing_current_matrix, try_window_id, pint2hrstr): Likewise. * xfns.c (Fx_window_property): Likewise. * xmenu.c (set_frame_menubar): Likewise. * xselect.c (x_get_window_property, x_handle_dnd_message): Likewise. * xsmfns.c (smc_save_yourself_CB): Likewise. * xterm.c (x_scroll_bar_set_handle): Likewise. --- src/alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 4245b3069fa..ea833c62b94 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -779,7 +779,7 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, ptrdiff_t nitems_incr_max = n_max - n; ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max)); - eassert (0 < item_size && 0 < nitems_incr_min && 0 <= n && -1 <= nitems_max); + eassert (item_size > 0 && nitems_incr_min > 0 && n >= 0 && nitems_max >= -1); if (! pa) *nitems = 0; if (nitems_incr_max < incr) @@ -5376,7 +5376,7 @@ See Info node `(elisp)Garbage Collection'. */) double tot = total_bytes_of_live_objects (); tot *= XFLOAT_DATA (Vgc_cons_percentage); - if (0 < tot) + if (tot > 0) { if (tot < TYPE_MAXIMUM (EMACS_INT)) gc_relative_threshold = tot; -- cgit v1.2.1