mark functions with const and pure attributes
authorJim Meyering <meyering@redhat.com>
Thu, 2 Jun 2011 08:05:59 +0000 (10:05 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 28 Nov 2011 08:27:17 +0000 (09:27 +0100)
Mark functions per suggestions from gcc-4.6 when using these options:
-Wsuggest-attribute=pure -Wsuggest-attribute=const.
Use gnulib's _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST macros.
Follow these guidelines: when possible, apply the attribute to
an extern declaration, not to its definition.  Apply it to the
definition only when the definition is static.
* lib/argmatch.h (argmatch, argmatch_to_argument): Mark.
* lib/argv-iter.h (argv_iter_n_args): Likewise.
* lib/base64.h (isbase64): Likewise.
* lib/basename-lgpl.c (last_component, base_len): Likewise.
* lib/c-ctype.h (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-strcase.h (c_strcasecmp, c_strncasecmp): Likewise.
* lib/chdir-long.c (find_non_slash): Likewise.
* lib/dirname.h (base_len, dir_len, last_component): Likewise.
* lib/exclude.h (fnmatch_pattern_has_wildcards): Likewise.
* lib/file-type.h (file_type): Likewise.
* lib/filenamecat-lgpl.c (longest_relative_suffix): Likewise.
* lib/filevercmp.c (verrevcmp): Likewise.
* lib/freadahead.h (freadahead): Likewise.
* lib/fts.c (fts_maxarglen): Likewise.
* lib/hash-pjw.h (hash_pjw): Likewise.
* lib/hash-triple.h (triple_hash_no_name, triple_compare_ino_str):
* lib/hash.c (is_prime, next_prime): Likewise.
* 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): Likewise.
(compute_bucket_size): Likewise.
* lib/i-ring.h (i_ring_empty): Likewise.
* lib/isnan.c (isnanl): Likewise.
* lib/math.h (isnanl, rpl_isnanl): Likewise.
* lib/memcasecmp.h (memcasecmp): Likewise.
* lib/memchr2.h (memchr2): Likewise.
* lib/memcmp2.h (memcmp2): Likewise.
* lib/parse-datetime.y (lookup_zone): Likewise.
* lib/sockets.h (gl_sockets_startup, gl_sockets_cleanup)
[!WINDOWS_SOCKETS]: Likewise.
* lib/strnlen1.h (strnlen1): Likewise.
* lib/uniwidth.in.h (uc_width): Likewise, but since this is installed
as a public header by libunistring, it cannot depend on the macro
definitions of gnulib-common.m4, so open-code the __attribute__...
* lib/quotearg.c: Add pragma to avoid unwarranted suggestion from
gcc's -Wsuggest-attribute=pure for quoting_options_from_style.
(quoting_options_from_style): Add a comment.
* lib/propername.h (proper_name): Add a comment.

30 files changed:
ChangeLog
lib/argmatch.h
lib/argv-iter.h
lib/base64.h
lib/c-ctype.h
lib/c-strcase.h
lib/chdir-long.c
lib/dirname.h
lib/exclude.h
lib/file-type.h
lib/filenamecat-lgpl.c
lib/filevercmp.c
lib/freadahead.h
lib/fts.c
lib/hash-pjw.h
lib/hash-triple.h
lib/hash.c
lib/hash.h
lib/i-ring.h
lib/isnan.c
lib/math.in.h
lib/memcasecmp.h
lib/memchr2.h
lib/memcmp2.h
lib/parse-datetime.y
lib/propername.h
lib/quotearg.c
lib/sockets.h
lib/strnlen1.h
lib/uniwidth.in.h

index cdc32a7..ba43f79 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,53 @@
+2011-11-27  Jim Meyering  <meyering@redhat.com>
+
+       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.
+       Use gnulib's _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST macros.
+       Follow these guidelines: when possible, apply the attribute to
+       an extern declaration, not to its definition.  Apply it to the
+       definition only when the definition is static.
+       * lib/argmatch.h (argmatch, argmatch_to_argument): Mark.
+       * lib/argv-iter.h (argv_iter_n_args): Likewise.
+       * lib/base64.h (isbase64): Likewise.
+       * lib/basename-lgpl.c (last_component, base_len): Likewise.
+       * lib/c-ctype.h (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-strcase.h (c_strcasecmp, c_strncasecmp): Likewise.
+       * lib/chdir-long.c (find_non_slash): Likewise.
+       * lib/dirname.h (base_len, dir_len, last_component): Likewise.
+       * lib/exclude.h (fnmatch_pattern_has_wildcards): Likewise.
+       * lib/file-type.h (file_type): Likewise.
+       * lib/filenamecat-lgpl.c (longest_relative_suffix): Likewise.
+       * lib/filevercmp.c (verrevcmp): Likewise.
+       * lib/freadahead.h (freadahead): Likewise.
+       * lib/fts.c (fts_maxarglen): Likewise.
+       * lib/hash-pjw.h (hash_pjw): Likewise.
+       * lib/hash-triple.h (triple_hash_no_name, triple_compare_ino_str):
+       * lib/hash.c (is_prime, next_prime): Likewise.
+       * 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): Likewise.
+       (compute_bucket_size): Likewise.
+       * lib/i-ring.h (i_ring_empty): Likewise.
+       * lib/isnan.c (isnanl): Likewise.
+       * lib/math.h (isnanl, rpl_isnanl): Likewise.
+       * lib/memcasecmp.h (memcasecmp): Likewise.
+       * lib/memchr2.h (memchr2): Likewise.
+       * lib/memcmp2.h (memcmp2): Likewise.
+       * lib/parse-datetime.y (lookup_zone): Likewise.
+       * lib/sockets.h (gl_sockets_startup, gl_sockets_cleanup)
+       [!WINDOWS_SOCKETS]: Likewise.
+       * lib/strnlen1.h (strnlen1): Likewise.
+       * lib/uniwidth.in.h (uc_width): Likewise.
+       * lib/quotearg.c: Add pragma to avoid unwarranted suggestion from
+       gcc's -Wsuggest-attribute=pure for quoting_options_from_style.
+       (quoting_options_from_style): Add a comment.
+       * lib/propername.h (proper_name): Add a comment.
+
 2011-11-27  Bruno Haible  <bruno@clisp.org>
 
        Remove unused macros from !_LIBC code in glibc-borrowed files.
index f87729d..b1a1193 100644 (file)
@@ -40,7 +40,7 @@
    to the same values in VALLIST).  */
 
 ptrdiff_t argmatch (char const *arg, char const *const *arglist,
-                    char const *vallist, size_t valsize);
+                    char const *vallist, size_t valsize) _GL_ATTRIBUTE_PURE;
 
 # define ARGMATCH(Arg, Arglist, Vallist) \
   argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
