From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Wed, 04 Jan 2012 21:04:36 +1100 Subject: [U-Boot] [PATCH 02/17] x86: Speed up copy-to-RAM and clear BSS operations In-Reply-To: References: <1325477374-6417-1-git-send-email-graeme.russ@gmail.com> <1325477374-6417-3-git-send-email-graeme.russ@gmail.com> Message-ID: <4F042434.9070004@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On 04/01/12 16:21, Simon Glass wrote: > Hi Graeme, > > On Sun, Jan 1, 2012 at 8:09 PM, Graeme Russ wrote: >> The implementations of memcpy and memset are now the optimised versions >> from glibc, so use them instead of simple copy loops >> >> Signed-off-by: Graeme Russ >> --- >> arch/x86/lib/board.c | 17 +++++------------ >> 1 files changed, 5 insertions(+), 12 deletions(-) >> >> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c >> index d742fec..ba6b59f 100644 >> --- a/arch/x86/lib/board.c >> +++ b/arch/x86/lib/board.c >> @@ -188,26 +188,19 @@ static int calculate_relocation_address(void) >> >> static int copy_uboot_to_ram(void) >> { >> - ulong *dst_addr = (ulong *)gd->relocaddr; >> - ulong *src_addr = (ulong *)&__text_start; >> - ulong *end_addr = (ulong *)&__data_end; >> + size_t len = (size_t)(&__data_end) - (size_t)(&__text_start); > > Extra brackets here. Also is the type of these not char[] already? Same Q below. I removed the brackets for v2 - The cast is required because &__data_end is a ulong * Actually: size_t len = &__data_end - &__text_start; works, but is dangerous - I have been caught out several times in this code doing raw arithmetic, particularly using increment and decrement operators. I prefer to make the casts explicit now Regards, Graeme