Give gcc some memmem optimization hints.
authorEric Blake <ebb9@byu.net>
Wed, 9 Jan 2008 00:15:27 +0000 (17:15 -0700)
committerEric Blake <ebb9@byu.net>
Wed, 9 Jan 2008 13:30:10 +0000 (06:30 -0700)
* lib/string.in.h (memmem, memrchr, strchrnul, strnlen, strpbrk)
(strcasestr): Declare as pure.
* modules/memmem (Maintainer): Claim my implementation.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/string.in.h
modules/memmem

index bd4daf8..975665d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-09  Eric Blake  <ebb9@byu.net>
+
+       Give gcc some memmem optimization hints.
+       * lib/string.in.h (memmem, memrchr, strchrnul, strnlen, strpbrk)
+       (strcasestr): Declare as pure.
+       * modules/memmem (Maintainer): Claim my implementation.
+
 2008-01-09  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Support AIX 6.1 and higher.
@@ -91,7 +98,7 @@
        Suggested by Paul Eggert.
 
 2008-01-01  Sylvain Beucler  <beuc@gnu.org>
-            Bruno Haible  <bruno@clisp.org>
+           Bruno Haible  <bruno@clisp.org>
 
        Improve memory cleanup in 'relocatable' module.
        * lib/relocatable.h (compute_curr_prefix): Change return type to
index 09205e7..355479a 100644 (file)
@@ -1,6 +1,6 @@
 /* A GNU-like <string.h>.
 
-   Copyright (C) 1995-1996, 2001-2007 Free Software Foundation, Inc.
+   Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #define _GL_STRING_H
 
 
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+#  define __attribute__(Spec) /* empty */
+# endif
+/* The attribute __pure__ was added in gcc 2.96.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#  define __pure__ /* empty */
+# endif
+#endif
+
+
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
@@ -40,7 +52,8 @@ extern "C" {
 # endif
 # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
 extern void *memmem (void const *__haystack, size_t __haystack_len,
-                    void const *__needle, size_t __needle_len);
+                    void const *__needle, size_t __needle_len)
+  __attribute__ ((__pure__));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef memmem
@@ -68,7 +81,8 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src,
 /* Search backwards through a block for a byte (specified as an int).  */
 #if @GNULIB_MEMRCHR@
 # if ! @HAVE_DECL_MEMRCHR@
-extern void *memrchr (void const *, int, size_t);
+extern void *memrchr (void const *, int, size_t)
+  __attribute__ ((__pure__));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef memrchr
@@ -121,7 +135,8 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
 /* Find the first occurrence of C in S or the final NUL byte.  */
 #if @GNULIB_STRCHRNUL@
 # if ! @HAVE_STRCHRNUL@
-extern char *strchrnul (char const *__s, int __c_in);
+extern char *strchrnul (char const *__s, int __c_in)
+  __attribute__ ((__pure__));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strchrnul
@@ -166,7 +181,8 @@ extern char *strndup (char const *__string, size_t __n);
    return MAXLEN.  */
 #if @GNULIB_STRNLEN@
 # if ! @HAVE_DECL_STRNLEN@
-extern size_t strnlen (char const *__string, size_t __maxlen);
+extern size_t strnlen (char const *__string, size_t __maxlen)
+  __attribute__ ((__pure__));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strnlen
@@ -192,7 +208,8 @@ extern size_t strnlen (char const *__string, size_t __maxlen);
 /* Find the first occurrence in S of any character in ACCEPT.  */
 #if @GNULIB_STRPBRK@
 # if ! @HAVE_STRPBRK@
-extern char *strpbrk (char const *__s, char const *__accept);
+extern char *strpbrk (char const *__s, char const *__accept)
+  __attribute__ ((__pure__));
 # endif
 # if defined GNULIB_POSIXCHECK
 /* strpbrk() assumes the second argument is a list of single-byte characters.
@@ -288,7 +305,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
    comparison.  */
 #if ! @HAVE_STRCASESTR@
-extern char *strcasestr (const char *haystack, const char *needle);
+extern char *strcasestr (const char *haystack, const char *needle)
+  __attribute__ ((__pure__));
 #endif
 #if defined GNULIB_POSIXCHECK
 /* strcasestr() does not work with multibyte strings:
index 2c02be9..71f770f 100644 (file)
@@ -25,4 +25,4 @@ License:
 LGPLv2+
 
 Maintainer:
-libc, Simon Josefsson
+libc, Eric Blake