bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 1/2] mark functions with const and pure attributes


From: Jim Meyering
Subject: [PATCH 1/2] mark functions with const and pure attributes
Date: Sun, 01 May 2011 15:31:24 +0200

Here's a better pair of patches.

The first one makes gnulib-common.m4 emit definitions of these
two _GL_ATTRIBUTE_... macros.
The second addresses all of the warnings in gnulib code induced
by building coreutils with CFLAGS='-O3 -Wsuggest-attribute=const
-Wsuggest-attribute=pure -Wsuggest-attribute=noreturn'
The latter affects pretty many modules, so if there's no
feedback, I'll wait a couple of days before pushing.


>From 3c24b3858618c276bdf84f9bf242f70e896bf00b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 24 Apr 2011 19:00:18 +0200
Subject: [PATCH 1/2] gnulib-common.m4: add _GL_ATTRIBUTE_CONST and
 _GL_ATTRIBUTE_PURE

* m4/gnulib-common.m4 (gl_COMMON): Emit definitions of
_GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE.
---
 ChangeLog           |    6 ++++++
 m4/gnulib-common.m4 |   16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3240937..4c0140d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-29  Jim Meyering  <address@hidden>
+
+       gnulib-common.m4: add _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE
+       * m4/gnulib-common.m4 (gl_COMMON): Emit definitions of
+       _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE.
+
 2011-04-30  Eric Blake  <address@hidden>

        fclose: don't fail on non-seekable input stream
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index c4d7a20..8b73f1d 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 24
+# gnulib-common.m4 serial 25
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,6 +34,20 @@ AC_DEFUN([gl_COMMON_BODY], [
 /* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
    is a misnomer outside of parameter lists.  */
 #define _UNUSED_PARAMETER_ _GL_UNUSED
+
+/* The __pure__ attribute was added in gcc 2.96.  */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+#else
+# define _GL_ATTRIBUTE_PURE /* empty */
+#endif
+
+/* The __const__ attribute was added in gcc 2.95.  */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
+#else
+# define _GL_ATTRIBUTE_CONST /* empty */
+#endif
 ])
   dnl Preparation for running test programs:
   dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
--
1.7.5.134.g1c08b


>From aa286595163a6d72b9a2df319d109519814a368a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 30 Apr 2011 00:16:01 +0100
Subject: [PATCH 2/2] mark functions with const and pure attributes

