From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.8895.1634010633931885043 for ; Mon, 11 Oct 2021 20:50:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=aRPAGr+K; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: ianx.kuo@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10134"; a="226988786" X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="226988786" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 20:50:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="460206347" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga002.jf.intel.com with ESMTP; 11 Oct 2021 20:50:33 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 11 Oct 2021 20:50:32 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Mon, 11 Oct 2021 20:50:32 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Mon, 11 Oct 2021 20:50:32 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fr6+bgP/7e1IIWmPHZepnkufIw2WkhSHixbAcByKG40DzXxjQgdzmqqAGAIYLi/lrhkkrFwUolXOhM+p8yEmxYrcT1fvlMWLbYJPBgjrIbeD8LZ6tYH2LNcakvmPFzUjFWSigqh2yamjHmHuVe+NQsdv4wXlmkmewpnXFEnpNUw6ydIi2zviLkvgJbSzVl47WfbxGUcMB93hibQ2Wo2l5s4Ioerh+rnfdfDbxgYQZzAwx70Lril9E8MJBDCt5Mo9HJv+xmOyFnJ+iCfifsd8Hg+vgYAlizfuvPzggREdFsfLqLR6Y0bj+L8b8drqG20fojbgkpNk+vA4SRU6SXZfJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k71CGOr0fXv4U8AIK6nxo4NlcUXLpN8JsY1t2X7f4BI=; b=OZYzvNz4+/dwRdeK+O9dfWWKc4P+VwSopZw9q0hggT5YESApNhWtKacI5fuJBJ3CTX4JKtJPfIpxqKY18DDWCKTVh1Vmn60vAjPlAEzyh8ubTDEwiM17JjA6JqIFSDmY/E99QAkKCxvrqwcd4vU0q5S4OE0zsX9iYuxJc04fnETuKWZAuZT7RatPhfZe1GTU6dnDfdN2zF+R37hf1JV2ztTIN/Z4llwda3UYOwOnRacBXiXjvEROTCe7N9n/jhEy2zEafV+2kxTdLPLxwzta2j2qyXJuvG5pdJEAuZezLYK3KLO2R+HsVPAfVk0lT8NRVGDzJS2V4B+raPpxQqKQ7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k71CGOr0fXv4U8AIK6nxo4NlcUXLpN8JsY1t2X7f4BI=; b=aRPAGr+K9P0E+xWpcWD5OR4Fal/aQP5FOyYsEO0UAWrpQ4rd1BSPiEKLoihpodZZTIhibiKCrBZwEiM9mLimVv9n9lSf354TOoceLY8vqKSR1RBzsJIg8Anwm0mExweaupNM+iFlfCqlGketjrbRg/vG/qwJ0HWgkLLwj2X11Ow= Received: from PH0PR11MB5174.namprd11.prod.outlook.com (2603:10b6:510:3b::12) by PH0PR11MB4774.namprd11.prod.outlook.com (2603:10b6:510:40::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 03:50:31 +0000 Received: from PH0PR11MB5174.namprd11.prod.outlook.com ([fe80::4435:90ac:24fe:b6a6]) by PH0PR11MB5174.namprd11.prod.outlook.com ([fe80::4435:90ac:24fe:b6a6%7]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 03:50:31 +0000 From: "IanX Kuo" To: "Ni, Ray" , "devel@edk2.groups.io" , "Kinney, Michael D" , Liming Gao CC: "Chan, Amy" , "Liu, Zhiguang" Subject: Re: [PATCH v9 1/1] MdePkg/BaseLib: Add QuickSort function on BaseLib Thread-Topic: [PATCH v9 1/1] MdePkg/BaseLib: Add QuickSort function on BaseLib Thread-Index: AQHXvvzp5bk7gYDkzUmae3XtF1CPcqvOodkAgAAYTCA= Date: Tue, 12 Oct 2021 03:50:31 +0000 Message-ID: References: <20211012000531.361-1-ianx.kuo@intel.com> <20211012000531.361-2-ianx.kuo@intel.com> In-Reply-To: Accept-Language: en-AS, zh-TW, en-US X-Mentions: michael.d.kinney@intel.com,gaoliming@byosoft.com.cn X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b062c743-3194-4564-dc3e-08d98d337027 x-ms-traffictypediagnostic: PH0PR11MB4774: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: T6rn3taIlu7WbJDqm0nR4MbP9tpcona4S7eXitX6/fyTrVY2lLSnBO0MbFmwuQ1qa2JvRAJWF7+PBP130QKiGH6P0TJtyavlMfGnY4xb+3LIVkwSID7u001OXyvo9pGAlEc2yg9re+4izI+95Amwt3bc2DgnInIq13sKqE5MD06EiMR7kwgnpRUtKimON33Y3agHxIv8eFdDWBNCR3MEf3BMYuWUUIo566cKprxKWNd4rDXk2revgbq8xQyQWX6vGLcG2WvojaxCIVbeN2ZIqvTwpPPf1akgAVJuAjsUu17YyD5fPRCaUriMiyeVAW5C2hKgIKZAkUHCfL6UK/hU9ffGaaTCu0+BNnwh2VkZWZfOsuG5dh9WkbKpXFw7m433oNA7V70z3UXvaMl+OlWaAp+SYDtrdp1Rs0mMvH2dqZoOMnZPuD6RL/TIeJB8qy+sU78zsK3cQEecVwiJ2FPpdS4mohgnvTotFVh8tktuMOWRZnijx0asRg5hsMljihTLBB19EJz4IB7vKkYeFAMZ/B/2g1bHPA6/NUm/qu5YjYFvIM6psDrKHfhWIEt9dxVZrfk1SICGCVEbL43+C5ytQ6khpb2u60ijqM1wadTsZxOY8iA663L9J3e6pk3fsQp8VpcZdlDD2KVISEBwWEEETU1cK0qbBgQTJwxinsP4uqN0StI2e3ayJPqShV3rAtvJLk1powf9x31fYCw3HAa+dNvm2+wijSc8qpBygB92zgf4KPjlPz5CwxlrOdIbMBmvm2qAI9lbCOYodPRSCqBQOYGEzqqwoHGnUA78YzFx+bLluDO7BBAulgPA7U2CEfUF6jBvZ0oAgfWfTfEdfpmB3A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB5174.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(107886003)(7696005)(38100700002)(110136005)(5660300002)(53546011)(6506007)(54906003)(8676002)(4326008)(86362001)(508600001)(26005)(186003)(316002)(122000001)(76116006)(9686003)(38070700005)(52536014)(55016002)(8936002)(71200400001)(66946007)(2906002)(83380400001)(33656002)(966005)(64756008)(66446008)(66556008)(66476007)(14943795004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ZdZm/b0mNOdVkrzFZGkT3pfrwC/3bzDbCE1QLyeH4Re7SIaU2PEmgZ/4QGkX?= =?us-ascii?Q?x1fDN7hYYGvJ7RnUTSBsJkIxl8f/HCksaSPZ1zvaavu5JoPDvg0bio+63fXF?= =?us-ascii?Q?bot2VdSiybeUQI8r+3phvjWK9ltnTe5WkuBCIZKOa+IPZEBgzT+jNzSvHiKb?= =?us-ascii?Q?jdEtpsHTIgJYqztaM2wUF+kGpjdTIO31SqH6vvLlV6ACpdvUHxSp9x370o03?= =?us-ascii?Q?lRuMMbLC8VynmxXCx/rBAiSrj0qOxjiMmmJw+jIIhW1hgzkol7hdBlxmmvLw?= =?us-ascii?Q?HbAXbe8F0iZvLy6QEBpTWUUn4ZugoQF9ev155+3gXWKEJAmiyOHkUyuIL4Qu?= =?us-ascii?Q?/YDkxAncTWgYIo4Fij2StVxy/69Ei+WqVMZdbdgKW3yA0JrmPBYO92NgIsnO?= =?us-ascii?Q?12+nCahudnaX1ONrnIJTYtS7CZy6MHqnWDu4w5uSGpAUAo19Niiuxz/hzk+r?= =?us-ascii?Q?aE2++voeoi3a4BRAdcNk+wSH8x+6skeOA43PjDnnOOeBE+yI6prs9EJbH9HI?= =?us-ascii?Q?Xqmw3z3Ol0EAIUD4vvPBZ1+DCuSQR7irmCmiUnckkriL1Ft7t6kTLfJcIKk0?= =?us-ascii?Q?1nHu920IRy2CMZfxzx7zzBhZJeVELwq5zAWPU+BPXMgimwX2lm9mFNvOKMFM?= =?us-ascii?Q?ej/uU1Q5bPnoxBiCR1MYkXJnEDgMLImnfm7sn0R6yPPG8AyJlU/XXYCNCFb6?= =?us-ascii?Q?iukozucG1K84876pxYmnb/kgyuuoo7hrjaPy35YxTQGDI0+yABflBiPcvVuN?= =?us-ascii?Q?N10Ratls4GO3OeIiIc6MdHbB4+ootUdqd0eFvj4w6ei0VOtYCcyXkLTQvdU7?= =?us-ascii?Q?tyTEQohD3okRTw0w1liYMu2r3iLcu8Bz3/JMWknDN6oo8oDF1wguwC24hY5p?= =?us-ascii?Q?rgC58kyEK/Vc/o+wnUTyI0OB79k/EwXvfkKWx1+PPWjqOjY+cBUdPFwozxZm?= =?us-ascii?Q?po5FOhB2RMeMM3RqC6VVJoWJg/drUHZBRVvXFO1cIGGIWMx+juF8h1zdxAE3?= =?us-ascii?Q?mdi/DqXDGuSE+VKSnZ04E+dab+oaq4hzDm6Vd0rl0gaPfGK3QnDWyo/jUOAC?= =?us-ascii?Q?q1lIkCRCauVlAZk/sRR55Z6mWgx/hLTXpIBujSdhKlF3jMzA1lolhnvgJf6l?= =?us-ascii?Q?2jaJX7uVUSx741YOJcHgXLN97oGzX4S+npwjW6tJIweghC+FaE2ZbSNYRPkz?= =?us-ascii?Q?1G1dAox5KgONIQk6+Y0fAq1w6f/U8cOTfkDkJNrUS1T67WJMItNGdrTmYv83?= =?us-ascii?Q?ueezDVBGGe+9gN60pS6IeCw3DMbT/xlO0Wvx2klF3IXjmiMhAFcYgP7KEa4c?= =?us-ascii?Q?rgUtJ8q3sEr33nZ8QWcj6CQ3?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5174.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b062c743-3194-4564-dc3e-08d98d337027 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2021 03:50:31.2123 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: s/0S0lDrIXbMafBvZCcpXc+Tdl5QNzWjkilgy9D93RSXdZOit0tdIwjFa71A4U6aRIkoliGFnylSBGWQ+u7b9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4774 Return-Path: ianx.kuo@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable @Liming Gao and @Kinney, Michael D May I get one of yours help for the reviewed from MdePkg maintainer side ? Have any concern, please also share for me. Thanks, Ian Kuo -----Original Message----- From: Ni, Ray =20 Sent: Tuesday, October 12, 2021 10:22 AM To: Kuo, IanX ; devel@edk2.groups.io Cc: Chan, Amy ; Kinney, Michael D ; Liming Gao ; Liu, Zhiguang Subject: RE: [PATCH v9 1/1] MdePkg/BaseLib: Add QuickSort function on BaseL= ib Reviewed-by: Ray Ni Ian, please take the approval from maintainers of MdePkg as the formal appr= oval. Thanks, Ray > -----Original Message----- > From: Kuo, IanX > Sent: Tuesday, October 12, 2021 8:06 AM > To: devel@edk2.groups.io > Cc: Chan, Amy ; Ni, Ray ; Kuo,=20 > IanX ; Kinney, Michael D=20 > ; Liming Gao ;=20 > Liu, Zhiguang > Subject: [PATCH v9 1/1] MdePkg/BaseLib: Add QuickSort function on=20 > BaseLib >=20 > From: IanX Kuo >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3675 >=20 > Add QuickSort function into BaseLib >=20 > Cc: Ray Ni > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Signed-off-by: IanX Kuo > --- > MdePkg/Include/Library/BaseLib.h | 49 ++++++++ > MdePkg/Library/BaseLib/BaseLib.inf | 1 + > MdePkg/Library/BaseLib/QuickSort.c | 116 ++++++++++++++++++ > .../Library/BaseLib/UnitTestHostBaseLib.inf | 3 +- > 4 files changed, 168 insertions(+), 1 deletion(-) create mode 100644=20 > MdePkg/Library/BaseLib/QuickSort.c >=20 > diff --git a/MdePkg/Include/Library/BaseLib.h=20 > b/MdePkg/Include/Library/BaseLib.h > index 2452c1d92e..0ae0f4e6af 100644 > --- a/MdePkg/Include/Library/BaseLib.h > +++ b/MdePkg/Include/Library/BaseLib.h > @@ -2856,6 +2856,55 @@ RemoveEntryList ( // >=20 > // Math Services >=20 > // >=20 > +/** >=20 > + Prototype for comparison function for any two element types. >=20 > + >=20 > + @param[in] Buffer1 The pointer to first buffer. >=20 > + @param[in] Buffer2 The pointer to second buffer. >=20 > + >=20 > + @retval 0 Buffer1 equal to Buffer2. >=20 > + @return <0 Buffer1 is less than Buffer2. >=20 > + @return >0 Buffer1 is greater than Buffer2. >=20 > +**/ >=20 > +typedef >=20 > +INTN >=20 > +(EFIAPI *BASE_SORT_COMPARE)( >=20 > + IN CONST VOID *Buffer1, >=20 > + IN CONST VOID *Buffer2 >=20 > + ); >=20 > + >=20 > +/** >=20 > + This function is identical to perform QuickSort, >=20 > + except that is uses the pre-allocated buffer so the in place=20 > + sorting does not need to >=20 > + allocate and free buffers constantly. >=20 > + >=20 > + Each element must be equal sized. >=20 > + >=20 > + if BufferToSort is NULL, then ASSERT. >=20 > + if CompareFunction is NULL, then ASSERT. >=20 > + if BufferOneElement is NULL, then ASSERT. >=20 > + if ElementSize is < 1, then ASSERT. >=20 > + >=20 > + if Count is < 2 then perform no action. >=20 > + >=20 > + @param[in, out] BufferToSort on call a Buffer of (possibly sorted) e= lements >=20 > + on return a buffer of sorted=20 > + elements >=20 > + @param[in] Count the number of elements in the buffer to= sort >=20 > + @param[in] ElementSize Size of an element in bytes >=20 > + @param[in] CompareFunction The function to call to perform the com= parison >=20 > + of any 2 elements >=20 > + @param[out] BufferOneElement Caller provided buffer whose size equal= s to ElementSize. >=20 > + It's used by QuickSort() for swapping i= n sorting. >=20 > +**/ >=20 > +VOID >=20 > +EFIAPI >=20 > +QuickSort ( >=20 > + IN OUT VOID *BufferToSort, >=20 > + IN CONST UINTN Count, >=20 > + IN CONST UINTN ElementSize, >=20 > + IN BASE_SORT_COMPARE CompareFunction, >=20 > + OUT VOID *BufferOneElement >=20 > + ); >=20 >=20 >=20 > /** >=20 > Shifts a 64-bit integer left between 0 and 63 bits. The low bits=20 > are filled >=20 > diff --git a/MdePkg/Library/BaseLib/BaseLib.inf=20 > b/MdePkg/Library/BaseLib/BaseLib.inf > index 6efa5315b6..cebda3b210 100644 > --- a/MdePkg/Library/BaseLib/BaseLib.inf > +++ b/MdePkg/Library/BaseLib/BaseLib.inf > @@ -32,6 +32,7 @@ > SwapBytes16.c >=20 > LongJump.c >=20 > SetJump.c >=20 > + QuickSort.c >=20 > RShiftU64.c >=20 > RRotU64.c >=20 > RRotU32.c >=20 > diff --git a/MdePkg/Library/BaseLib/QuickSort.c=20 > b/MdePkg/Library/BaseLib/QuickSort.c > new file mode 100644 > index 0000000000..a825c072b0 > --- /dev/null > +++ b/MdePkg/Library/BaseLib/QuickSort.c > @@ -0,0 +1,116 @@ > +/** @file >=20 > + Math worker functions. >=20 > + >=20 > + Copyright (c) 2021, Intel Corporation. All rights reserved.
>=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include "BaseLibInternals.h" >=20 > + >=20 > +/** >=20 > + This function is identical to perform QuickSort, >=20 > + except that is uses the pre-allocated buffer so the in place=20 > + sorting does not need to >=20 > + allocate and free buffers constantly. >=20 > + >=20 > + Each element must be equal sized. >=20 > + >=20 > + if BufferToSort is NULL, then ASSERT. >=20 > + if CompareFunction is NULL, then ASSERT. >=20 > + if BufferOneElement is NULL, then ASSERT. >=20 > + if ElementSize is < 1, then ASSERT. >=20 > + >=20 > + if Count is < 2 then perform no action. >=20 > + >=20 > + @param[in, out] BufferToSort on call a Buffer of (possibly sorted) e= lements >=20 > + on return a buffer of sorted=20 > + elements >=20 > + @param[in] Count the number of elements in the buffer to= sort >=20 > + @param[in] ElementSize Size of an element in bytes >=20 > + @param[in] CompareFunction The function to call to perform the com= parison >=20 > + of any 2 elements >=20 > + @param[out] BufferOneElement Caller provided buffer whose size equal= s to ElementSize. >=20 > + It's used by QuickSort() for swapping i= n sorting. >=20 > +**/ >=20 > +VOID >=20 > +EFIAPI >=20 > +QuickSort ( >=20 > + IN OUT VOID *BufferToSort, >=20 > + IN CONST UINTN Count, >=20 > + IN CONST UINTN ElementSize, >=20 > + IN BASE_SORT_COMPARE CompareFunction, >=20 > + OUT VOID *BufferOneElement >=20 > + ) >=20 > +{ >=20 > + VOID *Pivot; >=20 > + UINTN LoopCount; >=20 > + UINTN NextSwapLocation; >=20 > + >=20 > + ASSERT (BufferToSort !=3D NULL); >=20 > + ASSERT (CompareFunction !=3D NULL); >=20 > + ASSERT (BufferOneElement !=3D NULL); >=20 > + ASSERT (ElementSize >=3D 1); >=20 > + >=20 > + if (Count < 2) { >=20 > + return; >=20 > + } >=20 > + >=20 > + NextSwapLocation =3D 0; >=20 > + >=20 > + // >=20 > + // pick a pivot (we choose last element) >=20 > + // >=20 > + Pivot =3D ((UINT8*) BufferToSort + ((Count - 1) * ElementSize)); >=20 > + >=20 > + // >=20 > + // Now get the pivot such that all on "left" are below it >=20 > + // and everything "right" are above it >=20 > + // >=20 > + for (LoopCount =3D 0; LoopCount < Count -1; LoopCount++) { >=20 > + // >=20 > + // if the element is less than or equal to the pivot >=20 > + // >=20 > + if (CompareFunction ((VOID*) ((UINT8*) BufferToSort +=20 > + ((LoopCount) * ElementSize)), Pivot) <=3D 0){ >=20 > + // >=20 > + // swap >=20 > + // >=20 > + CopyMem (BufferOneElement, (UINT8*) BufferToSort +=20 > + (NextSwapLocation * ElementSize), ElementSize); >=20 > + CopyMem ((UINT8*) BufferToSort + (NextSwapLocation *=20 > + ElementSize), (UINT8*) BufferToSort + ((LoopCount) * > ElementSize), ElementSize); >=20 > + CopyMem ((UINT8*) BufferToSort + ((LoopCount)*ElementSize),=20 > + BufferOneElement, ElementSize); >=20 > + >=20 > + // >=20 > + // increment NextSwapLocation >=20 > + // >=20 > + NextSwapLocation++; >=20 > + } >=20 > + } >=20 > + // >=20 > + // swap pivot to it's final position (NextSwapLocation) >=20 > + // >=20 > + CopyMem (BufferOneElement, Pivot, ElementSize); >=20 > + CopyMem (Pivot, (UINT8*) BufferToSort + (NextSwapLocation *=20 > + ElementSize), ElementSize); >=20 > + CopyMem ((UINT8*) BufferToSort + (NextSwapLocation * ElementSize),=20 > + BufferOneElement, ElementSize); >=20 > + >=20 > + // >=20 > + // Now recurse on 2 partial lists. neither of these will have the=20 > + 'pivot' element >=20 > + // IE list is sorted left half, pivot element, sorted right half... >=20 > + // >=20 > + if (NextSwapLocation >=3D 2) { >=20 > + QuickSort ( >=20 > + BufferToSort, >=20 > + NextSwapLocation, >=20 > + ElementSize, >=20 > + CompareFunction, >=20 > + BufferOneElement >=20 > + ); >=20 > + } >=20 > + >=20 > + if ((Count - NextSwapLocation - 1) >=3D 2) { >=20 > + QuickSort ( >=20 > + (UINT8 *)BufferToSort + (NextSwapLocation + 1) * ElementSize, >=20 > + Count - NextSwapLocation - 1, >=20 > + ElementSize, >=20 > + CompareFunction, >=20 > + BufferOneElement >=20 > + ); >=20 > + } >=20 > +} >=20 > diff --git a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf=20 > b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf > index eae1a7158d..d09bd12bef 100644 > --- a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf > +++ b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf > @@ -1,7 +1,7 @@ > ## @file >=20 > # Base Library implementation for use with host based unit tests. >=20 > # >=20 > -# Copyright (c) 2007 - 2020, Intel Corporation. All rights=20 > reserved.
>=20 > +# Copyright (c) 2007 - 2021, Intel Corporation. All rights=20 > +reserved.
>=20 > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights=20 > reserved.
>=20 > # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights=20 > reserved.
>=20 > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All=20 > rights reserved.
>=20 > @@ -33,6 +33,7 @@ > SwapBytes16.c >=20 > LongJump.c >=20 > SetJump.c >=20 > + QuickSort.c >=20 > RShiftU64.c >=20 > RRotU64.c >=20 > RRotU32.c >=20 > -- > 2.30.0.windows.1