From patchwork Tue Apr 5 05:05:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1613232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=OQcPZYnl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KXbFC1w71z9s75 for ; Tue, 5 Apr 2022 15:05:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACAA63858407 for ; Tue, 5 Apr 2022 05:05:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACAA63858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1649135132; bh=geaS7N93NhFwoUxJRWytBOgXy/2BrVB7VCR/2h8zQ6M=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OQcPZYnlibtNR3V+WKKxTGZ0xoouKPAWoAIBvtshJ/5Olwz1vEjTUdQQ2/DSi/ElC 5XbPe00WFhRv9YQyDicrFJgB2+mx9pbTktxDXt6wouj/dW2LswekU1liolYmLhQKwz r1hAPfjPE8ZK6doyUwMgaXygsLxM7h+1z/l/fVH0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from brown.elm.relay.mailchannels.net (brown.elm.relay.mailchannels.net [23.83.212.23]) by sourceware.org (Postfix) with ESMTPS id 8D4963858D37 for ; Tue, 5 Apr 2022 05:05:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D4963858D37 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3948D1217E1; Tue, 5 Apr 2022 05:05:14 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5748C1210A8; Tue, 5 Apr 2022 05:05:13 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1649135113; a=rsa-sha256; cv=none; b=oOTjnTxJqKZTdK2xeyjbkDCzoCh1wsvboVFklewdxlfBL33Q/BhGoZN2yH/4Xt5dSgO2tq TVmb8cF9S4k0JAUCxriYp81X2LoA9oT5zwoqoSwFcUu5Ctq1aHHOCGWqCYHWAEyQbCayK/ hWCNKIyV6WfZyx78wG9DVSGwKGN5HbgOgp5Vzr0PQa6sfAUZR8VcjZBazfyVG6iO9YxSq6 1YVx0CHWWAxBEkoRZ1gsOPpwF50DL3QBJTsRK8rK3rBegwlSIp0gP1M3tRhW83r88QFk1/ qCzvQrwiqlwkX6dXLBHbMkhX+ftwi73i2GYgwd1l1IxOmubzSD2cJQEauHxXhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1649135113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=geaS7N93NhFwoUxJRWytBOgXy/2BrVB7VCR/2h8zQ6M=; b=CLwkfZBriVlOaSoONBeY4j8YArzWzyWR6cMA+zQTWQqSCGjMp+4bTEJhzEyf+V6G4oXJqP v9CRTxDY5d3rLyskXc+njl/RpsGFjbb8Y9GtnDNdLGfwZ5yWeMkolwwUQsj7+ZGtwFCMUR kkkvLGeN3Ks3r96Fr/7vUWTIclZ77B3ASIjHFer9mYjKF0L2kT0M7hpFmHC0YvsPQWYuJ+ IUGdR7rzCC1nTkErsi55BMqJlmwM03rPq5ShvJKMa3vM7bjMcogN0hydEUi1k0s102tVzI syf3SdA1RWdtgMZOS792/td/15/5EdGM9kHXqmFjr8QmB5AeatWBiNlWiUlmyQ== ARC-Authentication-Results: i=1; rspamd-786f77c8d-xdfs5; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.255.190 (trex/6.7.1); Tue, 05 Apr 2022 05:05:14 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Illustrious-Drop: 15f56f1b1b1f0e47_1649135113965_3052006690 X-MC-Loop-Signature: 1649135113964:4166812049 X-MC-Ingress-Time: 1649135113964 Received: from rhbox.redhat.com (unknown [1.186.223.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a306.dreamhost.com (Postfix) with ESMTPSA id 4KXbDk6KXFz2j; Mon, 4 Apr 2022 22:05:10 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] tests/string: Drop simple/stupid/builtin tests Date: Tue, 5 Apr 2022 10:35:01 +0530 Message-Id: <20220405050501.39309-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3492.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_ASCII_DIVIDERS, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" In most cases the simple/stupid/builtin functions were in there to benchmark optimized implementations against. Only in some cases the functions are used to check expected results. Remove these tests from IMPL() and only keep them in wherever they're used for a specific purpose, e.g. to generate expected results. This improves timing of `make subdirs=string` by over a minute and a half (over 15%) on a Whiskey Lake laptop. Signed-off-by: Siddhesh Poyarekar --- string/test-memccpy.c | 30 -------------------------- string/test-memchr.c | 13 ----------- string/test-memcmp.c | 1 - string/test-memcpy-support.h | 18 ---------------- string/test-memmem.c | 2 -- string/test-memmove.c | 28 ------------------------ string/test-mempcpy.c | 11 ---------- string/test-memrchr.c | 12 ----------- string/test-memset.c | 39 ++++----------------------------- string/test-strcasecmp.c | 34 ----------------------------- string/test-strcasestr.c | 9 ++++---- string/test-strcat.c | 1 - string/test-strchr.c | 15 +------------ string/test-strcmp.c | 1 - string/test-strcpy.c | 1 - string/test-strlen.c | 10 --------- string/test-strncasecmp.c | 24 --------------------- string/test-strncat.c | 20 ----------------- string/test-strncmp.c | 1 - string/test-strncpy.c | 34 ----------------------------- string/test-strnlen.c | 13 ----------- string/test-strpbrk.c | 33 ---------------------------- string/test-strrchr.c | 16 -------------- string/test-strspn.c | 42 ------------------------------------ string/test-strstr.c | 13 ++++++----- 25 files changed, 15 insertions(+), 406 deletions(-) diff --git a/string/test-memccpy.c b/string/test-memccpy.c index ee2cf8b8af..2539a25614 100644 --- a/string/test-memccpy.c +++ b/string/test-memccpy.c @@ -20,38 +20,8 @@ #define TEST_NAME "memccpy" #include "test-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) -{ - void *p = memchr (src, c, n); - - if (p != NULL) - return mempcpy (dst, src, p - src + 1); - - memcpy (dst, src, n); - return NULL; -} - typedef void *(*proto_t) (void *, const void *, int c, size_t); static void diff --git a/string/test-memchr.c b/string/test-memchr.c index a4617086b3..a48b8fa43d 100644 --- a/string/test-memchr.c +++ b/string/test-memchr.c @@ -30,7 +30,6 @@ # define MEMCHR memchr # define CHAR char # define UCHAR unsigned char -# define SIMPLE_MEMCHR simple_memchr # define BIG_CHAR CHAR_MAX # define SMALL_CHAR 127 #else @@ -38,26 +37,14 @@ # define MEMCHR wmemchr # define CHAR wchar_t # define UCHAR wchar_t -# define SIMPLE_MEMCHR simple_wmemchr # define BIG_CHAR WCHAR_MAX # define SMALL_CHAR 1273 #endif /* WIDE */ typedef CHAR *(*proto_t) (const CHAR *, int, size_t); -CHAR *SIMPLE_MEMCHR (const CHAR *, int, size_t); -IMPL (SIMPLE_MEMCHR, 0) IMPL (MEMCHR, 1) -CHAR * -SIMPLE_MEMCHR (const CHAR *s, int c, size_t n) -{ - while (n--) - if (*s++ == (CHAR) c) - return (CHAR *) s - 1; - return NULL; -} - static void do_one_test (impl_t *impl, const CHAR *s, int c, size_t n, CHAR *exp_res) { diff --git a/string/test-memcmp.c b/string/test-memcmp.c index 89ef3419a0..181b689f68 100644 --- a/string/test-memcmp.c +++ b/string/test-memcmp.c @@ -85,7 +85,6 @@ SIMPLE_MEMCMP (const char *s1, const char *s2, size_t n) typedef int (*proto_t) (const CHAR *, const CHAR *, size_t); -IMPL (SIMPLE_MEMCMP, 0) IMPL (MEMCMP, 1) static int diff --git a/string/test-memcpy-support.h b/string/test-memcpy-support.h index f1763da895..157b6a8683 100644 --- a/string/test-memcpy-support.h +++ b/string/test-memcpy-support.h @@ -29,26 +29,8 @@ #define TIMEOUT (8 * 60) #include "test-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) -{ - char *ret = dst; - while (n--) - *dst++ = *src++; - return ret; -} -char * -builtin_memcpy (char *dst, const char *src, size_t n) -{ - return __builtin_memcpy (dst, src, n); -} #endif typedef char *(*proto_t) (char *, const char *, size_t); typedef uint32_t __attribute__ ((may_alias, aligned (1))) unaligned_uint32_t; diff --git a/string/test-memmem.c b/string/test-memmem.c index 37d3ea4fca..2b266799b3 100644 --- a/string/test-memmem.c +++ b/string/test-memmem.c @@ -23,9 +23,7 @@ #include "test-string.h" typedef char *(*proto_t) (const void *, size_t, const void *, size_t); -void *simple_memmem (const void *, size_t, const void *, size_t); -IMPL (simple_memmem, 0) IMPL (memmem, 1) void * diff --git a/string/test-memmove.c b/string/test-memmove.c index 8d9ac86b4f..68b73b4f6d 100644 --- a/string/test-memmove.c +++ b/string/test-memmove.c @@ -25,45 +25,17 @@ #include "test-string.h" #include -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 -char * -inhibit_loop_to_libcall -simple_memmove (char *dst, const char *src, size_t n) -{ - char *ret = dst; - if (src < dst) - { - dst += n; - src += n; - while (n--) - *--dst = *--src; - } - else - while (n--) - *dst++ = *src++; - return ret; -} - static void do_one_test (impl_t *impl, char *dst, char *src, const char *orig_src, size_t len) diff --git a/string/test-mempcpy.c b/string/test-mempcpy.c index 9637d02787..b700bb8045 100644 --- a/string/test-mempcpy.c +++ b/string/test-mempcpy.c @@ -22,17 +22,6 @@ #define TEST_NAME "mempcpy" #include "test-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) -{ - while (n--) - *dst++ = *src++; - return dst; -} - #include "test-memcpy.c" diff --git a/string/test-memrchr.c b/string/test-memrchr.c index 8d60d178a0..4d1e41e7f8 100644 --- a/string/test-memrchr.c +++ b/string/test-memrchr.c @@ -21,21 +21,9 @@ #include "test-string.h" typedef char *(*proto_t) (const char *, int, size_t); -char *simple_memrchr (const char *, int, size_t); -IMPL (simple_memrchr, 0) IMPL (memrchr, 1) -char * -simple_memrchr (const char *s, int c, size_t n) -{ - s = s + n; - while (n--) - if (*--s == (char) c) - return (char *) s; - return NULL; -} - static void do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res) { diff --git a/string/test-memset.c b/string/test-memset.c index ee548f6924..995cedfd26 100644 --- a/string/test-memset.c +++ b/string/test-memset.c @@ -54,45 +54,14 @@ 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) -#ifdef TEST_EXPLICIT_BZERO +# ifdef TEST_EXPLICIT_BZERO IMPL (explicit_bzero, 1) -#else +# else IMPL (bzero, 1) -#endif - -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); -} +# endif #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 */ CHAR * @@ -116,7 +85,7 @@ do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n, int s[n] = sentinel; SIMPLE_MEMSET(s, ~c, n); #ifdef TEST_BZERO - simple_bzero (buf, n); + SIMPLE_MEMSET (buf, 0, n); CALL (impl, s, n); if (memcmp (s, buf, n) != 0 || (space_below && s[-1] != sentinel) diff --git a/string/test-strcasecmp.c b/string/test-strcasecmp.c index 438a9713ac..ee8e978bff 100644 --- a/string/test-strcasecmp.c +++ b/string/test-strcasecmp.c @@ -27,43 +27,9 @@ #include "test-string.h" 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) -static int -simple_strcasecmp (const char *s1, const char *s2) -{ - int ret; - - while ((ret = ((unsigned char) tolower (*s1) - - (unsigned char) tolower (*s2))) == 0 - && *s1++) - ++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/string/test-strcasestr.c b/string/test-strcasestr.c index b73bcfe8b4..ede96e6201 100644 --- a/string/test-strcasestr.c +++ b/string/test-strcasestr.c @@ -21,7 +21,7 @@ #include "test-string.h" -#define STRCASESTR simple_strcasestr +#define STRCASESTR c_strcasestr #define NO_ALIAS #define __strncasecmp strncasecmp #define __strnlen strnlen @@ -29,7 +29,7 @@ static char * -stupid_strcasestr (const char *s1, const char *s2) +simple_strcasestr (const char *s1, const char *s2) { ssize_t s1len = strlen (s1); ssize_t s2len = strlen (s2); @@ -53,8 +53,7 @@ stupid_strcasestr (const char *s1, const char *s2) typedef char *(*proto_t) (const char *, const char *); -IMPL (stupid_strcasestr, 0) -IMPL (simple_strcasestr, 0) +IMPL (c_strcasestr, 0) IMPL (strcasestr, 1) @@ -129,7 +128,7 @@ check1 (void) const char s2[] = "OK"; char *exp_result; - exp_result = stupid_strcasestr (s1, s2); + exp_result = simple_strcasestr (s1, s2); FOR_EACH_IMPL (impl, 0) check_result (impl, s1, s2, exp_result); } diff --git a/string/test-strcat.c b/string/test-strcat.c index b5aab0f66f..86924afb37 100644 --- a/string/test-strcat.c +++ b/string/test-strcat.c @@ -56,7 +56,6 @@ typedef CHAR *(*proto_t) (CHAR *, const CHAR *); CHAR *SIMPLE_STRCAT (CHAR *, const CHAR *); -IMPL (SIMPLE_STRCAT, 0) IMPL (STRCAT, 1) CHAR * diff --git a/string/test-strchr.c b/string/test-strchr.c index 4d2ab5fbeb..b2d146222e 100644 --- a/string/test-strchr.c +++ b/string/test-strchr.c @@ -35,7 +35,6 @@ #ifndef WIDE # ifdef USE_FOR_STRCHRNUL # define STRCHR strchrnul -# define stupid_STRCHR stupid_STRCHRNUL # define simple_STRCHR simple_STRCHRNUL # else # define STRCHR strchr @@ -51,7 +50,6 @@ # include # ifdef USE_FOR_STRCHRNUL # define STRCHR wcschrnul -# define stupid_STRCHR stupid_WCSCHRNUL # define simple_STRCHR simple_WCSCHRNUL # else # define STRCHR wcschr @@ -76,15 +74,6 @@ typedef CHAR *(*proto_t) (const CHAR *, int); CHAR * simple_STRCHR (const CHAR *s, int c) -{ - for (; *s != (CHAR) c; ++s) - if (*s == '\0') - return NULLRET ((CHAR *) s); - return (CHAR *) s; -} - -CHAR * -stupid_STRCHR (const CHAR *s, int c) { size_t n = STRLEN (s) + 1; @@ -94,8 +83,6 @@ stupid_STRCHR (const CHAR *s, int c) return NULLRET ((CHAR *) s - 1); } -IMPL (stupid_STRCHR, 0) -IMPL (simple_STRCHR, 0) IMPL (STRCHR, 1) static int @@ -231,7 +218,7 @@ check1 (void) { CHAR s[] __attribute__((aligned(16))) = L ("\xff"); CHAR c = L ('\xfe'); - CHAR *exp_result = stupid_STRCHR (s, c); + CHAR *exp_result = simple_STRCHR (s, c); FOR_EACH_IMPL (impl, 0) check_result (impl, s, c, exp_result); diff --git a/string/test-strcmp.c b/string/test-strcmp.c index ece03c6d0b..2372e92eaf 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -99,7 +99,6 @@ simple_strcmp (const char *s1, const char *s2) typedef int (*proto_t) (const CHAR *, const CHAR *); -IMPL (SIMPLE_STRCMP, 1) IMPL (STRCMP, 1) static int diff --git a/string/test-strcpy.c b/string/test-strcpy.c index 83b77073bb..898e675226 100644 --- a/string/test-strcpy.c +++ b/string/test-strcpy.c @@ -56,7 +56,6 @@ CHAR *SIMPLE_STRCPY (CHAR *, const CHAR *); -IMPL (SIMPLE_STRCPY, 0) IMPL (STRCPY, 1) CHAR * diff --git a/string/test-strlen.c b/string/test-strlen.c index dd394dadc5..9c3f432134 100644 --- a/string/test-strlen.c +++ b/string/test-strlen.c @@ -37,15 +37,6 @@ typedef size_t (*proto_t) (const CHAR *); -size_t -simple_STRLEN (const CHAR *s) -{ - const CHAR *p; - - for (p = s; *p; ++p); - return p - s; -} - #ifndef WIDE size_t builtin_strlen (const CHAR *p) @@ -55,7 +46,6 @@ builtin_strlen (const CHAR *p) IMPL (builtin_strlen, 0) #endif -IMPL (simple_STRLEN, 0) IMPL (STRLEN, 1) diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c index 1aebc37bb6..24633aa95b 100644 --- a/string/test-strncasecmp.c +++ b/string/test-strncasecmp.c @@ -29,10 +29,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) static int @@ -54,27 +51,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 int check_result (impl_t *impl, const char *s1, const char *s2, size_t n, int exp_result) diff --git a/string/test-strncat.c b/string/test-strncat.c index 86ec101258..4eead42986 100644 --- a/string/test-strncat.c +++ b/string/test-strncat.c @@ -27,8 +27,6 @@ # define STRNCAT strncat # define CHAR char # define UCHAR unsigned char -# define SIMPLE_STRNCAT simple_strncat -# define STUPID_STRNCAT stupid_strncat # define STRLEN strlen # define MEMSET memset # define MEMCPY memcpy @@ -40,8 +38,6 @@ # define STRNCAT wcsncat # define CHAR wchar_t # define UCHAR wchar_t -# define SIMPLE_STRNCAT simple_wcsncat -# define STUPID_STRNCAT stupid_wcsncat # define STRLEN wcslen # define MEMSET wmemset # define MEMCPY wmemcpy @@ -51,25 +47,9 @@ #endif /* WIDE */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); -CHAR *STUPID_STRNCAT (CHAR *, const CHAR *, size_t); -CHAR *SIMPLE_STRNCAT (CHAR *, const CHAR *, size_t); -IMPL (STUPID_STRNCAT, 0) IMPL (STRNCAT, 2) -CHAR * -STUPID_STRNCAT (CHAR *dst, const CHAR *src, size_t n) -{ - CHAR *ret = dst; - while (*dst++ != '\0'); - --dst; - while (n--) - if ((*dst++ = *src++) == '\0') - return ret; - *dst = '\0'; - return ret; -} - static void do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n) { diff --git a/string/test-strncmp.c b/string/test-strncmp.c index 3e35142548..693ab4d6c9 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -88,7 +88,6 @@ simple_strncmp (const char *s1, const char *s2, size_t n) typedef int (*proto_t) (const CHAR *, const CHAR *, size_t); -IMPL (SIMPLE_STRNCMP, 0) IMPL (STRNCMP, 1) diff --git a/string/test-strncpy.c b/string/test-strncpy.c index 4ae08abe44..e10179ba95 100644 --- a/string/test-strncpy.c +++ b/string/test-strncpy.c @@ -46,48 +46,14 @@ # endif /* WIDE */ # include "test-string.h" # ifndef WIDE -# define SIMPLE_STRNCPY simple_strncpy -# define STUPID_STRNCPY stupid_strncpy # define STRNCPY strncpy # else -# define SIMPLE_STRNCPY simple_wcsncpy -# define STUPID_STRNCPY stupid_wcsncpy # define STRNCPY wcsncpy # endif /* WIDE */ -CHAR *SIMPLE_STRNCPY (CHAR *, const CHAR *, size_t); -CHAR *STUPID_STRNCPY (CHAR *, const CHAR *, size_t); -IMPL (STUPID_STRNCPY, 0) -IMPL (SIMPLE_STRNCPY, 0) IMPL (STRNCPY, 1) -CHAR * -SIMPLE_STRNCPY (CHAR *dst, const CHAR *src, size_t n) -{ - CHAR *ret = dst; - while (n--) - if ((*dst++ = *src++) == '\0') - { - while (n--) - *dst++ = '\0'; - return ret; - } - return ret; -} - -CHAR * -STUPID_STRNCPY (CHAR *dst, const CHAR *src, size_t n) -{ - size_t nc = STRNLEN (src, n); - size_t i; - - for (i = 0; i < nc; ++i) - dst[i] = src[i]; - for (; i < n; ++i) - dst[i] = '\0'; - return dst; -} #endif /* !STRNCPY_RESULT */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); diff --git a/string/test-strnlen.c b/string/test-strnlen.c index 726c630db2..bcbbe87925 100644 --- a/string/test-strnlen.c +++ b/string/test-strnlen.c @@ -30,7 +30,6 @@ # define CHAR char # define BIG_CHAR CHAR_MAX # define MIDDLE_CHAR 127 -# define SIMPLE_STRNLEN simple_strnlen #else # include # define STRNLEN wcsnlen @@ -38,24 +37,12 @@ # define CHAR wchar_t # define BIG_CHAR WCHAR_MAX # define MIDDLE_CHAR 1121 -# define SIMPLE_STRNLEN simple_wcsnlen #endif /* !WIDE */ typedef size_t (*proto_t) (const CHAR *, size_t); -size_t SIMPLE_STRNLEN (const CHAR *, size_t); -IMPL (SIMPLE_STRNLEN, 0) IMPL (STRNLEN, 1) -size_t -SIMPLE_STRNLEN (const CHAR *s, size_t maxlen) -{ - size_t i; - - for (i = 0; i < maxlen && s[i]; ++i); - return i; -} - static void do_one_test (impl_t *impl, const CHAR *s, size_t maxlen, size_t exp_len) { diff --git a/string/test-strpbrk.c b/string/test-strpbrk.c index 05fd81e0fc..eb13621090 100644 --- a/string/test-strpbrk.c +++ b/string/test-strpbrk.c @@ -46,48 +46,15 @@ # ifndef WIDE # define STRPBRK strpbrk -# define SIMPLE_STRPBRK simple_strpbrk -# define STUPID_STRPBRK stupid_strpbrk # else # include # define STRPBRK wcspbrk -# 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) -CHAR * -SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej) -{ - const CHAR *r; - CHAR c; - - while ((c = *s++) != '\0') - for (r = rej; *r != '\0'; ++r) - if (*r == c) - return (CHAR *) s - 1; - 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/string/test-strrchr.c b/string/test-strrchr.c index a610200c11..16712ed69d 100644 --- a/string/test-strrchr.c +++ b/string/test-strrchr.c @@ -26,14 +26,12 @@ #ifdef WIDE # include -# define SIMPLE_STRRCHR simple_wcsrchr # define STRRCHR wcsrchr # define CHAR wchar_t # define UCHAR wchar_t # define BIG_CHAR WCHAR_MAX # define SMALL_CHAR 1273 #else -# define SIMPLE_STRRCHR simple_strrchr # define STRRCHR strrchr # define CHAR char # define UCHAR unsigned char @@ -42,23 +40,9 @@ #endif typedef CHAR *(*proto_t) (const CHAR *, int); -CHAR *SIMPLE_STRRCHR (const CHAR *, int); -IMPL (SIMPLE_STRRCHR, 0) IMPL (STRRCHR, 1) -CHAR * -SIMPLE_STRRCHR (const CHAR *s, int c) -{ - const CHAR *ret = NULL; - - for (; *s != '\0'; ++s) - if (*s == (CHAR) c) - ret = s; - - return (CHAR *) (c == '\0' ? s : ret); -} - static void do_one_test (impl_t *impl, const CHAR *s, int c, CHAR *exp_res) { diff --git a/string/test-strspn.c b/string/test-strspn.c index 1680cb7828..494e98efad 100644 --- a/string/test-strspn.c +++ b/string/test-strspn.c @@ -28,8 +28,6 @@ # define STRSPN strspn # define CHAR char # define UCHAR unsigned char -# define SIMPLE_STRSPN simple_strspn -# define STUPID_STRSPN stupid_strspn # define STRLEN strlen # define STRCHR strchr # define BIG_CHAR CHAR_MAX @@ -39,8 +37,6 @@ # define STRSPN wcsspn # define CHAR wchar_t # define UCHAR wchar_t -# define SIMPLE_STRSPN simple_wcsspn -# define STUPID_STRSPN stupid_wcsspn # define STRLEN wcslen # define STRCHR wcschr # define BIG_CHAR WCHAR_MAX @@ -48,47 +44,9 @@ #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) -size_t -SIMPLE_STRSPN (const CHAR *s, const CHAR *acc) -{ - const CHAR *r, *str = s; - CHAR c; - - while ((c = *s++) != '\0') - { - for (r = acc; *r != '\0'; ++r) - if (*r == c) - break; - if (*r == '\0') - return s - str - 1; - } - 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) { diff --git a/string/test-strstr.c b/string/test-strstr.c index 7f610f4cac..397c22c0fd 100644 --- a/string/test-strstr.c +++ b/string/test-strstr.c @@ -21,14 +21,14 @@ #include "test-string.h" -#define STRSTR simple_strstr +#define STRSTR c_strstr #define libc_hidden_builtin_def(arg) /* nothing */ #define __strnlen strnlen #include "strstr.c" static char * -stupid_strstr (const char *s1, const char *s2) +simple_strstr (const char *s1, const char *s2) { ssize_t s1len = strlen (s1); ssize_t s2len = strlen (s2); @@ -52,8 +52,7 @@ stupid_strstr (const char *s1, const char *s2) typedef char *(*proto_t) (const char *, const char *); -IMPL (stupid_strstr, 0) -IMPL (simple_strstr, 0) +IMPL (c_strstr, 0) IMPL (strstr, 1) @@ -130,7 +129,7 @@ check1 (void) const char s2[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"; char *exp_result; - exp_result = stupid_strstr (s1, s2); + exp_result = simple_strstr (s1, s2); FOR_EACH_IMPL (impl, 0) check_result (impl, s1, s2, exp_result); } @@ -163,7 +162,7 @@ check2 (void) char *s2_page_cross = (void *) buf2 + page_size_real - 8; strcpy (s2_page_cross, s2_stack); - exp_result = stupid_strstr (s1_stack, s2_stack); + exp_result = simple_strstr (s1_stack, s2_stack); FOR_EACH_IMPL (impl, 0) { check_result (impl, s1_stack, s2_stack, exp_result); @@ -201,7 +200,7 @@ pr23637 (void) /* Ensure we don't match at the first 'x'. */ h[0] = 'x'; - char *exp_result = stupid_strstr (h, n); + char *exp_result = simple_strstr (h, n); FOR_EACH_IMPL (impl, 0) check_result (impl, h, n, exp_result); }