summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-01-08 17:15:27 -0700
committerEric Blake <ebb9@byu.net>2008-01-09 06:30:10 -0700
commitc01669e0970410a989f44883c4117b1a74b651e3 (patch)
treeb99019ab89d56d2e478f7c3c518256fdb78be8d9
parent9b863cbe091485e27568961d23bde16e0ff7dbdb (diff)
downloadgnulib-c01669e0970410a989f44883c4117b1a74b651e3.tar.gz
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>
-rw-r--r--ChangeLog9
-rw-r--r--lib/string.in.h32
-rw-r--r--modules/memmem2
3 files changed, 34 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index bd4daf8e22..975665dec8 100644
--- 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
diff --git a/lib/string.in.h b/lib/string.in.h
index 09205e7f0c..355479a717 100644
--- 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 @@ 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:
diff --git a/modules/memmem b/modules/memmem
index 2c02be9925..71f770f820 100644
--- a/modules/memmem
+++ b/modules/memmem
@@ -25,4 +25,4 @@ License:
LGPLv2+
Maintainer:
-libc, Simon Josefsson
+libc, Eric Blake