* alloc.c: Use bool for booleans.

(gc_in_progress, abort_on_gc)
(setjmp_tested_p) [!GC_SAVE_REGISTERS_ON_STACK && !GC_SETJMP_WORKS]:
(dont_register_blocks) [GC_MALLOC_CHECK]:
(suppress_checking) [ENABLE_CHECKING]: Now bool, not int.
(check_string_bytes, make_specified_string, memory_full)
(live_string_p, live_cons_p, live_symbol_p, live_float_p)
(live_misc_p, live_vector_p, live_buffer_p, mark_maybe_object)
(mark_stack, valid_pointer_p, make_pure_string)
(Fgarbage_collect, survives_gc_p, gc_sweep):
Use bool for booleans, instead of int.
(test_setjmp) [!GC_SAVE_REGISTERS_ON_STACK && !GC_SETJMP_WORKS]:
Remove unused local.
* alloc.c (PURE_POINTER_P):
* lisp.h (STRING_MULTIBYTE): Document that it returns a boolean.
* editfns.c (Fformat):
* fileio.c (Fexpand_file_name, Fsubstitute_in_file_name)
(Fdo_auto_save):
* fns.c (sweep_weak_table):
* lisp.h (suppress_checking, push_message, survives_gc_p)
(make_pure_string, gc_in_progress, abort_on_gc):
* lread.c (readchar, read1):
* print.c (Fprin1_to_string):
* xdisp.c (push_message):
Use bool for booleans affected directly or indirectly by
alloc.c's changes.
This commit is contained in:
Paul Eggert 2012-08-21 16:39:56 -07:00
parent d0d2d26fba
commit fce31d69dc
9 changed files with 95 additions and 67 deletions

View file

@ -1,5 +1,32 @@
2012-08-21 Paul Eggert <eggert@cs.ucla.edu>
* alloc.c: Use bool for booleans.
(gc_in_progress, abort_on_gc)
(setjmp_tested_p) [!GC_SAVE_REGISTERS_ON_STACK && !GC_SETJMP_WORKS]:
(dont_register_blocks) [GC_MALLOC_CHECK]:
(suppress_checking) [ENABLE_CHECKING]: Now bool, not int.
(check_string_bytes, make_specified_string, memory_full)
(live_string_p, live_cons_p, live_symbol_p, live_float_p)
(live_misc_p, live_vector_p, live_buffer_p, mark_maybe_object)
(mark_stack, valid_pointer_p, make_pure_string)
(Fgarbage_collect, survives_gc_p, gc_sweep):
Use bool for booleans, instead of int.
(test_setjmp) [!GC_SAVE_REGISTERS_ON_STACK && !GC_SETJMP_WORKS]:
Remove unused local.
* alloc.c (PURE_POINTER_P):
* lisp.h (STRING_MULTIBYTE): Document that it returns a boolean.
* editfns.c (Fformat):
* fileio.c (Fexpand_file_name, Fsubstitute_in_file_name)
(Fdo_auto_save):
* fns.c (sweep_weak_table):
* lisp.h (suppress_checking, push_message, survives_gc_p)
(make_pure_string, gc_in_progress, abort_on_gc):
* lread.c (readchar, read1):
* print.c (Fprin1_to_string):
* xdisp.c (push_message):
Use bool for booleans affected directly or indirectly by
alloc.c's changes.
Make recently-introduced setters macros.
* fontset.c (set_fontset_id, set_fontset_name, set_fontset_ascii)
(set_fontset_base, set_fontset_frame, set_fontset_nofont_face)

View file

