macros: add BIT(n) and BIT_SIZE(t) macros
This commit is contained in:
parent
1188b24a31
commit
cd9d974a91
1 changed files with 6 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define min(x, y) ((x < y) ? (x) : (y))
|
||||
#define max(x, y) ((x > y) ? (x) : (y))
|
||||
|
||||
|
@ -12,3 +14,7 @@
|
|||
#define IS_ROUND(x, k) (!((x) & ((k) - 1)))
|
||||
#define ROUND_DOWN(x, k) ((x) & ~((k) - 1))
|
||||
#define ROUND_UP(x, k) (((x) + (k) - 1) & ~((k) - 1))
|
||||
|
||||
/* Bit manipulation */
|
||||
#define BIT_SIZE(t) (CHAR_BIT * sizeof(t))
|
||||
#define BIT(n) (1 << (n))
|
||||
|
|
Loading…
Add table
Reference in a new issue