diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2014-07-30 13:25:19 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-30 18:27:30 +0200 |
commit | 1b3864fc472ed82ad35625c8d950d0711a8aa3d6 (patch) | |
tree | d00053cea4ec21a6683d444ca9e490418aece031 /src/tbf.h | |
parent | 4bbe3349c28c33ad8b7f4f526696a41535ef30e7 (diff) |
tbf: Use plain old data structure (PODS) for llist management
The PODS struct has a back pointer to access the actual object.
llist_pods_for_each_entry traverses the list of struct llist_pods and
makes the entry available (through the back pointer).
Ticket: SYS#389
Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/tbf.h')
-rw-r--r-- | src/tbf.h | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -84,6 +84,28 @@ enum gprs_rlcmac_tbf_direction { #define GPRS_RLCMAC_FLAG_TO_DL_ASS 7 #define GPRS_RLCMAC_FLAG_TO_MASK 0xf0 /* timeout bits */ +struct llist_pods { + struct llist_head list; + void *back; +}; + +#define llist_pods_entry(ptr, type) \ + ((type *)(container_of(ptr, struct llist_pods, list)->back)) + +/** + * llist_pods_for_each_entry - like llist_for_each_entry, but uses + * struct llist_pods ->back to access the entry. + * This is necessary for non-PODS classes because container_of is + * not guaranteed to work anymore. */ +#define llist_pods_for_each_entry(pos, head, member, lpods) \ + for (lpods = llist_entry((head)->next, typeof(struct llist_pods), list), \ + pos = ((typeof(pos))lpods->back), \ + prefetch(pos->member.list.next); \ + &lpods->list != (head); \ + lpods = llist_entry(lpods->list.next, typeof(struct llist_pods), list), \ + pos = ((typeof(pos))lpods->back),\ + prefetch(pos->member.list.next)) + struct gprs_rlcmac_tbf { static void free_all(struct gprs_rlcmac_trx *trx); @@ -143,7 +165,7 @@ struct gprs_rlcmac_tbf { /* attempt to make things a bit more fair */ void rotate_in_list(); - struct llist_head list; + struct llist_pods list; uint32_t state_flags; enum gprs_rlcmac_tbf_direction direction; struct gprs_rlcmac_trx *trx; |