From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id DC2A63858CDA for ; Tue, 20 Feb 2024 11:56:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC2A63858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC2A63858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708430212; cv=none; b=Z6k/37zCwrNNHC1fMLkBDzNnvi8ApSxS2atqoJAo+W4csTNGdSGA3MIDa1nWJ0ZfdslDEdN3aZ65o/MdWiqixn1FqFAZU8D91D5f50fuuwZoE0jkIpyJ86QydntQssk3Zuti6JJndcJKNrrlq+62QFMLL85z6I+Fzj1AbmCP8/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708430212; c=relaxed/simple; bh=3VfDYQFpoMbEiO/EpTv1AlBYiVqK2uh+hJap25+8y5k=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=dZ+o8ZUb2JIBQVNdE6rC3/3VVN8g+8Nd/60/9E7fIUsJDzOotcD20t9upGyQX/5RiUHnyCOGG0aGj++kB+vZ5VgHfJk59434Kfa91lyAeM8af8/Vd1ooE/Bws7Ik3z0+/kTYF2FuvVqh/oy13/kjht74prh6WY7dOJmfXYZ0iro= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso4128608a12.2 for ; Tue, 20 Feb 2024 03:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708430209; x=1709035009; darn=sourceware.org; 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=sXtSsCMyI3DBuKdDl77LVc9aky+6T/Ydg05rGOAbEH0=; b=OatkAKCt8WSc2BJFNo0d4UNXdrGT+yahhu3Bu0xphJopb5F9dkKxjSTz561COV5CEf yWtSpTTLnQUqYtgW/9ohoqPWdEVoK8hV8MgaIOqJjUGAiv6lNe055SjTeWn/GoeKH1xw CYY6QHNiUiv7tfUgFbFEV+j7cp0IvIZays3Bs8az84JI1h0eRIV1prvi0pIkxjnJ3F1k VhccXI4dxr7wcmOBjupZuvr2SkR/mUn9tOqviVt+6zI1B5CD37BlNGHdcXo+Y90+I5/z mGi5QpS1+X9YKg779Pc8P4KdK2Wii1ySj0qUkRsiesXxbDcVulqy1eircRln56QO5pB6 QaVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708430209; x=1709035009; 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=sXtSsCMyI3DBuKdDl77LVc9aky+6T/Ydg05rGOAbEH0=; b=q2EU8Z7nu6y9MnQgMRDZMSKqcfjQjoNNnmpHzb/H8P/n3115mct8F8Vc7VWeIDQIfz 3l2eEVbK0fECgj71+GTUe+6EFRkSTphdg+tuatUcr9qc2rHCYl337HIQjIzqvsGuGnKn 7QkBINYxem+TDcOGSTQ8sQpQyjXEarLK85Mpqi8lk+b1o7UW9PmfBDi1ma6ciFg8+1jn 41s4PqZpWtJb6yY+eOBQ9Udy+x3/VJxLVbBRk+kaAxYlOWo7mYgMDUvnvjYEmVWbPsnE q8U2RcpnkOD4UfM7yfdC9Ap7Br3vo6M8OHYQqnDvotqab2D9JFXal13cEBCylMkGQF6U 0IAw== X-Gm-Message-State: AOJu0YysFCMdT4dOPdfYzYEncA+3z1cgxj6+WCT5MaongoBtoLruBOpx YDuL2rODpT7ZTz5K8n7VlwhFYFi+KUj0dsGyR31MEdDI9O93cEa4DKnAPN6VFDBxhmIZuuzWGxZ o X-Google-Smtp-Source: AGHT+IGYCbV3tXejFZXmVrudTIdscCFNEnQYcKmdAglKD6cAOjpipVvfsuWG6RYu+nNuIr3q4foeug== X-Received: by 2002:a05:6a20:9f0a:b0:19c:6297:13b1 with SMTP id mk10-20020a056a209f0a00b0019c629713b1mr10779083pzb.58.1708430208644; Tue, 20 Feb 2024 03:56:48 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:8177:94f3:b846:f4ad:67a9? ([2804:1b3:a7c0:8177:94f3:b846:f4ad:67a9]) by smtp.gmail.com with ESMTPSA id n7-20020aa79847000000b006e43c263cf1sm4694069pfq.185.2024.02.20.03.56.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 03:56:47 -0800 (PST) Message-ID: <900b4b0a-e1d2-44e6-bfc9-3e41e1999122@linaro.org> Date: Tue, 20 Feb 2024 08:56:45 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865) Content-Language: en-US To: Noah Goldstein Cc: libc-alpha@sourceware.org References: <20240219204502.3095343-1-adhemerval.zanella@linaro.org> <20240219204502.3095343-4-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 19/02/24 21:15, Noah Goldstein wrote: > On Mon, Feb 19, 2024 at 8:45 PM Adhemerval Zanella > wrote: >> + >> +/* Hash character pairs so a small shift table can be used. All bits of >> + p[0] are included, but not all bits from p[-1]. So if two equal hashes >> + match on p[-1], p[0] matches too. Hash collisions are harmless and result >> + in smaller shifts. */ >> +#define hash2(p) (((size_t)(p)[0] - ((size_t)(p)[-1] << 3)) % sizeof (shift)) >> >> wchar_t * >> wcsstr (const wchar_t *haystack, const wchar_t *needle) >> { > any issue with just doing? > ``` > memmem(haystack, sizeof(wchar_t) * wcslen(haystack), needle, > sizeof(wchar_t) * wcslen(needle)) > ``` None at all, in fact this is a better simplification. I will update the patch.