@ -173,15 +173,15 @@ EMACS_INT gc_relative_threshold;
EMACS_INT memory_full_cons_threshold;
/* Nonzero during GC. */
/* True during GC. */
int gc_in_progress;
bool gc_in_progress;
/* Nonzero means abort if try to GC.
/* True means abort if try to GC.
This is for code which is written on the assumption that
no GC will happen, so as to verify that assumption. */
int abort_on_gc;
bool abort_on_gc;
/* Number of live and free conses etc. */
@ -223,7 +223,7 @@ static ptrdiff_t pure_size;
static ptrdiff_t pure_bytes_used_before_overflow;
/* Value is non-zero if P points into pure space. */
/* True if P points into pure space. */
#define PURE_POINTER_P(P) \
((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size)
@ -392,13 +392,13 @@ static struct mem_node mem_z;
static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t);
static void lisp_free (void *);
static void mark_stack (void);
static int live_vector_p (struct mem_node *, void *);
static int live_buffer_p (struct mem_node *, void *);
static int live_string_p (struct mem_node *, void *);
static int live_cons_p (struct mem_node *, void *);
static int live_symbol_p (struct mem_node *, void *);
static int live_float_p (struct mem_node *, void *);
static int live_misc_p (struct mem_node *, 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
@ -1241,7 +1241,7 @@ static void (*old_free_hook) (void*, const void*);
#endif
#ifdef GC_MALLOC_CHECK
static int dont_register_blocks;
static bool dont_register_blocks;
#endif
static size_t bytes_used_when_reconsidered;
@ -1828,11 +1828,11 @@ check_sblock (struct sblock *b)
/* Check validity of Lisp strings' string_bytes member. ALL_P
non-zero means check all strings, otherwise check only most
means check all strings, otherwise check only most
recently allocated strings. Used for hunting a bug. */
static void
check_string_bytes (int all_p)
check_string_bytes (bool all_p)
{
if (all_p)
{
@ -2437,9 +2437,9 @@ make_string_from_bytes (const char *contents,
Lisp_Object
make_specified_string (const char *contents,
ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte)
ptrdiff_t nchars, ptrdiff_t nbytes, bool multibyte)
{
register Lisp_Object val;
Lisp_Object val;
if (nchars < 0)
{
@ -3094,7 +3094,7 @@ sweep_vectors (void)
for (block = vector_blocks; block; block = *bprev)
{
int free_this_block = 0;
bool free_this_block = 0;
for (vector = (struct Lisp_Vector *) block->data;
VECTOR_IN_BLOCK (vector, block); vector = next)
@ -3753,7 +3753,7 @@ void
memory_full (size_t nbytes)
{
/* Do not go into hysterics merely because a large request failed. */
int enough_free_memory = 0;
bool enough_free_memory = 0;
if (SPARE_MEMORY < nbytes)
{
void *p;
@ -4246,7 +4246,7 @@ mem_delete_fixup (struct mem_node *x)
/* Value is non-zero if P is a pointer to a live Lisp string on
the heap. M is a pointer to the mem_block for P. */
static inline int
static inline bool
live_string_p (struct mem_node *m, void *p)
{
if (m->type == MEM_TYPE_STRING)
@ -4269,7 +4269,7 @@ live_string_p (struct mem_node *m, void *p)
/* Value is non-zero if P is a pointer to a live Lisp cons on
the heap. M is a pointer to the mem_block for P. */
static inline int
static inline bool
live_cons_p (struct mem_node *m, void *p)
{
if (m->type == MEM_TYPE_CONS)
@ -4295,7 +4295,7 @@ live_cons_p (struct mem_node *m, void *p)
/* Value is non-zero if P is a pointer to a live Lisp symbol on
the heap. M is a pointer to the mem_block for P. */
static inline int
static inline bool
live_symbol_p (struct mem_node *m, void *p)
{
if (m->type == MEM_TYPE_SYMBOL)
@ -4321,7 +4321,7 @@ live_symbol_p (struct mem_node *m, void *p)
/* Value is non-zero if P is a pointer to a live Lisp float on
the heap. M is a pointer to the mem_block for P. */
static inline int
static inline bool
live_float_p (struct mem_node *m, void *p)
{
if (m->type == MEM_TYPE_FLOAT)
@ -4345,7 +4345,7 @@ live_float_p (struct mem_node *m, void *p)
/* Value is non-zero if P is a pointer to a live Lisp Misc on
the heap. M is a pointer to the mem_block for P. */
static inline int
static inline bool
live_misc_p (struct mem_node *m, void *p)
{
if (m->type == MEM_TYPE_MISC)
@ -4371,7 +4371,7 @@ live_misc_p (struct mem_node *m, void *p)
/* Value is non-zero if P is a pointer to a live vector-like object.
M is a pointer to the mem_block for P. */
static inline int
static inline bool
live_vector_p (struct mem_node *m, void *p)
{
if (m->type == MEM_TYPE_VECTOR_BLOCK)
@ -4407,7 +4407,7 @@ live_vector_p (struct mem_node *m, void *p)
/* Value is non-zero if P is a pointer to a live buffer. M is a
pointer to the mem_block for P. */
static inline int
static inline bool
live_buffer_p (struct mem_node *m, void *p)
{
/* P must point to the start of the block, and the buffer
@ -4487,7 +4487,7 @@ mark_maybe_object (Lisp_Object obj)
if (m != MEM_NIL)
{
int mark_p = 0;
bool mark_p = 0;
switch (XTYPE (obj))
{
@ -4707,7 +4707,8 @@ mark_memory (void *start, void *end)
#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS
static int setjmp_tested_p, longjmps_done;
static bool setjmp_tested_p;
static int longjmps_done;
#define SETJMP_WILL_LIKELY_WORK "\
\n\
@ -4751,7 +4752,6 @@ test_setjmp (void)
char buf[10];
register int x;
jmp_buf jbuf;
int result = 0;
/* Arrange for X to be put in a register. */
sprintf (buf, "1");
@ -4891,7 +4891,7 @@ mark_stack (void)
Lisp_Object o;
jmp_buf j;
} j;
volatile int stack_grows_down_p = (char *) &j > (char *) stack_base;
volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base;
#endif
/* This trick flushes the register windows so that all the state of
the process is contained in the stack. */
@ -4965,7 +4965,7 @@ valid_pointer_p (void *p)
if (pipe (fd) == 0)
{
int valid = (emacs_write (fd[1], (char *) p, 16) == 16);
bool valid = emacs_write (fd[1], (char *) p, 16) == 16;
emacs_close (fd[1]);
emacs_close (fd[0]);
return valid;
@ -5186,7 +5186,7 @@ find_string_data_in_pure (const char *data, ptrdiff_t nbytes)
/* Return a string allocated in pure space. DATA is a buffer holding
NCHARS characters, and NBYTES bytes of string data. MULTIBYTE
non-zero means make the result string multibyte.
means make the result string multibyte.
Must get an error if pure storage is full, since if it cannot hold
a large string it may be able to hold conses that point to that
@ -5194,7 +5194,7 @@ find_string_data_in_pure (const char *data, ptrdiff_t nbytes)
Lisp_Object
make_pure_string (const char *data,
ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte)
ptrdiff_t nchars, ptrdiff_t nbytes, bool multibyte)
{
Lisp_Object string;
struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
@ -5389,11 +5389,11 @@ returns nil, because real GC can't be done.
See Info node `(elisp)Garbage Collection'. */)
(void)
{
register struct specbinding *bind;
register struct buffer *nextb;
struct specbinding *bind;
struct buffer *nextb;
char stack_top_variable;
ptrdiff_t i;
int message_p;
bool message_p;
ptrdiff_t count = SPECPDL_INDEX ();
EMACS_TIME start;
Lisp_Object retval = Qnil;
@ -6208,10 +6208,10 @@ mark_terminals (void)
/* Value is non-zero if OBJ will survive the current GC because it's
either marked or does not need to be marked to survive. */
int
bool
survives_gc_p (Lisp_Object obj)
{
int survives_p;
bool survives_p;
switch (XTYPE (obj))
{
@ -6456,7 +6456,7 @@ gc_sweep (void)
/* Check if the symbol was created during loadup. In such a case
it might be pointed to by pure bytecode which we don't trace,
so we conservatively assume that it is live. */
int pure_p = PURE_POINTER_P (XSTRING (sym->s.name));
bool pure_p = PURE_POINTER_P (XSTRING (sym->s.name));
if (!sym->s.gcmarkbit && !pure_p)
{
@ -6681,7 +6681,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
}
#ifdef ENABLE_CHECKING
int suppress_checking;
bool suppress_checking;
void
die (const char *msg, const char *file, int line)

View file

@ -3642,13 +3642,13 @@ usage: (format STRING &rest OBJECTS) */)
ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
char *p;
Lisp_Object buf_save_value IF_LINT (= {0});
register char *format, *end, *format_start;
char *format, *end, *format_start;
ptrdiff_t formatlen, nchars;
/* Nonzero if the format is multibyte. */
int multibyte_format = 0;
/* Nonzero if the output should be a multibyte string,
/* True if the format is multibyte. */
bool multibyte_format = 0;
/* True if the output should be a multibyte string,
which is true if any of the inputs is one. */
int multibyte = 0;
bool multibyte = 0;
/* When we make a multibyte string, we must pay attention to the
byte combining problem, i.e., a byte may be combined with a
multibyte character of the previous string. This flag tells if we

View file

@ -766,7 +766,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
#endif /* DOS_NT */
ptrdiff_t length;
Lisp_Object handler, result, handled_name;
int multibyte;
bool multibyte;
Lisp_Object hdir;
CHECK_STRING (name);
@ -1566,7 +1566,7 @@ those `/' is discarded. */)
char *target = NULL;
int total = 0;
int substituted = 0;
int multibyte;
bool multibyte;
char *xnm;
Lisp_Object handler;
@ -5306,7 +5306,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
FILE *stream = NULL;
ptrdiff_t count = SPECPDL_INDEX ();
int orig_minibuffer_auto_raise = minibuffer_auto_raise;
int old_message_p = 0;
bool old_message_p = 0;
struct gcpro gcpro1, gcpro2;
if (max_specpdl_size < specpdl_size + 40)

View file

@ -3967,8 +3967,8 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
for (idx = HASH_INDEX (h, bucket); !NILP (idx); idx = next)
{
ptrdiff_t i = XFASTINT (idx);
int key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
int value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
int remove_p;
if (EQ (h->weak, Qkey))

View file

@ -124,7 +124,7 @@ extern _Noreturn void die (const char *, const char *, int);
eassert macro altogether, e.g., if XSTRING (x) uses eassert to test
STRINGP (x), but a particular use of XSTRING is invoked only after
testing that STRINGP (x) is true, making the test redundant. */
extern int suppress_checking EXTERNALLY_VISIBLE;
extern bool suppress_checking EXTERNALLY_VISIBLE;
# define eassert(cond) \
((cond) || suppress_checking \
@ -702,7 +702,7 @@ struct Lisp_Cons
#define CDR_SAFE(c) \
(CONSP ((c)) ? XCDR ((c)) : Qnil)
/* Nonzero if STR is a multibyte string. */
/* True if STR is a multibyte string. */
#define STRING_MULTIBYTE(STR) \
(XSTRING (STR)->size_byte >= 0)
@ -2799,7 +2799,7 @@ extern Lisp_Object echo_area_buffer[2];
extern void add_to_log (const char *, Lisp_Object, Lisp_Object);
extern void check_message_stack (void);
extern void setup_echo_area_for_printing (int);
extern int push_message (void);
extern bool push_message (void);
extern Lisp_Object pop_message_unwind (Lisp_Object);
extern Lisp_Object restore_message_unwind (Lisp_Object);
extern void restore_message (void);
@ -2842,7 +2842,7 @@ extern void uninterrupt_malloc (void);
extern void malloc_warning (const char *);
extern _Noreturn void memory_full (size_t);
extern _Noreturn void buffer_memory_full (ptrdiff_t);
extern int survives_gc_p (Lisp_Object);
extern bool survives_gc_p (Lisp_Object);
extern void mark_object (Lisp_Object);
#if defined REL_ALLOC && !defined SYSTEM_MALLOC
extern void refill_memory_reserve (void);
@ -2881,8 +2881,8 @@ extern Lisp_Object make_uninit_string (EMACS_INT);
extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT);
extern Lisp_Object make_string_from_bytes (const char *, ptrdiff_t, ptrdiff_t);
extern Lisp_Object make_specified_string (const char *,
ptrdiff_t, ptrdiff_t, int);
extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, int);
ptrdiff_t, ptrdiff_t, bool);
extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, bool);
extern Lisp_Object make_pure_c_string (const char *, ptrdiff_t);
/* Make a string allocated in pure space, use STR as string data. */
@ -2916,8 +2916,8 @@ extern struct window *allocate_window (void);
extern struct frame *allocate_frame (void);
extern struct Lisp_Process *allocate_process (void);
extern struct terminal *allocate_terminal (void);
extern int gc_in_progress;
extern int abort_on_gc;
extern bool gc_in_progress;
extern bool abort_on_gc;
extern Lisp_Object make_float (double);
extern void display_malloc_warning (void);
extern ptrdiff_t inhibit_garbage_collection (void);

View file

@ -189,7 +189,7 @@ static int readbyte_from_string (int, Lisp_Object);
static int unread_char;
static int
readchar (Lisp_Object readcharfun, int *multibyte)
readchar (Lisp_Object readcharfun, bool *multibyte)
{
Lisp_Object tem;
register int c;
@ -2354,9 +2354,9 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix)
static Lisp_Object
read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
{
register int c;
unsigned uninterned_symbol = 0;
int multibyte;
int c;
bool uninterned_symbol = 0;
bool multibyte;
*pch = 0;
load_each_byte = 0;

View file

@ -586,6 +586,7 @@ A printed representation of an object is text which describes that object. */)
(Lisp_Object object, Lisp_Object noescape)
{
Lisp_Object printcharfun;
bool prev_abort_on_gc;
/* struct gcpro gcpro1, gcpro2; */
Lisp_Object save_deactivate_mark;
ptrdiff_t count = SPECPDL_INDEX ();
@ -601,7 +602,8 @@ A printed representation of an object is text which describes that object. */)
No need for specbind, since errors deactivate the mark. */
save_deactivate_mark = Vdeactivate_mark;
/* GCPRO2 (object, save_deactivate_mark); */
abort_on_gc++;
prev_abort_on_gc = abort_on_gc;
abort_on_gc = 1;
printcharfun = Vprin1_to_string_buffer;
PRINTPREPARE;
@ -625,7 +627,7 @@ A printed representation of an object is text which describes that object. */)
Vdeactivate_mark = save_deactivate_mark;
/* UNGCPRO; */
abort_on_gc--;
abort_on_gc = prev_abort_on_gc;
return unbind_to (count, object);
}

View file

@ -10480,11 +10480,10 @@ current_message_1 (ptrdiff_t a1, Lisp_Object a2, ptrdiff_t a3, ptrdiff_t a4)
empty. This is a relatively infrequent operation, so it's not
worth optimizing. */
int
bool
push_message (void)
{
Lisp_Object msg;
msg = current_message ();
Lisp_Object msg = current_message ();
Vmessage_stack = Fcons (msg, Vmessage_stack);
return STRINGP (msg);
}