From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.8286.1634005314321745372 for ; Mon, 11 Oct 2021 19:21:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ek4WHIwB; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: ray.ni@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10134"; a="224437076" X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="224437076" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 19:21:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="524040202" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga001.jf.intel.com with ESMTP; 11 Oct 2021 19:21:53 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) 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 19:21:52 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) 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 19:21:52 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (192.55.55.68) 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 19:21:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1DElv+jHg3GQdZO5r5dwYTwU6mEZxs/99RkN4LMe+yvwq9UHSKNCcqtSDamPZX4mGtJ81csi8pzjxKG/LzL2NSmHDSJJKWg+vQi/vB483Dxm6kNXUhlQzSDh8ayOcdvBvfPalbs4PNY3X7uYqxkstvQkfbssCJkh9mwtMpw/sOAbNwHxWlZ3UVOOgLHYJmWC0klZ4Pfe/d0VAPAh9qRllJUqQi7qpXfH+V39W0N0Jh+I7QIOvWXlQwrCPWake5fIcyH2tC0f+q+GF7GeuppxCJbEzfA0uaX5QaMRDWd5G18fmxElSvgv5bYC+g06i4mzBU5Zia0+0r425IHxdxi9Q== 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=0G8BgO2uEgkanQpjgbB7KNziJhw1sYkCJDRXq8hPBfQ=; b=Pgs5KVGW4IGFWglRHBu0bcFBAofNtus0pQor0KLiZvOSOPZQfLhpYLGUK2Q6fhUCsycM12UWq6x8EopOhAZszv4zFayHXDSN5HBM0CdExJKmP30gI1s5Vw2ehMbwAk7s/dAU3HQTPRqf/Fx++UbrpoaX4L1xe/6W2Tg+fwHbEBBagWuYTbRdyNDKnOp1wTeOc2YXbNvBLPxjTaFEUeHEMatFm7BJwNmIbWoWyS3iwE+VgGprd9XzqiMSXUcDwIjHjPN8mYpi1IkYYdp55R+tx8KYiBSclHDBhjcM7TZiWLo4PCxNSOQ9+jJuvZ9E65hsrQ5MsntFyQBWD0hbHBznAA== 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=0G8BgO2uEgkanQpjgbB7KNziJhw1sYkCJDRXq8hPBfQ=; b=ek4WHIwBPcxh0E1nryEV8Y1RSk8F4dFhRxcNu/B2Q3hKLrLoF7HNUeEBHWI68svFSUdLzV7gCuicc+3QQzgGSCtFIo9wOk1ldVaCV+7L1YnaGcq4+a38VyWRngePGoR65nts9Nd9NXR7ZmYeJiEeqeWRvgNGwyzTIWy0UpA4uyE= Received: from BN0PR11MB5696.namprd11.prod.outlook.com (2603:10b6:408:14b::11) by BN6PR1101MB2212.namprd11.prod.outlook.com (2603:10b6:405:52::12) 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 02:21:50 +0000 Received: from BN0PR11MB5696.namprd11.prod.outlook.com ([fe80::317e:de35:e920:7778]) by BN0PR11MB5696.namprd11.prod.outlook.com ([fe80::317e:de35:e920:7778%3]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 02:21:50 +0000 From: "Ni, Ray" 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 BaseLib Thread-Topic: [PATCH v9 1/1] MdePkg/BaseLib: Add QuickSort function on BaseLib Thread-Index: AQHXvvzpuSFLE9KLukmL+j5+JoNFdqvOoYmA Date: Tue, 12 Oct 2021 02:21:50 +0000 Message-ID: References: <20211012000531.361-1-ianx.kuo@intel.com> <20211012000531.361-2-ianx.kuo@intel.com> In-Reply-To: <20211012000531.361-2-ianx.kuo@intel.com> Accept-Language: en-US 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: 996a4049-fa8f-49f4-a5e9-08d98d270cdc x-ms-traffictypediagnostic: BN6PR1101MB2212: 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: Jwxdogrvy0aIk4fslPje6r96Uo63XqHnzGgBxNoT1PC/za0DkK38GP/6mr3NWrkHgfTiJuj5Z35J0JXYgWOpUko1TAS0P/ui5zFSy8+K1Bnk0FgVIhwqEMGu23ZYyXERjeqsK4G/cTt0/7uuui5H4mk7R7ixAc9570NVnJedJl1bQ0rbizf83+EZ6ftkVW1zykNpgdZjz+dffp+VXP8A4wFrFAbCYQ2cGgHKzwwxeO9U0Nw4ig7A5uyApoIgUPQFXNL8qwA15GSipXFTtu8WbAhcRTRU+bZcK2ZbXxy/97arVTAXmX9FKuP4uYOeNk3ZYiVpGBPKt6giCwLLf+7+t+IzPJR8xGHpOBCYdqvO/kpYIYLGKyhKxuuicbr1r+bkKff3vGuJENaLp61DmjfNX0vh1dIxMwmrmr1s1Xn/R38QsDMkNQX82QAIJeku+wWtSdqNlCe4lDh7D2+dnRJpbBN2YPtbHF0SaOJ/Iz1k7gDi4UDyC8WwwqHsDnvX4x+043kdgsSlHOAITFeBp/HUddEvO5Bj/1jSWaYL2zLMs/zpOP1/thxy0k0NGpu5U4PQv1TD64UFwfGddqN/LMoR+Kk6ENFl7z8TvapMDFdbQ2ejpaYvQuaWvnUStTN/uKtHqLXPC53IGSOtpb8jdrNPooQJozMW+uK/h97jPCUpT/gT6Dws1ch9yAVj/+yhJYs2+ndg4xgNTU2W8HyGodZyKVQA94ohtY4jyXZJQfQ0S2Oj6etLGDfHoW3+VwOqOcWG2OkNOdyVAEH0UjWcsjHp5wjHsTqdaXvCFAr/x8D1y/12TB/AjvHUyeWZWfSo2eh2oOQ6c+bI9oavyT2oMROtYg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN0PR11MB5696.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(54906003)(55016002)(38100700002)(66446008)(71200400001)(966005)(66476007)(122000001)(66556008)(66946007)(53546011)(508600001)(6506007)(76116006)(8676002)(83380400001)(110136005)(33656002)(9686003)(64756008)(316002)(7696005)(38070700005)(26005)(107886003)(5660300002)(186003)(86362001)(2906002)(52536014)(4326008)(8936002)(14943795004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?zxLYXGeO8NxeIWeq+CVYlNR20Q+YoX+Pg3cd4FO6OEc0JfTv6Bpe9Y6hvLSl?= =?us-ascii?Q?OTeHrJS7OHWs8qD6Ajw+5sbPKH6JmsaLXlnaLuMK8gP+91PY1PBEG9dDjxg0?= =?us-ascii?Q?qxn2QEPgAMFohQdiQ/OhYY28YflxIfOxyEsjZPT7eMwanPbKBo2U74nwJlyd?= =?us-ascii?Q?SJwY4OIlETFRreqyvUpTvhlYD2roc8hXFnqe3KlbiM/8++SMif48vhOm2Miz?= =?us-ascii?Q?DjP/exbHf84J2MPwjYiyPn6EjlhkPB6n2wqLx5W3u9CLJ4OV53mnrohWVErJ?= =?us-ascii?Q?x8LCb3X0k16LhhhuyVcceeeeywDA7DFq4B9dBfJFoXROEHzA9Zn1/zT76YxE?= =?us-ascii?Q?IoD0ngMa/56gWADS0/5HH8WuNsm1QgdXgTtdPxzfoZK8StkhS89s/H9uiKLc?= =?us-ascii?Q?Xm+wTwtrNFEKhPnCDmrvgVzvlE+BYCn1Bl+hOAb58xEKdd4WCXSiCcqCRD1R?= =?us-ascii?Q?xgteEn51HyU5GN5QCfhXksgD9sZ1mZ/KtZ+Vxxctfch7KXucg+A4XGOdondm?= =?us-ascii?Q?BKzI1+brXrK0dhHcTixdE9ooKiaNwdjyo3JfTCZAWmXX5dYUVrOJmTHLa4u2?= =?us-ascii?Q?+qW8oGUYky1iEG5krp1//iwt9jJUo0G6acyuvuyHx5g6S19SkFUPxBx3LaDE?= =?us-ascii?Q?ou1722ZyMPIdsBuBg459xu9LlkkkAdbyQIBvWN3jEvRjtF1so7n7IFB3faUy?= =?us-ascii?Q?RCs1LX5UuIYm63IWAONhg4W3FIa1Jb5aOkuqxOR+ppGEGfUl5rLNIHlmRFlN?= =?us-ascii?Q?PpD5NDCb/LAuV7N7H7S2r/nUljjs+vghcwL8fQjdVlSNZYavxJ/O94FEsM1f?= =?us-ascii?Q?yA+ECByAvBg3C1fBzeHP+it12tKokWUj3d9Njj6LQQkXrQedU2ZwW3jdyyz0?= =?us-ascii?Q?fpWZfyrb41hJFPK2lEtWG7N8HAaxB+Tm4ESzlIjtxejkkZll3KDEjqdKnl2m?= =?us-ascii?Q?AdNRzcDgLndz359X5a0Ef/91x/64usZqNkENBZEW8/U1pXyL6zmPNKbdl8eZ?= =?us-ascii?Q?6pV6OqsHTtv91tYlMJ4kfLxMitFOUZHJYFWjJADLa+VwO1bSpaowbjn8THsg?= =?us-ascii?Q?3PD74C0pnPelBl/SexTNSVR7ZaIqD8T62OGllienVaVaVdETVT1GkPMwtOxi?= =?us-ascii?Q?UbY9dMtQsfQ5oxFi4YW77sqXfKigECFDUVsX+dYcnSbohXcB+PHA9h7yZRuC?= =?us-ascii?Q?Bo7wOByfZdmgtIgTEzUK0aZAP6KLE3gK7GieKvpUyz89KycohKHNqyfi4B9y?= =?us-ascii?Q?bcvI4RRFmMzWjR1BI0jOfJJKw2BNWWddtZbiWDNZ99anBTw5hj9c/jC2vHto?= =?us-ascii?Q?RmUoZqZBaY9LPLvwB9+6fDmm?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN0PR11MB5696.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 996a4049-fa8f-49f4-a5e9-08d98d270cdc X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2021 02:21:50.7727 (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: JvZgUfaho5o752TrqiNiGiJEVzNCci20IqRijUBrZWr+dVftJueWzyTT7W8qLBE8xz42WVxTCWqp469euOk2UA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1101MB2212 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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, IanX= ; Kinney, Michael D > ; Liming Gao ; Liu,= Zhiguang > Subject: [PATCH v9 1/1] MdePkg/BaseLib: Add QuickSort function on 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 MdePkg/Library/BaseLib/QuickSort.c >=20 > diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/Ba= seLib.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 sorting d= oes 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 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 are f= illed >=20 > diff --git a/MdePkg/Library/BaseLib/BaseLib.inf 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 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 sorting d= oes 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 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 + ((LoopCount) *= ElementSize)), Pivot) <=3D 0){ >=20 > + // >=20 > + // swap >=20 > + // >=20 > + CopyMem (BufferOneElement, (UINT8*) BufferToSort + (NextSwapLocati= on * ElementSize), ElementSize); >=20 > + CopyMem ((UINT8*) BufferToSort + (NextSwapLocation * ElementSize),= (UINT8*) BufferToSort + ((LoopCount) * > ElementSize), ElementSize); >=20 > + CopyMem ((UINT8*) BufferToSort + ((LoopCount)*ElementSize), Buffer= OneElement, 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 * ElementSiz= e), ElementSize); >=20 > + CopyMem ((UINT8*) BufferToSort + (NextSwapLocation * ElementSize), Buf= ferOneElement, ElementSize); >=20 > + >=20 > + // >=20 > + // Now recurse on 2 partial lists. neither of these will have the 'pi= vot' 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 b/MdePkg/Libr= ary/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 reserved. >=20 > +# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved. >=20 > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. >=20 > # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
>=20 > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All ri= ghts 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