summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Szewczyk <p.szewczyk@samsung.com>2018-06-25 10:57:23 (GMT)
committerPaweł Szewczyk <p.szewczyk@samsung.com>2018-06-26 13:40:14 (GMT)
commit5baef35afbf4d869e14c177237536ff5ed61c390 (patch)
tree072761d192473c76b3879a91a825591ca8000bab
parentd69bf8461e734e444b5180630ab92c5d8e03f5ea (diff)
downloadlibdevice-node-5baef35afbf4d869e14c177237536ff5ed61c390.zip
libdevice-node-5baef35afbf4d869e14c177237536ff5ed61c390.tar.gz
libdevice-node-5baef35afbf4d869e14c177237536ff5ed61c390.tar.bz2
Move container_of macro to common.hrefs/changes/99/182499/4
The container_of macro can be used by many modules. This commit moves it to common header to prevent duplication. Change-Id: I3d87766b561db8f67354d0abe8784ea62d05016d Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
-rw-r--r--hw/common.h8
-rwxr-xr-xhw/usb_gadget.h6
2 files changed, 8 insertions, 6 deletions
diff --git a/hw/common.h b/hw/common.h
index 76c88f4..46134b9 100644
--- a/hw/common.h
+++ b/hw/common.h
@@ -24,6 +24,7 @@
extern "C" {
#endif
+#include <stddef.h>
#include <stdint.h>
#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
@@ -86,6 +87,13 @@ int hw_get_info(const char *id, const struct hw_info **info);
__attribute__ ((visibility("default"))) \
struct hw_info HARDWARE_INFO_SYM
+#ifndef container_of
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/usb_gadget.h b/hw/usb_gadget.h
index 48f6aaf..4c49e70 100755
--- a/hw/usb_gadget.h
+++ b/hw/usb_gadget.h
@@ -36,12 +36,6 @@
*/
#define USB_GADGET_DEVICE_VERSION MAKE_VERSION(0,1)
-#ifndef container_of
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-#endif
-
#define _HELPER_Y(x) ((x) & -(x))
/* Count number of trailing zeros using Dean Gaudet's algorithm */