2022-04-13 05:59:01 +08:00
|
|
|
#ifndef SC_COMMON_H
|
|
|
|
#define SC_COMMON_H
|
2018-01-22 23:50:08 +08:00
|
|
|
|
2019-09-30 04:36:56 +08:00
|
|
|
#include "config.h"
|
2021-01-09 02:18:02 +08:00
|
|
|
#include "compat.h"
|
2019-09-30 04:36:56 +08:00
|
|
|
|
2018-03-25 21:23:00 +08:00
|
|
|
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
|
2023-03-01 06:52:26 +08:00
|
|
|
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
|
|
|
|
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
|
2021-12-28 18:50:24 +08:00
|
|
|
#define CLAMP(V,X,Y) MIN( MAX((V),(X)), (Y) )
|
2018-01-22 23:50:08 +08:00
|
|
|
|
2021-04-11 21:01:05 +08:00
|
|
|
#define container_of(ptr, type, member) \
|
|
|
|
((type *) (((char *) (ptr)) - offsetof(type, member)))
|
|
|
|
|
2018-01-22 23:50:08 +08:00
|
|
|
#endif
|