lib/: Use multi-line macro definitions
This reduces the complexity of those nested parentheses. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
3049bef9c3
commit
5111e5ed1b
+4
-1
@@ -11,7 +11,10 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define CALLOC(n, type) ((type *) calloc(n, sizeof(type)))
|
||||
#define CALLOC(n, type) \
|
||||
( \
|
||||
(type *) calloc(n, sizeof(type)) \
|
||||
)
|
||||
|
||||
|
||||
#endif // include guard
|
||||
|
||||
+4
-1
@@ -13,7 +13,10 @@
|
||||
#include "attr.h"
|
||||
|
||||
|
||||
#define MALLOC(n, type) ((type *) mallocarray(n, sizeof(type)))
|
||||
#define MALLOC(n, type) \
|
||||
( \
|
||||
(type *) mallocarray(n, sizeof(type)) \
|
||||
)
|
||||
|
||||
|
||||
ATTR_MALLOC(free)
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
#include "attr.h"
|
||||
|
||||
|
||||
#define XCALLOC(n, type) ((type *) xcalloc(n, sizeof(type)))
|
||||
#define XCALLOC(n, type) \
|
||||
( \
|
||||
(type *) xcalloc(n, sizeof(type)) \
|
||||
)
|
||||
|
||||
|
||||
ATTR_MALLOC(free)
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
#include "attr.h"
|
||||
|
||||
|
||||
#define XMALLOC(n, type) ((type *) xmallocarray(n, sizeof(type)))
|
||||
#define XMALLOC(n, type) \
|
||||
( \
|
||||
(type *) xmallocarray(n, sizeof(type)) \
|
||||
)
|
||||
|
||||
|
||||
ATTR_MALLOC(free)
|
||||
|
||||
+22
-4
@@ -90,10 +90,28 @@
|
||||
*/
|
||||
|
||||
|
||||
#define is_same_type(a, b) __builtin_types_compatible_p(a, b)
|
||||
#define is_same_typeof(a, b) is_same_type(typeof(a), typeof(b))
|
||||
#define is_array(a) (!is_same_typeof((a), &(a)[0]))
|
||||
#define must_be_array(a) must_be(is_array(a))
|
||||
#define is_same_type(a, b) \
|
||||
( \
|
||||
__builtin_types_compatible_p(a, b) \
|
||||
)
|
||||
|
||||
|
||||
#define is_same_typeof(a, b) \
|
||||
( \
|
||||
is_same_type(typeof(a), typeof(b)) \
|
||||
)
|
||||
|
||||
|
||||
#define is_array(a) \
|
||||
( \
|
||||
!is_same_typeof(a, &(a)[0]) \
|
||||
)
|
||||
|
||||
|
||||
#define must_be_array(a) \
|
||||
( \
|
||||
must_be(is_array(a)) \
|
||||
)
|
||||
|
||||
|
||||
#endif // include guard
|
||||
|
||||
Reference in New Issue
Block a user