From: Roy Marples Date: Thu, 7 Mar 2019 12:00:37 +0000 (+0000) Subject: Use __BIT X-Git-Tag: v8.0.0~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c38e7128eb6419c60472ea230304d8dc42a25ba1;p=thirdparty%2Fdhcpcd.git Use __BIT --- diff --git a/compat/rbtree.h b/compat/rbtree.h index 3196d341..9eb78512 100644 --- a/compat/rbtree.h +++ b/compat/rbtree.h @@ -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)) diff --git a/src/common.h b/src/common.h index 3f8f66e1..e70b8b9e 100644 --- a/src/common.h +++ b/src/common.h @@ -40,6 +40,12 @@ #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))