macros: add BIT(n) and BIT_SIZE(t) macros

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent 1188b24a31
commit cd9d974a91
  1. 6
      include/macros.h

@ -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…
Cancel
Save