Commit 3fcc3af4d270dac159fc0c8b2a28ae4f9198befe
1 parent
ea0ebc8662
Exists in
v2017.01-smarct4x
and in
37 other branches
dm: linker_lists: Add a way to declare multiple objects
The existing ll_entry_declare() permits a single element of the list to be added to a linker list. Sometimes we want to add several objects at once. To avoid lots of messy declarations, add a macro to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 21 additions and 0 deletions Side-by-side Diff
include/linker_lists.h
... | ... | @@ -143,6 +143,27 @@ |
143 | 143 | section(".u_boot_list_2_"#_list"_2_"#_name))) |
144 | 144 | |
145 | 145 | /** |
146 | + * ll_entry_declare_list() - Declare a list of link-generated array entries | |
147 | + * @_type: Data type of each entry | |
148 | + * @_name: Name of the entry | |
149 | + * @_list: name of the list. Should contain only characters allowed | |
150 | + * in a C variable name! | |
151 | + * | |
152 | + * This is like ll_entry_declare() but creates multiple entries. It should | |
153 | + * be assigned to an array. | |
154 | + * | |
155 | + * ll_entry_declare_list(struct my_sub_cmd, my_sub_cmd, cmd_sub, cmd.sub) = { | |
156 | + * { .x = 3, .y = 4 }, | |
157 | + * { .x = 8, .y = 2 }, | |
158 | + * { .x = 1, .y = 7 } | |
159 | + * }; | |
160 | + */ | |
161 | +#define ll_entry_declare_list(_type, _name, _list) \ | |
162 | + _type _u_boot_list_2_##_list##_2_##_name[] __aligned(4) \ | |
163 | + __attribute__((unused, \ | |
164 | + section(".u_boot_list_2_"#_list"_2_"#_name))) | |
165 | + | |
166 | +/** | |
146 | 167 | * We need a 0-byte-size type for iterator symbols, and the compiler |
147 | 168 | * does not allow defining objects of C type 'void'. Using an empty |
148 | 169 | * struct is allowed by the compiler, but causes gcc versions 4.4 and |