From: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC][PATCH] Code Clean-up (weak functions)
Date: Thu, 25 Dec 2008 09:56:37 +0900 [thread overview]
Message-ID: <4952DA45.3000805@necel.com> (raw)
In-Reply-To: <3efb10970812241141x3e885bfakd74f631bc710b726@mail.gmail.com>
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.
--
Shinya Kuribayashi
NEC Electronics
next prev parent reply other threads:[~2008-12-25 0:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-13 5:26 [U-Boot] [RFC][PATCH] Code Clean-up (weak functions) Graeme Russ
2008-12-13 22:48 ` Remy Bohmer
2008-12-14 9:23 ` Graeme Russ
2008-12-22 9:05 ` Mike Frysinger
2008-12-22 9:16 ` Graeme Russ
2008-12-22 11:44 ` Mike Frysinger
2008-12-22 11:20 ` Graeme Russ
2008-12-23 4:18 ` Mike Frysinger
2008-12-24 1:14 ` Shinya Kuribayashi
2008-12-24 14:12 ` Joakim Tjernlund
2008-12-24 16:55 ` Shinya Kuribayashi
2008-12-24 19:41 ` Remy Bohmer
2008-12-25 0:56 ` Shinya Kuribayashi [this message]
2008-12-25 11:26 ` Graeme Russ
2008-12-25 14:00 ` Joakim Tjernlund
2008-12-25 14:39 ` Shinya Kuribayashi
2008-12-25 11:22 ` Graeme Russ
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4952DA45.3000805@necel.com \
--to=shinya.kuribayashi@necel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox