mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-09 17:53:41 +08:00
46e0ee7750
old-commit-hash: 6f46f988d9d89b5bd18e38c5e5509b5c252ae2c1
30 lines
696 B
C
30 lines
696 B
C
#ifndef COMMON_UTIL_H
|
|
#define COMMON_UTIL_H
|
|
|
|
#define min(a,b) \
|
|
({ __typeof__ (a) _a = (a); \
|
|
__typeof__ (b) _b = (b); \
|
|
_a < _b ? _a : _b; })
|
|
|
|
#define max(a,b) \
|
|
({ __typeof__ (a) _a = (a); \
|
|
__typeof__ (b) _b = (b); \
|
|
_a > _b ? _a : _b; })
|
|
|
|
#define clamp(a,b,c) \
|
|
({ __typeof__ (a) _a = (a); \
|
|
__typeof__ (b) _b = (b); \
|
|
__typeof__ (c) _c = (c); \
|
|
_a < _b ? _b : (_a > _c ? _c : _a); })
|
|
|
|
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
|
|
|
|
// Reads a file into a newly allocated buffer.
|
|
//
|
|
// Returns NULL on failure, otherwise the NULL-terminated file contents.
|
|
// The result must be freed by the caller.
|
|
void* read_file(const char* path, size_t* out_len);
|
|
|
|
|
|
#endif
|