[PATCH 1/2] utils: Define ARRAY_SIZE() if not yet defined
Thomas Graf
tgraf at suug.ch
Wed Aug 27 03:26:36 PDT 2014
Allows using ARRAY_SIZE() in src examples
Signed-off-by: Thomas Graf <tgraf at suug.ch>
---
include/netlink-private/netlink.h | 2 --
include/netlink/utils.h | 4 ++++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h
index 39f4dff..dcc3ad2 100644
--- a/include/netlink-private/netlink.h
+++ b/include/netlink-private/netlink.h
@@ -144,8 +144,6 @@ static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg)
return ret;
}
-#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
-
/* This is also defined in stddef.h */
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
diff --git a/include/netlink/utils.h b/include/netlink/utils.h
index 6b4b787..9c64eba 100644
--- a/include/netlink/utils.h
+++ b/include/netlink/utils.h
@@ -118,6 +118,10 @@ enum {
};
int nl_has_capability (int capability);
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
+#endif
+
#ifdef __cplusplus
}
#endif
--
1.9.3
More information about the libnl
mailing list