From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Mon, 24 Sep 2012 18:52:05 +0200 Subject: [U-Boot] [PATCH 2/3] common: Implement support for linker-generated arrays In-Reply-To: References: <1348449718-16463-1-git-send-email-marex@denx.de> <1348449718-16463-3-git-send-email-marex@denx.de> Message-ID: <201209241852.05258.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Joe Hershberger, [...] > > +#define ll_entry_declare(_type, _name, _section_u, _section_d) \ > > + _type _u_boot_list_##_section_u##_##_name __attribute__(( \ > > + unused, aligned(4), \ > > + section(".u_boot_list."#_section_d"."#_name))); \ > > + _type _u_boot_list_##_section_u##_##_name > > Why repeat the "_type _u_boot_list_##_section_u##_##_name" instead of > just leaving the semicolon off after the __attribute__()? Good idea. Do you like my documentation fairytail btw ? :p > > + > > +/** > > + * ll_entry_start() - Point to first entry of linker-generated array > > + * _type: Data type of the entry > > + * _section_u: Subsection of u_boot_list in which this entry is placed > > + * (with underscores instead of dots) > > + * > > + * This function returns (_type *) pointer to the very first entry of a > > + * linker-generated array placed into subsection of .u_boot_list section > > + * specified by _section_u argument. > > + * > > + * Example of usage: > > + * > > + * struct my_sub_cmd *msc = ll_entry_start(struct my_sub_cmd, cmd_sub); > > + */ > > +#define ll_entry_start(_type, _section_u) \ > > + ({ \ > > + extern _type _u_boot_list_##_section_u##__start; \ > > + _type *_ll_result = &_u_boot_list_##_section_u##__start;\ > > + _ll_result; \ > > + }) > > Tricky. I didn't realize this gcc extension existed. All this is a horrible pile of tricks [...]