Loading...
Searching...
No Matches
7#define FURI_RETURNS_NONNULL __attribute__((returns_nonnull))
12 __typeof__(a) _a = (a); \
13 __typeof__(b) _b = (b); \
21 __typeof__(a) _a = (a); \
22 __typeof__(b) _b = (b); \
28#define ABS(a) ({ (a) < 0 ? -(a) : (a); })
32#define ROUND_UP_TO(a, b) \
34 __typeof__(a) _a = (a); \
35 __typeof__(b) _b = (b); \
36 _a / _b + !!(_a % _b); \
41#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
44#ifndef CLAMP_WRAPAROUND
45#define CLAMP_WRAPAROUND(x, upper, lower) \
47 __typeof__(x) _x = (x); \
48 __typeof__(upper) _upper = (upper); \
49 __typeof__(lower) _lower = (lower); \
50 (_x > _upper) ? _lower : ((_x < _lower) ? _upper : _x); \
55#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
59#define FURI_SWAP(x, y) \
67#ifndef PLACE_IN_SECTION
68#define PLACE_IN_SECTION(x) __attribute__((section(x)))
72#define ALIGN(n) __attribute__((aligned(n)))
76#define __weak __attribute__((weak))
80#define UNUSED(X) (void)(X)
84#define STRINGIFY(x) #x
88#define TOSTRING(x) STRINGIFY(x)
92#define CONCATENATE(a, b) CONCATENATE_(a, b)
93#define CONCATENATE_(a, b) a##b
96#ifndef REVERSE_BYTES_U32
97#define REVERSE_BYTES_U32(x) \
98 ((((x) & 0x000000FF) << 24) | (((x) & 0x0000FF00) << 8) | (((x) & 0x00FF0000) >> 8) | \
99 (((x) & 0xFF000000) >> 24))
103#define FURI_BIT(x, n) (((x) >> (n)) & 1)
107#define FURI_BIT_SET(x, n) \
109 __typeof__(x) _x = (1); \
110 (x) |= (_x << (n)); \
114#ifndef FURI_BIT_CLEAR
115#define FURI_BIT_CLEAR(x, n) \
117 __typeof__(x) _x = (1); \
118 (x) &= ~(_x << (n)); \
122#define FURI_SW_MEMBARRIER() asm volatile("" : : : "memory")