From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id 4885E38493D4 for ; Wed, 1 Feb 2023 17:05:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4885E38493D4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-16346330067so24359679fac.3 for ; Wed, 01 Feb 2023 09:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WlwRBvpBuUGYAO3ObfLqIDIYorlFz4kL9P0jSfzvCFk=; b=NG+jrh/Mt7AxTl8v1OowUiCLIfgLRaud+lBPWX9fbdVTXmlpgKII0j0MvYYtkI5iqw jLISJcOIyETj1Wl4VhNwFFbeVBoI0dMMJRrE+sVC8Qkrs17gLiYivKd1Dt6+xpj9zIis 7PwuWJXbL9+CJWBPtO3REXCL2h2ZunqG7erhyhmiyCg3DhPb82/rj9TbmM/qm576OX/U FzfBLZ5UW6A1GK+Whqa6/CgDf8r/HZ8qO4e2JIHxd0muoY5D3yfILgsXD39U+YiKKHhR JDaWLkQcC/GVozPvp9Mwp7m/2vDaMKU98R/LMAIRnSzUnzD7PtOlY72gE4G2qTsrr6Y4 BcbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WlwRBvpBuUGYAO3ObfLqIDIYorlFz4kL9P0jSfzvCFk=; b=QEgzM84twyCaQ+HTNNkNaEfJ8e8TFuutvI/lpc0FhF5XnAE8h+nDMl4olMwO9M+o9j gBnVgCto9nX4rbRpssjBJFjIs6BNs+Rv/DN74UxGKttcCmkfIJ6kDaLTh0TNQceu0ssh yj9NbqtDlEvUmiXD+5PfgGBWhpChhwdb1HV/t2r/OxdO5FfA7EP3siR4Spx8MPWOlFZZ LCxk3R/stTAQ2DdOLwVeTRCnKxHMLo9eeMU1OBzhhko3klq3hnc0YwjVkd24wrm4nRCD 0KJq0Jy6PoFKjUTzTV/bqCXDqHIlOBIagQV28qRgw7D2ocdH0sb3LhxbMmMzdNBJ34i+ Mg4A== X-Gm-Message-State: AO0yUKWXDl3MJlS3LRZIGwu5mZH+3a7m5XfUFSIakoYtOvvSaf684Ahv nf+PlNHDuxPAAtHXos77ihlVDqwnDmGzXPFV7S4= X-Google-Smtp-Source: AK7set+tURo+IpQmdjgI/JvPVZ4ogTmyXxKKwTXi4OPEfprF6WP66z+qr7FICHwD4KRJBGE1JhkzTQ== X-Received: by 2002:a05:6871:411:b0:163:cd07:a5a5 with SMTP id d17-20020a056871041100b00163cd07a5a5mr1431652oag.56.1675271111199; Wed, 01 Feb 2023 09:05:11 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:05:10 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 23/29] string: Hook up the default implementation on test-strchr Date: Wed, 1 Feb 2023 14:04:00 -0300 Message-Id: <20230201170406.303978-24-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Also remove the simple_STRCHR, which can be easily replaced. --- string/test-strchr.c | 53 +++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/string/test-strchr.c b/string/test-strchr.c index 323c844d21..933fc0bbba 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 simple_STRCHR simple_STRCHRNUL # else # define STRCHR strchr # endif /* !USE_FOR_STRCHRNUL */ @@ -50,7 +49,6 @@ # include # ifdef USE_FOR_STRCHRNUL # define STRCHR wcschrnul -# define simple_STRCHR simple_WCSCHRNUL # else # define STRCHR wcschr # endif /* !USE_FOR_STRCHRNUL */ @@ -72,20 +70,41 @@ typedef CHAR *(*proto_t) (const CHAR *, int); -/* Naive implementation to verify results. */ -CHAR * -simple_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 (STRCHR, 1) +/* Also check the generic implementation. */ +#undef STRCHR +#undef weak_alias +#define weak_alias(a, b) +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(a) +#undef libc_hidden_def +#define libc_hidden_def(a) +#undef libc_hidden_weak +#define libc_hidden_weak(a) +#ifndef WIDE +# define STRCHRNUL __strchrnul_default +# include "string/strchrnul.c" +# ifndef USE_FOR_STRCHRNUL +# define STRCHR __strchr_default +# include "string/strchr.c" +# define STRCHR_DEFAULT STRCHR +# else +# define STRCHR_DEFAULT STRCHRNUL +# endif +#else +# ifndef USE_FOR_STRCHRNUL +# define WCSCHR __wcschr_default +# include "wcsmbs/wcschr.c" +# define STRCHR_DEFAULT WCSCHR +# else +# define WCSCHRNUL __wcschrnul_default +# include "wcsmbs/wcschrnul.c" +# define STRCHR_DEFAULT WCSCHRNUL +# endif +#endif +IMPL (STRCHR_DEFAULT, 1) + static int check_result (impl_t *impl, const CHAR *s, int c, const CHAR *exp_res) { @@ -219,7 +238,11 @@ check1 (void) { CHAR s[] __attribute__((aligned(16))) = L ("\xff"); CHAR c = L ('\xfe'); - CHAR *exp_result = simple_STRCHR (s, c); +#ifndef USE_FOR_STRCHRNUL + CHAR *exp_result = NULL; +#else + CHAR *exp_result = s + STRLEN (s); +#endif FOR_EACH_IMPL (impl, 0) check_result (impl, s, c, exp_result); -- 2.34.1