Mark functions per suggestions from gcc-4.6 when using these options:
-Wsuggest-attribute=pure -Wsuggest-attribute=const
* lib/argmatch.c (argmatch, argmatch_to_argument): Mark.
* lib/argv-iter.c (argv_iter_n_args): Likewise.
* lib/base64.c (isbase64): Likewise.
* lib/basename-lgpl.c (last_component, base_len): Likewise.
* lib/c-ctype.c (c_isascii, c_isalnum, c_isalpha): Likewise.
(c_isblank, c_iscntrl, c_isdigit, c_islower, c_isgraph): Likewise.
(c_isprint, c_ispunct, c_isspace, c_isupper, c_isxdigit): Likewise.
(c_tolower, c_toupper): Likewise.
* lib/c-strcasecmp.c (c_strcasecmp): Likewise.
* lib/c-strncasecmp.c (c_strncasecmp): Likewise.
* lib/chdir-long.c (find_non_slash): Likewise.
* lib/exclude.c (fnmatch_pattern_has_wildcards): Likewise.
* lib/file-type.c (file_type): Likewise.
* lib/filenamecat-lgpl.c (longest_relative_suffix): Likewise.
* lib/filevercmp.c (verrevcmp): Likewise.
* lib/freadahead.c (freadahead): Likewise.
* lib/fts.c (fts_maxarglen): Likewise.
* lib/hash-pjw.c (hash_pjw): Likewise.
* lib/hash-triple.c (triple_hash_no_name, triple_compare_ino_str):
* lib/hash.c (hash_get_n_buckets, hash_get_n_buckets_used): Likewise.
(hash_get_n_entries, hash_get_max_bucket_length): Likewise.
(hash_table_ok, hash_get_first, hash_string, is_prime): Likewise.
(next_prime, compute_bucket_size): Likewise.
* lib/i-ring.c (i_ring_empty): Likewise.
* lib/isnan.c (FUNC): Likewise.
* lib/localename.c (string_hash, gl_locale_name_default): Likewise.
* lib/memcasecmp.c (memcasecmp): Likewise.
* lib/memchr2.c (memchr2): Likewise.
* lib/memcmp2.c (memcmp2): Likewise.
* lib/parse-datetime.y (lookup_zone): Likewise.
* lib/propername.c (proper_name): Likewise.
* lib/quotearg.c (get_quoting_style): Likewise.
(quoting_options_from_style): Likewise.
* lib/sockets.c (gl_sockets_startup, gl_sockets_cleanup): Likewise.
* lib/strnlen1.c (strnlen1): Likewise.
* lib/uniwidth/width.c (uc_width): Likewise.
---
 ChangeLog              |   42 ++++++++++++++++++++++++++++++++++++++++++
 lib/argmatch.c         |    4 ++--
 lib/argv-iter.c        |    2 +-
 lib/base64.c           |    2 +-
 lib/basename-lgpl.c    |    4 ++--
 lib/c-ctype.c          |   30 +++++++++++++++---------------
 lib/c-strcasecmp.c     |    2 +-
 lib/c-strncasecmp.c    |    2 +-
 lib/chdir-long.c       |    2 +-
 lib/exclude.c          |    2 +-
 lib/file-type.c        |    2 +-
 lib/filenamecat-lgpl.c |    2 +-
 lib/filevercmp.c       |    2 +-
 lib/freadahead.c       |    2 +-
 lib/fts.c              |    2 +-
 lib/hash-pjw.c         |    2 +-
 lib/hash-triple.c      |    4 ++--
 lib/hash.c             |   22 +++++++++++-----------
 lib/i-ring.c           |    2 +-
 lib/isnan.c            |    2 +-
 lib/localename.c       |    4 ++--
 lib/memcasecmp.c       |    2 +-
 lib/memchr2.c          |    2 +-
 lib/memcmp2.c          |    2 +-
 lib/parse-datetime.y   |    2 +-
 lib/propername.c       |    2 +-
 lib/quotearg.c         |    4 ++--
 lib/sockets.c          |    4 ++--
 lib/strnlen1.c         |    2 +-
 lib/uniwidth/width.c   |    2 +-
 30 files changed, 101 insertions(+), 59 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4c0140d..03b89cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,45 @@
+2011-04-30  Jim Meyering  <address@hidden>
+
+       mark functions with const and pure attributes
+       Mark functions per suggestions from gcc-4.6 when using these options:
+       -Wsuggest-attribute=pure -Wsuggest-attribute=const
+       * lib/argmatch.c (argmatch, argmatch_to_argument): Mark.
+       * lib/argv-iter.c (argv_iter_n_args): Likewise.
+       * lib/base64.c (isbase64): Likewise.
+       * lib/basename-lgpl.c (last_component, base_len): Likewise.
+       * lib/c-ctype.c (c_isascii, c_isalnum, c_isalpha): Likewise.
+       (c_isblank, c_iscntrl, c_isdigit, c_islower, c_isgraph): Likewise.
+       (c_isprint, c_ispunct, c_isspace, c_isupper, c_isxdigit): Likewise.
+       (c_tolower, c_toupper): Likewise.
+       * lib/c-strcasecmp.c (c_strcasecmp): Likewise.
+       * lib/c-strncasecmp.c (c_strncasecmp): Likewise.
+       * lib/chdir-long.c (find_non_slash): Likewise.
+       * lib/exclude.c (fnmatch_pattern_has_wildcards): Likewise.
+       * lib/file-type.c (file_type): Likewise.
+       * lib/filenamecat-lgpl.c (longest_relative_suffix): Likewise.
+       * lib/filevercmp.c (verrevcmp): Likewise.
+       * lib/freadahead.c (freadahead): Likewise.
+       * lib/fts.c (fts_maxarglen): Likewise.
+       * lib/hash-pjw.c (hash_pjw): Likewise.
+       * lib/hash-triple.c (triple_hash_no_name, triple_compare_ino_str):
+       * lib/hash.c (hash_get_n_buckets, hash_get_n_buckets_used): Likewise.
+       (hash_get_n_entries, hash_get_max_bucket_length): Likewise.
+       (hash_table_ok, hash_get_first, hash_string, is_prime): Likewise.
+       (next_prime, compute_bucket_size): Likewise.
+       * lib/i-ring.c (i_ring_empty): Likewise.
+       * lib/isnan.c (FUNC): Likewise.
+       * lib/localename.c (string_hash, gl_locale_name_default): Likewise.
+       * lib/memcasecmp.c (memcasecmp): Likewise.
+       * lib/memchr2.c (memchr2): Likewise.
+       * lib/memcmp2.c (memcmp2): Likewise.
+       * lib/parse-datetime.y (lookup_zone): Likewise.
+       * lib/propername.c (proper_name): Likewise.
+       * lib/quotearg.c (get_quoting_style): Likewise.
+       (quoting_options_from_style): Likewise.
+       * lib/sockets.c (gl_sockets_startup, gl_sockets_cleanup): Likewise.
+       * lib/strnlen1.c (strnlen1): Likewise.
+       * lib/uniwidth/width.c (uc_width): Likewise.
+
 2011-04-29  Jim Meyering  <address@hidden>

        gnulib-common.m4: add _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE
