From patchwork Wed Feb 1 17:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1735795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=dTcDUpTm; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6T3t23f6z1yhq for ; Thu, 2 Feb 2023 04:11:54 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 217A6382E6A2 for ; Wed, 1 Feb 2023 17:11:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 217A6382E6A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271512; bh=JRmZ2V3BqZ/QE9sTw/u6YDP8y8zkOWJrmkIgxVMn3T0=; 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=dTcDUpTm5g/I7iaZpR2GgCW4A6BXsrzBTijpBnOcoTY3zPSLuZ2wzPP1lvKLpZP8K dDG6Mu9yTy7BZmkY1DFl7oW01kjtouVOzFb9vIIVTlxUX9D2tzCliuayCUymAaDq8c I+KwJfuqdAjteqSyuS8Znzb47QAaiGhgq0XpyjZ8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 493F9383FBA2 for ; Wed, 1 Feb 2023 17:05:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 493F9383FBA2 Received: by mail-ot1-x32d.google.com with SMTP id e12-20020a0568301e4c00b0068bc93e7e34so3545712otj.4 for ; Wed, 01 Feb 2023 09:05:24 -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=JRmZ2V3BqZ/QE9sTw/u6YDP8y8zkOWJrmkIgxVMn3T0=; b=3cZpXPvHsWVmzCvLCIGN06X79q+wPSlvmrWgGvb0FDMUAaK4kNisRbWMqppMZPlmry j6mmb4vgZTtgi8E68xPTu7KYjmTs9NNwyIIXn7+DA5x9Q/j1GGv2F8MpN07mz7X0BaCu iuxbrKwbyoryCpbBEfak3v8HSzA+jsTBt4a8+Tf1n7IweFHkZSrrhWIoZjS7vI+wWlAv RADvfzhuvc39dVhR4RtSQOuG/d08ghaWEAhxrmYyQL8SsiQ9bpV17/OQEAoBQ83bmHsQ fgZobpGrjGsMnxLKc2QX08k2s8yNvMfsyeS5NROUmyJsDVUv9UOAm16ENdGcwFPDfGgU +Jbw== X-Gm-Message-State: AO0yUKUdktOFUjbWiHYoR5CIb96JY/PymTPdIUUqwsijP02ZP5jofaK4 7SoIrGx2dTK424TFCwDI8DPpB0fI1dRWKEeMXRQ= X-Google-Smtp-Source: AK7set94mvPMAeFiN1l2RkoLPObIMtgRA31xh06SPzgK4rpFGnuCMPgRwx9jNTzx7E6wWzG11OhF6w== X-Received: by 2002:a05:6830:40a9:b0:68b:dddf:a26b with SMTP id x41-20020a05683040a900b0068bdddfa26bmr1523647ott.10.1675271123353; Wed, 01 Feb 2023 09:05:23 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:05:22 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 28/29] string: Hook up the default implementation on test-memchr Date: Wed, 1 Feb 2023 14:04:05 -0300 Message-Id: <20230201170406.303978-29-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 Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" And remove SIMPLE_MEMCHR, which is not used anywhere. Reviewed-by: Richard Henderson --- string/test-memchr.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/string/test-memchr.c b/string/test-memchr.c index 862094ef0b..0daecab537 100644 --- a/string/test-memchr.c +++ b/string/test-memchr.c @@ -30,7 +30,6 @@ # define MEMCHR memchr # define CHAR char # define UCHAR unsigned char -# define SIMPLE_MEMCHR simple_memchr # define BIG_CHAR CHAR_MAX # define SMALL_CHAR 127 #else @@ -38,7 +37,6 @@ # define MEMCHR wmemchr # define CHAR wchar_t # define UCHAR wchar_t -# define SIMPLE_MEMCHR simple_wmemchr # define BIG_CHAR WCHAR_MAX # define SMALL_CHAR 1273 #endif /* WIDE */ @@ -47,15 +45,26 @@ typedef CHAR *(*proto_t) (const CHAR *, int, size_t); IMPL (MEMCHR, 1) -/* Naive implementation to verify results. */ -CHAR * -SIMPLE_MEMCHR (const CHAR *s, int c, size_t n) -{ - while (n--) - if (*s++ == (CHAR) c) - return (CHAR *) s - 1; - return NULL; -} +/* Also check the generic implementation. */ +#undef MEMCHR +#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 MEMCHR __memchr_default +# include "string/memchr.c" +# define MEMCHR_DEFAULT MEMCHR +#else +# define WMEMCHR __wmemchr_default +# include "wcsmbs/wmemchr.c" +# define MEMCHR_DEFAULT WMEMCHR +#endif +IMPL (MEMCHR_DEFAULT, 1) static void do_one_test (impl_t *impl, const CHAR *s, int c, size_t n, CHAR *exp_res)