mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 13:33:59 +08:00
* fix mac nui
* fix cereal
* builds on mac without warnings
* ui swap shouldn't be instant on pc
* camerad builds on mac
* modeld, and now everything, builds on mac
* ui draws pictures on mac now
* fix camerad shutdown
* support ui looping on pc
* python3 on that
* SCNu64 should be cross platform
* bump cereal and new apk
* clean up
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 344a9a3699
55 lines
1.0 KiB
C
55 lines
1.0 KiB
C
#ifndef COMMON_UTIL_H
|
|
#define COMMON_UTIL_H
|
|
|
|
#include <stdio.h>
|
|
|
|
#ifndef sighandler_t
|
|
typedef void (*sighandler_t)(int sig);
|
|
#endif
|
|
|
|
#ifndef __cplusplus
|
|
|
|
#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; })
|
|
|
|
#endif
|
|
|
|
#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]))
|
|
|
|
#undef ALIGN
|
|
#define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1))
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// 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);
|
|
|
|
void set_thread_name(const char* name);
|
|
|
|
int set_realtime_priority(int level);
|
|
int set_core_affinity(int core);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|