diff --git a/lib/argmatch.c b/lib/argmatch.c
index 9a3eca4..95fa469 100644
--- a/lib/argmatch.c
+++ b/lib/argmatch.c
@@ -79,7 +79,7 @@ argmatch_exit_fn argmatch_die = __argmatch_die;
      "no", "nope" -> 1
    "y" is a valid argument, for `0', and "n" for `1'.  */

-ptrdiff_t
+ptrdiff_t _GL_ATTRIBUTE_PURE
 argmatch (const char *arg, const char *const *arglist,
           const char *vallist, size_t valsize)
 {
@@ -192,7 +192,7 @@ __xargmatch_internal (const char *context,

 /* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
    return the first corresponding argument in ARGLIST */
-const char *
+const char * _GL_ATTRIBUTE_PURE
 argmatch_to_argument (const char *value,
                       const char *const *arglist,
                       const char *vallist, size_t valsize)
diff --git a/lib/argv-iter.c b/lib/argv-iter.c
index 340e588..d829d36 100644
--- a/lib/argv-iter.c
+++ b/lib/argv-iter.c
@@ -96,7 +96,7 @@ argv_iter (struct argv_iterator *ai, enum argv_iter_err *err)
     }
 }

-size_t
+size_t _GL_ATTRIBUTE_PURE
 argv_iter_n_args (struct argv_iterator const *ai)
 {
   return ai->fp ? ai->item_idx : ai->p - ai->arg_list;
diff --git a/lib/base64.c b/lib/base64.c
index 99fcc57..7dafb43 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -295,7 +295,7 @@ static const signed char b64[0x100] = {
 /* Return true if CH is a character from the Base64 alphabet, and
    false otherwise.  Note that '=' is padding and not considered to be
    part of the alphabet.  */
-bool
+bool _GL_ATTRIBUTE_CONST
 isbase64 (char ch)
 {
   return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
diff --git a/lib/basename-lgpl.c b/lib/basename-lgpl.c
index 529bc35..555ed6e 100644
--- a/lib/basename-lgpl.c
+++ b/lib/basename-lgpl.c
@@ -26,7 +26,7 @@
    NAME has no relative file name components because it is a file
    system root, return the empty string.  */

-char *
+char * _GL_ATTRIBUTE_PURE
 last_component (char const *name)
 {
   char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
@@ -54,7 +54,7 @@ last_component (char const *name)
    value returned by base_name or last_component.  Act like strlen
    (NAME), except omit all trailing slashes.  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 base_len (char const *name)
 {
   size_t len;
diff --git a/lib/c-ctype.c b/lib/c-ctype.c
index 335cde5..993de8d 100644
--- a/lib/c-ctype.c
+++ b/lib/c-ctype.c
@@ -24,13 +24,13 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
02110-1301, USA.  */

 /* The function isascii is not locale dependent. Its use in EBCDIC is
    questionable. */
-bool
+bool _GL_ATTRIBUTE_CONST
 c_isascii (int c)
 {
   return (c >= 0x00 && c <= 0x7f);
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isalnum (int c)
 {
 #if C_CTYPE_CONSECUTIVE_DIGITS \
@@ -65,7 +65,7 @@ c_isalnum (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isalpha (int c)
 {
 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
@@ -94,13 +94,13 @@ c_isalpha (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isblank (int c)
 {
   return (c == ' ' || c == '\t');
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_iscntrl (int c)
 {
 #if C_CTYPE_ASCII
@@ -134,7 +134,7 @@ c_iscntrl (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isdigit (int c)
 {
 #if C_CTYPE_CONSECUTIVE_DIGITS
@@ -151,7 +151,7 @@ c_isdigit (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_islower (int c)
 {
 #if C_CTYPE_CONSECUTIVE_LOWERCASE
@@ -171,7 +171,7 @@ c_islower (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isgraph (int c)
 {
 #if C_CTYPE_ASCII
@@ -205,7 +205,7 @@ c_isgraph (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isprint (int c)
 {
 #if C_CTYPE_ASCII
@@ -239,7 +239,7 @@ c_isprint (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_ispunct (int c)
 {
 #if C_CTYPE_ASCII
@@ -263,14 +263,14 @@ c_ispunct (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isspace (int c)
 {
   return (c == ' ' || c == '\t'
           || c == '\n' || c == '\v' || c == '\f' || c == '\r');
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isupper (int c)
 {
 #if C_CTYPE_CONSECUTIVE_UPPERCASE
@@ -290,7 +290,7 @@ c_isupper (int c)
 #endif
 }

-bool
+bool _GL_ATTRIBUTE_CONST
 c_isxdigit (int c)
 {
 #if C_CTYPE_CONSECUTIVE_DIGITS \
@@ -317,7 +317,7 @@ c_isxdigit (int c)
 #endif
 }

-int
+int _GL_ATTRIBUTE_CONST
 c_tolower (int c)
 {
 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
@@ -356,7 +356,7 @@ c_tolower (int c)
 #endif
 }

-int
+int _GL_ATTRIBUTE_CONST
 c_toupper (int c)
 {
 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index f5e5e48..8bf8217 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -24,7 +24,7 @@

 #include "c-ctype.h"

-int
+int _GL_ATTRIBUTE_PURE
 c_strcasecmp (const char *s1, const char *s2)
 {
   register const unsigned char *p1 = (const unsigned char *) s1;
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index 0085185..fac021a 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -24,7 +24,7 @@

 #include "c-ctype.h"

-int
+int _GL_ATTRIBUTE_PURE
 c_strncasecmp (const char *s1, const char *s2, size_t n)
 {
   register const unsigned char *p1 = (const unsigned char *) s1;
diff --git a/lib/chdir-long.c b/lib/chdir-long.c
index 96b750c..af41b12 100644
--- a/lib/chdir-long.c
+++ b/lib/chdir-long.c
@@ -83,7 +83,7 @@ cdb_advance_fd (struct cd_buf *cdb, char const *dir)
 }

 /* Return a pointer to the first non-slash in S.  */
-static inline char *
+static inline char * _GL_ATTRIBUTE_PURE
 find_non_slash (char const *s)
 {
   size_t n_slash = strspn (s, "/");
diff --git a/lib/exclude.c b/lib/exclude.c
index df49714..932c8f8 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -111,7 +111,7 @@ struct exclude
   };

 /* Return true if str has wildcard characters */
-bool
+bool _GL_ATTRIBUTE_PURE
 fnmatch_pattern_has_wildcards (const char *str, int options)
 {
   const char *cset = "\\?*[]";
diff --git a/lib/file-type.c b/lib/file-type.c
index 109db44..b1c770d 100644
--- a/lib/file-type.c
+++ b/lib/file-type.c
@@ -25,7 +25,7 @@
 #include <gettext.h>
 #define _(text) gettext (text)

-char const *
+char const * _GL_ATTRIBUTE_PURE
 file_type (struct stat const *st)
 {
   /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of
diff --git a/lib/filenamecat-lgpl.c b/lib/filenamecat-lgpl.c
index 8cb2da4..26d1c73 100644
--- a/lib/filenamecat-lgpl.c
+++ b/lib/filenamecat-lgpl.c
@@ -34,7 +34,7 @@
 /* Return the longest suffix of F that is a relative file name.
    If it has no such suffix, return the empty string.  */

-static char const *
+static char const * _GL_ATTRIBUTE_PURE
 longest_relative_suffix (char const *f)
 {
   for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++)
diff --git a/lib/filevercmp.c b/lib/filevercmp.c
index f6ed248..fd9e9f4 100644
--- a/lib/filevercmp.c
+++ b/lib/filevercmp.c
@@ -80,7 +80,7 @@ order (unsigned char c)
    section on the `Version' control field.  This version of the code
    implements that from s5.6.12 of Debian Policy v3.8.0.1
    http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version */
-static int
+static int _GL_ATTRIBUTE_PURE
 verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len)
 {
   size_t s1_pos = 0;
diff --git a/lib/freadahead.c b/lib/freadahead.c
index 27f5c95..6b7c702 100644
--- a/lib/freadahead.c
+++ b/lib/freadahead.c
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include "stdio-impl.h"

-size_t
+size_t _GL_ATTRIBUTE_PURE
 freadahead (FILE *fp)
 {
 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, 
Linux libc5 */
diff --git a/lib/fts.c b/lib/fts.c
index ad762dd..8d3277d 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1906,7 +1906,7 @@ fts_padjust (FTS *sp, FTSENT *head)
 }

 static size_t
-internal_function
+internal_function _GL_ATTRIBUTE_PURE
 fts_maxarglen (char * const *argv)
 {
         size_t len, max;
diff --git a/lib/hash-pjw.c b/lib/hash-pjw.c
index 743bb57..8997a10 100644
--- a/lib/hash-pjw.c
+++ b/lib/hash-pjw.c
@@ -27,7 +27,7 @@
    the method described by Bruno Haible.
    See http://www.haible.de/bruno/hashfunc.html.  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_pjw (const void *x, size_t tablesize)
 {
   const char *s;
diff --git a/lib/hash-triple.c b/lib/hash-triple.c
index 1649377..e2a0400 100644
--- a/lib/hash-triple.c
+++ b/lib/hash-triple.c
@@ -41,7 +41,7 @@ triple_hash (void const *x, size_t table_size)
 }

 /* Hash an F_triple, without considering the file name.  */
-size_t
+size_t _GL_ATTRIBUTE_PURE
 triple_hash_no_name (void const *x, size_t table_size)
 {
   struct F_triple const *p = x;
@@ -59,7 +59,7 @@ triple_compare (void const *x, void const *y)
   return (SAME_INODE (*a, *b) && same_name (a->name, b->name)) ? true : false;
 }

-bool
+bool _GL_ATTRIBUTE_PURE
 triple_compare_ino_str (void const *x, void const *y)
 {
   struct F_triple const *a = x;
diff --git a/lib/hash.c b/lib/hash.c
index 4d76f76..7b7e2af 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -146,7 +146,7 @@ static const Hash_tuning default_tuning =
    number of buckets (used plus unused), or the maximum number of slots, are
    the same quantity.  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_get_n_buckets (const Hash_table *table)
 {
   return table->n_buckets;
@@ -154,7 +154,7 @@ hash_get_n_buckets (const Hash_table *table)

 /* Return the number of slots in use (non-empty buckets).  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_get_n_buckets_used (const Hash_table *table)
 {
   return table->n_buckets_used;
@@ -162,7 +162,7 @@ hash_get_n_buckets_used (const Hash_table *table)

 /* Return the number of active entries.  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_get_n_entries (const Hash_table *table)
 {
   return table->n_entries;
@@ -170,7 +170,7 @@ hash_get_n_entries (const Hash_table *table)

 /* Return the length of the longest chain (bucket).  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_get_max_bucket_length (const Hash_table *table)
 {
   struct hash_entry const *bucket;
@@ -197,7 +197,7 @@ hash_get_max_bucket_length (const Hash_table *table)
 /* Do a mild validation of a hash table, by traversing it and checking two
    statistics.  */

-bool
+bool _GL_ATTRIBUTE_PURE
 hash_table_ok (const Hash_table *table)
 {
   struct hash_entry const *bucket;
@@ -284,7 +284,7 @@ hash_lookup (const Hash_table *table, const void *entry)

 /* Return the first data in the table, or NULL if the table is empty.  */

-void *
+void * _GL_ATTRIBUTE_PURE
 hash_get_first (const Hash_table *table)
 {
   struct hash_entry const *bucket;
@@ -401,7 +401,7 @@ hash_do_for_each (const Hash_table *table, Hash_processor 
processor,
    algorithms tend to be domain-specific, so what's good for [diffutils'] io.c
    may not be good for your application."  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_string (const char *string, size_t n_buckets)
 {
 # define HASH_ONE_CHAR(Value, Byte) \
@@ -424,7 +424,7 @@ hash_string (const char *string, size_t n_buckets)
    very old Cyber `snoop', itself written in typical Greg Mansfield style.
    (By the way, what happened to this excellent man?  Is he still alive?)  */

-size_t
+size_t _GL_ATTRIBUTE_PURE
 hash_string (const char *string, size_t n_buckets)
 {
   size_t value = 0;
@@ -440,7 +440,7 @@ hash_string (const char *string, size_t n_buckets)
 /* Return true if CANDIDATE is a prime number.  CANDIDATE should be an odd
    number at least equal to 11.  */

-static bool
+static bool _GL_ATTRIBUTE_CONST
 is_prime (size_t candidate)
 {
   size_t divisor = 3;
@@ -459,7 +459,7 @@ is_prime (size_t candidate)
 /* Round a given CANDIDATE number up to the nearest prime, and return that
    prime.  Primes lower than 10 are merely skipped.  */

-static size_t
+static size_t _GL_ATTRIBUTE_CONST
 next_prime (size_t candidate)
 {
   /* Skip small primes.  */
@@ -540,7 +540,7 @@ check_tuning (Hash_table *table)
    TUNING, or return 0 if there is no possible way to allocate that
    many entries.  */

-static size_t
+static size_t _GL_ATTRIBUTE_PURE
 compute_bucket_size (size_t candidate, const Hash_tuning *tuning)
 {
   if (!tuning->is_n_buckets)
diff --git a/lib/i-ring.c b/lib/i-ring.c
index b603b0b..f8eca70 100644
--- a/lib/i-ring.c
+++ b/lib/i-ring.c
@@ -33,7 +33,7 @@ i_ring_init (I_ring *ir, int default_val)
   ir->ir_default_val = default_val;
 }

-bool
+bool _GL_ATTRIBUTE_PURE
 i_ring_empty (I_ring const *ir)
 {
   return ir->ir_empty;
diff --git a/lib/isnan.c b/lib/isnan.c
index d9c653d..1d810d6 100644
--- a/lib/isnan.c
+++ b/lib/isnan.c
@@ -79,7 +79,7 @@ extern int rpl_isnanf (float x);
   ((sizeof (DOUBLE) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
 typedef union { DOUBLE value; unsigned int word[NWORDS]; } memory_double;

-int
+int _GL_ATTRIBUTE_CONST
 FUNC (DOUBLE x)
 {
 #ifdef KNOWN_EXPBIT0_LOCATION
diff --git a/lib/localename.c b/lib/localename.c
index 3ab8822..829ed34 100644
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -2517,7 +2517,7 @@ gl_locale_name_from_win32_LCID (LCID lcid)
 /* A hash function for NUL-terminated char* strings using
    the method described by Bruno Haible.
    See http://www.haible.de/bruno/hashfunc.html.  */
-static size_t
+static size_t _GL_ATTRIBUTE_PURE
 string_hash (const void *x)
 {
   const char *s = (const char *) x;
@@ -2837,7 +2837,7 @@ gl_locale_name_environ (int category, const char 
*categoryname)
   return NULL;
 }

-const char *
+const char * _GL_ATTRIBUTE_CONST
 gl_locale_name_default (void)
 {
   /* POSIX:2001 says:
diff --git a/lib/memcasecmp.c b/lib/memcasecmp.c
index 6ae7c4f..4cc6d8e 100644
--- a/lib/memcasecmp.c
+++ b/lib/memcasecmp.c
@@ -28,7 +28,7 @@
    Convert to upper case (not lower) before comparing so that
    join -i works with sort -f.  */

-int
+int _GL_ATTRIBUTE_PURE
 memcasecmp (const void *vs1, const void *vs2, size_t n)
 {
   size_t i;
diff --git a/lib/memchr2.c b/lib/memchr2.c
index 2e3c7cd..faadb04 100644
--- a/lib/memchr2.c
+++ b/lib/memchr2.c
@@ -32,7 +32,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.  */
 /* Return the first address of either C1 or C2 (treated as unsigned
    char) that occurs within N bytes of the memory region S.  If
    neither byte appears, return NULL.  */
-void *
+void * _GL_ATTRIBUTE_PURE
 memchr2 (void const *s, int c1_in, int c2_in, size_t n)
 {
   /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
diff --git a/lib/memcmp2.c b/lib/memcmp2.c
index 14ab666..f9519f6 100644
--- a/lib/memcmp2.c
+++ b/lib/memcmp2.c
@@ -21,7 +21,7 @@

 #include <string.h>

-int
+int _GL_ATTRIBUTE_PURE
 memcmp2 (const char *s1, size_t n1, const char *s2, size_t n2)
 {
   int cmp = memcmp (s1, s2, n1 <= n2 ? n1 : n2);
diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
index d77955f..51abe6f 100644
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -868,7 +868,7 @@ to_year (textint textyear)
   return year;
 }

-static table const *
+static table const * _GL_ATTRIBUTE_PURE
 lookup_zone (parser_control const *pc, char const *name)
 {
   table const *tp;
diff --git a/lib/propername.c b/lib/propername.c
index b74923d..4265ac8 100644
--- a/lib/propername.c
+++ b/lib/propername.c
@@ -148,7 +148,7 @@ mbsstr_trimmed_wordbounded (const char *string, const char 
*sub)

 /* Return the localization of NAME.  NAME is written in ASCII.  */

-const char *
+const char * _GL_ATTRIBUTE_CONST
 proper_name (const char *name)
 {
   /* See whether there is a translation.   */
diff --git a/lib/quotearg.c b/lib/quotearg.c
index da8ba1e..fc2edc2 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -105,7 +105,7 @@ clone_quoting_options (struct quoting_options *o)
 }

 /* Get the value of O's quoting style.  If O is null, use the default.  */
-enum quoting_style
+enum quoting_style _GL_ATTRIBUTE_PURE
 get_quoting_style (struct quoting_options *o)
 {
   return (o ? o : &default_quoting_options)->style;
@@ -165,7 +165,7 @@ set_custom_quoting (struct quoting_options *o,
 }

 /* Return quoting options for STYLE, with no extra quoting.  */
-static struct quoting_options
+static struct quoting_options _GL_ATTRIBUTE_PURE
 quoting_options_from_style (enum quoting_style style)
 {
   struct quoting_options o = { 0 };
diff --git a/lib/sockets.c b/lib/sockets.c
index 42b8f9e..0b7fe10 100644
--- a/lib/sockets.c
+++ b/lib/sockets.c
@@ -103,7 +103,7 @@ static int initialized_sockets_version /* = 0 */;

 #endif /* WINDOWS_SOCKETS */

-int
+int _GL_ATTRIBUTE_CONST
 gl_sockets_startup (int version _GL_UNUSED)
 {
 #if WINDOWS_SOCKETS
@@ -130,7 +130,7 @@ gl_sockets_startup (int version _GL_UNUSED)
   return 0;
 }

-int
+int _GL_ATTRIBUTE_CONST
 gl_sockets_cleanup (void)
 {
 #if WINDOWS_SOCKETS
diff --git a/lib/strnlen1.c b/lib/strnlen1.c
index f64ce10..84f5cea 100644
--- a/lib/strnlen1.c
+++ b/lib/strnlen1.c
@@ -24,7 +24,7 @@
 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
    If no '\0' terminator is found in that many characters, return MAXLEN.  */
 /* This is the same as strnlen (string, maxlen - 1) + 1.  */
-size_t
+size_t _GL_ATTRIBUTE_PURE
 strnlen1 (const char *string, size_t maxlen)
 {
   const char *end = (const char *) memchr (string, '\0', maxlen);
diff --git a/lib/uniwidth/width.c b/lib/uniwidth/width.c
index a314e71..8a88ce7 100644
--- a/lib/uniwidth/width.c
+++ b/lib/uniwidth/width.c
@@ -311,7 +311,7 @@ static const signed char nonspacing_table_ind[240] = {
 };

 /* Determine number of column positions required for UC.  */
-int
+int _GL_ATTRIBUTE_PURE
 uc_width (ucs4_t uc, const char *encoding)
 {
   /* Test for non-spacing or control character.  */
--
1.7.5.134.g1c08b



reply via email to

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