public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v3 3/7] string/test-str*cmp: remove stupid_[strcmp, strncmp, wcscmp, wcsncmp].
Date: Mon, 10 Jan 2022 15:35:36 -0600	[thread overview]
Message-ID: <20220110213540.1258344-3-goldstein.w.n@gmail.com> (raw)
In-Reply-To: <20220110213540.1258344-1-goldstein.w.n@gmail.com>

These implementations just add to test duration. Since we have
simple_* implementations we already have a safe reference
implementation.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
 string/test-strcmp.c  | 35 -----------------------------------
 string/test-strncmp.c | 34 ----------------------------------
 2 files changed, 69 deletions(-)

diff --git a/string/test-strcmp.c b/string/test-strcmp.c
index 3c75076fb8..97d7bf5043 100644
--- a/string/test-strcmp.c
+++ b/string/test-strcmp.c
@@ -34,7 +34,6 @@
 # define STRLEN wcslen
 # define MEMCPY wmemcpy
 # define SIMPLE_STRCMP simple_wcscmp
-# define STUPID_STRCMP stupid_wcscmp
 # define CHAR wchar_t
 # define UCHAR wchar_t
 # define CHARBYTES 4
@@ -64,25 +63,6 @@ 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>
 
@@ -92,7 +72,6 @@ stupid_wcscmp (const wchar_t *s1, const wchar_t *s2)
 # define STRLEN strlen
 # define MEMCPY memcpy
 # define SIMPLE_STRCMP simple_strcmp
-# define STUPID_STRCMP stupid_strcmp
 # define CHAR char
 # define UCHAR unsigned char
 # define CHARBYTES 1
@@ -113,24 +92,10 @@ 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
 
 typedef int (*proto_t) (const CHAR *, const CHAR *);
 
-IMPL (STUPID_STRCMP, 1)
 IMPL (SIMPLE_STRCMP, 1)
 IMPL (STRCMP, 1)
 
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
index e7d5edea39..61a283a0af 100644
--- a/string/test-strncmp.c
+++ b/string/test-strncmp.c
@@ -33,7 +33,6 @@
 # define STRDUP wcsdup
 # define MEMCPY wmemcpy
 # define SIMPLE_STRNCMP simple_wcsncmp
-# define STUPID_STRNCMP stupid_wcsncmp
 # define CHAR wchar_t
 # define UCHAR wchar_t
 # define CHARBYTES 4
@@ -57,25 +56,6 @@ 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 STRNCMP strncmp
@@ -83,7 +63,6 @@ stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
 # define STRDUP strdup
 # define MEMCPY memcpy
 # define SIMPLE_STRNCMP simple_strncmp
-# define STUPID_STRNCMP stupid_strncmp
 # define CHAR char
 # define UCHAR unsigned char
 # define CHARBYTES 1
@@ -101,23 +80,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
 
 typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
 
-IMPL (STUPID_STRNCMP, 0)
 IMPL (SIMPLE_STRNCMP, 0)
 IMPL (STRNCMP, 1)
 
