emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109734: * alloc.c: Use bool for bool


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109734: * alloc.c: Use bool for booleans.
Date: Tue, 21 Aug 2012 16:39:56 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109734
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2012-08-21 16:39:56 -0700
message:
  * 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.
modified:
  src/ChangeLog
  src/alloc.c
  src/editfns.c
  src/fileio.c
  src/fns.c
  src/lisp.h
  src/lread.c
  src/print.c
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-21 23:09:01 +0000
+++ b/src/ChangeLog     2012-08-21 23:39:56 +0000
@@ -1,5 +1,32 @@
 2012-08-21  Paul Eggert  <address@hidden>
 
+       * 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)

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-08-17 21:12:11 +0000
+++ b/src/alloc.c       2012-08-21 23:39:56 +0000
@@ -173,15 +173,15 @@
 
 EMACS_INT memory_full_cons_threshold;
 
-/* Nonzero during GC.  */
-
-int gc_in_progress;
-
-/* Nonzero means abort if try to GC.
+/* True during GC.  */
+
+bool gc_in_progress;
+
+/* 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_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 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 @@
 #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 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 @@
 
 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 @@
 
   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 @@
 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 
   if (m != MEM_NIL)
     {
-      int mark_p = 0;
+      bool mark_p = 0;
 
       switch (XTYPE (obj))
        {
@@ -4707,7 +4707,8 @@
 
 #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 @@
   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 @@
     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 @@
 
   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 @@
 
 /* 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 @@
 
 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 @@
 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 @@
 /* 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 @@
            /* 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 @@
 }
 
 #ifdef ENABLE_CHECKING
-int suppress_checking;
+bool suppress_checking;
 
 void
 die (const char *msg, const char *file, int line)

=== modified file 'src/editfns.c'
--- a/src/editfns.c     2012-08-19 21:00:09 +0000
+++ b/src/editfns.c     2012-08-21 23:39:56 +0000
@@ -3642,13 +3642,13 @@
   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

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2012-08-18 06:06:39 +0000
+++ b/src/fileio.c      2012-08-21 23:39:56 +0000
@@ -766,7 +766,7 @@
 #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 @@
   char *target = NULL;
   int total = 0;
   int substituted = 0;
-  int multibyte;
+  bool multibyte;
   char *xnm;
   Lisp_Object handler;
 
@@ -5306,7 +5306,7 @@
   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)

=== modified file 'src/fns.c'
--- a/src/fns.c 2012-08-21 10:21:04 +0000
+++ b/src/fns.c 2012-08-21 23:39:56 +0000
@@ -3967,8 +3967,8 @@
       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))

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-08-21 17:18:21 +0000
+++ b/src/lisp.h        2012-08-21 23:39:56 +0000
@@ -124,7 +124,7 @@
    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 @@
 #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 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 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_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 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);

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-08-21 10:21:04 +0000
+++ b/src/lread.c       2012-08-21 23:39:56 +0000
@@ -189,7 +189,7 @@
 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 @@
 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;

=== modified file 'src/print.c'
--- a/src/print.c       2012-08-18 06:06:39 +0000
+++ b/src/print.c       2012-08-21 23:39:56 +0000
@@ -586,6 +586,7 @@
   (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 @@
        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 @@
   Vdeactivate_mark = save_deactivate_mark;
   /* UNGCPRO; */
 
-  abort_on_gc--;
+  abort_on_gc = prev_abort_on_gc;
   return unbind_to (count, object);
 }
 

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2012-08-19 19:22:41 +0000
+++ b/src/xdisp.c       2012-08-21 23:39:56 +0000
@@ -10480,11 +10480,10 @@
    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);
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]