| list.h | | list.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| #ifndef container_of | | #ifndef container_of | |
| # define container_of(ptr, type, member) ({ \ | | # define container_of(ptr, type, member) ({ \ | |
| const typeof(((type *)0)->member) *__mptr = (ptr); \ | | const typeof(((type *)0)->member) *__mptr = (ptr); \ | |
| (type *)((char *)__mptr - offsetof(type, member)); \ | | (type *)((char *)__mptr - offsetof(type, member)); \ | |
| }) | | }) | |
| #endif | | #endif | |
|
| | | #define HXlist_entry(ptr, type, member) container_of((ptr), type, member) | |
| | | | |
| struct HXlist_head { | | struct HXlist_head { | |
| struct HXlist_head *next, *prev; | | struct HXlist_head *next, *prev; | |
| }; | | }; | |
| | | | |
| #define HXLIST_HEAD_INIT(name) {&(name), &(name)} | | #define HXLIST_HEAD_INIT(name) {&(name), &(name)} | |
| #define HXLIST_HEAD(name) \ | | #define HXLIST_HEAD(name) \ | |
| struct HXlist_head name = HXLIST_HEAD_INIT(name) | | struct HXlist_head name = HXLIST_HEAD_INIT(name) | |
| | | | |
|
| static inline void HXlist_init_head(struct HXlist_head *list) | | static inline void HXlist_init(struct HXlist_head *list) | |
| | | { | |
| | | list->next = list->prev = list; | |
| | | } | |
| | | | |
| | | static __attribute__((deprecated)) inline void | |
| | | HXlist_init_head(struct HXlist_head *list) | |
| { | | { | |
| list->next = list->prev = list; | | list->next = list->prev = list; | |
| } | | } | |
| | | | |
| static inline void __HXlist_add(struct HXlist_head *nu, | | static inline void __HXlist_add(struct HXlist_head *nu, | |
| struct HXlist_head *prev, struct HXlist_head *next) | | struct HXlist_head *prev, struct HXlist_head *next) | |
| { | | { | |
| nu->next = next; | | nu->next = next; | |
| nu->prev = prev; | | nu->prev = prev; | |
| next->prev = nu; | | next->prev = nu; | |
| | | | |
| skipping to change at line 67 | | skipping to change at line 74 | |
| entry->prev->next = entry->next; | | entry->prev->next = entry->next; | |
| entry->next->prev = entry->prev; | | entry->next->prev = entry->prev; | |
| entry->next = NULL; | | entry->next = NULL; | |
| entry->prev = NULL; | | entry->prev = NULL; | |
| } | | } | |
| | | | |
| #define HXlist_for_each(pos, head) \ | | #define HXlist_for_each(pos, head) \ | |
| for ((pos) = (head)->next; (pos) != (void *)(head); \ | | for ((pos) = (head)->next; (pos) != (void *)(head); \ | |
| (pos) = (pos)->next) | | (pos) = (pos)->next) | |
| | | | |
|
| | | #define HXlist_for_each_safe(pos, n, head) \ | |
| | | for ((pos) = (head)->next, (n) = (pos)->next; (pos) != (void *)(head | |
| | | ); \ | |
| | | (pos) = (n), (n) = (pos)->next) | |
| | | | |
| #define HXlist_for_each_entry(pos, head, member) \ | | #define HXlist_for_each_entry(pos, head, member) \ | |
|
| for ((pos) = container_of((head)->next, typeof(*(pos)), member); \ | | for ((pos) = HXlist_entry((head)->next, typeof(*(pos)), member); \ | |
| &(pos)->member != (void *)(head); \ | | &(pos)->member != (void *)(head); \ | |
|
| (pos) = container_of((pos)->member.next, typeof(*(pos)), member | | (pos) = HXlist_entry((pos)->member.next, typeof(*(pos)), member | |
| )) | | )) | |
| | | | |
| | | #define HXlist_for_each_entry_safe(pos, n, head, member) \ | |
| | | for ((pos) = HXlist_entry((head)->next, typeof(*(pos)), member), \ | |
| | | (n) = HXlist_entry((pos)->member.next, typeof(*(pos)), member); | |
| | | \ | |
| | | &(pos)->member != (void *)(head); \ | |
| | | (pos) = (n), (n) = HXlist_entry((n)->member.next, typeof(*(n)), | |
| | | \ | |
| | | member)) | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } /* extern "C" */ | | } /* extern "C" */ | |
| #endif | | #endif | |
| | | | |
| #endif /* _LIBHX_LIST_H */ | | #endif /* _LIBHX_LIST_H */ | |
| | | | |
End of changes. 5 change blocks. |
| 4 lines changed or deleted | | 25 lines changed or added | |
|