Monday, April 19, 2010

Learning from Linux Kernel

1. container_of: Being passed a pointer, it returns the pointer to the structure that contains this.


#define container_of(ptr, type, member) ({                      \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
where
#define offsetof(type, member) \
    ((size_t) ( (char *)&((type *)(0))->member - (char *)0 ))

Monday, April 5, 2010

My Favourite Quotes

Pascal : "If I had more time, I would written you a shorter letter "


Einstein : "God doesn't play dice with the Universe"


Neils Bohr : "Prediction is very difficult, especially if it's about the future"