-- 
2.25.1


  parent reply	other threads:[~2022-01-10 21:35 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 12:29 [PATCH v1 1/5] x86: Optimize strcmp-avx2.S and fix for [BZ# 28755] Noah Goldstein
2022-01-09 12:29 ` [PATCH v1 2/5] x86: Optimize strcmp-evex.S " Noah Goldstein
2022-01-09 12:29 ` [PATCH v1 3/5] string: remove stupid_[strcmp, strncmp, wcscmp, wcsncmp] Noah Goldstein
2022-01-09 12:29 ` [PATCH v1 4/5] string: Improve coverage in test-strcmp.c and test-strncmp.c Noah Goldstein
2022-01-09 12:29 ` [PATCH v1 5/5] benchtests: Add more coverage for strcmp and strncmp benchmarks Noah Goldstein
2022-01-09 12:35 ` [PATCH v1 1/5] x86: Optimize strcmp-avx2.S and fix for [BZ# 28755] Noah Goldstein
2022-01-09 14:07   ` H.J. Lu
2022-01-10  0:29     ` Noah Goldstein
2022-01-10  0:27 ` [PATCH v2 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S " Noah Goldstein
2022-01-10  0:27   ` [PATCH v2 2/7] x86: Fix __wcsncmp_evex in strcmp-evex.S " Noah Goldstein
2022-01-10  0:35     ` H.J. Lu
2022-01-10  0:27   ` [PATCH v2 3/7] string/test-str*cmp: remove stupid_[strcmp, strncmp, wcscmp, wcsncmp] Noah Goldstein
2022-01-10  0:37     ` H.J. Lu
2022-01-10  0:27   ` [PATCH v2 4/7] string: Improve coverage in test-strcmp.c and test-strncmp.c Noah Goldstein
2022-01-10  0:38     ` H.J. Lu
2022-01-10  2:51       ` Noah Goldstein
2022-01-10  0:27   ` [PATCH v2 5/7] x86: Optimize strcmp-avx2.S Noah Goldstein
2022-01-10  0:41     ` H.J. Lu
2022-01-10  1:06       ` Noah Goldstein
2022-01-10  1:58         ` H.J. Lu
2022-01-10  2:54           ` Noah Goldstein
2022-01-10  0:27   ` [PATCH v2 6/7] x86: Optimize strcmp-evex.S Noah Goldstein
2022-01-10  0:41     ` H.J. Lu
2022-01-10  0:27   ` [PATCH v2 7/7] benchtests: Add more coverage for strcmp and strncmp benchmarks Noah Goldstein
2022-01-10  0:34   ` [PATCH v2 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] H.J. Lu
2022-01-10 21:35 ` [PATCH v3 " Noah Goldstein
2022-01-10 21:35   ` [PATCH v3 2/7] x86: Fix __wcsncmp_evex in strcmp-evex.S " Noah Goldstein
2022-01-11  2:15     ` H.J. Lu
2022-01-26 22:04       ` H.J. Lu
2022-04-29 22:05         ` Sunil Pandey
2022-01-10 21:35   ` Noah Goldstein [this message]
2022-01-10 21:35   ` [PATCH v3 4/7] string: Improve coverage in test-strcmp.c and test-strncmp.c Noah Goldstein
2022-01-10 21:35   ` [PATCH v3 5/7] x86: Optimize strcmp-avx2.S Noah Goldstein
2022-02-14 14:10     ` Andreas Schwab
2022-02-14 18:23       ` H.J. Lu
2022-02-14 19:16         ` Andreas Schwab
2022-02-14 19:30           ` H.J. Lu
2022-02-14 19:35             ` Andreas Schwab
2022-02-14 20:59               ` H.J. Lu
2022-02-14 21:10                 ` H.J. Lu
2022-02-15 11:11                   ` Andreas Schwab
2022-02-15 12:55                   ` Andreas Schwab
2022-02-15 12:58                     ` Noah Goldstein
2022-02-15 13:09                       ` Noah Goldstein
2022-02-15 13:32                         ` Noah Goldstein
2022-02-15 13:37                           ` Noah Goldstein
2022-02-15 16:33                             ` Noah Goldstein
2022-02-14 23:42                 ` Noah Goldstein
2022-02-15 10:43                   ` Andreas Schwab
2022-02-15 11:22                   ` Andreas Schwab
2022-02-15 11:28                     ` Noah Goldstein
2022-02-15 12:24                       ` Andreas Schwab
2022-01-10 21:35   ` [PATCH v3 6/7] x86: Optimize strcmp-evex.S Noah Goldstein
2022-01-10 21:35   ` [PATCH v3 7/7] benchtests: Add more coverage for strcmp and strncmp benchmarks Noah Goldstein
2022-01-11  2:15   ` [PATCH v3 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] H.J. Lu
2022-01-26 22:05     ` H.J. Lu
2022-01-27  4:29       ` H.J. Lu
2022-01-27  5:10         ` H.J. Lu
2022-01-27  5:52           ` Noah Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220110213540.1258344-3-goldstein.w.n@gmail.com \
    --to=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).