blob: a1518e2f99002f4004d2a7c80bc30ac8c226867b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#ifndef CHAD_BITS_H
#define CHAD_BITS_H
#include <stdbool.h>
#include <iso646>
#define UNUSED(x) ((void)x)
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define STRINGIFY(x) #x
// could be a generic
static inline
long map(
long x,
long in_min,
long in_max,
long out_min,
long out_max
) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
#endif
|