]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use __BIT
authorRoy Marples <roy@marples.name>
Thu, 7 Mar 2019 12:00:37 +0000 (12:00 +0000)
committerRoy Marples <roy@marples.name>
Thu, 7 Mar 2019 12:00:37 +0000 (12:00 +0000)
compat/rbtree.h
src/common.h

index 3196d3418434430156b231263e8417a70de6bf32..9eb78512973e395c56794f2c47e994af5699f56b 100644 (file)
@@ -61,8 +61,8 @@ typedef struct rb_node {
         * rb_node will have an alignment of 4 or 8 bytes.
         */
        uintptr_t rb_info;
-#define        RB_FLAG_POSITION        (uintptr_t)0x2
-#define        RB_FLAG_RED             (uintptr_t)0x1
+#define        RB_FLAG_POSITION        __BIT(1)
+#define        RB_FLAG_RED             __BIT(0)
 #define        RB_FLAG_MASK            (RB_FLAG_POSITION|RB_FLAG_RED)
 #define        RB_FATHER(rb) \
     ((struct rb_node *)((rb)->rb_info & ~RB_FLAG_MASK))
index 3f8f66e1ee09a452a65e2609f28c4257b33cee30..e70b8b9efa880b4909ef82141a50030bae4ca138 100644 (file)
 #define HOSTNAME_MAX_LEN       250     /* 255 - 3 (FQDN) - 2 (DNS enc) */
 #endif
 
+#ifndef __BIT
+#define __BIT(__n)     \
+    (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \
+    ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1))))
+#endif
+
 #ifndef MIN
 #define MIN(a,b)               ((/*CONSTCOND*/(a)<(b))?(a):(b))
 #define MAX(a,b)               ((/*CONSTCOND*/(a)>(b))?(a):(b))