Linux カーネルをブラウズしているとcontainer_of
、次のように定義されたマクロを見つけました。
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
container_of が何をするかは理解できますが、理解できないのは最後の文です。
(type *)( (char *)__mptr - offsetof(type,member) );})
次のようにマクロを使用する場合:
container_of(dev, struct wifi_device, dev);
最後の文の対応する部分は次のようになります。
(struct wifi_device *)( (char *)__mptr - offset(struct wifi_device, dev);
何もしていないように見えます。誰かここの穴を埋めてくれませんか?