Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102832678
D35502.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D35502.diff
View Options
diff --git a/sys/sys/tree.h b/sys/sys/tree.h
--- a/sys/sys/tree.h
+++ b/sys/sys/tree.h
@@ -372,7 +372,7 @@
#endif
#define RB_UPDATE_AUGMENT(elm, field) do { \
- __typeof(elm) rb_update_tmp = (elm); \
+ __typeof(elm) rb_update_tmp = (elm); \
do { \
RB_AUGMENT(rb_update_tmp); \
} while ((rb_update_tmp = RB_PARENT(rb_update_tmp, field)) != NULL); \
@@ -395,7 +395,6 @@
RB_SWAP_CHILD(head, elm, tmp, field); \
RB_LEFT(tmp, field) = (elm); \
RB_SET_PARENT(elm, tmp, field); \
- RB_AUGMENT(elm); \
} while (/*CONSTCOND*/ 0)
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
@@ -406,7 +405,6 @@
RB_SWAP_CHILD(head, elm, tmp, field); \
RB_RIGHT(tmp, field) = (elm); \
RB_SET_PARENT(elm, tmp, field); \
- RB_AUGMENT(elm); \
} while (/*CONSTCOND*/ 0)
/* Generates prototypes and inline functions */
@@ -494,7 +492,9 @@
elm = parent; \
continue; \
} \
- if (!RB_RED_RIGHT(elm, field)) { \
+ if (RB_RED_RIGHT(elm, field)) \
+ child = elm; \
+ else { \
/* coverity[uninit_use] */ \
RB_ROTATE_LEFT(head, elm, child, field);\
if (RB_RED_RIGHT(child, field)) \
@@ -503,9 +503,11 @@
RB_FLIP_ALL(elm, field); \
else \
RB_FLIP_LEFT(elm, field); \
- elm = child; \
+ if ((RB_BITS(child, field) & \
+ RB_RED_MASK) == 0) \
+ elm = child; \
} \
- RB_ROTATE_RIGHT(head, parent, elm, field); \
+ RB_ROTATE_RIGHT(head, parent, child, field); \
} else { \
if (RB_RED_RIGHT(parent, field)) { \
RB_FLIP_RIGHT(parent, field); \
@@ -517,7 +519,9 @@
elm = parent; \
continue; \
} \
- if (!RB_RED_LEFT(elm, field)) { \
+ if (RB_RED_LEFT(elm, field)) \
+ child = elm; \
+ else { \
/* coverity[uninit_use] */ \
RB_ROTATE_RIGHT(head, elm, child, field);\
if (RB_RED_LEFT(child, field)) \
@@ -526,11 +530,16 @@
RB_FLIP_ALL(elm, field); \
else \
RB_FLIP_RIGHT(elm, field); \
- elm = child; \
+ if ((RB_BITS(child, field) & \
+ RB_RED_MASK) == 0) \
+ elm = child; \
} \
- RB_ROTATE_LEFT(head, parent, elm, field); \
+ RB_ROTATE_LEFT(head, parent, child, field); \
} \
- RB_BITS(elm, field) &= ~RB_RED_MASK; \
+ RB_BITS(child, field) &= ~RB_RED_MASK; \
+ if (elm != child) \
+ RB_AUGMENT(elm); \
+ RB_AUGMENT(parent); \
break; \
} \
}
@@ -589,21 +598,22 @@
else \
RB_FLIP_RIGHT(sib, field); \
RB_BITS(elm, field) |= RB_RED_MASK; \
- sib = elm; \
break; \
case RB_RED_L: \
if (RB_STRICT_HST && elm != NULL) { \
RB_FLIP_RIGHT(parent, field); \
RB_FLIP_ALL(sib, field); \
+ elm = sib; \
break; \
} \
RB_FLIP_LEFT(parent, field); \
/* FALLTHROUGH */ \
default: \
RB_FLIP_RIGHT(sib, field); \
+ elm = sib; \
break; \
} \
- RB_ROTATE_LEFT(head, parent, sib, field); \
+ RB_ROTATE_LEFT(head, parent, elm, field); \
} else { \
if (!RB_RED_RIGHT(parent, field)) { \
RB_FLIP_RIGHT(parent, field); \
@@ -632,22 +642,25 @@
else \
RB_FLIP_LEFT(sib, field); \
RB_BITS(elm, field) |= RB_RED_MASK; \
- sib = elm; \
break; \
case RB_RED_R: \
if (RB_STRICT_HST && elm != NULL) { \
RB_FLIP_LEFT(parent, field); \
RB_FLIP_ALL(sib, field); \
+ elm = sib; \
break; \
} \
RB_FLIP_RIGHT(parent, field); \
/* FALLTHROUGH */ \
default: \
RB_FLIP_LEFT(sib, field); \
+ elm = sib; \
break; \
} \
- RB_ROTATE_RIGHT(head, parent, sib, field); \
+ RB_ROTATE_RIGHT(head, parent, elm, field); \
} \
+ if (sib != elm) \
+ RB_AUGMENT(sib); \
break; \
} while ((parent = RB_PARENT(elm, field)) != NULL); \
}
@@ -687,6 +700,8 @@
RB_SET_PARENT(child, parent, field); \
if (parent != NULL) { \
name##_RB_REMOVE_COLOR(head, parent, child); \
+ if (parent == elm && RB_LEFT(parent, field) == NULL) \
+ parent = RB_PARENT(parent, field); \
RB_UPDATE_AUGMENT(parent, field); \
} \
return (old); \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 6:26 PM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14702617
Default Alt Text
D35502.diff (4 KB)
Attached To
Mode
D35502: iommu_gas: avoid needless tree augmentations
Attached
Detach File
Event Timeline
Log In to Comment