Lines Matching +full:t +full:- +full:head
1 // SPDX-License-Identifier: MIT
20 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
22 * container_of - cast a member of a structure out to the containing structure
29 const typeof(((type *)0)->member)*__mptr = (ptr); \
30 (type *)((char *)__mptr - offsetof(type, member)); })
39 * using the generic single-entry routines.
49 list->next = list; in INIT_LIST_HEAD()
50 list->prev = list; in INIT_LIST_HEAD()
63 next->prev = new; in __list_add()
64 new->next = next; in __list_add()
65 new->prev = prev; in __list_add()
66 prev->next = new; in __list_add()
74 * list_add_tail - add a new entry
76 * @head: list head to add it before
78 * Insert a new entry before the specified head.
81 static inline void list_add_tail(struct list_head *new, struct list_head *head) in list_add_tail() argument
83 __list_add(new, head->prev, head); in list_add_tail()
87 * list_entry - get the struct for this entry
96 * list_for_each_entry - iterate over list of given type
98 * @head: the head for your list.
101 #define list_for_each_entry(pos, head, member) \ argument
102 for (pos = list_entry((head)->next, typeof(*pos), member); \
103 &pos->member != (head); \
104 pos = list_entry(pos->member.next, typeof(*pos), member))
125 INIT_LIST_HEAD(&offset->list); in offset_new()
126 offset->offset = o; in offset_new()
131 static void table_offset_add(struct table *t, struct offset *offset) in table_offset_add() argument
133 list_add_tail(&offset->list, &t->offsets); in table_offset_add()
136 static void table_init(struct table *t) in table_init() argument
138 INIT_LIST_HEAD(&t->offsets); in table_init()
139 t->offset_max = 0; in table_init()
140 t->nentry = 0; in table_init()
141 t->table = NULL; in table_init()
144 static void table_print(struct table *t) in table_print() argument
148 nlloop = (t->nentry + 3) / 4; in table_print()
149 c = t->nentry; in table_print()
150 printf("static const unsigned %s_reg_safe_bm[%d] = {\n", t->gpu_prefix, in table_print()
151 t->nentry); in table_print()
156 c -= n; in table_print()
159 printf("\t"); in table_print()
162 printf("0x%08X,", t->table[id++]); in table_print()
169 static int table_build(struct table *t) in table_build() argument
174 t->nentry = ((t->offset_max >> 2) + 31) / 32; in table_build()
175 t->table = (unsigned *)malloc(sizeof(unsigned) * t->nentry); in table_build()
176 if (t->table == NULL) in table_build()
177 return -1; in table_build()
178 memset(t->table, 0xff, sizeof(unsigned) * t->nentry); in table_build()
179 list_for_each_entry(offset, &t->offsets, list) { in table_build()
180 i = (offset->offset >> 2) / 32; in table_build()
181 m = (offset->offset >> 2) & 31; in table_build()
183 t->table[i] ^= m; in table_build()
189 static int parser_auth(struct table *t, const char *filename) in parser_auth() argument
205 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) { in parser_auth()
207 return -1; in parser_auth()
212 return -1; in parser_auth()
221 return -1; in parser_auth()
227 t->gpu_prefix = gpu_name; in parser_auth()
233 return -1; in parser_auth()
246 return -1; in parser_auth()
253 table_offset_add(t, offset); in parser_auth()
254 if (o > t->offset_max) in parser_auth()
255 t->offset_max = o; in parser_auth()
260 if (t->offset_max < last_reg) in parser_auth()
261 t->offset_max = last_reg; in parser_auth()
262 return table_build(t); in parser_auth()
267 struct table t; in main() local
273 table_init(&t); in main()
274 if (parser_auth(&t, argv[1])) { in main()
276 return -1; in main()
278 table_print(&t); in main()