From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.92.20.37]) by mx.groups.io with SMTP id smtpd.web12.17772.1586462776640398692 for ; Thu, 09 Apr 2020 13:06:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=HES0Fan8; spf=pass (domain: outlook.com, ip: 40.92.20.37, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nGNYkaSerUSrvrS739haCl0guC7K5fQNwx9ObodmTVYzkNY5LKQDTTm/kX/w/Aqy7zWNAHvtBXgdyAEW21F+xaiiH3kh8DTk0TGLcejyCYkInMEANd/u3er5ZdDiBAjy217KYR08BGMJdDB+9b0mjshuMTqKCYXBhd7cySTOE+WpFDRTVUx6fMlVC4oMq9VD/wBJUa2vLltylpLCDvLJk8YSANjVxS9h900d4hG9ir4UjqxktXc1hb4aA37JffsIL1QyV0/ZgweNQ4mAHkFct6PyDWVghYVa/CTqngo6vY29CpyEMjfaVTVSDVQdgCZnoYz3rrm4k5G3CRHHlHfSvw== 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-SenderADCheck; bh=4pRJAevP0kUPmnLLAsGaLsiiD8gcaJRmZBrGfeZUYGo=; b=YCxXlZLh/M5AAp4Ldb+kwoEv9gDb2CaMoDqYfOHpWQhxVWMeFaiiiF2Ic+wIRrci4sBQKPJrE5vgjR7z3XDh4BstguBoQTelU3LOu0bmQeozfT0XzBtHBGm9QnLnBfXZ61kEXr/KGnsb4mjnmGRZk2yFFYV6FPa0kIKAez82SpwIaZ/K1F6vFrFcjzqr0uNev7BbeTDi0aK0++/l+n8O61zRosm6/DlQfMpsdqWnIR0CMut8GbX3tonmFx3OwgKFmL+xbjE5fcdvdlZd1lfSRGFmltGjR54DdJ+eRHw6GYpH2it2hVqjDBhYXuV8mpocxuCni4To0Fr0PmPq6IJTZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4pRJAevP0kUPmnLLAsGaLsiiD8gcaJRmZBrGfeZUYGo=; b=HES0Fan8O0QReuMr8wxjlS6EXjUGWcNb69dryeP1D+Mt3UzrOadoAsdsHyv5syb1cB3OeejlenLFZaaryY37AppUSeqfKixJ6+QUqwDVhI85fxsHv5pmrl8cnNbqJma/A0Jm7hTiSsLhIgYw+TgfvqQk8S32pA9YNKFabBvr460obn/KpGeNKmN88A3ACZ9f+EFQVTIuzLMCLJAi+ZBjK3htsUcCbh4/7ck3t135lITeVYZduIG3dBe6xKJiapJHWd9Zsb3yr9ZlwJEk80+Q3C0OGiWrFaZjtqK4Tz/h+Kml50EZbxd6itypLDeQiAX/qXbqEg2QOnIu+dXtIh4PKw== Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::4f) by BN8NAM11HT179.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::418) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15; Thu, 9 Apr 2020 20:06:15 +0000 Received: from DM5PR07MB3435.namprd07.prod.outlook.com (2a01:111:e400:fc4b::44) by BN8NAM11FT019.mail.protection.outlook.com (2a01:111:e400:fc4b::158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.18 via Frontend Transport; Thu, 9 Apr 2020 20:06:15 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:AB86D69EB1D65052883037ADB3A00635ED9E2781A352D701E9F8C0C48FE6347B;UpperCasedChecksum:2794515B4A3E25C15400EF23627EEAD70C6BC17B14C1F36E29EC1E646E43CFB2;SizeAsReceived:7889;Count:49 Received: from DM5PR07MB3435.namprd07.prod.outlook.com ([fe80::801e:fde0:da7d:191f]) by DM5PR07MB3435.namprd07.prod.outlook.com ([fe80::801e:fde0:da7d:191f%6]) with mapi id 15.20.2900.015; Thu, 9 Apr 2020 20:06:15 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Dandan Bi , Hao A Wu , Jian J Wang , Liming Gao , Michael D Kinney , Sean Brogan Subject: [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros Date: Thu, 9 Apr 2020 13:05:08 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 In-Reply-To: <20200409200514.32796-1-michael.kubacki@outlook.com> References: <20200409200514.32796-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MWHPR10CA0062.namprd10.prod.outlook.com (2603:10b6:300:2c::24) To DM5PR07MB3435.namprd07.prod.outlook.com (2603:10b6:4:67::14) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200409200514.32796-2-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:7:9d66:7f00:4b99:db3e) by MWHPR10CA0062.namprd10.prod.outlook.com (2603:10b6:300:2c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Thu, 9 Apr 2020 20:06:14 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200409200514.32796-2-michael.kubacki@outlook.com> X-TMN: [EJ3FZOCQPuAXzIQeNtojCBrCj/u5M743LsVZZBP7JsPK4lRAwODFIfGUb0gePB6f] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c62c7a4f-872a-42bb-bbaf-08d7dcc17557 X-MS-TrafficTypeDiagnostic: BN8NAM11HT179: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wj5Q+acBe1mtR3qQd7uHyQjDJ3JOXXFTqQqflrNfdYVjhHdzjRRIDyAZWbf4cLYugzfJ41Wu5nMd2ohB7tg8I9ZgYTTg/2ikoz8n0X2mKvvxFKKbgWtn2g8ceZ2WUG/fz/wYs22VKVb5XfeUsESXt1aAoFdefuA9X89iRqYbB4XLxfAsmhAfUuqTJ+7SfHmPSOSKzb3YCzBVoqn+G5YS5e/fETUWEXJ4YN1B8smtyiA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR07MB3435.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: Lo1E/tJ+vMLEzNvkdKQ4jfS80WO5kMaZzBzCSDdioXWnXP/prwNkTKQNGKjp38sBpMn+8Pqpn1KIHu2G9oJdYt/p7FMLPXlx51MmpP9QOYSGa1gYuBRFml3KzFCGDb8fckrcb/olPQrOzGBUtKss9vav/AW20DbD58NZ0b1ATxhqK2XNplFIP5I8NQefoF8p4UwumHTc2vs7U70ltTgxaQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c62c7a4f-872a-42bb-bbaf-08d7dcc17557 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2020 20:06:15.3546 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM11HT179 Content-Type: text/plain From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959 The macros EFI_LIST_FOR_EACH and EFI_LIST_FOR_EACH_SAFE have been duplicated across several drivers. These macros have proven useful and established a commonly used pattern for linked list iteration. This change defines the macros in BaseLib.h alongside other generic linked list macros and functions. Cc: Dandan Bi Cc: Hao A Wu Cc: Jian J Wang Cc: Liming Gao Cc: Michael D Kinney Cc: Sean Brogan Signed-off-by: Michael Kubacki --- MdePkg/Include/Library/BaseLib.h | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h index ecadff8b235e..d066f1be2495 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -4,6 +4,7 @@ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -2972,6 +2973,32 @@ PathCleanUpDirectories( **/ #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)} +/** + Iterates over each node in a doubly linked list using each node's forward link. + + @param Entry A pointer to a list node used as a loop cursor during iteration + @param ListHead The head node of the doubly linked list + +**/ +#define BASE_LIST_FOR_EACH(Entry, ListHead) \ + for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink) + +/** + Iterates over each node in a doubly linked list using each node's forward link + with safety against node removal. + + This macro uses NextEntry to temporarily store the next list node so the node + pointed to by Entry may be deleted in the current loop iteration step and + iteration can continue from the node pointed to by NextEntry. + + @param Entry A pointer to a list node used as a loop cursor during iteration + @param NextEntry A pointer to a list node used to temporarily store the next node + @param ListHead The head node of the doubly linked list + +**/ +#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \ + for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\ + Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink) /** Checks whether FirstEntry and SecondEntry are part of the same doubly-linked -- 2.16.3.windows.1