From patchwork Thu Feb 2 18:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 64186 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A95783884508 for ; Thu, 2 Feb 2023 18:20:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A95783884508 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675362028; bh=kzGuyfJWcNU2IX1SBElhnkD+5hzdocahp3CTjowzN0Y=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=MFBdLJecgi06EkBj8s/7Opxp5l41wQFJsSLzpI0ZUVpIWGEyVoNNUw42Me53vneQX NZjPjR65/16t19E9cNAy4FUai7NUlXXzn+78xrgvxr8pbqOrxVjxVw4MZVio1MRmkR 2WiEAL+iUx2cw6hrqc1lAY4cufzauli8y7saM75M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id ABC7B383A330 for ; Thu, 2 Feb 2023 18:12:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABC7B383A330 Received: by mail-oi1-x230.google.com with SMTP id r9so2111131oig.12 for ; Thu, 02 Feb 2023 10:12:54 -0800 (PST) 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=kzGuyfJWcNU2IX1SBElhnkD+5hzdocahp3CTjowzN0Y=; b=rq0qOqozLLtiPp6qkcU+bPSKlMaSA1E/4IR0wuB+Q9JcxdwriWbGu7szteWkADcFWe FCMoB4fzuN0LkSVJHTbhk2afMejgnVS2eWv5ZsCZo7VPYYSN13WGke3WqmvL8vsuiOSk FbaQxjX74j3bxr890oeVhom6JjQqaj9SDewZ/mU9+E/n9/Ug4fqkWaY2Kx1ZeKKTDZ9g /2IjlS7ZFQYyq9nMyG4F+UC71sCzCCmdCmKuBsf1WXJ1LyyxqZ5isO5j2So7t5F7v+Mz luPEj0rq6p+rG6PWb3M7PsIT3iaS8bkmmidx1mmMWlDeiRAjCbnybGPkGCCnVwYGocFH t43w== X-Gm-Message-State: AO0yUKUwZohPnxVLYxe0dOSGQz7rtpqUw4rYePUwpjKK5kLa+YDEYb4+ A55WZX6mbpfCDg8r96rmxQ/dx0RQkN2uRyspkwg= X-Google-Smtp-Source: AK7set9vLE3kgrPWqSXjbU7BcYCGbMY4PiMPank69X1Ts/AUhcdvTMsZNTYtFayO5qBXT+rUn1VQ/Q== X-Received: by 2002:aca:a9cc:0:b0:36c:d1c7:ba37 with SMTP id s195-20020acaa9cc000000b0036cd1c7ba37mr3138938oie.41.1675361573390; Thu, 02 Feb 2023 10:12:53 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:52 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 24/31] string: Hook up the default implementation on test-strchr Date: Thu, 2 Feb 2023 15:11:42 -0300 Message-Id: <20230202181149.2181553-25-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 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 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Also remove the simple_STRCHR, which can be easily replaced. Reviewed-by: Richard Henderson --- 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);