From nobody Thu May 2 12:06:06 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+82204+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+82204+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634530901; cv=none; d=zohomail.com; s=zohoarc; b=cqSoNmYbLCjMTVZPZsc+AF73HR+oc0sfIJhaQgeuS2ieqjVHC529bqHg9NbBfNn5I0vcnQ2xRDyaJAGOS9SN1gTXDkjq8k5Uy7vGhTT52BFpJWVEhftnM2yFLCq5XFGvpuSr/oCP0xrd/9CONjXr9kO0E390MI1UkirsOsdu9V0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634530901; 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=GkKyIGZwAEej8ZefwjqBJ3kPRYCS+nL9OJLab7q4byE=; b=A0M1KDEm3d9/T9A/A4AlaCYgmVY3FBu38Mpn98BRWpD7yOBNF5MZLimpUooyC8EO77OpzxKcEpwGdoACXTeEXh3j7ZVtxIPRVSKVnbd2RhvZyazvgenDYanwoSvyKljwmZ+NqZKzVkh/rqZlG9JUT+4DlCueEqyK9OMF0VTI6ww= 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+82204+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 1634530901025745.3743150555468; Sun, 17 Oct 2021 21:21:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TW8SYY1788612xUeUQoJi4XN; Sun, 17 Oct 2021 21:21:40 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.31753.1634530898587126374 for ; Sun, 17 Oct 2021 21:21:39 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="291637909" X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="291637909" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2021 21:21:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="443251291" X-Received: from ikuox-desk1.gar.corp.intel.com ([10.227.107.18]) by orsmga006.jf.intel.com with ESMTP; 17 Oct 2021 21:21:31 -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 v6 1/3] MdeModulePkg/SortLib: Add QuickSort function on BaseLib Date: Mon, 18 Oct 2021 12:21:25 +0800 Message-Id: <20211018042127.1306-2-ianx.kuo@intel.com> In-Reply-To: <20211018042127.1306-1-ianx.kuo@intel.com> References: <20211018042127.1306-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: adGRamseobEgSlPCb2uxUkknx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634530900; bh=X62tUeKQSESjNP5J6t0xdoGoTa2+zQe/t0dBZKnT+DI=; h=Cc:Date:From:Reply-To:Subject:To; b=Jn1iv96cxmDgBN/uYY2mwbjpL5O2P0Gk4jbGu0sww8efW3mTeUGwNQE/n0G5pt7icvo drDUAk8ccgYVVXmcy9/tx5HaXShLbEHda5+NgqGFV/z89LGcMGmcajorXJTJZIwVz1Utl tDlsgPzM8G3WW/DPmO+hBQNjt0lkr+Ic9ic= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634530901557100005 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 Reviewed-by: Jian J Wang --- .../Library/BaseSortLib/BaseSortLib.c | 115 +---------------- .../Library/UefiSortLib/UefiSortLib.c | 116 +----------------- 2 files changed, 8 insertions(+), 223 deletions(-) diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c b/MdeModulePkg/= Library/BaseSortLib/BaseSortLib.c index a12c7bc0ec..0903943ee4 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); + Buffer + ); =20 FreePool(Buffer); return; diff --git a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c b/MdeModulePkg/= Library/UefiSortLib/UefiSortLib.c index 46dc443638..29d8735c22 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); + 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 (#82204): https://edk2.groups.io/g/devel/message/82204 Mute This Topic: https://groups.io/mt/86406843/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 Thu May 2 12:06:06 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+82206+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+82206+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634530901; cv=none; d=zohomail.com; s=zohoarc; b=EviTwYHzzMLkw654LW/qNNDWMv4N9Yp6hqMNGUHqtj28rTHiPBY6eJtFHyqoj7bvyjWMBzjsVFA0OgVGoEgs3s/owPBENwJZT10N9/f+1Gnkw1++iUIXLXoOSoZr2+SVmcyoRUW2oBidojYut4km8MLe/tR+eINHUvAZpJh46yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634530901; 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=NDHgjG6nd+vqjhXyj7vxH64785huL/T6l/gHD09NB5E=; b=YWMT0914Exoj2jk59BF8khXHUsCItj0wrXRT69pJjBaTBw8r1C0nkWIUeZtXbBjYYaFkrm8pd2R+bfwdx1rQoPAw0FUts2psx0BE4ONr9KF2Luw8I2FPuqSA8rXzidwYrizaWRt+YjU8poIrCC5Ak2hWyEskH4Brf1cW16Rz1Gc= 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+82206+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 1634530901716326.72393559464626; Sun, 17 Oct 2021 21:21:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GfHcYY1788612x3M2bDeswns; Sun, 17 Oct 2021 21:21:41 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.31842.1634530900219059091 for ; Sun, 17 Oct 2021 21:21:40 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="291637912" X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="291637912" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2021 21:21:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="443251298" X-Received: from ikuox-desk1.gar.corp.intel.com ([10.227.107.18]) by orsmga006.jf.intel.com with ESMTP; 17 Oct 2021 21:21:33 -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 v6 2/3] CryptoPkg/CryptLib: Add QuickSort function on BaseLib Date: Mon, 18 Oct 2021 12:21:26 +0800 Message-Id: <20211018042127.1306-3-ianx.kuo@intel.com> In-Reply-To: <20211018042127.1306-1-ianx.kuo@intel.com> References: <20211018042127.1306-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: 25ioRgwLQ9cMA8bXOzbfJvUix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634530901; bh=GOaB/t77XEQH8wo+x2edGlDU3BhBcbJbNrzW5f/X1FU=; h=Cc:Date:From:Reply-To:Subject:To; b=j4ZeJAn66nR7Aa1Lg2ZmuJz5ez/Q3YSuJdrMAw2m+9Fd6mzvesh/BOUdGsm2cfF8hAF T1fo7QHKY0rFxDikbl/tKWLUw8btcOqlHp0Y7Xq6zpU0+N8vAtKKs9XXotEpWUbgnY8qf 1jJI0B+vg/L6cDIALipUK33e6qBiJeeIUws= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634531805363100005 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 Reviewed-by: Guomin Jiang --- .../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 (#82206): https://edk2.groups.io/g/devel/message/82206 Mute This Topic: https://groups.io/mt/86406845/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 Thu May 2 12:06:06 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+82205+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+82205+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634530901; cv=none; d=zohomail.com; s=zohoarc; b=DKfNpr46rs1K8UW+HG0RJ2RZp+0F1Nmg6LUkflUEIHyzaiu9HClV0zBDfa7/niKxm36H5MqFn3g64aEkHnOLwEegylFeLKXhgzWwAUf32pU7d0XvV1si6GpWduw9AcmBJp3zTLozEN8gXpIOgKHvwdepKIm4RBnN5eFnz9YnYL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634530901; 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=2VHelGDAImHICeInwH9MeYevWBCieNSCtN6uWVLR01A=; b=WKOocx21PIxGeRs63cipYg4wFoeVaECzEv9YvLElwT69i3bbpomheJ9XWmPdIJoS6MtonTVGn5D34j/fHTh3II5L2Rr70FUiMU2BKhw3+JvUBXxCpsvu0kNtpybXBHT4UXURv+qODVNsrobQtnDPfIUwbeQDmg0HI8xIfulszcU= 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+82205+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 1634530901761341.9976085177; Sun, 17 Oct 2021 21:21:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dK3fYY1788612xEHJjvfuKAF; Sun, 17 Oct 2021 21:21:41 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.31753.1634530898587126374 for ; Sun, 17 Oct 2021 21:21:40 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="291637914" X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="291637914" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2021 21:21:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="443251306" X-Received: from ikuox-desk1.gar.corp.intel.com ([10.227.107.18]) by orsmga006.jf.intel.com with ESMTP; 17 Oct 2021 21:21:35 -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 v6 3/3] UefiCpuPkg/CpuCacheInfoLib: Add QuickSort function on BaseLib Date: Mon, 18 Oct 2021 12:21:27 +0800 Message-Id: <20211018042127.1306-4-ianx.kuo@intel.com> In-Reply-To: <20211018042127.1306-1-ianx.kuo@intel.com> References: <20211018042127.1306-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: U5esngfvAL6hqLefap4q8TwMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634530901; bh=9QV+G5BbZvDkg+I9/MzqzAzJev9QNAO6eNJDr+CHrqo=; h=Cc:Date:From:Reply-To:Subject:To; b=aVPKoXl6VL3ExLumkuVfdaj2ehxhwYEUpSbnhU97bns46k3b/Qm5wjOjLqytMpwd0z2 2HTxh+O7PiafBoSiEvUcYft6vaGW4C3UEeW0Fg1cnd2V1hNKSjnhyRzl1plezvr5UsSH6 fJszkkZR0kuvegtA7LHPbGPZhe51ZYoAllY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634530903577100012 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 Reviewed-by: Ray Ni --- UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c | 3 ++- UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf | 2 -- UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h | 1 - UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c b/UefiCpu= Pkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c index c0077d6770..f4fcee39e9 100644 --- a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c @@ -282,6 +282,7 @@ CpuCacheInfoCollectCpuCacheInfoData ( UINTN LocalCacheInfoCount; UINTN Index; UINTN NextIndex; + CPU_CACHE_INFO SortBuffer; =20 // // Get number of Packages and Package ID. @@ -369,7 +370,7 @@ CpuCacheInfoCollectCpuCacheInfoData ( // // Sort LocalCacheInfo array by CPU package ID, core type, cache level= and cache type. // - PerformQuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalC= acheInfo), (SORT_COMPARE) CpuCacheInfoCompare); + QuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalCacheInf= o), CpuCacheInfoCompare, (VOID*) &SortBuffer); 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 (#82205): https://edk2.groups.io/g/devel/message/82205 Mute This Topic: https://groups.io/mt/86406844/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-