@@ -93,7 +93,8 @@ ptrdiff_t __xargmatch_internal (char const *context,
 
 char const *argmatch_to_argument (char const *value,
                                   char const *const *arglist,
-                                  char const *vallist, size_t valsize);
+                                  char const *vallist, size_t valsize)
+  _GL_ATTRIBUTE_PURE;
 
 # define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist)                  \
   argmatch_to_argument (Value, Arglist,                                 \
index 9f76f28..73db77d 100644 (file)
@@ -37,6 +37,6 @@ struct argv_iterator *argv_iter_init_stream (FILE *fp)
 char *argv_iter (struct argv_iterator *, enum argv_iter_err *)
   _GL_ARG_NONNULL ((1, 2));
 size_t argv_iter_n_args (struct argv_iterator const *)
-  _GL_ARG_NONNULL ((1));
+  _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1));
 void argv_iter_free (struct argv_iterator *)
   _GL_ARG_NONNULL ((1));
index 98f962f..1d65edc 100644 (file)
@@ -35,7 +35,7 @@ struct base64_decode_context
   char buf[4];
 };
 
-extern bool isbase64 (char ch);
+extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
 
 extern void base64_encode (const char *restrict in, size_t inlen,
                            char *restrict out, size_t outlen);
index ed8859e..078bd9a 100644 (file)
@@ -118,23 +118,23 @@ extern "C" {
          if (c_isalpha (*s)) ...
  */
 
-extern bool c_isascii (int c); /* not locale dependent */
-
-extern bool c_isalnum (int c);
-extern bool c_isalpha (int c);
-extern bool c_isblank (int c);
-extern bool c_iscntrl (int c);
-extern bool c_isdigit (int c);
-extern bool c_islower (int c);
-extern bool c_isgraph (int c);
-extern bool c_isprint (int c);
-extern bool c_ispunct (int c);
-extern bool c_isspace (int c);
-extern bool c_isupper (int c);
-extern bool c_isxdigit (int c);
-
-extern int c_tolower (int c);
-extern int c_toupper (int c);
+extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */
+
+extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_islower (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST;
+
+extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
+extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
 
 
 #if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
index 66a5492..df2f070 100644 (file)
@@ -40,12 +40,13 @@ extern "C" {
 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
    greater than zero if S1 is lexicographically less than, equal to or greater
    than S2.  */
-extern int c_strcasecmp (const char *s1, const char *s2);
+extern int c_strcasecmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE;
 
 /* Compare no more than N characters of strings S1 and S2, ignoring case,
    returning less than, equal to or greater than zero if S1 is
    lexicographically less than, equal to or greater than S2.  */
-extern int c_strncasecmp (const char *s1, const char *s2, size_t n);
+extern int c_strncasecmp (const char *s1, const char *s2, size_t n)
+  _GL_ATTRIBUTE_PURE;
 
 
 #ifdef __cplusplus
index 96b750c..af41b12 100644 (file)
@@ -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, "/");
index 2ef9882..ba9c56e 100644 (file)
@@ -37,9 +37,9 @@ char *dir_name (char const *file);
 # endif
 
 char *mdir_name (char const *file);
-size_t base_len (char const *file);
-size_t dir_len (char const *file);
-char *last_component (char const *file);
+size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
+size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
+char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
 
 bool strip_trailing_slashes (char *file);
 
index 0a314a9..63e94d3 100644 (file)
@@ -39,7 +39,7 @@
 
 struct exclude;
 
-bool fnmatch_pattern_has_wildcards (const char *, int);
+bool fnmatch_pattern_has_wildcards (const char *, int) _GL_ATTRIBUTE_PURE;
 
 struct exclude *new_exclude (void);
 void free_exclude (struct exclude *);
index 0d1b9a4..d7c66e9 100644 (file)
@@ -24,6 +24,6 @@
 # include <sys/types.h>
 # include <sys/stat.h>
 
-char const *file_type (struct stat const *);
+char const *file_type (struct stat const *) _GL_ATTRIBUTE_PURE;
 
 #endif /* FILE_TYPE_H */
index 8cb2da4..26d1c73 100644 (file)
@@ -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++)
index f6ed248..fd9e9f4 100644 (file)
@@ -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;
index af03b89..0ddb826 100644 (file)
@@ -31,7 +31,7 @@ extern "C" {
 
    STREAM must not be wide-character oriented.  */
 
-extern size_t freadahead (FILE *stream);
+extern size_t freadahead (FILE *stream) _GL_ATTRIBUTE_PURE;
 
 #ifdef __cplusplus
 }
index f61a91e..ccd1980 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1988,7 +1988,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;
index 80c1838..36b776a 100644 (file)
@@ -20,4 +20,4 @@
    and return the hash code modulo TABLESIZE.
    The result is platform dependent: it depends on the size of the 'size_t'
    type and on the signedness of the 'char' type.  */
-extern size_t hash_pjw (void const *x, size_t tablesize);
+extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE;
index 51863c9..0658d81 100644 (file)
@@ -13,10 +13,12 @@ struct F_triple
   dev_t st_dev;
 };
 
