From nobody Mon Feb 9 19:37:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40489+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40489+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1557737675; cv=none; d=zoho.com; s=zohoarc; b=Z9unRyM1DxKLi1Bx4dpQV1FC++Th4sAYV0f+qNh3EnUKIRS6r7WS3NjCXlrAerM0qhGKDYIP7VrqzFSX8iJq8qbjRHcfEqyMsHqiganWKFvh0UKyP+wpuyjh9+8JvuN6hrHxdfhnasqtSfjgS5qcbV/o6g/l4yXnStOxusjZyvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557737675; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=sYw1/zhxPQnuWWW3QXQZItMbEOzexYmT6i72glr9okk=; b=Z70FhvtN/cBrGcvsItijLQQiIasPy4tGNY4JkujB6MJZ6X51c6+nV0LtnsY0ouHkce0g9QwmcaaItWZQ6F+mMAtW2q14jfeJlTDWc3h9UdypyBXM/3YNuNJseUxmrQV6d6AtMKnm3oXijODoRAe+5za/IluRmzt+uCUf3SMoG7Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40489+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557737675543640.7499467742086; Mon, 13 May 2019 01:54:35 -0700 (PDT) Return-Path: X-Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by groups.io with SMTP; Mon, 13 May 2019 01:54:34 -0700 X-Received: by mail-ed1-f48.google.com with SMTP id e24so16418491edq.6 for ; Mon, 13 May 2019 01:54:33 -0700 (PDT) X-Gm-Message-State: APjAAAV2fFS7sS9+MqjDXQUJI/E51yvyd2z0tutiZ4oCb5u/tGJ7kqex fSAGewsl+tVcG9ZFYjB6GMRWgdSFuYw= X-Google-Smtp-Source: APXvYqy8zVAV6oEYJkh5ngZk3RFN/mE0Vep/CgtWdiUIAGxL/CjbIUPbzqL3zW4ybcbpt7J7bNuM0g== X-Received: by 2002:a17:906:4995:: with SMTP id p21mr17254562eju.140.1557737672179; Mon, 13 May 2019 01:54:32 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.49.55]) by smtp.gmail.com with ESMTPSA id k57sm3595701ede.17.2019.05.13.01.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 01:54:31 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [PATCH v2 2/4] ArmPkg/CompilerIntrinsicsLib: Add memcmp, memmove intrinsics for MSFT Date: Mon, 13 May 2019 09:54:14 +0100 Message-Id: <20190513085416.1352-3-pete@akeo.ie> In-Reply-To: <20190513085416.1352-1-pete@akeo.ie> References: <20190513085416.1352-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557737674; bh=da38peRHltauMh7Y6iY3R/tYYukh7F3uSBGPhsukFuU=; h=Cc:Date:From:Reply-To:Subject:To; b=gapwVbIx8J6P6LFfi9v6oMatWlAPlbgZBx9cUzQsubrR+BuWJTs5ku9e31JE3Iiqhhn wtfa3ckZuzQLZeYptPZAhzjL8S9wHlSHsgIz/hTfxDVrT9cRtVrrZQXTD/i/gxpSOJeLT vrJ6KIUvhKQq5J1fbkj49+T38cjwMICIlDw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" We could have reused memmove.asm for ARM, but we would still need to add an implemention for ARM64, so we use the same source for both archs. Cc: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Pete Batard --- ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 2 ++ ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c | 31 ++++++= ++++++++++++ ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c | 34 ++++++= ++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf= b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf index 0203ecb4870f..d6cc63db75c7 100644 --- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf +++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf @@ -26,6 +26,8 @@ [Sources] =20 memcpy_ms.c | MSFT memset_ms.c | MSFT + memcmp_ms.c | MSFT + memmove_ms.c | MSFT =20 [Sources.ARM] Arm/mullu.asm | RVCT diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/ArmPkg/Libr= ary/CompilerIntrinsicsLib/memcmp_ms.c new file mode 100644 index 000000000000..551f8e77c12f --- /dev/null +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------= ------ +// +// Copyright (c) 2019, Pete Batard. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +//------------------------------------------------------------------------= ------ + +#if defined(_M_ARM64) +typedef unsigned __int64 size_t; +#else +typedef unsigned __int32 size_t; +#endif + +int memcmp(void *, void *, size_t); +#pragma intrinsic(memcmp) +#pragma function(memcmp) +int memcmp(const void *s1, const void *s2, size_t n) +{ + unsigned char const *t1 =3D s1; + unsigned char const *t2 =3D s2; + + while (n--) { + if (*t1 !=3D *t2) + return (int)*t1 - (int)*t2; + t1++; + t2++; + } + + return 0; +} diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/ArmPkg/Lib= rary/CompilerIntrinsicsLib/memmove_ms.c new file mode 100644 index 000000000000..5b261ef8b948 --- /dev/null +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------= ------ +// +// Copyright (c) 2019, Pete Batard. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +//------------------------------------------------------------------------= ------ + +#if defined(_M_ARM64) +typedef unsigned __int64 size_t; +#else +typedef unsigned __int32 size_t; +#endif + +void* memmove(void *, const void *, size_t); +#pragma intrinsic(memmove) +#pragma function(memmove) +void* memmove(void *dest, const void *src, size_t n) +{ + unsigned char *d =3D dest; + unsigned char const *s =3D src; + + if (d < s) { + while (n--) + *d++ =3D *s++; + } else { + d +=3D n; + s +=3D n; + while (n--) + *--d =3D *--s; + } + + return dest; +} --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#40489): https://edk2.groups.io/g/devel/message/40489 Mute This Topic: https://groups.io/mt/31605110/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-