You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
461 B
20 lines
461 B
#pragma once
|
|
|
|
#include <limits.h>
|
|
|
|
#define min(x, y) ((x < y) ? (x) : (y))
|
|
#define max(x, y) ((x > y) ? (x) : (y))
|
|
|
|
/* Human-readable sizes */
|
|
#define KIB 1024
|
|
#define MIB (1024 * KIB)
|
|
#define GIB (1024 * GIB)
|
|
|
|
/* Rounding */
|
|
#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))
|
|
|