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