From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 4F9DC221BF for ; Thu, 29 Feb 2024 01:02:29 +0100 (CET) Received: (qmail 18383 invoked by uid 550); 28 Feb 2024 23:58:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 18345 invoked from network); 28 Feb 2024 23:58:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709164936; x=1709769736; darn=lists.openwall.com; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lQp1yJYYew+gDCE/dpzaKAVFurYaETLwiq62WRYT+ZU=; b=jFWruwK1FAxuWiEmSlaEocZ+GUOcix/V23XluTscg+PdD7yKVwlCedypo1ycHUJPuY MCTV6Ho/82Wp90Op3mEb0JluKS5ACF7QaY92kisMnvGHb0RQnZyV/WcJVdXdgK0XhYLM 2brGASngsvodcmgU9iNa0EP2zjXjLCsBOo4KuEn88m9oPocTLtk+Fh3LHTbFP9357m1y YvkQ+Zv6O140ZG7zxmAj9Vy/iRkTaBqJv5ePv3xRgQMPx2VrJw18oUE4UVq+OeHzpup5 HRG7sLAy7EBiuLSONaupDglT/WztrGXepie4RbWURhSXamzavl4dVOtFwIkAsiJKKUTQ KyzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709164936; x=1709769736; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lQp1yJYYew+gDCE/dpzaKAVFurYaETLwiq62WRYT+ZU=; b=QBBoMkwdHD0BLjk7HLyj6nszs1TGL2GbQJEISrsB8nmcK5A4qK0P0xFDFE1anDqMBs otnyhcnlyTg7MACHQ7H+u9UixBlxKEKSm5hYgGDVihicbJAd/2yYEv/5G2v/Wqons8/c yIcXg/oZw4g5B+Q/Epo/ge+d6zhS5od+1iCB/4fsI5XqWjrqb7kU9fm5cBD4sJagVIzI aJ7TiZRWj/kRf1mTNPwVGnqK/XoeBNwwL1n9qtPNq0T9SB3qVaRUzGSda/+EickA1mLK Tq4GIy3tnT1Ha+GedzFCcPrj6iu231qSHaY4HHRcAJeLFngzyfJvy+TuD3gG7TVVNiT0 q1hw== X-Gm-Message-State: AOJu0Yw9rK4o1SsLjuT5PlXyrW301PQZt+6HFR0ljotd024v5zoR2/k7 /eiuuUEz97Vzu2avhf1a4I4E4Lyhlp0nNY5zGq9fRx8JZXXGw3mI8yYGjHiYGYN+/bU+OrJCNHT mC7SA8pjL52mBhxscUarF6z8szIT4wIci X-Google-Smtp-Source: AGHT+IFwWXjcFjUBAfjP7IEivsHO2F4nIL1ax2VEWJyVSYuREcK8eU3CvLWpUehuJigk7dgjUnn7ErslF+pqYca+qzQ= X-Received: by 2002:a1f:ed41:0:b0:4c0:1bb6:322 with SMTP id l62-20020a1fed41000000b004c01bb60322mr373595vkh.15.1709164936049; Wed, 28 Feb 2024 16:02:16 -0800 (PST) MIME-Version: 1.0 References: <20240227140756.216904-1-tirtajames45@gmail.com> <20240227144926.GK4163@brightrain.aerifal.cx> <20240227145123.GL4163@brightrain.aerifal.cx> In-Reply-To: From: Pedro Falcato Date: Thu, 29 Feb 2024 00:02:04 +0000 Message-ID: To: musl@lists.openwall.com Cc: James Tirta Halim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] [PATCH] add memcmpeq: memcmp that returns length of first mismatch On Wed, Feb 28, 2024 at 11:18=E2=80=AFPM Thorsten Glaser wro= te: > > Markus Wichmann dixit: > > >> > > + for (; n >=3D sizeof(word) && *(word *)p1 =3D=3D *(word *= )p2; p1+=3Dsizeof(word), p2+=3Dsizeof(word), n-=3Dsizeof(word)); > > Very much UB. > > >4. All the other musl C code avoids misaligned word access. I don't know > >which architecture/ABI doesn't allow it, but it is nevertheless the > > Almost all of them. i386/amd64 penalise it heavily and it can cause Small note: This isn't quite true for remotely modern x86, unaligned accesses are pretty cheap compared to extra branches, and this fact is abused very frequently in optimized stringops implementations (see every optimized memcpy - which use overlapping loads and stores, effectively abusing unaligned mem ops). --=20 Pedro