summaryrefslogtreecommitdiffstats
path: root/container_of.c
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2009-11-07 19:25:34 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2009-11-07 19:25:34 +0100
commit604f2f86cff27b2368239f42a119bda6f244b9ee (patch)
tree71562c4c5d82a673635701788c1610bee914620a /container_of.c
parent7d6c42c89447947de20e4b50390b6c3b3ee8ff9f (diff)
downloadlock_free-604f2f86cff27b2368239f42a119bda6f244b9ee.zip
lock_free-604f2f86cff27b2368239f42a119bda6f244b9ee.tar.gz
clean
Diffstat (limited to 'container_of.c')
-rw-r--r--container_of.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/container_of.c b/container_of.c
index 2c0be09..f67b644 100644
--- a/container_of.c
+++ b/container_of.c
@@ -34,23 +34,23 @@
(type *)( (char *)__mptr - offsetof(type,member) );})
struct node {
- int data;
- int daat2;
- int daat3;
- int daat4;
- int daaat4;
+ int data1;
+ int data2;
+ int data3;
+ int data4;
+ int data5;
};
-#define OFFSET offsetof(struct node,daat3)
+
#define my_offset(ptr, type, member) ( { (type*)(((char*)ptr)-offsetof(type,member)); } )
struct node n;
struct node* use_container_of() {
- return container_of( &n.daat3, struct node, daat3);
+ return container_of( &n.data3, struct node, data3);
}
struct node* use_mine() {
- return my_offset( &n.daat3, struct node, daat3);
+ return my_offset( &n.data3, struct node, data3);
/* return (struct node*)(((char*)&n.daat3)-OFFSET); */
}