From patchwork Tue Jan 17 20:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 63302 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 C87FC3899035 for ; Tue, 17 Jan 2023 20:05:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C87FC3899035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985910; bh=iIZDKGZN8632x4Sc4VqyImn12gfKSlq5E3Nzmocs5JM=; 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=NLXvEATSUCQ8YjbIXefxRkf0GVyPM3WbCSfxawtAJmX0MKVwve0ky+OvyXkkttC2j WhZSzZke0JCpIJZAFQIgx8alg2gu5uvvHaYdCWAH+HHiAufyb/1+BUwVO7m45+Rik/ gZ4UqdEdfEqD1uywbSCkkoMdB+K9yX5FDPmdb9RI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id B92C73858C2C for ; Tue, 17 Jan 2023 20:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B92C73858C2C Received: by mail-oi1-x233.google.com with SMTP id o66so26870958oia.6 for ; Tue, 17 Jan 2023 12:00:58 -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=iIZDKGZN8632x4Sc4VqyImn12gfKSlq5E3Nzmocs5JM=; b=ThkKePj0c6wApLrX/sw0pPIXA+xcLjJMJGK1TvZQkqDkmc8N/EPjPU/GeS2h1Takwi lXu3a/w8OKfIbMbVad/EbIY/XCzf2PzE3tlmUFmp/QQR1qsGvRCO/Ii8SYGBNn5i4tOD GbR21P3RFRMdgRBP6ZzGPUE2pdYOC/NO4d0vrQK3Yj/8ZFbGqu9vyNuJJkjE8DX8uHZB Jv+jjB5jftpPhKSvnPeKSNJdP/InXpBfn8lFlyHdNwfDRM6cv+439M8Axn2vSn4R3wQ+ gvhcOb3mFFa4E3Ny1Jq+M9uKjvD6lCrq0Gfk/0abyFqqnwU+dgxNwkPEzdKTnEAufFIB Qfew== X-Gm-Message-State: AFqh2kpEkLKyA+Z+Dow7HhtnOQq3H5kk0lFow3FXtDxhmwL2EfM7Kra/ zRhDLJViOJXufpP8YGaU3JPuhT3Veo/k/rsYFnU= X-Google-Smtp-Source: AMrXdXsJHQGCrtSjCW893wYv2zmdvqd3N2Odammgeo5C/DcsNo0C+WiRAgYRgJXjoXs8uP9Rg74D4A== X-Received: by 2002:a05:6808:16a6:b0:364:8f2c:1861 with SMTP id bb38-20020a05680816a600b003648f2c1861mr2652735oib.4.1673985657921; Tue, 17 Jan 2023 12:00:57 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:57 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 19/22] string: Hook up the default implementation on test-strchr Date: Tue, 17 Jan 2023 17:00:11 -0300 Message-Id: <20230117200014.1299923-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-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. --- string/test-strchr.c | 47 ++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/string/test-strchr.c b/string/test-strchr.c index 323c844d21..e6f3b3b243 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,35 @@ 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 +# define WCSCHR __wcschr_default +# include "wcsmbs/wcschr.c" +# define STRCHR_DEFAULT WCSCHR +#endif +IMPL (STRCHR_DEFAULT, 1) + static int check_result (impl_t *impl, const CHAR *s, int c, const CHAR *exp_res) { @@ -219,7 +232,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);