mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-23 21:34:35 +03:00
fbccb9fbaf
* IRDA HAL: Fill buffer refactoring * IRDA: Add SIRC protocol * IRDA: correct adr/cmd bit length * Disable Unit tests Co-authored-by: あく <alleteam@gmail.com>
60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
#pragma once
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a, b) \
|
|
({ \
|
|
__typeof__(a) _a = (a); \
|
|
__typeof__(b) _b = (b); \
|
|
_a > _b ? _a : _b; \
|
|
})
|
|
#endif
|
|
|
|
#ifndef MIN
|
|
#define MIN(a, b) \
|
|
({ \
|
|
__typeof__(a) _a = (a); \
|
|
__typeof__(b) _b = (b); \
|
|
_a < _b ? _a : _b; \
|
|
})
|
|
#endif
|
|
|
|
#ifndef ROUND_UP_TO
|
|
#define ROUND_UP_TO(a, b) \
|
|
({ \
|
|
__typeof__(a) _a = (a); \
|
|
__typeof__(b) _b = (b); \
|
|
_a / _b + !!(_a % _b); \
|
|
})
|
|
#endif
|
|
|
|
#ifndef CLAMP
|
|
#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
|
|
#endif
|
|
|
|
// need some common semantics for those two
|
|
#ifndef SIZEOF_ARRAY
|
|
#define SIZEOF_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
|
#endif
|
|
|
|
#ifndef COUNT_OF
|
|
#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
|
|
#endif
|
|
|
|
#ifndef FURI_SWAP
|
|
#define FURI_SWAP(x, y) \
|
|
do { \
|
|
typeof(x) SWAP = x; \
|
|
x = y; \
|
|
y = SWAP; \
|
|
} while(0)
|
|
#endif
|
|
|
|
#ifndef PLACE_IN_SECTION
|
|
#define PLACE_IN_SECTION(x) __attribute__((section(x)))
|
|
#endif
|
|
|
|
#ifndef ALIGN
|
|
#define ALIGN(n) __attribute__((aligned(n)))
|
|
#endif
|