[U-Boot] [RFC][PATCH] Code Clean-up (weak functions)

Graeme Russ graeme.russ at gmail.com
Thu Dec 25 12:26:28 CET 2008


On Thu, Dec 25, 2008 at 11:56 AM, Shinya Kuribayashi
<shinya.kuribayashi at necel.com> wrote:
> Remy Bohmer wrote:
>> Create a default fallback routine that can be used if there is no
>> strong implementation:
>> -------------------------------------------------------------------------------------------
>> __attribute__((weak)) unsigned long long printk_clock(void)
>> {
>>         return sched_clock();
>> }
>> -------------------------------------------------------------------------------------------
>> and here is an example of the strong implementation (from the ARM architecture):
>> -------------------------------------------------------------------------------------------
>> unsigned long long printk_clock(void)
>> {
>>         return (unsigned long long)(jiffies - INITIAL_JIFFIES) *
>>                         (1000000000 / HZ);
>> }
>> -------------------------------------------------------------------------------------------
>>
>> If the strong implementation is available, the weak is simply
>> discarded during linking, if the strong is omitted, the weak is used
>> as fallback. This is a clean, lean and mean example without
>> complex/superfluous aliases or checks for NULL pointers.
>> It should not get any harder than this...
>
> +1.  I like this one, and U-Boot/MIPS _machine_restart() is implemented
> in the same manner.
>

Looks like removing the aliases seems to be gaining group consensus. Shall I
create a patch which removes all the aliases (It will need thorough regression
testing)


More information about the U-Boot mailing list