summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-07-09 09:38:45 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-07-09 09:38:45 -0700
commit5994c1836bc3c2457aa1e27c1191bf03a9be1721 (patch)
tree7aee5e4d288885098634f9356a485b1908a48775
parent26bccfaebf452511a06c2b19414a73b041b17853 (diff)
downloademacs-5994c1836bc3c2457aa1e27c1191bf03a9be1721.tar.gz
Add GCC-style 'const' attribute to functions that can use it.
-rw-r--r--ChangeLog6
-rw-r--r--configure.ac3
-rw-r--r--lib-src/ChangeLog5
-rw-r--r--lib-src/etags.c2
-rw-r--r--nt/ChangeLog4
-rw-r--r--nt/config.nt2
-rw-r--r--src/ChangeLog14
-rw-r--r--src/character.h2
-rw-r--r--src/emacs.c2
-rw-r--r--src/keyboard.h2
-rw-r--r--src/lisp.h20
-rw-r--r--src/mem-limits.h2
-rw-r--r--src/menu.h2
13 files changed, 51 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index bc6e1157c6c..ef14255208d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-07-09 Paul Eggert <eggert@cs.ucla.edu>
+
+ Add GCC-style 'const' attribute to functions that can use it.
+ * configure.ac (WARN_CFLAGS): Add -Wsuggest-attribute=const.
+ (ATTRIBUTE_CONST): New macro, in config.h.
+
2012-07-09 Juanma Barranquero <lekktu@gmail.com>
* lib/makefile.w32-in: Rework dependencies.
diff --git a/configure.ac b/configure.ac
index e4371970012..8db9652fc06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -683,7 +683,6 @@ else
# The following lines should be removable at some point.
nw="$nw -Wstack-protector"
nw="$nw -Wstrict-overflow"
- nw="$nw -Wsuggest-attribute=const"
nw="$nw -Wsuggest-attribute=pure"
gl_MANYWARN_ALL_GCC([ws])
@@ -3636,6 +3635,8 @@ AH_BOTTOM([
ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
#endif
+#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
+
/* Some versions of GNU/Linux define noinline in their headers. */
#ifdef noinline
#undef noinline
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index e2eb418327e..bc7c5d7114d 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,8 @@
+2012-07-09 Paul Eggert <eggert@cs.ucla.edu>
+
+ Add GCC-style 'const' attribute to functions that can use it.
+ * etags.c (number_len): Add ATTRIBUTE_CONST.
+
2012-07-09 Juanma Barranquero <lekktu@gmail.com>
* emacsclient.c (w32_execvp): Declare execvp to silence the compiler.
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 5bdf3402e55..7141811239f 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -2123,7 +2123,7 @@ invalidate_nodes (fdesc *badfdp, node **npp)
static int total_size_of_entries (node *);
-static int number_len (long);
+static int number_len (long) ATTRIBUTE_CONST;
/* Length of a non-negative number's decimal representation. */
static int
diff --git a/nt/ChangeLog b/nt/ChangeLog
index d2bbe4944fd..718f0a81734 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,7 @@
+2012-07-09 Paul Eggert <eggert@cs.ucla.edu>
+
+ * config.nt (ATTRIBUTE_CONST): Add, to sync with configure.ac.
+
2012-07-09 Juanma Barranquero <lekktu@gmail.com>
* config.nt: Sync with autogen/config.in.
diff --git a/nt/config.nt b/nt/config.nt
index 96d303078a5..d873ae7a57d 100644
--- a/nt/config.nt
+++ b/nt/config.nt
@@ -1501,6 +1501,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
#endif
+#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
+
/* Some versions of GNU/Linux define noinline in their headers. */
#ifdef noinline
#undef noinline
diff --git a/src/ChangeLog b/src/ChangeLog
index d5a8abe5c56..2f8dfbdedf3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,19 @@
2012-07-09 Paul Eggert <eggert@cs.ucla.edu>
+ Add GCC-style 'const' attribute to functions that can use it.
+ * character.h (char_resolve_modifier_mask):
+ * keyboard.h (make_ctrl_char):
+ * lisp.h (multibyte_char_to_unibyte, multibyte_char_to_unibyte_safe)
+ (init_character_once, next_almost_prime, init_fns, init_image)
+ (flush_pending_output, init_sound):
+ * mem-limits.h (start_of_data):
+ * menu.h (finish_menu_items):
+ Add ATTRIBUTE_CONST.
+ * emacs.c (DEFINE_DUMMY_FUNCTION):
+ Declare the dummy function with ATTRIBUTE_CONST.
+ * lisp.h (Fbyteorder, Fmax_char, Fidentity):
+ Add decls with ATTRIBUTE_CONST.
+
Minor improvements to make_formatted_string.
* alloc.c (make_formatted_string): Prefer int to ptrdiff_t
where int is good enough, as vsprintf returns an int.
diff --git a/src/character.h b/src/character.h
index a64b48d896c..2cfeff85fee 100644
--- a/src/character.h
+++ b/src/character.h
@@ -665,7 +665,7 @@ typedef enum {
UNICODE_CATEGORY_Cn
} unicode_category_t;
-extern EMACS_INT char_resolve_modifier_mask (EMACS_INT);
+extern EMACS_INT char_resolve_modifier_mask (EMACS_INT) ATTRIBUTE_CONST;
extern int char_string (unsigned, unsigned char *);
extern int string_char (const unsigned char *,
const unsigned char **, int *);
diff --git a/src/emacs.c b/src/emacs.c
index bdc92f88e8e..2b386bac176 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -569,7 +569,7 @@ static char dump_tz[] = "UtC0";
/* Define a dummy function F. Declare F too, to pacify gcc
-Wmissing-prototypes. */
#define DEFINE_DUMMY_FUNCTION(f) \
- void f (void) EXTERNALLY_VISIBLE; void f (void) {}
+ void f (void) ATTRIBUTE_CONST EXTERNALLY_VISIBLE; void f (void) {}
#ifndef GCC_CTORS_IN_LIBC
DEFINE_DUMMY_FUNCTION (__do_global_ctors)
diff --git a/src/keyboard.h b/src/keyboard.h
index 202972ffbd8..752064a6121 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -487,7 +487,7 @@ extern int input_polling_used (void);
extern void clear_input_pending (void);
extern int requeued_events_pending_p (void);
extern void bind_polling_period (int);
-extern int make_ctrl_char (int);
+extern int make_ctrl_char (int) ATTRIBUTE_CONST;
extern void stuff_buffered_input (Lisp_Object);
extern void clear_waiting_for_input (void);
extern void swallow_events (int);
diff --git a/src/lisp.h b/src/lisp.h
index 440a37c8bfb..ba27d86fc85 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2336,6 +2336,8 @@ extern Lisp_Object Qinteger;
extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
+EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST;
+
/* Defined in frame.c */
extern Lisp_Object Qframep;
@@ -2395,11 +2397,12 @@ extern void init_coding_once (void);
extern void syms_of_coding (void);
/* Defined in character.c */
+EXFUN (Fmax_char, 0) ATTRIBUTE_CONST;
extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t);
extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t);
-extern int multibyte_char_to_unibyte (int);
-extern int multibyte_char_to_unibyte_safe (int);
-extern void init_character_once (void);
+extern int multibyte_char_to_unibyte (int) ATTRIBUTE_CONST;
+extern int multibyte_char_to_unibyte_safe (int) ATTRIBUTE_CONST;
+extern void init_character_once (void) ATTRIBUTE_CONST;
extern void syms_of_character (void);
/* Defined in charset.c */
@@ -2419,7 +2422,8 @@ extern void syms_of_syntax (void);
/* Defined in fns.c */
extern Lisp_Object QCrehash_size, QCrehash_threshold;
enum { NEXT_ALMOST_PRIME_LIMIT = 11 };
-extern EMACS_INT next_almost_prime (EMACS_INT);
+EXFUN (Fidentity, 1) ATTRIBUTE_CONST;
+extern EMACS_INT next_almost_prime (EMACS_INT) ATTRIBUTE_CONST;
extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t);
extern void sweep_weak_hash_tables (void);
extern Lisp_Object Qcursor_in_echo_area;
@@ -2434,7 +2438,7 @@ ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
EMACS_UINT);
void init_weak_hash_tables (void);
-extern void init_fns (void);
+extern void init_fns (void) ATTRIBUTE_CONST;
extern Lisp_Object substring_both (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t);
@@ -2470,7 +2474,7 @@ extern Lisp_Object QCascent, QCmargin, QCrelief;
extern Lisp_Object QCconversion;
extern int x_bitmap_mask (struct frame *, ptrdiff_t);
extern void syms_of_image (void);
-extern void init_image (void);
+extern void init_image (void) ATTRIBUTE_CONST;
/* Defined in insdel.c */
extern Lisp_Object Qinhibit_modification_hooks;
@@ -3119,7 +3123,7 @@ extern void init_all_sys_modes (void);
extern void reset_all_sys_modes (void);
extern void wait_for_termination (pid_t);
extern void interruptible_wait_for_termination (pid_t);
-extern void flush_pending_output (int);
+extern void flush_pending_output (int) ATTRIBUTE_CONST;
extern void child_setup_tty (int);
extern void setup_pty (int);
extern int set_window_size (int, int, int);
@@ -3141,7 +3145,7 @@ extern void init_filelock (void);
/* Defined in sound.c */
extern void syms_of_sound (void);
-extern void init_sound (void);
+extern void init_sound (void) ATTRIBUTE_CONST;
/* Defined in category.c */
extern void init_category_once (void);
diff --git a/src/mem-limits.h b/src/mem-limits.h
index 01b0e6ebb2b..dbe58dc9156 100644
--- a/src/mem-limits.h
+++ b/src/mem-limits.h
@@ -33,7 +33,7 @@ extern int etext;
# endif
#endif
-extern char *start_of_data (void);
+extern char *start_of_data (void) ATTRIBUTE_CONST;
#if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX
#define EXCEEDS_LISP_PTR(ptr) 0
#elif defined DATA_SEG_BITS
diff --git a/src/menu.h b/src/menu.h
index cb22a5255d6..3406928a8d5 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -26,7 +26,7 @@ extern void x_set_menu_bar_lines (struct frame *f,
Lisp_Object oldval);
extern void init_menu_items (void);
-extern void finish_menu_items (void);
+extern void finish_menu_items (void) ATTRIBUTE_CONST;
extern void discard_menu_items (void);
extern void save_menu_items (void);
extern int parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);