From patchwork Fri Jan 20 21:16:18 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: 63514 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 C4B6B383FBA7 for ; Fri, 20 Jan 2023 21:22:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4B6B383FBA7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674249745; 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=Vc0jRH2++iS92N5lRaSKvWAXPQMQMcZ59Md1/J2DYmIYIO+4+XbifMujxa6dQabLM s78Hg0z1X9mtBst2ZTWjiTnN8P/epXYJ1g5eAx+9Nek6KSSoyPHgH+AgeIhpRyXEYe lhMDmkv4l2dSP2cagJb56FY32/17k97HU9eOnmwE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id CB337385841E for ; Fri, 20 Jan 2023 21:17:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB337385841E Received: by mail-ot1-x32f.google.com with SMTP id f88-20020a9d03e1000000b00684c4041ff1so3819431otf.8 for ; Fri, 20 Jan 2023 13:17:14 -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=tvkkkKEb7wEQw45Z+7wroAg50e3u3a0wpRntEvPaPGU6K0kOolsCBC5NRatwbkADDN ogpgq36TW5Rj0nokyZTOqV972Tlr5OebbFmt3ekqNwqDUDFx4CVkszNd5BtOpRTjpVC/ BalbuVdOTRGy1yQTs2NhYHgCPGGTEfrOd99RqigxBOYCr3GS/gIv9H8SoDeAmnEh+kl5 ubbmljy7fQpoFtoic+U+AaBbrI0Mq1j/MuR9pYCqp+iRjQS9V1KcIikFyMCwt28XkyYn yBAtqdjys8bSJk6CIIPdQQPxzEA7SORUqYiq4BVBJBHOyFsE+d5edokfFR4yW/yFBNU9 maUQ== X-Gm-Message-State: AFqh2krVPmd6/S+bFghljTbLXjYZnfzXoTYqeS/tmGV4m5xQGXdZFzzw kMZUHxM1blRQ8KmYRGxydC2fykwewK72YUglSIw= X-Google-Smtp-Source: AMrXdXtAxNXrfEjni/SzaqGEAGsYbs3PHmucWHvYxQt7Wsyx6ZWjnm23Dw7JkuPT4cklQXhFaf17Gw== X-Received: by 2002:a05:6830:1482:b0:684:a027:f831 with SMTP id s2-20020a056830148200b00684a027f831mr7425988otq.13.1674249433498; Fri, 20 Jan 2023 13:17:13 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:7e99:f284:be2f:4ee5:d122]) by smtp.gmail.com with ESMTPSA id d18-20020a056830139200b00686467f920bsm6937432otq.48.2023.01.20.13.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 13:17:12 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v10 20/24] string: Hook up the default implementation on test-strchr Date: Fri, 20 Jan 2023 18:16:18 -0300 Message-Id: <20230120211622.3445279-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120211622.3445279-1-adhemerval.zanella@linaro.org> References: <20230120211622.3445279-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. --- 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);