aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog28
-rw-r--r--benchtests/Makefile2
-rw-r--r--benchtests/bench-bcopy.c20
-rw-r--r--benchtests/bench-bzero.c19
-rw-r--r--benchtests/bench-memccpy.c25
-rw-r--r--benchtests/bench-memcpy.c15
-rw-r--r--benchtests/bench-memmove.c26
-rw-r--r--benchtests/bench-mempcpy.c14
-rw-r--r--benchtests/bench-memset.c60
-rw-r--r--benchtests/bench-rawmemchr.c17
-rw-r--r--benchtests/bench-strcasecmp.c20
-rw-r--r--benchtests/bench-strcasestr.c25
-rw-r--r--benchtests/bench-strchr.c14
-rw-r--r--benchtests/bench-strcmp.c35
-rw-r--r--benchtests/bench-strcspn.c17
-rw-r--r--benchtests/bench-strlen.c9
-rw-r--r--benchtests/bench-strncasecmp.c23
-rw-r--r--benchtests/bench-strncmp.c34
-rw-r--r--benchtests/bench-strpbrk.c16
-rw-r--r--benchtests/bench-strspn.c21
20 files changed, 56 insertions, 384 deletions
diff --git a/ChangeLog b/ChangeLog
index 77b4587..56f3007 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2019-02-12 Wilco Dijkstra <wdijkstr@arm.com>
+
+ * benchtests/bench-strcasecmp.c (stupid_strcasecmp): Remove.
+ * benchtests/bench-strcasestr.c (stupid_strcasestr): Remove.
+ * benchtests/bench-strchr.c (stupid_strchr): Remove.
+ * benchtests/bench-strcmp.c (stupid_strcmp): Remove.
+ * benchtests/bench-strcspn.c (stupid_strcspn): Remove.
+ * benchtests/bench-strlen.c (builtin_strlen): Remove.
+ * benchtests/bench-strncasecmp.c (stupid_strncasecmp): Remove.
+ * benchtests/bench-strncmp.c (stupid_strncmp): Remove.
+ * benchtests/bench-strpbrk.c (stupid_strpbrk): Remove.
+ * benchtests/bench-strspn.c (stupid_strspn): Remove.
+ * benchtests/Makefile: Remove bench-bcopy.c and bench-bzero.c.
+ * benchtests/bench-bcopy.c: Delete file.
+ * benchtests/bench-bzero.c: Likewise.
+ * benchtests/bench-memccpy.c (stupid_memccpy): Remove.
+ (simple_memccpy): Remove.
+ (generic_memccpy): Add function.
+ * benchtests/bench-memcpy.c: (builtin_memcpy): Remove.
+ * benchtests/bench-memmove.c (simple_bcopy): Remove.
+ * benchtests/bench-mempcpy.c (simple_mempcpy): Remove.
+ (generic_mempcpy): Add new function.
+ * benchtests/bench-memset.c (simple_bzero): Remove.
+ (builtin_bzero): Remove.
+ (builtin_memset): Remove.
+ * benchtests/bench-rawmemchr.c (simple_rawmemchr): Remove.
+ (generic_rawmemchr): Add new function.
+
2019-02-12 Florian Weimer <fweimer@redhat.com>
* nss/getent.c (ahosts_keys_int): Include IPv6 scope ID in output.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index e190775..3339f2c 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -37,7 +37,7 @@ bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
endif
# String function benchmarks.
-string-benchset := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
+string-benchset := memccpy memchr memcmp memcpy memmem memmove \
mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
strcat strchr strchrnul strcmp strcpy strcspn strlen \
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
diff --git a/benchtests/bench-bcopy.c b/benchtests/bench-bcopy.c
deleted file mode 100644
index f8f33cb..0000000
--- a/benchtests/bench-bcopy.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Measure bcopy functions.
- Copyright (C) 2013-2019 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#define TEST_BCOPY
-#include "bench-memmove.c"
diff --git a/benchtests/bench-bzero.c b/benchtests/bench-bzero.c
deleted file mode 100644
index 36f884a..0000000
--- a/benchtests/bench-bzero.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Measure bzero functions.
- Copyright (C) 2013-2019 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-#define TEST_BZERO
-#include "bench-memset.c"
diff --git a/benchtests/bench-memccpy.c b/benchtests/bench-memccpy.c
index 6dca16b..d3a2df5 100644
--- a/benchtests/bench-memccpy.c
+++ b/benchtests/bench-memccpy.c
@@ -20,28 +20,8 @@
#define TEST_NAME "memccpy"
#include "bench-string.h"
-void *simple_memccpy (void *, const void *, int, size_t);
-void *stupid_memccpy (void *, const void *, int, size_t);
-
-IMPL (stupid_memccpy, 0)
-IMPL (simple_memccpy, 0)
-IMPL (memccpy, 1)
-
-void *
-simple_memccpy (void *dst, const void *src, int c, size_t n)
-{
- const char *s = src;
- char *d = dst;
-
- while (n-- > 0)
- if ((*d++ = *s++) == (char) c)
- return d;
-
- return NULL;
-}
-
void *
-stupid_memccpy (void *dst, const void *src, int c, size_t n)
+generic_memccpy (void *dst, const void *src, int c, size_t n)
{
void *p = memchr (src, c, n);
@@ -52,6 +32,9 @@ stupid_memccpy (void *dst, const void *src, int c, size_t n)
return NULL;
}
+IMPL (memccpy, 1)
+IMPL (generic_memccpy, 0)
+
typedef void *(*proto_t) (void *, const void *, int c, size_t);
static void
diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
index b32ca4c..6c5c549 100644
--- a/benchtests/bench-memcpy.c
+++ b/benchtests/bench-memcpy.c
@@ -23,13 +23,6 @@
# define TEST_NAME "memcpy"
# include "bench-string.h"
-char *simple_memcpy (char *, const char *, size_t);
-char *builtin_memcpy (char *, const char *, size_t);
-
-IMPL (simple_memcpy, 0)
-IMPL (builtin_memcpy, 0)
-IMPL (memcpy, 1)
-
char *
simple_memcpy (char *dst, const char *src, size_t n)
{
@@ -39,11 +32,9 @@ simple_memcpy (char *dst, const char *src, size_t n)
return ret;
}
-char *
-builtin_memcpy (char *dst, const char *src, size_t n)
-{
- return __builtin_memcpy (dst, src, n);
-}
+IMPL (memcpy, 1)
+IMPL (simple_memcpy, 0)
+
#endif
# include "json-lib.h"
diff --git a/benchtests/bench-memmove.c b/benchtests/bench-memmove.c
index ad1f0bb..a5d9577 100644
--- a/benchtests/bench-memmove.c
+++ b/benchtests/bench-memmove.c
@@ -17,34 +17,16 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
-#ifdef TEST_BCOPY
-# define TEST_NAME "bcopy"
-#else
-# define TEST_NAME "memmove"
-#endif
+#define TEST_NAME "memmove"
#include "bench-string.h"
#include "json-lib.h"
char *simple_memmove (char *, const char *, size_t);
-#ifdef TEST_BCOPY
-typedef void (*proto_t) (const char *, char *, size_t);
-void simple_bcopy (const char *, char *, size_t);
-
-IMPL (simple_bcopy, 0)
-IMPL (bcopy, 1)
-
-void
-simple_bcopy (const char *src, char *dst, size_t n)
-{
- simple_memmove (dst, src, n);
-}
-#else
typedef char *(*proto_t) (char *, const char *, size_t);
-IMPL (simple_memmove, 0)
IMPL (memmove, 1)
-#endif
+IMPL (simple_memmove, 0)
char *
inhibit_loop_to_libcall
@@ -74,11 +56,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, const
TIMING_NOW (start);
for (i = 0; i < iters; ++i)
{
-#ifdef TEST_BCOPY
- CALL (impl, src, dst, len);
-#else
CALL (impl, dst, src, len);
-#endif
}
TIMING_NOW (stop);
diff --git a/benchtests/bench-mempcpy.c b/benchtests/bench-mempcpy.c
index 82b276b..09f8557 100644
--- a/benchtests/bench-mempcpy.c
+++ b/benchtests/bench-mempcpy.c
@@ -21,17 +21,13 @@
#define TEST_NAME "mempcpy"
#include "bench-string.h"
-char *simple_mempcpy (char *, const char *, size_t);
-
-IMPL (simple_mempcpy, 0)
-IMPL (mempcpy, 1)
-
char *
-simple_mempcpy (char *dst, const char *src, size_t n)
+generic_mempcpy (char *dst, const char *src, size_t n)
{
- while (n--)
- *dst++ = *src++;
- return dst;
+ return memcpy (dst, src, n) + n;
}
+IMPL (mempcpy, 1)
+IMPL (generic_mempcpy, 0)
+
#include "bench-memcpy.c"
diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
index c2679a6..0df55d1 100644
--- a/benchtests/bench-memset.c
+++ b/benchtests/bench-memset.c
@@ -17,66 +17,22 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
-#ifdef TEST_BZERO
-# define TEST_NAME "bzero"
-#else
-# ifndef WIDE
-# define TEST_NAME "memset"
-# else
-# define TEST_NAME "wmemset"
-# endif /* WIDE */
-#endif /* !TEST_BZERO */
-#define MIN_PAGE_SIZE 131072
-#include "bench-string.h"
-
#ifndef WIDE
-# define SIMPLE_MEMSET simple_memset
+# define TEST_NAME "memset"
#else
-# define SIMPLE_MEMSET simple_wmemset
+# define TEST_NAME "wmemset"
#endif /* WIDE */
+#define MIN_PAGE_SIZE 131072
+#include "bench-string.h"
#include "json-lib.h"
CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
-#ifdef TEST_BZERO
-typedef void (*proto_t) (char *, size_t);
-void simple_bzero (char *, size_t);
-void builtin_bzero (char *, size_t);
-
-IMPL (simple_bzero, 0)
-IMPL (builtin_bzero, 0)
-IMPL (bzero, 1)
-
-void
-simple_bzero (char *s, size_t n)
-{
- SIMPLE_MEMSET (s, 0, n);
-}
-
-void
-builtin_bzero (char *s, size_t n)
-{
- __builtin_bzero (s, n);
-}
-#else
typedef CHAR *(*proto_t) (CHAR *, int, size_t);
-IMPL (SIMPLE_MEMSET, 0)
-# ifndef WIDE
-char *builtin_memset (char *, int, size_t);
-IMPL (builtin_memset, 0)
-# endif /* !WIDE */
IMPL (MEMSET, 1)
-
-# ifndef WIDE
-char *
-builtin_memset (char *s, int c, size_t n)
-{
- return __builtin_memset (s, c, n);
-}
-# endif /* !WIDE */
-#endif /* !TEST_BZERO */
+IMPL (SIMPLE_MEMSET, 0)
CHAR *
inhibit_loop_to_libcall
@@ -98,11 +54,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
TIMING_NOW (start);
for (i = 0; i < iters; ++i)
{
-#ifdef TEST_BZERO
- CALL (impl, s, n);
-#else
CALL (impl, s, c, n);
-#endif /* !TEST_BZERO */
}
TIMING_NOW (stop);
@@ -159,9 +111,7 @@ test_main (void)
json_array_begin (&json_ctx, "results");
-#ifndef TEST_BZERO
for (c = -65; c <= 130; c += 65)
-#endif
{
for (i = 0; i < 18; ++i)
do_test (&json_ctx, 0, c, 1 << i);
diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c
index 2b11cfe..44f3114 100644
--- a/benchtests/bench-rawmemchr.c
+++ b/benchtests/bench-rawmemchr.c
@@ -17,26 +17,25 @@
<http://www.gnu.org/licenses/>. */
#include <assert.h>
+#include <stdint.h>
#define TEST_MAIN
#define TEST_NAME "rawmemchr"
#include "bench-string.h"
typedef char *(*proto_t) (const char *, int);
-char *simple_rawmemchr (const char *, int);
-
-IMPL (simple_rawmemchr, 0)
-IMPL (rawmemchr, 1)
char *
-simple_rawmemchr (const char *s, int c)
+generic_rawmemchr (const char *s, int c)
{
- while (1)
- if (*s++ == (char) c)
- return (char *) s - 1;
- return NULL;
+ if (c != 0)
+ return memchr (s, c, PTRDIFF_MAX);
+ return (char *)s + strlen (s);
}
+IMPL (rawmemchr, 1)
+IMPL (generic_rawmemchr, 0)
+
static void
do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
{
diff --git a/benchtests/bench-strcasecmp.c b/benchtests/bench-strcasecmp.c
index 5c471a8..4e9bcdc 100644
--- a/benchtests/bench-strcasecmp.c
+++ b/benchtests/bench-strcasecmp.c
@@ -23,9 +23,7 @@
typedef int (*proto_t) (const char *, const char *);
static int simple_strcasecmp (const char *, const char *);
-static int stupid_strcasecmp (const char *, const char *);
-IMPL (stupid_strcasecmp, 0)
IMPL (simple_strcasecmp, 0)
IMPL (strcasecmp, 1)
@@ -41,24 +39,6 @@ simple_strcasecmp (const char *s1, const char *s2)
return ret;
}
-static int
-stupid_strcasecmp (const char *s1, const char *s2)
-{
- size_t ns1 = strlen (s1) + 1, ns2 = strlen (s2) + 1;
- size_t n = ns1 < ns2 ? ns1 : ns2;
- int ret = 0;
-
- while (n--)
- {
- if ((ret = ((unsigned char) tolower (*s1)
- - (unsigned char) tolower (*s2))) != 0)
- break;
- ++s1;
- ++s2;
- }
- return ret;
-}
-
static void
do_one_test (impl_t *impl, const char *s1, const char *s2, int exp_result)
{
diff --git a/benchtests/bench-strcasestr.c b/benchtests/bench-strcasestr.c
index 030e5c7..1458070 100644
--- a/benchtests/bench-strcasestr.c
+++ b/benchtests/bench-strcasestr.c
@@ -27,33 +27,8 @@
#define __strnlen strnlen
#include "../string/strcasestr.c"
-
-static char *
-stupid_strcasestr (const char *s1, const char *s2)
-{
- ssize_t s1len = strlen (s1);
- ssize_t s2len = strlen (s2);
-
- if (s2len > s1len)
- return NULL;
-
- for (ssize_t i = 0; i <= s1len - s2len; ++i)
- {
- size_t j;
- for (j = 0; j < s2len; ++j)
- if (tolower (s1[i + j]) != tolower (s2[j]))
- break;
- if (j == s2len)
- return (char *) s1 + i;
- }
-
- return NULL;
-}
-
-
typedef char *(*proto_t) (const char *, const char *);
-IMPL (stupid_strcasestr, 0)
IMPL (simple_strcasestr, 0)
IMPL (strcasestr, 1)
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 0648c99..b8dba17 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -38,7 +38,6 @@
# ifdef USE_FOR_STRCHRNUL
# undef STRCHR
# define STRCHR strchrnul
-# define stupid_STRCHR stupid_STRCHRNUL
# define simple_STRCHR simple_STRCHRNUL
# endif /* !USE_FOR_STRCHRNUL */
# define MIDDLE_CHAR 127
@@ -47,7 +46,6 @@
# ifdef USE_FOR_STRCHRNUL
# undef STRCHR
# define STRCHR wcschrnul
-# define stupid_STRCHR stupid_WCSCHRNUL
# define simple_STRCHR simple_WCSCHRNUL
# endif /* !USE_FOR_STRCHRNUL */
# define MIDDLE_CHAR 1121
@@ -72,18 +70,6 @@ simple_STRCHR (const CHAR *s, int c)
return (CHAR *) s;
}
-CHAR *
-stupid_STRCHR (const CHAR *s, int c)
-{
- size_t n = STRLEN (s) + 1;
-
- while (n--)
- if (*s++ == (CHAR) c)
- return (CHAR *) s - 1;
- return NULLRET ((CHAR *) s - 1);
-}
-
-IMPL (stupid_STRCHR, 0)
IMPL (simple_STRCHR, 0)
IMPL (STRCHR, 1)
diff --git a/benchtests/bench-strcmp.c b/benchtests/bench-strcmp.c
index 695aa19..c87b3ac 100644
--- a/benchtests/bench-strcmp.c
+++ b/benchtests/bench-strcmp.c
@@ -27,7 +27,6 @@
#ifdef WIDE
# define L(str) L##str
# define SIMPLE_STRCMP simple_wcscmp
-# define STUPID_STRCMP stupid_wcscmp
# define CHARBYTESLOG 2
# define MIDCHAR 0x7fffffff
# define LARGECHAR 0xfffffffe
@@ -51,31 +50,11 @@ simple_wcscmp (const wchar_t *s1, const wchar_t *s2)
return c1 < c2 ? -1 : 1;
}
-int
-stupid_wcscmp (const wchar_t *s1, const wchar_t *s2)
-{
- size_t ns1 = wcslen (s1) + 1;
- size_t ns2 = wcslen (s2) + 1;
- size_t n = ns1 < ns2 ? ns1 : ns2;
- int ret = 0;
-
- wchar_t c1, c2;
-
- while (n--) {
- c1 = *s1++;
- c2 = *s2++;
- if ((ret = c1 < c2 ? -1 : c1 == c2 ? 0 : 1) != 0)
- break;
- }
- return ret;
-}
-
#else
# include <limits.h>
# define L(str) str
# define SIMPLE_STRCMP simple_strcmp
-# define STUPID_STRCMP stupid_strcmp
# define CHARBYTESLOG 0
# define MIDCHAR 0x7f
# define LARGECHAR 0xfe
@@ -90,26 +69,12 @@ simple_strcmp (const char *s1, const char *s2)
return ret;
}
-int
-stupid_strcmp (const char *s1, const char *s2)
-{
- size_t ns1 = strlen (s1) + 1;
- size_t ns2 = strlen (s2) + 1;
- size_t n = ns1 < ns2 ? ns1 : ns2;
- int ret = 0;
-
- while (n--)
- if ((ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) != 0)
- break;
- return ret;
-}
#endif
# include "json-lib.h"
typedef int (*proto_t) (const CHAR *, const CHAR *);
-IMPL (STUPID_STRCMP, 1)
IMPL (SIMPLE_STRCMP, 1)
IMPL (STRCMP, 1)
diff --git a/benchtests/bench-strcspn.c b/benchtests/bench-strcspn.c
index c5d723d..bf9c4f8 100644
--- a/benchtests/bench-strcspn.c
+++ b/benchtests/bench-strcspn.c
@@ -28,17 +28,13 @@
#ifndef WIDE
# define SIMPLE_STRCSPN simple_strcspn
-# define STUPID_STRCSPN stupid_strcspn
#else
# define SIMPLE_STRCSPN simple_wcscspn
-# define STUPID_STRCSPN stupid_wcscspn
#endif /* WIDE */
typedef size_t (*proto_t) (const CHAR *, const CHAR *);
size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *);
-size_t STUPID_STRCSPN (const CHAR *, const CHAR *);
-IMPL (STUPID_STRCSPN, 0)
IMPL (SIMPLE_STRCSPN, 0)
IMPL (STRCSPN, 1)
@@ -55,17 +51,4 @@ SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej)
return s - str - 1;
}
-size_t
-STUPID_STRCSPN (const CHAR *s, const CHAR *rej)
-{
- size_t ns = STRLEN (s), nrej = STRLEN (rej);
- size_t i, j;
-
- for (i = 0; i < ns; ++i)
- for (j = 0; j < nrej; ++j)
- if (s[i] == rej[j])
- return i;
- return i;
-}
-
#include "bench-strpbrk.c"
diff --git a/benchtests/bench-strlen.c b/benchtests/bench-strlen.c
index b1cd2ac..f86095a 100644
--- a/benchtests/bench-strlen.c
+++ b/benchtests/bench-strlen.c
@@ -34,15 +34,6 @@ size_t memchr_strlen (const CHAR *);
IMPL (memchr_strlen, 0)
IMPL (generic_strlen, 0)
-#ifndef WIDE
-size_t
-builtin_strlen (const CHAR *p)
-{
- return __builtin_strlen (p);
-}
-IMPL (builtin_strlen, 0)
-#endif
-
size_t
memchr_strlen (const CHAR *p)
{
diff --git a/benchtests/bench-strncasecmp.c b/benchtests/bench-strncasecmp.c
index e18302a..7c97877 100644
--- a/benchtests/bench-strncasecmp.c
+++ b/benchtests/bench-strncasecmp.c
@@ -23,9 +23,7 @@
typedef int (*proto_t) (const char *, const char *, size_t);
static int simple_strncasecmp (const char *, const char *, size_t);
-static int stupid_strncasecmp (const char *, const char *, size_t);
-IMPL (stupid_strncasecmp, 0)
IMPL (simple_strncasecmp, 0)
IMPL (strncasecmp, 1)
@@ -48,27 +46,6 @@ simple_strncasecmp (const char *s1, const char *s2, size_t n)
return ret;
}
-static int
-stupid_strncasecmp (const char *s1, const char *s2, size_t max)
-{
- size_t ns1 = strlen (s1) + 1;
- size_t ns2 = strlen (s2) + 1;
- size_t n = ns1 < ns2 ? ns1 : ns2;
- if (n > max)
- n = max;
- int ret = 0;
-
- while (n--)
- {
- if ((ret = ((unsigned char) tolower (*s1)
- - (unsigned char) tolower (*s2))) != 0)
- break;
- ++s1;
- ++s2;
- }
- return ret;
-}
-
static void
do_one_test (impl_t *impl, const char *s1, const char *s2, size_t n,
int exp_result)
diff --git a/benchtests/bench-strncmp.c b/benchtests/bench-strncmp.c
index 750150c..a4f3412 100644
--- a/benchtests/bench-strncmp.c
+++ b/benchtests/bench-strncmp.c
@@ -28,7 +28,6 @@
#ifdef WIDE
# define L(str) L##str
# define SIMPLE_STRNCMP simple_wcsncmp
-# define STUPID_STRNCMP stupid_wcsncmp
/* Wcsncmp uses signed semantics for comparison, not unsigned.
Avoid using substraction since possible overflow. */
@@ -47,29 +46,9 @@ simple_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
return 0;
}
-int
-stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
-{
- wchar_t c1, c2;
- size_t ns1 = wcsnlen (s1, n) + 1, ns2 = wcsnlen (s2, n) + 1;
-
- n = ns1 < n ? ns1 : n;
- n = ns2 < n ? ns2 : n;
-
- while (n--)
- {
- c1 = *s1++;
- c2 = *s2++;
- if (c1 != c2)
- return c1 > c2 ? 1 : -1;
- }
- return 0;
-}
-
#else
# define L(str) str
# define SIMPLE_STRNCMP simple_strncmp
-# define STUPID_STRNCMP stupid_strncmp
/* Strncmp uses unsigned semantics for comparison. */
int
@@ -82,23 +61,10 @@ simple_strncmp (const char *s1, const char *s2, size_t n)
return ret;
}
-int
-stupid_strncmp (const char *s1, const char *s2, size_t n)
-{
- size_t ns1 = strnlen (s1, n) + 1, ns2 = strnlen (s2, n) + 1;
- int ret = 0;
-
- n = ns1 < n ? ns1 : n;
- n = ns2 < n ? ns2 : n;
- while (n-- && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0);
- return ret;
-}
-
#endif /* !WIDE */
typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
-IMPL (STUPID_STRNCMP, 0)
IMPL (SIMPLE_STRNCMP, 0)
IMPL (STRNCMP, 1)
diff --git a/benchtests/bench-strpbrk.c b/benchtests/bench-strpbrk.c
index 61639cf..14e1bcb 100644
--- a/benchtests/bench-strpbrk.c
+++ b/benchtests/bench-strpbrk.c
@@ -37,17 +37,13 @@
# ifndef WIDE
# define SIMPLE_STRPBRK simple_strpbrk
-# define STUPID_STRPBRK stupid_strpbrk
# else
# define SIMPLE_STRPBRK simple_wcspbrk
-# define STUPID_STRPBRK stupid_wcspbrk
# endif /* WIDE */
typedef CHAR *(*proto_t) (const CHAR *, const CHAR *);
CHAR *SIMPLE_STRPBRK (const CHAR *, const CHAR *);
-CHAR *STUPID_STRPBRK (const CHAR *, const CHAR *);
-IMPL (STUPID_STRPBRK, 0)
IMPL (SIMPLE_STRPBRK, 0)
IMPL (STRPBRK, 1)
@@ -64,18 +60,6 @@ SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej)
return NULL;
}
-CHAR *
-STUPID_STRPBRK (const CHAR *s, const CHAR *rej)
-{
- size_t ns = STRLEN (s), nrej = STRLEN (rej);
- size_t i, j;
-
- for (i = 0; i < ns; ++i)
- for (j = 0; j < nrej; ++j)
- if (s[i] == rej[j])
- return (CHAR *) s + i;
- return NULL;
-}
#endif /* !STRPBRK_RESULT */
static void
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
index 04507cd..ac874fe 100644
--- a/benchtests/bench-strspn.c
+++ b/benchtests/bench-strspn.c
@@ -28,19 +28,15 @@
#ifndef WIDE
# define SIMPLE_STRSPN simple_strspn
-# define STUPID_STRSPN stupid_strspn
# define SMALL_CHAR 127
#else
# define SIMPLE_STRSPN simple_wcsspn
-# define STUPID_STRSPN stupid_wcsspn
# define SMALL_CHAR 1273
#endif /* WIDE */
typedef size_t (*proto_t) (const CHAR *, const CHAR *);
size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
-size_t STUPID_STRSPN (const CHAR *, const CHAR *);
-IMPL (STUPID_STRSPN, 0)
IMPL (SIMPLE_STRSPN, 0)
IMPL (STRSPN, 1)
@@ -61,23 +57,6 @@ SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
return s - str - 1;
}
-size_t
-STUPID_STRSPN (const CHAR *s, const CHAR *acc)
-{
- size_t ns = STRLEN (s), nacc = STRLEN (acc);
- size_t i, j;
-
- for (i = 0; i < ns; ++i)
- {
- for (j = 0; j < nacc; ++j)
- if (s[i] == acc[j])
- break;
- if (j == nacc)
- return i;
- }
- return i;
-}
-
static void
do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
{