From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=ylydbHwL; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.208.48, mailfrom: pete@akeo.ie) 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 Received: by mail-ed1-f48.google.com with SMTP id e24so16418491edq.6 for ; Mon, 13 May 2019 01:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K/PWVOgd5OYxBfcIPJkSaUT5kvKD5nZjqjww0+oXkXI=; b=ylydbHwLqH3YJchPx0ZtjqchIuuxAd+O4AZbPznNOXrdIoKEJv0WRT5DUzXj6oeike 7OWQxFRl4S/dzrn8w58IeoRA43GL8eQwSnYewAcaNZ9YButPDKe4+STKAmoqH+iGzmPt m34jc9M2Fvmy0Q8HFKkSZorlwOR5SotUFUuDkvcvoPEQ9HQ64rUgaTMt28/ApMF6FWVg PC0jtJW4TLei0jIdG0Gf8V/E4AM8D9eGZE60596mLU3lOJKM/xI+7ml3Rvxbg/Ihfyak rsYdNLSoJ/HQoqbwsThVehmIsPkfgDZA1Im7Tl85TrdMQ1w8DKvS0EN58sW5gU26IInc wj+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K/PWVOgd5OYxBfcIPJkSaUT5kvKD5nZjqjww0+oXkXI=; b=EO9VO3Oc8AlCdti9Ilst1IiIVl23d2vRA9vFQ9tj1tkQqKeljRSi2l2C0+Vlm79gH6 5VtOocn2k07OAhId5DKctXLJ4J5ows2qk7Tk8nRzE5QfUGNQzV+Ws5/aa9LjxyB44orB NNdiMbQ4+p6qZ3PvnMt/4n4SminKEIqap+p2apUFcNTI37dgfoqX4RYCiyDzzx8rET4z a86Yl0vd8V0VzYxJVY6a64WrEaquuYWxQZEcpMeKHIhilyzAZPviYBFNiqg+ZnKhFlaA LwjvnLwp/Sx8DO8NNep9400PgIbDymFARfIoesZMCjgLh2ADXiokoXq3VV/4/lfoMBE2 vd3Q== 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190513085416.1352-1-pete@akeo.ie> References: <20190513085416.1352-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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] memcpy_ms.c | MSFT memset_ms.c | MSFT + memcmp_ms.c | MSFT + memmove_ms.c | MSFT [Sources.ARM] Arm/mullu.asm | RVCT diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/ArmPkg/Library/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 = s1; + unsigned char const *t2 = s2; + + while (n--) { + if (*t1 != *t2) + return (int)*t1 - (int)*t2; + t1++; + t2++; + } + + return 0; +} diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/ArmPkg/Library/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 = dest; + unsigned char const *s = src; + + if (d < s) { + while (n--) + *d++ = *s++; + } else { + d += n; + s += n; + while (n--) + *--d = *--s; + } + + return dest; +} -- 2.21.0.windows.1