From nobody Tue Apr 30 20:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82138+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82138+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634308438; cv=none; d=zohomail.com; s=zohoarc; b=RvmNFLcE1MRzlIi4Ul1l68BMBXoplx7oJmj7Iy2c7uX0tV2a9HFez73pGkmOomYLRKuqTCdm9G/L1pyWreop9RRFn3zYDMQ078uVvvOddKcYt6Y+1RqLeUC7kA2rrkYW7Snz+nDhA5+E0fdYS+kY9VlpMbwBdtOTw0RQsdlTQ1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634308438; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l9eW3LgxLYMnd8zoKmeFniIma1co/uv2kLZN0GzZTWM=; b=ibcrvks9KfJ1lAUt7fW42lZDBgk8MRjej8KJiTNPvapFhDEmJ/vKx6Sp5B2UzinqycqEivTwSfjaYs7O+39i3HbNvDWAMRrMJegJ7v5tZ+oFLLvbUbRfUD1Ti8/ZNqOQih5KOEftFOqqeU5vgkSTq5qo0kzhEt5oMVGy+WjKOEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82138+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634308438930862.6859598484226; Fri, 15 Oct 2021 07:33:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Z3HoYY1788612xXkcQ4mhgDG; Fri, 15 Oct 2021 07:33:58 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.10228.1634308437665760576 for ; Fri, 15 Oct 2021 07:33:58 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="228203307" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="228203307" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 07:33:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="481712660" X-Received: from ikuox-desk1.gar.corp.intel.com ([10.227.107.18]) by orsmga007.jf.intel.com with ESMTP; 15 Oct 2021 07:33:52 -0700 From: "IanX Kuo" To: devel@edk2.groups.io Cc: amy.chan@intel.com, ray.ni@intel.com, IanX Kuo , Jian J Wang , Liming Gao Subject: [edk2-devel] [PATCH v1 1/3] MdeModulePkg/SortLib: Add QuickSort function on BaseLib Date: Fri, 15 Oct 2021 22:33:44 +0800 Message-Id: <20211015143346.31-2-ianx.kuo@intel.com> In-Reply-To: <20211015143346.31-1-ianx.kuo@intel.com> References: <20211015143346.31-1-ianx.kuo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,ianx.kuo@intel.com X-Gm-Message-State: BELZlTuV8p35RZscmyJpCh8Rx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634308438; bh=wnrDVJtEfrXXO08Xh/VfXxsUswZbIPH1kAekUnVeoE0=; h=Cc:Date:From:Reply-To:Subject:To; b=uUi0nRLgw5/se1HnIgytm7jD6o4sg365hSHoBtqu7bh1ed2PlHX1ZIyRDz762hXQSo8 /zoyi/orCl+jWIwNxTXfOtBFLR9mnlkkt2CZ1hSmQV9/C9caAsmXWlb3vERRe8UI2JIe/ i+u6PCcy/BOR2og9wI3EFXqlRVSDzv3sSdc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634308439872100002 Content-Type: text/plain; charset="utf-8" From: IanX Kuo REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3675 Use QuickSort instead of QuickSortWorker Cc: Ray Ni Cc: Jian J Wang Cc: Liming Gao Signed-off-by: IanX Kuo --- .../Library/BaseSortLib/BaseSortLib.c | 117 +---------------- .../Library/UefiSortLib/UefiSortLib.c | 118 +----------------- 2 files changed, 10 insertions(+), 225 deletions(-) diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c b/MdeModulePkg/= Library/BaseSortLib/BaseSortLib.c index a12c7bc0ec..b33339ac7c 100644 --- a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c +++ b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c @@ -1,7 +1,7 @@ /** @file Library used for sorting routines. =20 - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -13,114 +13,6 @@ #include #include =20 -/** - Worker function for QuickSorting. This function is identical to Perform= QuickSort, - except that is uses the pre-allocated buffer so the in place sorting doe= s not need to - allocate and free buffers constantly. - - Each element must be equal sized. - - if BufferToSort is NULL, then ASSERT. - if CompareFunction is NULL, then ASSERT. - if Buffer is NULL, then ASSERT. - - if Count is < 2 then perform no action. - if Size is < 1 then perform no action. - - @param[in, out] BufferToSort on call a Buffer of (possibly sorted) ele= ments - on return a buffer of sorted elements - @param[in] Count the number of elements in the buffer to s= ort - @param[in] ElementSize Size of an element in bytes - @param[in] CompareFunction The function to call to perform the compa= rison - of any 2 elements - @param[in] Buffer Buffer of size ElementSize for use in swa= pping -**/ -VOID -EFIAPI -QuickSortWorker ( - IN OUT VOID *BufferToSort, - IN CONST UINTN Count, - IN CONST UINTN ElementSize, - IN SORT_COMPARE CompareFunction, - IN VOID *Buffer - ) -{ - VOID *Pivot; - UINTN LoopCount; - UINTN NextSwapLocation; - - ASSERT(BufferToSort !=3D NULL); - ASSERT(CompareFunction !=3D NULL); - ASSERT(Buffer !=3D NULL); - - if ( Count < 2 - || ElementSize < 1 - ){ - return; - } - - NextSwapLocation =3D 0; - - // - // pick a pivot (we choose last element) - // - Pivot =3D ((UINT8*)BufferToSort+((Count-1)*ElementSize)); - - // - // Now get the pivot such that all on "left" are below it - // and everything "right" are above it - // - for ( LoopCount =3D 0 - ; LoopCount < Count -1 - ; LoopCount++ - ){ - // - // if the element is less than the pivot - // - if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementS= ize)),Pivot) <=3D 0){ - // - // swap - // - CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize)= , ElementSize); - CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8= *)BufferToSort+((LoopCount)*ElementSize), ElementSize); - CopyMem ((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer, Ele= mentSize); - - // - // increment NextSwapLocation - // - NextSwapLocation++; - } - } - // - // swap pivot to it's final position (NextSwapLocaiton) - // - CopyMem (Buffer, Pivot, ElementSize); - CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Ele= mentSize); - CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, El= ementSize); - - // - // Now recurse on 2 paritial lists. neither of these will have the 'piv= ot' element - // IE list is sorted left half, pivot element, sorted right half... - // - if (NextSwapLocation >=3D 2) { - QuickSortWorker( - BufferToSort, - NextSwapLocation, - ElementSize, - CompareFunction, - Buffer); - } - - if ((Count - NextSwapLocation - 1) >=3D 2) { - QuickSortWorker( - (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize, - Count - NextSwapLocation - 1, - ElementSize, - CompareFunction, - Buffer); - } - return; -} /** Function to perform a Quick Sort alogrithm on a buffer of comparable ele= ments. =20 @@ -156,12 +48,13 @@ PerformQuickSort ( Buffer =3D AllocateZeroPool(ElementSize); ASSERT(Buffer !=3D NULL); =20 - QuickSortWorker( + QuickSort ( BufferToSort, Count, ElementSize, - CompareFunction, - Buffer); + (SORT_COMPARE) CompareFunction, + Buffer + ); =20 FreePool(Buffer); return; diff --git a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c b/MdeModulePkg/= Library/UefiSortLib/UefiSortLib.c index 46dc443638..151a5a9ac3 100644 --- a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c +++ b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c @@ -1,7 +1,7 @@ /** @file Library used for sorting routines. =20 - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -29,115 +29,6 @@ STATIC EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollat= ion =3D NULL; } \ } =20 -/** - Worker function for QuickSorting. This function is identical to Perform= QuickSort, - except that is uses the pre-allocated buffer so the in place sorting doe= s not need to - allocate and free buffers constantly. - - Each element must be equal sized. - - if BufferToSort is NULL, then ASSERT. - if CompareFunction is NULL, then ASSERT. - if Buffer is NULL, then ASSERT. - - if Count is < 2 then perform no action. - if Size is < 1 then perform no action. - - @param[in, out] BufferToSort on call a Buffer of (possibly sorted) ele= ments - on return a buffer of sorted elements - @param[in] Count the number of elements in the buffer to s= ort - @param[in] ElementSize Size of an element in bytes - @param[in] CompareFunction The function to call to perform the compa= rison - of any 2 elements - @param[in] Buffer Buffer of size ElementSize for use in swa= pping -**/ -VOID -EFIAPI -QuickSortWorker ( - IN OUT VOID *BufferToSort, - IN CONST UINTN Count, - IN CONST UINTN ElementSize, - IN SORT_COMPARE CompareFunction, - IN VOID *Buffer - ) -{ - VOID *Pivot; - UINTN LoopCount; - UINTN NextSwapLocation; - - ASSERT(BufferToSort !=3D NULL); - ASSERT(CompareFunction !=3D NULL); - ASSERT(Buffer !=3D NULL); - - if ( Count < 2 - || ElementSize < 1 - ){ - return; - } - - NextSwapLocation =3D 0; - - // - // pick a pivot (we choose last element) - // - Pivot =3D ((UINT8*)BufferToSort+((Count-1)*ElementSize)); - - // - // Now get the pivot such that all on "left" are below it - // and everything "right" are above it - // - for ( LoopCount =3D 0 - ; LoopCount < Count -1 - ; LoopCount++ - ){ - // - // if the element is less than the pivot - // - if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementS= ize)),Pivot) <=3D 0){ - // - // swap - // - CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize)= , ElementSize); - CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8= *)BufferToSort+((LoopCount)*ElementSize), ElementSize); - CopyMem ((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer, Ele= mentSize); - - // - // increment NextSwapLocation - // - NextSwapLocation++; - } - } - // - // swap pivot to it's final position (NextSwapLocaiton) - // - CopyMem (Buffer, Pivot, ElementSize); - CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Ele= mentSize); - CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, El= ementSize); - - // - // Now recurse on 2 paritial lists. neither of these will have the 'piv= ot' element - // IE list is sorted left half, pivot element, sorted right half... - // - if (NextSwapLocation >=3D 2) { - QuickSortWorker( - BufferToSort, - NextSwapLocation, - ElementSize, - CompareFunction, - Buffer); - } - - if ((Count - NextSwapLocation - 1) >=3D 2) { - QuickSortWorker( - (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize, - Count - NextSwapLocation - 1, - ElementSize, - CompareFunction, - Buffer); - } - - return; -} /** Function to perform a Quick Sort alogrithm on a buffer of comparable ele= ments. =20 @@ -173,12 +64,13 @@ PerformQuickSort ( Buffer =3D AllocateZeroPool(ElementSize); ASSERT(Buffer !=3D NULL); =20 - QuickSortWorker( + QuickSort ( BufferToSort, Count, ElementSize, - CompareFunction, - Buffer); + (SORT_COMPARE) CompareFunction, + Buffer + ); =20 FreePool(Buffer); return; --=20 2.30.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 (#82138): https://edk2.groups.io/g/devel/message/82138 Mute This Topic: https://groups.io/mt/86340400/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- From nobody Tue Apr 30 20:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82139+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82139+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634308440; cv=none; d=zohomail.com; s=zohoarc; b=istIIpcZkX/lBj0jcwDzs4SgF5YP2T03t6G5Uvy6GTsZQG7aVtNlB7OU4hiBTkJtJCRLiqLMu901PWlirhWO7HnuswGocI+KcNpqZCpbC1X3PEI3B4N3drxVWTXC5cE/bpXCN5e+vv1c53FDbnnVX7QsPbsUy2ahK1R2edsdxZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634308440; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=1+R5RoOBXJyVEcJrErVg5lIbb5LdYLpMn3Upf7n+JCo=; b=kfPmTii5WhzJegT4oj2/nCSbcIuy3GVP5w0nKFi4lEFkaEVavdalAdd57KUPkqRivS8pyPezvBnm/WvvHpkAAvd+aPrCFq9qCEDIIpj5aEDsizWV+RyQ6bOgZjH+tNvPENXdwUdv7PHeGztMbyKf2cG8M8iwmr/zriMY+3x2YUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82139+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634308440217846.6341476825019; Fri, 15 Oct 2021 07:34:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id LqktYY1788612xhxiBhxd8vz; Fri, 15 Oct 2021 07:33:59 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.10228.1634308437665760576 for ; Fri, 15 Oct 2021 07:33:59 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="228203316" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="228203316" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 07:33:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="481712678" X-Received: from ikuox-desk1.gar.corp.intel.com ([10.227.107.18]) by orsmga007.jf.intel.com with ESMTP; 15 Oct 2021 07:33:54 -0700 From: "IanX Kuo" To: devel@edk2.groups.io Cc: amy.chan@intel.com, ray.ni@intel.com, IanX Kuo , Jiewen Yao , Jian J Wang , Xiaoyu Lu , Guomin Jiang Subject: [edk2-devel] [PATCH v1 2/3] CryptoPkg/CryptLib: Add QuickSort function on BaseLib Date: Fri, 15 Oct 2021 22:33:45 +0800 Message-Id: <20211015143346.31-3-ianx.kuo@intel.com> In-Reply-To: <20211015143346.31-1-ianx.kuo@intel.com> References: <20211015143346.31-1-ianx.kuo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,ianx.kuo@intel.com X-Gm-Message-State: xI3AN4uVLIBVxWuQmsyiYW4nx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634308439; bh=GQmWI10XxXTpSozoo9ZIBtGqQxPKtvMmGPuBmrs4xP8=; h=Cc:Date:From:Reply-To:Subject:To; b=rMlIjSWkOAW2l1O189rV9ShsCmdn9bcd9ernHeDdxBsjS7P+Bg2o1kYo56ZNip0v+k7 3zpeWHg36zMvuJ867+mF39r64HrE55zKrf3rgqWqvtPYKV/0wboT2oiYxPeoYvI06I27+ TMstMYd366xwrduz4TE3SwtLWMZI1gNJ9j8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634308441224100010 Content-Type: text/plain; charset="utf-8" From: IanX Kuo REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3675 Use QuickSort instead of QuickSortWorker Cc: Ray Ni Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang Signed-off-by: IanX Kuo --- .../Library/BaseCryptLib/SysCall/CrtWrapper.c | 92 +------------------ 1 file changed, 2 insertions(+), 90 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c b/CryptoPk= g/Library/BaseCryptLib/SysCall/CrtWrapper.c index 42235ab96a..b10edaae5b 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c @@ -2,7 +2,7 @@ C Run-Time Libraries (CRT) Wrapper Implementation for OpenSSL-based Cryptographic Library. =20 -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -22,91 +22,6 @@ int IN VOID *Buffer2 ); =20 -// -// Duplicated from EDKII BaseSortLib for qsort() wrapper -// -STATIC -VOID -QuickSortWorker ( - IN OUT VOID *BufferToSort, - IN CONST UINTN Count, - IN CONST UINTN ElementSize, - IN SORT_COMPARE CompareFunction, - IN VOID *Buffer - ) -{ - VOID *Pivot; - UINTN LoopCount; - UINTN NextSwapLocation; - - ASSERT(BufferToSort !=3D NULL); - ASSERT(CompareFunction !=3D NULL); - ASSERT(Buffer !=3D NULL); - - if (Count < 2 || ElementSize < 1) { - return; - } - - NextSwapLocation =3D 0; - - // - // Pick a pivot (we choose last element) - // - Pivot =3D ((UINT8 *)BufferToSort + ((Count - 1) * ElementSize)); - - // - // Now get the pivot such that all on "left" are below it - // and everything "right" are above it - // - for (LoopCount =3D 0; LoopCount < Count - 1; LoopCount++) - { - // - // If the element is less than the pivot - // - if (CompareFunction ((VOID *)((UINT8 *)BufferToSort + ((LoopCount) * E= lementSize)), Pivot) <=3D 0) { - // - // Swap - // - CopyMem (Buffer, (UINT8 *)BufferToSort + (NextSwapLocation * Element= Size), ElementSize); - CopyMem ((UINT8 *)BufferToSort + (NextSwapLocation * ElementSize), (= UINT8 *)BufferToSort + ((LoopCount) * ElementSize), ElementSize); - CopyMem ((UINT8 *)BufferToSort + ((LoopCount) * ElementSize), Buffer= , ElementSize); - - // - // Increment NextSwapLocation - // - NextSwapLocation++; - } - } - // - // Swap pivot to its final position (NextSwapLocation) - // - CopyMem (Buffer, Pivot, ElementSize); - CopyMem (Pivot, (UINT8 *)BufferToSort + (NextSwapLocation * ElementSize)= , ElementSize); - CopyMem ((UINT8 *)BufferToSort + (NextSwapLocation * ElementSize), Buffe= r, ElementSize); - - // - // Now recurse on 2 partial lists. Neither of these will have the 'pivo= t' element. - // IE list is sorted left half, pivot element, sorted right half... - // - QuickSortWorker ( - BufferToSort, - NextSwapLocation, - ElementSize, - CompareFunction, - Buffer - ); - - QuickSortWorker ( - (UINT8 *)BufferToSort + (NextSwapLocation + 1) * ElementSize, - Count - NextSwapLocation - 1, - ElementSize, - CompareFunction, - Buffer - ); - - return; -} - //--------------------------------------------------------- // Standard C Run-time Library Interface Wrapper //--------------------------------------------------------- @@ -337,10 +252,7 @@ void qsort (void *base, size_t num, size_t width, int = (*compare)(const void *, c Buffer =3D malloc (width); ASSERT (Buffer !=3D NULL); =20 - // - // Re-use PerformQuickSort() function Implementation in EDKII BaseSortLi= b. - // - QuickSortWorker (base, (UINTN)num, (UINTN)width, (SORT_COMPARE)compare, = Buffer); + QuickSort (base, (UINTN)num, (UINTN)width, (BASE_SORT_COMPARE)compare, B= uffer); =20 free (Buffer); return; --=20 2.30.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 (#82139): https://edk2.groups.io/g/devel/message/82139 Mute This Topic: https://groups.io/mt/86340401/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- From nobody Tue Apr 30 20:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82140+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82140+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634308440; cv=none; d=zohomail.com; s=zohoarc; b=foPKMYY7PLQMQdd36BDHAxs8sVrMMkj4Xb191vIKXN4JEL992Q4/dtq5GoqL5fAneb0Cu1smiv53OLjbCl8iBKTK2Axl6wEAGDPmtC+du5gJFSQ5yALu3JlOwXOf5tBXmCqjMO2Us+sXpLTFKo589elfXN86npH+qpaWckRsQ9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634308440; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=i1BxaOiuViFYuF0HCV1kiAAiY2aLS7JcNQAhArjDXxE=; b=J23oRqtZuyFzU/vqUOiWqVlpwsuH4SjYRGZGMEzUJeJSlbtDt97OI1Mff45MAbBDJUgjme9BzEpAN165/dyVpP3AwBVbALptfZFt/pPfhtj8/a+0+End0um5AA5grLPO6HINelB5aYxDgdzomfWixN89PKqEIQESvnepa933ozw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82140+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634308440843368.2408527199118; Fri, 15 Oct 2021 07:34:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qp9XYY1788612xIEFslj3bVX; Fri, 15 Oct 2021 07:34:00 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.10228.1634308437665760576 for ; Fri, 15 Oct 2021 07:34:00 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="228203320" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="228203320" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 07:33:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="481712690" X-Received: from ikuox-desk1.gar.corp.intel.com ([10.227.107.18]) by orsmga007.jf.intel.com with ESMTP; 15 Oct 2021 07:33:56 -0700 From: "IanX Kuo" To: devel@edk2.groups.io Cc: amy.chan@intel.com, ray.ni@intel.com, IanX Kuo , Eric Dong , Rahul Kumar Subject: [edk2-devel] [PATCH v1 3/3] UefiCpuPkg/CpuCacheInfoLib: Add QuickSort function on BaseLib Date: Fri, 15 Oct 2021 22:33:46 +0800 Message-Id: <20211015143346.31-4-ianx.kuo@intel.com> In-Reply-To: <20211015143346.31-1-ianx.kuo@intel.com> References: <20211015143346.31-1-ianx.kuo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,ianx.kuo@intel.com X-Gm-Message-State: WmVeaLk7iEcL9ciicptQXtE4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634308440; bh=qciwhOwu2wbwEFfOU9B0p5omn7ZiivC3t21l20CkVFQ=; h=Cc:Date:From:Reply-To:Subject:To; b=MgP5lSfNnZD9W3DMVcm4v2HSl1DriQmdgB81IfMUklfBqn1V0HM8lVQ5m9M4cACTrnX pITpp6/7K2GjP0P1sunZUCaCV9syDrVNLemnushlmrjOZ3OOLQfbQX0q+sJV1UiKdNsVS YckzR6yfp4ypXSneqNa9qjt8tQcVZPFIMJE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634308441489100013 Content-Type: text/plain; charset="utf-8" From: IanX Kuo REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3675 Remove MdeModulePkg dependency Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: IanX Kuo --- UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c | 5 ++++- UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf | 2 -- UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h | 1 - UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf | 2 -- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c b/UefiCpu= Pkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c index c0077d6770..b5ed05bd43 100644 --- a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c @@ -282,6 +282,7 @@ CpuCacheInfoCollectCpuCacheInfoData ( UINTN LocalCacheInfoCount; UINTN Index; UINTN NextIndex; + VOID *QuickSortBuffer; =20 // // Get number of Packages and Package ID. @@ -369,7 +370,9 @@ CpuCacheInfoCollectCpuCacheInfoData ( // // Sort LocalCacheInfo array by CPU package ID, core type, cache level= and cache type. // - PerformQuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalC= acheInfo), (SORT_COMPARE) CpuCacheInfoCompare); + QuickSortBuffer =3D AllocateZeroPool (sizeof (*LocalCacheInfo)); + ASSERT (QuickSortBuffer !=3D NULL); + QuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalCacheInf= o), (BASE_SORT_COMPARE) CpuCacheInfoCompare, QuickSortBuffer); CopyMem (CacheInfo, LocalCacheInfo, sizeof (*CacheInfo) * LocalCacheIn= foCount); DEBUG_CODE ( CpuCacheInfoPrintCpuCacheInfoTable (CacheInfo, LocalCacheInfoCount); diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf b/Ue= fiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf index c3d3f1e799..fdd79970f9 100644 --- a/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf @@ -25,7 +25,6 @@ =20 [Packages] MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec UefiCpuPkg/UefiCpuPkg.dec =20 [LibraryClasses] @@ -34,7 +33,6 @@ BaseMemoryLib MemoryAllocationLib UefiBootServicesTableLib - SortLib =20 [Protocols] gEfiMpServiceProtocolGuid diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h b= /UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h index 26e1f46516..829a9f43ce 100644 --- a/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h @@ -17,7 +17,6 @@ #include #include #include -#include #include =20 typedef union { diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf b/Ue= fiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf index 0864497849..c643fc89be 100644 --- a/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf @@ -25,7 +25,6 @@ =20 [Packages] MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec UefiCpuPkg/UefiCpuPkg.dec =20 [LibraryClasses] @@ -34,7 +33,6 @@ BaseMemoryLib MemoryAllocationLib PeiServicesTablePointerLib - SortLib =20 [Ppis] gEdkiiPeiMpServices2PpiGuid --=20 2.30.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 (#82140): https://edk2.groups.io/g/devel/message/82140 Mute This Topic: https://groups.io/mt/86340402/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-