From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 758233858C60 for ; Thu, 2 Feb 2023 12:01:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 758233858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1685cf2003aso2075605fac.12 for ; Thu, 02 Feb 2023 04:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=xQkpYm8zuhk3IQoI7fzpYcthpzKXFGEKvOlcFAuYg2Q=; b=Xv/yYqO1MIJYJYFDc3ltyuqOBHZ0yb50DYnJOiZYWJTrCV983gNNz4AFdzLEFKaWZ5 6u6H9bC4PyNMMVjYctvVmXma19iZF3m+Kas+vIJtyWwbLSPYpJFqiYYpg3gfscx9YDSx acVbpgb6LCJPUuIRPx55C7Sox7e47MTc6bB/MRsBppYYgtZ1ZZ8WLvL2pEIp3Tv1khrv AxeY/vks5EeZNlTu/MYTmmkP5brW4GgX+v9f93EWKwohN2LyRlrnmfvovFl+FwcWL5hx WYK124XrF3d+uSOAxd4+dKQfJTZkNKPNUwQw7IT2fyXI8/vcmKT4wRrFr/6QhsEC2pxC uVXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xQkpYm8zuhk3IQoI7fzpYcthpzKXFGEKvOlcFAuYg2Q=; b=M4Uhrg/2HR4u8H6ISbxFRXaI/7kMaq1WmBS+cDI0DVMHzVH5NQsjZLTc0etWG28b8z G8uZ4sSiwF9CsPYIazYfKP/Bn7nLtgvMBoqUQUeoIwv6grWgFzD3tRtJK2RiDhzivRsz vgfX7fQ9WKQi3yrehyeOh7pRhDgxN+9uJ053wSL+aLAgnq1a1MN5wex0mzUGxFKzUO5e Om1uXpRXDOJiatgZ6ume0YV7/uV5Zm426Z4ngT482CgzPsAqQ9WS3obsmUqlF6Iwxfhh xN2BeFZ/3c+4BHTzu7HYAvH3XBdBXcO8M1eeasP8eCWNiLQLZU9yqH3KQuNEHUPWQFbC 7pSw== X-Gm-Message-State: AO0yUKXZBjeSvCmNZofXTdjiCgFdouq0kga4XliEa2VRwwGhIwYZoev/ 8xgq7VlWia1m2XGPhVSEGGY0QQ== X-Google-Smtp-Source: AK7set9GiSjDYH4IBGJM0bngbY+G3DoS9J2ddbzEbiY5Jqx0lsQOSoBoEcqzKNAwzYTu9v2JPgCOQg== X-Received: by 2002:a05:6870:d610:b0:163:1d4a:da10 with SMTP id a16-20020a056870d61000b001631d4ada10mr3516490oaq.34.1675339298717; Thu, 02 Feb 2023 04:01:38 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c2:1887:5d31:5c36:95c5:9e2e? ([2804:1b3:a7c2:1887:5d31:5c36:95c5:9e2e]) by smtp.gmail.com with ESMTPSA id ck14-20020a056830648e00b0068664355604sm9098238otb.22.2023.02.02.04.01.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Feb 2023 04:01:37 -0800 (PST) Message-ID: <56df2e9b-cbe0-0ebb-45f1-60d3ac1e21cc@linaro.org> Date: Thu, 2 Feb 2023 09:01:35 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH v11 09/29] string: Improve generic strncmp Content-Language: en-US To: Noah Goldstein Cc: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao References: <20230201170406.303978-1-adhemerval.zanella@linaro.org> <20230201170406.303978-10-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 List-Id: On 01/02/23 16:42, Noah Goldstein wrote: >> +/* Compare no more than N characters of S1 and S2, >> + returning less than, equal to or greater than zero >> + if S1 is lexicographically less than, equal to or >> + greater than S2. */ >> +int >> +STRNCMP (const char *p1, const char *p2, size_t n) >> +{ >> + /* Handle the unaligned bytes of p1 first. */ >> + uintptr_t a = MIN (-(uintptr_t)p1 % sizeof(op_t), n); >> + int diff = 0; >> + for (int i = 0; i < a; ++i) >> + { >> + unsigned char c1 = *p1++; >> + unsigned char c2 = *p2++; >> + diff = c1 - c2; >> + if (c1 == '\0' || diff != 0) >> + return diff; >> + } >> + if (a == n) >> + return diff; > > NIT: return 0 IMO Ack.