Add macro to compute number of elements inside an array.

This commit is contained in:
Enrico Fraccaroli (Galfurian)
2023-07-01 16:06:34 -04:00
parent 3ed59b6f55
commit 28276bf565
+7
View File
@@ -71,3 +71,10 @@ typedef unsigned int pgprot_t;
/// Counts the number of elements of an array.
#define count_of(x) ((sizeof(x) / sizeof((x)[0])) / ((size_t)(!(sizeof(x) % sizeof((x)[0])))))
#define swap(a, b) \
do { \
typeof(a) temp = (a); \
(a) = (b); \
(b) = temp; \
} while (0)