summaryrefslogtreecommitdiff
path: root/src/shared/macro.h
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-05-07 21:06:55 +0200
committerKay Sievers <kay@vrfy.org>2012-05-08 01:57:17 +0200
commitbbc98d32560cc456531bf254f7b69054921082bd (patch)
tree0c4c10fe1944119fa17a051cd69e840201ed94bc /src/shared/macro.h
parentb80efeb9ae23b493d03501caa7e6334d1db65dd9 (diff)
util: split-out hwclock.[ch]
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r--src/shared/macro.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 1355aac908..1c0aa915ad 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -57,6 +57,17 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
+/*
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
#ifndef MAX
#define MAX(a,b) \
__extension__ ({ \