common: add ARRAY_SIZE() macro
This commit is contained in:
parent
e36d38660b
commit
4977886293
5
common.h
5
common.h
@ -32,6 +32,11 @@
|
||||
#define container_of(P,T,M) (T *)((char *)(P) - offsetof(T, M))
|
||||
#endif
|
||||
|
||||
/** calculate number of elements of an array */
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
/** shortcut to printf to stderr */
|
||||
#define errf(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user