From patchwork Wed Feb 1 17:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64104 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 018A7394882E for ; Wed, 1 Feb 2023 17:07:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 018A7394882E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271264; bh=WlwRBvpBuUGYAO3ObfLqIDIYorlFz4kL9P0jSfzvCFk=; 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=eDODEh9QrimVryphYy8QG91p5ebFRd/e1yqPZhRXxd447NEUUdKWdNzTVskBpyuPt gzibrHziPnQAOYlxQbwdkgokpx+TFoXtMn16y38sUJ2AoQEmP3EQc4vagTLWaUQTcl MBSnMeEeEyCtP6FcTYLTLchjqZ5HyqvZBjXPGS30= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-16346330067so24359679fac.3 for ; Wed, 01 Feb 2023 09:05:12 -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=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) 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 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 Netto 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);