Finish spliting sgen-nursery-allocator into a separate compilation unit
[mono.git] / mono / utils / mono-linked-list-set.h
index 9401c5593f955718367563a80e77938f9925056e..5009fc8c8c2a06994d71970d3ed3e6dba95e5026 100644 (file)
 #define __MONO_SPLIT_ORDERED_LIST_H__
 
 #include <mono/utils/hazard-pointer.h>
+#include <mono/utils/mono-membar.h>
 
 typedef struct _MonoLinkedListSetNode MonoLinkedListSetNode;
 
 struct _MonoLinkedListSetNode {
+       /* next must be the first element in this struct! */
        MonoLinkedListSetNode *next;
        uintptr_t key;
 };
@@ -62,9 +64,9 @@ Requires the world to be stoped
 */
 #define MONO_LLS_FOREACH(list, element) {\
        MonoLinkedListSetNode *__cur;   \
-       for (__cur = list->head; __cur; __cur = mono_lls_pointer_unmask (__cur->next))  \
+       for (__cur = (list)->head; __cur; __cur = mono_lls_pointer_unmask (__cur->next)) \
                if (!mono_lls_pointer_get_mark (__cur->next)) { \
-                       element = (typeof(element))__cur;       \
+                       (element) = (typeof((element)))__cur;                   \
 
 #define MONO_LLS_END_FOREACH }}
 
@@ -82,12 +84,12 @@ Provides snapshot iteration
 #define MONO_LLS_FOREACH_SAFE(list, element) {\
        MonoThreadHazardPointers *__hp = mono_hazard_pointer_get ();    \
        MonoLinkedListSetNode *__cur, *__next;  \
-       for (__cur = mono_lls_pointer_unmask (get_hazardous_pointer ((gpointer volatile*)&list->head, __hp, 1)); \
+       for (__cur = mono_lls_pointer_unmask (get_hazardous_pointer ((gpointer volatile*)&(list)->head, __hp, 1)); \
                __cur;  \
                __cur = mono_lls_info_step (__next, __hp)) {    \
                __next = get_hazardous_pointer_with_mask ((gpointer volatile*)&__cur->next, __hp, 0);   \
                if (!mono_lls_pointer_get_mark (__next)) {      \
-                       element = (typeof(element))__cur;
+                       (element) = (typeof((element)))__cur;
 
 #define MONO_LLS_END_FOREACH_SAFE \
                } \