This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 8th, 2011  |  syntax: None  |  size: 0.45 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  * container_of - cast a member of a structure out to the containing structure
  3.  * @ptr:        the pointer to the member.
  4.  * @type:       the type of the container struct this is embedded in.
  5.  * @member:     the name of the member within the struct.
  6.  *
  7.  */
  8. #define container_of(ptr, type, member) ({                      \
  9.         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
  10.         (type *)( (char *)__mptr - offsetof(type,member) );})
  11.  
  12.  
clone this paste RAW Paste Data