GRPC Core  18.0.0
Macros
useful.h File Reference

Go to the source code of this file.

Macros

#define GPR_MIN(a, b)   ((a) < (b) ? (a) : (b))
 useful macros that don't belong anywhere else More...
 
#define GPR_MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define GPR_CLAMP(a, min, max)   ((a) < (min) ? (min) : (a) > (max) ? (max) : (a))
 
#define GPR_ROTL(x, n)   (((x) << (n)) | ((x) >> (sizeof(x) * 8 - (n))))
 rotl, rotr assume x is unsigned More...
 
#define GPR_ROTR(x, n)   (((x) >> (n)) | ((x) << (sizeof(x) * 8 - (n))))
 
#define GPR_ARRAY_SIZE(array)   (sizeof(array) / sizeof(*(array)))
 
#define GPR_SWAP(type, a, b)
 
#define GPR_BITSET(i, n)   ((*(i)) |= (1u << (n)))
 Set the n-th bit of i (a mutable pointer). More...
 
#define GPR_BITCLEAR(i, n)   ((*(i)) &= ~(1u << (n)))
 Clear the n-th bit of i (a mutable pointer). More...
 
#define GPR_BITGET(i, n)   (((i) & (1u << (n))) != 0)
 Get the n-th bit of i. More...
 
#define GPR_INTERNAL_HEXDIGIT_BITCOUNT(x)
 
#define GPR_BITCOUNT(i)
 Returns number of bits set in bitset i. More...
 
#define GPR_ICMP(a, b)   ((a) < (b) ? -1 : ((a) > (b) ? 1 : 0))
 
#define GPR_HASH_POINTER(x, range)
 

Macro Definition Documentation

◆ GPR_ARRAY_SIZE

#define GPR_ARRAY_SIZE (   array)    (sizeof(array) / sizeof(*(array)))

◆ GPR_BITCLEAR

#define GPR_BITCLEAR (   i,
 
)    ((*(i)) &= ~(1u << (n)))

Clear the n-th bit of i (a mutable pointer).

◆ GPR_BITCOUNT

#define GPR_BITCOUNT (   i)
Value:
0x0f0f0f0f) % \
255)
#define GPR_INTERNAL_HEXDIGIT_BITCOUNT(x)
Definition: useful.h:49

Returns number of bits set in bitset i.

◆ GPR_BITGET

#define GPR_BITGET (   i,
 
)    (((i) & (1u << (n))) != 0)

Get the n-th bit of i.

◆ GPR_BITSET

#define GPR_BITSET (   i,
 
)    ((*(i)) |= (1u << (n)))

Set the n-th bit of i (a mutable pointer).

◆ GPR_CLAMP

#define GPR_CLAMP (   a,
  min,
  max 
)    ((a) < (min) ? (min) : (a) > (max) ? (max) : (a))

◆ GPR_HASH_POINTER

#define GPR_HASH_POINTER (   x,
  range 
)
Value:
(((((size_t)(x)) >> 4) ^ (((size_t)(x)) >> 9) ^ (((size_t)(x)) >> 14)) % \
(range))

◆ GPR_ICMP

#define GPR_ICMP (   a,
 
)    ((a) < (b) ? -1 : ((a) > (b) ? 1 : 0))

◆ GPR_INTERNAL_HEXDIGIT_BITCOUNT

#define GPR_INTERNAL_HEXDIGIT_BITCOUNT (   x)
Value:
((x) - (((x) >> 1) & 0x77777777) - (((x) >> 2) & 0x33333333) - \
(((x) >> 3) & 0x11111111))

◆ GPR_MAX

#define GPR_MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

◆ GPR_MIN

#define GPR_MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

useful macros that don't belong anywhere else

◆ GPR_ROTL

#define GPR_ROTL (   x,
 
)    (((x) << (n)) | ((x) >> (sizeof(x) * 8 - (n))))

rotl, rotr assume x is unsigned

◆ GPR_ROTR

#define GPR_ROTR (   x,
 
)    (((x) >> (n)) | ((x) << (sizeof(x) * 8 - (n))))

◆ GPR_SWAP

#define GPR_SWAP (   type,
  a,
 
)
Value:
do { \
type x = a; \
(a) = b; \
(b) = x; \
} while (0)