Linux Kernelã®Linked Listã®å®è£ ãé¢ç½ã件
æè¿ãRobert Love先生の本ãæãªæã«ãã©ã¼ã¨èªãã§ãããããããã§ãããããã®ä¸ã«Linux Kernelå é¨ã§ä½¿ããã¦ããLinked Listã®å®è£ ãæ¸ãã¦ãã£ã¦é¢ç½ãã£ãã®ã§å ±æã
ã¾ããLinked Listã®ä¸åä¸åã®ã¨ã³ããªã表ãstructãå®ç¾©ãã¾ãã
struct list_head { struct list_head *next, *prev; };
ãããããããããããã«Cåã®ä½ãåã§ãæµç³ã«ããã¯ããã¾ãããé¨ããã¾ããããåå¾ã®ã¨ã³ããªã¸ã®ãã¤ã³ã¿ã¯ç¢ºãã«ããããã©ããããã«ã¯ãã¼ã¿ãæãããã®ãã¤ã³ã¿ããªããããªãã®ããããã¡ããã¾ããã¼ã¿å¿ãã¦ãã¡ãã£ãã®ï¼ãããããã
ãããã¡ããã¯è¨ã£ãããããã¯ãåã®çè¦ã¨ãããã®ããããã®Linked Listã¯ä»¥ä¸ã®ã³ã¼ãã®ããã«ãã¼ã¿æ§é ã«åãè¾¼ãã§ä½¿ããã®ãªããããããããã¦ããã¯æ£ããã£ãã
struct item { int value; struct list_head list; };
ãã£ãã¼ï¼Linked Listã®ã¨ã³ããªã¼ã®ä¸ã«ãã¼ã¿ãæã¤ããããªãã¦ããã¼ã¿æ§é ã®ä¸ã«Linked Listãåãè¾¼ãã¨ããé転ã®çºæ³ãªãã ãï¼ãã£ãããããã¡ããï¼ããã§ä¸äºè§£æ±ºã ã
...ããããããé¨ãããªãããããã ã¨ãitem1->list->next->next ... ã£ã¦è¾¿ã£ã¦ãã£ã¦ãè¦ã¤ããã®ã¯list_headã¸ã®ãã¤ã³ã¿ã ãã§ãæ°¸é ã«struct itemã«è¾¿ãã¤ããªããããªããï¼ãã£ã±ãåãã®ãããã¡ããã¯ãã±ã¦ããã®ãï¼
ãããã¡ãããlist_entryãå«ããï¼ããããã¡ãããcontainer_ofãå«ãã
/** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ #define list_entry(ptr, type, member) \ container_of(ptr, type, member) /* * 'kernel.h' contains some often-used function prototypes etc */ #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) _人人 人人人人人_ ï¼ çªç¶ã®é»éè¡ ï¼ ï¿£Y^Y^Y^Y^Y^Y^Yï¿£
ãããã¡ãããããã©ãããããã説æã¯çãããæ§é ä½ã®ã¡ã³ãã¼ã®ã¢ãã¬ã¹ã¨æ§é ä½ã®å宣è¨ã¨æ§é ä½ã®ã¡ã³ãã¼ã®ååã渡ãã°æ§é ä½ãã®ãã®ã®ã¢ãã¬ã¹ãè¿ãã¦ããããã¯ãããããããããå«ããã¼ã
_人人_ ï¼ å® ï¼ ï¿£Y^Y^ï¿£
ããããããããªã®æãã¤ããªã¼
Linux Kernel Development (Developer's Library)
- ä½è : Robert Love
- åºç社/ã¡ã¼ã«ã¼: Addison-Wesley Professional
- çºå£²æ¥: 2010/06/22
- ã¡ãã£ã¢: ãã¼ãã¼ããã¯
- è³¼å ¥: 3人 ã¯ãªãã¯: 62å
- ãã®ååãå«ãããã° (8件) ãè¦ã