changeset 9590:246fc6fd3787

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. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Tue, 08 Jan 2008 17:15:27 -0700
parents 2f578a20fda7
children 83fd101f67f0
files ChangeLog lib/string.in.h modules/memmem
diffstat 3 files changed, 34 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -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
@@ -25,6 +25,18 @@
 #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 @@
 # 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 @@
 /* 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 @@
 /* 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 @@
    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 @@
 /* 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 @@
 /* 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:
--- a/modules/memmem
+++ b/modules/memmem
@@ -25,4 +25,4 @@
 LGPLv2+
 
 Maintainer:
-libc, Simon Josefsson
+libc, Eric Blake