X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdePkg%2FInclude%2FLibrary%2FBaseLib.h;h=d066f1be2495e261c9f7340221fad4fd7541885b;hb=3b5a58c5f0056c0dd93ffaa3b1d51d23eec0692b;hp=ecadff8b235ee3ea112c0d2d19af57586b8bbc81;hpb=0f127f31871a439250556d8ae93a325d4ff985c6;p=mirror_edk2.git
diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index ecadff8b23..d066f1be24 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