Re: enable cmp macro for rb-trees in sys/tree.h

2013-06-10 Thread Philip Guenther
On Sun, Jun 9, 2013 at 3:22 PM, Franco Fichtner fra...@lastsummer.de wrote:
 I've had this patch in my tree for a while.  It's just a consistency
 fix so that cmp can be a plain macro for rb-trees, too.
...
 -   comp = cmp(elm, tmp);   \
 +   comp = (cmp)(elm, tmp); \

Your diff doesn't do what you say it does: adding parens would keep a
functional macro from being used.


Philip Guenther



Re: enable cmp macro for rb-trees in sys/tree.h

2013-06-10 Thread Franco Fichtner
You are right, my mistake.  The previous patch was the consistency
patch, but this one actually does what the subject says.  The motivation
behind it was the fact that rb trees *almost* support this and I can't
see any harm.  The same could be done for splay trees, but I found this
too intrusive without further feedback.


Thanks,
Franco

Index: tree.h
===
RCS file: /OpenBSD/src/sys/sys/tree.h,v
retrieving revision 1.13
diff -u -r1.13 tree.h
--- tree.h  9 Jul 2011 00:19:45 -   1.13
+++ tree.h  11 Jun 2013 05:15:50 -
@@ -594,7 +594,7 @@
tmp = RB_ROOT(head);\
while (tmp) {   \
parent = tmp;   \
-   comp = (cmp)(elm, parent);  \
+   comp = cmp(elm, parent);\
if (comp  0)   \
tmp = RB_LEFT(tmp, field);  \
else if (comp  0)  \



enable cmp macro for rb-trees in sys/tree.h

2013-06-09 Thread Franco Fichtner
Hi,

I've had this patch in my tree for a while.  It's just a consistency
fix so that cmp can be a plain macro for rb-trees, too.


Regards,
Franco

Index: tree.h
===
RCS file: /OpenBSD/src/sys/sys/tree.h,v
retrieving revision 1.13
diff -u -r1.13 tree.h
--- tree.h  9 Jul 2011 00:19:45 -   1.13
+++ tree.h  9 Jun 2013 19:02:37 -
@@ -622,7 +622,7 @@
struct type *tmp = RB_ROOT(head);   \
int comp;   \
while (tmp) {   \
-   comp = cmp(elm, tmp);   \
+   comp = (cmp)(elm, tmp); \
if (comp  0)   \
tmp = RB_LEFT(tmp, field);  \
else if (comp  0)  \
@@ -641,7 +641,7 @@
struct type *res = NULL;\
int comp;   \
while (tmp) {   \
-   comp = cmp(elm, tmp);   \
+   comp = (cmp)(elm, tmp); \
if (comp  0) { \
res = tmp;  \
tmp = RB_LEFT(tmp, field);  \