CardSight 0.1.0
C API reference for the CardSight firmware and application
Loading...
Searching...
No Matches
bits.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
7
8#ifndef CARDSIGHT_BITS_H
9#define CARDSIGHT_BITS_H
10
11#include <stddef.h>
12
14#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
20#define MIN(a, b) (((a) < (b)) ? (a) : (b))
26#define MAX(a, b) (((a) > (b)) ? (a) : (b))
28#define CLAMP(value, low, high) ((value) < (low) ? (low) : ((value) > (high) ? (high) : (value)))
30#define BIT(n) (1UL << (n))
36#define ALIGN_UP(value, alignment) (((value) + (alignment) - 1U) & ~((alignment) - 1U))
44#define container_of(pointer, type, member) \
45 ((type *)((char *)(pointer) - offsetof(type, member)))
46
47#endif /* CARDSIGHT_BITS_H */