Commit 5994c183 authored by Paul Eggert's avatar Paul Eggert

Add GCC-style 'const' attribute to functions that can use it.

parent 26bccfae
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.
......
......@@ -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
......
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.
......
......@@ -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
......
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.
......
......@@ -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
......
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.
......
......@@ -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 *);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment