i'm trying study linux kernel , reading kernel code, can't understand structure use page structure shown below: mean,why use union nested in struct nested in union (the code simplified...)
struct page { unsigned long flags; struct address_space *mapping; struct { union { pgoff_t index; void *freelist; }; union { unsigned counters; struct { union { atomic_t _mapcount; struct { unsigned inuse:16; unsigned objects:15; unsigned frozen:1; }; }; atomic_t _count; }; }; }; }
it used bring clarity code. easier read , understand if members grouped.
since not using 'sub-structures' in other data-structure, nested. else, declared separate , included members, below:
struct list_based{ pgoff_t index; void *freelist; }; struct page { unsigned long flags; struct address_space *mapping; struct list_based lpage; }; struct sector { unsigned long sub sect; struct list_based lsect; };
Comments
Post a Comment