-extern size_t triple_hash (void const *x, size_t table_size);
-extern size_t triple_hash_no_name (void const *x, size_t table_size);
+extern size_t triple_hash (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE;
+extern size_t triple_hash_no_name (void const *x, size_t table_size)
+  _GL_ATTRIBUTE_PURE;
 extern bool triple_compare (void const *x, void const *y);
-extern bool triple_compare_ino_str (void const *x, void const *y);
+extern bool triple_compare_ino_str (void const *x, void const *y)
+  _GL_ATTRIBUTE_PURE;
 extern void triple_free (void *x);
 
 #endif
index 9f2d075..a0e6416 100644 (file)
@@ -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.  */
index 572032d..541abc4 100644 (file)
@@ -69,22 +69,22 @@ struct hash_table;
 typedef struct hash_table Hash_table;
 
 /* Information and lookup.  */
-size_t hash_get_n_buckets (const Hash_table *);
-size_t hash_get_n_buckets_used (const Hash_table *);
-size_t hash_get_n_entries (const Hash_table *);
-size_t hash_get_max_bucket_length (const Hash_table *);
-bool hash_table_ok (const Hash_table *);
+size_t hash_get_n_buckets (const Hash_table *) _GL_ATTRIBUTE_PURE;
+size_t hash_get_n_buckets_used (const Hash_table *) _GL_ATTRIBUTE_PURE;
+size_t hash_get_n_entries (const Hash_table *) _GL_ATTRIBUTE_PURE;
+size_t hash_get_max_bucket_length (const Hash_table *) _GL_ATTRIBUTE_PURE;
+bool hash_table_ok (const Hash_table *) _GL_ATTRIBUTE_PURE;
 void hash_print_statistics (const Hash_table *, FILE *);
 void *hash_lookup (const Hash_table *, const void *);
 
 /* Walking.  */
-void *hash_get_first (const Hash_table *);
+void *hash_get_first (const Hash_table *) _GL_ATTRIBUTE_PURE;
 void *hash_get_next (const Hash_table *, const void *);
 size_t hash_get_entries (const Hash_table *, void **, size_t);
 size_t hash_do_for_each (const Hash_table *, Hash_processor, void *);
 
 /* Allocation and clean-up.  */
-size_t hash_string (const char *, size_t);
+size_t hash_string (const char *, size_t) _GL_ATTRIBUTE_PURE;
 void hash_reset_tuning (Hash_tuning *);
 Hash_table *hash_initialize (size_t, const Hash_tuning *,
                              Hash_hasher, Hash_comparator,
index f0700b6..ae81f68 100644 (file)
@@ -41,4 +41,4 @@ typedef struct I_ring I_ring;
 void i_ring_init (I_ring *ir, int ir_default_val);
 int i_ring_push (I_ring *ir, int val);
 int i_ring_pop (I_ring *ir);
-bool i_ring_empty (I_ring const *ir);
+bool i_ring_empty (I_ring const *ir) _GL_ATTRIBUTE_PURE;
index 1d0754c..db0c685 100644 (file)
@@ -21,7 +21,7 @@
 /* Specification.  */
 #ifdef USE_LONG_DOUBLE
 /* Specification found in math.h or isnanl-nolibm.h.  */
-extern int rpl_isnanl (long double x);
+extern int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
 #elif ! defined USE_FLOAT
 /* Specification found in math.h or isnand-nolibm.h.  */
 extern int rpl_isnand (double x);
index eadb489..6b5966a 100644 (file)
@@ -1246,7 +1246,7 @@ _GL_EXTERN_C int isnand (double x);
 /* Test whether X is a NaN.  */
 #  undef isnanl
 #  define isnanl rpl_isnanl
-_GL_EXTERN_C int isnanl (long double x);
+_GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
 # endif
 #endif
 
@@ -1272,7 +1272,7 @@ _GL_EXTERN_C int rpl_isnand (double x);
 #  if @HAVE_ISNANL@ && __GNUC__ >= 4
 #   define gl_isnan_l(x) __builtin_isnanl ((long double)(x))
 #  else
-_GL_EXTERN_C int rpl_isnanl (long double x);
+_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
 #   define gl_isnan_l(x) rpl_isnanl (x)
 #  endif
 #  undef isnan
index d2e14ac..502b856 100644 (file)
@@ -19,4 +19,4 @@
 
 #include <stddef.h>
 
-int memcasecmp (const void *vs1, const void *vs2, size_t n);
+int memcasecmp (const void *vs1, const void *vs2, size_t n) _GL_ATTRIBUTE_PURE;
index e575223..c34acbd 100644 (file)
@@ -24,7 +24,8 @@ extern "C" {
    char) that occurs within N bytes of the memory region S.  If
    neither byte appears, return NULL.  */
 
-extern void *memchr2 (void const *s, int c1, int c2, size_t n);
+extern void *memchr2 (void const *s, int c1, int c2, size_t n)
+  _GL_ATTRIBUTE_PURE;
 
 #ifdef __cplusplus
 }
index cbe6e8c..21552b2 100644 (file)
@@ -29,7 +29,8 @@ extern "C" {
    This function's result is locale independent, unlike memcoll()'s.
    Return a negative number if S1 < S2, a positive number if S1 > S2, or
    0 if S1 and S2 have the same contents.  */
-extern int memcmp2 (const char *s1, size_t n1, const char *s2, size_t n2);
+extern int memcmp2 (const char *s1, size_t n1, const char *s2, size_t n2)
+  _GL_ATTRIBUTE_PURE;
 
 
 #ifdef __cplusplus
index d99c955..5621adc 100644 (file)
@@ -905,7 +905,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;
index d2a1e3b..a4eac01 100644 (file)
@@ -89,7 +89,7 @@ extern "C" {
 #endif
 
 /* Return the localization of NAME.  NAME is written in ASCII.  */
-extern const char * proper_name (const char *name);
+extern const char * proper_name (const char *name) /* NOT PURE */;
 
 /* Return the localization of a name whose original writing is not ASCII.
    NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal
index da8ba1e..3c15411 100644 (file)
 
 /* Written by Paul Eggert <eggert@twinsun.com> */
 
+/* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
+   the quoting_options_from_style function might be candidate for
+   attribute 'pure'  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+#endif
+
 #include <config.h>
 
 #include "quotearg.h"
@@ -165,7 +172,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 /* NOT PURE!! */
 quoting_options_from_style (enum quoting_style style)
 {
   struct quoting_options o = { 0 };
index 323f68c..68bf731 100644 (file)
 #define SOCKETS_2_1 0x201
 #define SOCKETS_2_2 0x202
 
-int gl_sockets_startup (int version);
-int gl_sockets_cleanup (void);
+int gl_sockets_startup (int version)
+#if !WINDOWS_SOCKETS
+  _GL_ATTRIBUTE_CONST
+#endif
+  ;
+
+int gl_sockets_cleanup (void)
+#if !WINDOWS_SOCKETS
+  _GL_ATTRIBUTE_CONST
+#endif
+  ;
 
 /* This function is useful it you create a socket using gnulib's
    Winsock wrappers but needs to pass on the socket handle to some
index 1bb13de..a0634fe 100644 (file)
@@ -28,7 +28,8 @@ extern "C" {
 /* 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.  */
-extern size_t strnlen1 (const char *string, size_t maxlen);
+extern size_t strnlen1 (const char *string, size_t maxlen)
+  _GL_ATTRIBUTE_PURE;
 
 
 #ifdef __cplusplus
index be99b97..e806744 100644 (file)
@@ -38,7 +38,11 @@ extern "C" {
 
 /* Determine number of column positions required for UC.  */
 extern int
-       uc_width (ucs4_t uc, const char *encoding);
+       uc_width (ucs4_t uc, const char *encoding)
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+       __attribute__ ((__pure__))
+#endif
+       ;
 
 /* Determine number of column positions required for first N units
    (or fewer if S ends before this) in S.  */