Guest User

Untitled

a guest
Nov 9th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. void *ptr = ((char*)l_p - (unsigned int)&((struct node_s*)0)->list);
  2.  
  3. struct node_s{
  4. char a;
  5. char b;
  6. char c;
  7. char d;
  8. struct list_head list;
  9. };
  10.  
  11. (unsigned int)&((struct node_s*)0)->list
  12.  
  13. (struct node_s*)0
  14.  
  15. ((struct node_s*)0)->list
  16.  
  17. &((struct node_s*)0)->list;
  18.  
  19. (unsigned int)&((struct node_s*)0)->list
  20.  
  21. ((char*)l_p - (unsigned int)&((struct node_s*)0)->list)
  22.  
  23. void *ptr = (char*)l_p - offsetof(struct node_s, list);
  24.  
  25. void *ptr = container_of(l_p, struct node_s, list);
Add Comment
Please, Sign In to add comment