aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-08-21 16:39:56 -0700
committerPaul Eggert2012-08-21 16:39:56 -0700
commitfce31d69dc4d6ff8810d499deebe568437fbf38b (patch)
tree4deb5628e430c3f756d235cdbb87244680636173 /src/alloc.c
parentd0d2d26fba3df1121108fcf80e4a26549d7736a3 (diff)
downloademacs-fce31d69dc4d6ff8810d499deebe568437fbf38b.tar.gz
emacs-fce31d69dc4d6ff8810d499deebe568437fbf38b.zip
* 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.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 522f33f5379..f0da9416ece 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -173,15 +173,15 @@ EMACS_INT gc_relative_threshold;
173 173
174EMACS_INT memory_full_cons_threshold; 174EMACS_INT memory_full_cons_threshold;
175 175
176/* Nonzero during GC. */ 176/* True during GC. */
177 177
178int gc_in_progress; 178bool gc_in_progress;
179 179
180/* Nonzero means abort if try to GC. 180/* True means abort if try to GC.
181 This is for code which is written on the assumption that 181 This is for code which is written on the assumption that
182 no GC will happen, so as to verify that assumption. */ 182 no GC will happen, so as to verify that assumption. */
183 183
184int abort_on_gc; 184bool abort_on_gc;
185 185
186/* Number of live and free conses etc. */ 186/* Number of live and free conses etc. */
187 187
@@ -223,7 +223,7 @@ static ptrdiff_t pure_size;
223 223
224static ptrdiff_t pure_bytes_used_before_overflow; 224static ptrdiff_t pure_bytes_used_before_overflow;
225 225
226/* Value is non-zero if P points into pure space. */ 226/* True if P points into pure space. */
227 227
228#define PURE_POINTER_P(P) \ 228#define PURE_POINTER_P(P) \
229 ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size) 229 ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size)
@@ -392,13 +392,13 @@ static struct mem_node mem_z;
392static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t); 392static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t);
393static void lisp_free (void *); 393static void lisp_free (void *);
394static void mark_stack (void); 394static void mark_stack (void);
395static int live_vector_p (struct mem_node *, void *); 395static bool live_vector_p (struct mem_node *, void *);
396static int live_buffer_p (struct mem_node *, void *); 396static bool live_buffer_p (struct mem_node *, void *);
397static int live_string_p (struct mem_node *, void *); 397static bool live_string_p (struct mem_node *, void *);
398static int live_cons_p (struct mem_node *, void *); 398static bool live_cons_p (struct mem_node *, void *);
399static int live_symbol_p (struct mem_node *, void *); 399static bool live_symbol_p (struct mem_node *, void *);
400static int live_float_p (struct mem_node *, void *); 400static bool live_float_p (struct mem_node *, void *);
401static int live_misc_p (struct mem_node *, void *); 401static bool live_misc_p (struct mem_node *, void *);
402static void mark_maybe_object (Lisp_Object); 402static void mark_maybe_object (Lisp_Object);
403static void mark_memory (void *, void *); 403static void mark_memory (void *, void *);
404#if GC_MARK_STACK || defined GC_MALLOC_CHECK 404#if GC_MARK_STACK || defined GC_MALLOC_CHECK
@@ -1241,7 +1241,7 @@ static void (*old_free_hook) (void*, const void*);
1241#endif 1241#endif
1242 1242
1243#ifdef GC_MALLOC_CHECK 1243#ifdef GC_MALLOC_CHECK
1244static int dont_register_blocks; 1244static bool dont_register_blocks;
1245#endif 1245#endif
1246 1246
1247static size_t bytes_used_when_reconsidered; 1247static size_t bytes_used_when_reconsidered;
@@ -1828,11 +1828,11 @@ check_sblock (struct sblock *b)
1828 1828
1829 1829
1830/* Check validity of Lisp strings' string_bytes member. ALL_P 1830/* Check validity of Lisp strings' string_bytes member. ALL_P
1831 non-zero means check all strings, otherwise check only most 1831 means check all strings, otherwise check only most
1832 recently allocated strings. Used for hunting a bug. */ 1832 recently allocated strings. Used for hunting a bug. */
1833 1833
1834static void 1834static void
1835check_string_bytes (int all_p) 1835check_string_bytes (bool all_p)
1836{ 1836{
1837 if (all_p) 1837 if (all_p)
1838 { 1838 {
@@ -2437,9 +2437,9 @@ make_string_from_bytes (const char *contents,
2437 2437
2438Lisp_Object 2438Lisp_Object
2439make_specified_string (const char *contents, 2439make_specified_string (const char *contents,
2440 ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) 2440 ptrdiff_t nchars, ptrdiff_t nbytes, bool multibyte)
2441{ 2441{
2442 register Lisp_Object val; 2442 Lisp_Object val;
2443 2443
2444 if (nchars < 0) 2444 if (nchars < 0)
2445 { 2445 {
@@ -3094,7 +3094,7 @@ sweep_vectors (void)
3094 3094
3095 for (block = vector_blocks; block; block = *bprev) 3095 for (block = vector_blocks; block; block = *bprev)
3096 { 3096 {
3097 int free_this_block = 0; 3097 bool free_this_block = 0;
3098 3098
3099 for (vector = (struct Lisp_Vector *) block->data; 3099 for (vector = (struct Lisp_Vector *) block->data;
3100 VECTOR_IN_BLOCK (vector, block); vector = next) 3100 VECTOR_IN_BLOCK (vector, block); vector = next)
@@ -3753,7 +3753,7 @@ void
3753memory_full (size_t nbytes) 3753memory_full (size_t nbytes)
3754{ 3754{
3755 /* Do not go into hysterics merely because a large request failed. */ 3755 /* Do not go into hysterics merely because a large request failed. */
3756 int enough_free_memory = 0; 3756 bool enough_free_memory = 0;
3757 if (SPARE_MEMORY < nbytes) 3757 if (SPARE_MEMORY < nbytes)
3758 { 3758 {
3759 void *p; 3759 void *p;
@@ -4246,7 +4246,7 @@ mem_delete_fixup (struct mem_node *x)
4246/* Value is non-zero if P is a pointer to a live Lisp string on 4246/* Value is non-zero if P is a pointer to a live Lisp string on
4247 the heap. M is a pointer to the mem_block for P. */ 4247 the heap. M is a pointer to the mem_block for P. */
4248 4248
4249static inline int 4249static inline bool
4250live_string_p (struct mem_node *m, void *p) 4250live_string_p (struct mem_node *m, void *p)
4251{ 4251{
4252 if (m->type == MEM_TYPE_STRING) 4252 if (m->type == MEM_TYPE_STRING)
@@ -4269,7 +4269,7 @@ live_string_p (struct mem_node *m, void *p)
4269/* Value is non-zero if P is a pointer to a live Lisp cons on 4269/* Value is non-zero if P is a pointer to a live Lisp cons on
4270 the heap. M is a pointer to the mem_block for P. */ 4270 the heap. M is a pointer to the mem_block for P. */
4271 4271
4272static inline int 4272static inline bool
4273live_cons_p (struct mem_node *m, void *p) 4273live_cons_p (struct mem_node *m, void *p)
4274{ 4274{
4275 if (m->type == MEM_TYPE_CONS) 4275 if (m->type == MEM_TYPE_CONS)
@@ -4295,7 +4295,7 @@ live_cons_p (struct mem_node *m, void *p)
4295/* Value is non-zero if P is a pointer to a live Lisp symbol on 4295/* Value is non-zero if P is a pointer to a live Lisp symbol on
4296 the heap. M is a pointer to the mem_block for P. */ 4296 the heap. M is a pointer to the mem_block for P. */
4297 4297
4298static inline int 4298static inline bool
4299live_symbol_p (struct mem_node *m, void *p) 4299live_symbol_p (struct mem_node *m, void *p)
4300{ 4300{
4301 if (m->type == MEM_TYPE_SYMBOL) 4301 if (m->type == MEM_TYPE_SYMBOL)
@@ -4321,7 +4321,7 @@ live_symbol_p (struct mem_node *m, void *p)
4321/* Value is non-zero if P is a pointer to a live Lisp float on 4321/* Value is non-zero if P is a pointer to a live Lisp float on
4322 the heap. M is a pointer to the mem_block for P. */ 4322 the heap. M is a pointer to the mem_block for P. */
4323 4323
4324static inline int 4324static inline bool
4325live_float_p (struct mem_node *m, void *p) 4325live_float_p (struct mem_node *m, void *p)
4326{ 4326{
4327 if (m->type == MEM_TYPE_FLOAT) 4327 if (m->type == MEM_TYPE_FLOAT)
@@ -4345,7 +4345,7 @@ live_float_p (struct mem_node *m, void *p)
4345/* Value is non-zero if P is a pointer to a live Lisp Misc on 4345/* Value is non-zero if P is a pointer to a live Lisp Misc on
4346 the heap. M is a pointer to the mem_block for P. */ 4346 the heap. M is a pointer to the mem_block for P. */
4347 4347
4348static inline int 4348static inline bool
4349live_misc_p (struct mem_node *m, void *p) 4349live_misc_p (struct mem_node *m, void *p)
4350{ 4350{
4351 if (m->type == MEM_TYPE_MISC) 4351 if (m->type == MEM_TYPE_MISC)
@@ -4371,7 +4371,7 @@ live_misc_p (struct mem_node *m, void *p)
4371/* Value is non-zero if P is a pointer to a live vector-like object. 4371/* Value is non-zero if P is a pointer to a live vector-like object.
4372 M is a pointer to the mem_block for P. */ 4372 M is a pointer to the mem_block for P. */
4373 4373
4374static inline int 4374static inline bool
4375live_vector_p (struct mem_node *m, void *p) 4375live_vector_p (struct mem_node *m, void *p)
4376{ 4376{
4377 if (m->type == MEM_TYPE_VECTOR_BLOCK) 4377 if (m->type == MEM_TYPE_VECTOR_BLOCK)
@@ -4407,7 +4407,7 @@ live_vector_p (struct mem_node *m, void *p)
4407/* Value is non-zero if P is a pointer to a live buffer. M is a 4407/* Value is non-zero if P is a pointer to a live buffer. M is a
4408 pointer to the mem_block for P. */ 4408 pointer to the mem_block for P. */
4409 4409
4410static inline int 4410static inline bool
4411live_buffer_p (struct mem_node *m, void *p) 4411live_buffer_p (struct mem_node *m, void *p)
4412{ 4412{
4413 /* P must point to the start of the block, and the buffer 4413 /* P must point to the start of the block, and the buffer
@@ -4487,7 +4487,7 @@ mark_maybe_object (Lisp_Object obj)
4487 4487
4488 if (m != MEM_NIL) 4488 if (m != MEM_NIL)
4489 { 4489 {
4490 int mark_p = 0; 4490 bool mark_p = 0;
4491 4491
4492 switch (XTYPE (obj)) 4492 switch (XTYPE (obj))
4493 { 4493 {
@@ -4707,7 +4707,8 @@ mark_memory (void *start, void *end)
4707 4707
4708#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS 4708#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS
4709 4709
4710static int setjmp_tested_p, longjmps_done; 4710static bool setjmp_tested_p;
4711static int longjmps_done;
4711 4712
4712#define SETJMP_WILL_LIKELY_WORK "\ 4713#define SETJMP_WILL_LIKELY_WORK "\
4713\n\ 4714\n\
@@ -4751,7 +4752,6 @@ test_setjmp (void)
4751 char buf[10]; 4752 char buf[10];
4752 register int x; 4753 register int x;
4753 jmp_buf jbuf; 4754 jmp_buf jbuf;
4754 int result = 0;
4755 4755
4756 /* Arrange for X to be put in a register. */ 4756 /* Arrange for X to be put in a register. */
4757 sprintf (buf, "1"); 4757 sprintf (buf, "1");
@@ -4891,7 +4891,7 @@ mark_stack (void)
4891 Lisp_Object o; 4891 Lisp_Object o;
4892 jmp_buf j; 4892 jmp_buf j;
4893 } j; 4893 } j;
4894 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base; 4894 volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base;
4895#endif 4895#endif
4896 /* This trick flushes the register windows so that all the state of 4896 /* This trick flushes the register windows so that all the state of
4897 the process is contained in the stack. */ 4897 the process is contained in the stack. */
@@ -4965,7 +4965,7 @@ valid_pointer_p (void *p)
4965 4965
4966 if (pipe (fd) == 0) 4966 if (pipe (fd) == 0)
4967 { 4967 {
4968 int valid = (emacs_write (fd[1], (char *) p, 16) == 16); 4968 bool valid = emacs_write (fd[1], (char *) p, 16) == 16;
4969 emacs_close (fd[1]); 4969 emacs_close (fd[1]);
4970 emacs_close (fd[0]); 4970 emacs_close (fd[0]);
4971 return valid; 4971 return valid;
@@ -5186,7 +5186,7 @@ find_string_data_in_pure (const char *data, ptrdiff_t nbytes)
5186 5186
5187/* Return a string allocated in pure space. DATA is a buffer holding 5187/* Return a string allocated in pure space. DATA is a buffer holding
5188 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE 5188 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE
5189 non-zero means make the result string multibyte. 5189 means make the result string multibyte.
5190 5190
5191 Must get an error if pure storage is full, since if it cannot hold 5191 Must get an error if pure storage is full, since if it cannot hold
5192 a large string it may be able to hold conses that point to that 5192 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)
5194 5194
5195Lisp_Object 5195Lisp_Object
5196make_pure_string (const char *data, 5196make_pure_string (const char *data,
5197 ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) 5197 ptrdiff_t nchars, ptrdiff_t nbytes, bool multibyte)
5198{ 5198{
5199 Lisp_Object string; 5199 Lisp_Object string;
5200 struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String); 5200 struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
@@ -5389,11 +5389,11 @@ returns nil, because real GC can't be done.
5389See Info node `(elisp)Garbage Collection'. */) 5389See Info node `(elisp)Garbage Collection'. */)
5390 (void) 5390 (void)
5391{ 5391{
5392 register struct specbinding *bind; 5392 struct specbinding *bind;
5393 register struct buffer *nextb; 5393 struct buffer *nextb;
5394 char stack_top_variable; 5394 char stack_top_variable;
5395 ptrdiff_t i; 5395 ptrdiff_t i;
5396 int message_p; 5396 bool message_p;
5397 ptrdiff_t count = SPECPDL_INDEX (); 5397 ptrdiff_t count = SPECPDL_INDEX ();
5398 EMACS_TIME start; 5398 EMACS_TIME start;
5399 Lisp_Object retval = Qnil; 5399 Lisp_Object retval = Qnil;
@@ -6208,10 +6208,10 @@ mark_terminals (void)
6208/* Value is non-zero if OBJ will survive the current GC because it's 6208/* Value is non-zero if OBJ will survive the current GC because it's
6209 either marked or does not need to be marked to survive. */ 6209 either marked or does not need to be marked to survive. */
6210 6210
6211int 6211bool
6212survives_gc_p (Lisp_Object obj) 6212survives_gc_p (Lisp_Object obj)
6213{ 6213{
6214 int survives_p; 6214 bool survives_p;
6215 6215
6216 switch (XTYPE (obj)) 6216 switch (XTYPE (obj))
6217 { 6217 {
@@ -6456,7 +6456,7 @@ gc_sweep (void)
6456 /* Check if the symbol was created during loadup. In such a case 6456 /* Check if the symbol was created during loadup. In such a case
6457 it might be pointed to by pure bytecode which we don't trace, 6457 it might be pointed to by pure bytecode which we don't trace,
6458 so we conservatively assume that it is live. */ 6458 so we conservatively assume that it is live. */
6459 int pure_p = PURE_POINTER_P (XSTRING (sym->s.name)); 6459 bool pure_p = PURE_POINTER_P (XSTRING (sym->s.name));
6460 6460
6461 if (!sym->s.gcmarkbit && !pure_p) 6461 if (!sym->s.gcmarkbit && !pure_p)
6462 { 6462 {
@@ -6681,7 +6681,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6681} 6681}
6682 6682
6683#ifdef ENABLE_CHECKING 6683#ifdef ENABLE_CHECKING
6684int suppress_checking; 6684bool suppress_checking;
6685 6685
6686void 6686void
6687die (const char *msg, const char *file, int line) 6687die (const char *msg, const char *file, int line)