[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned acce
From: |
Curt McDowell |
Subject: |
Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access |
Date: |
Sat, 22 Apr 2006 22:25:08 -0700 |
User-agent: |
Mutt/1.2.5.1i |
On Sat, Apr 22, 2006 at 01:27:44PM +0200, Timmy Brolin wrote:
> Either ip_addr2 or memcpy is needed.
> The code "sipaddr = hdr->sipaddr;" would crash on any CPU which do not
> support unaligned accesses.
> The current ip_addr2 solution is technically more efficient than memcpy
> since it copies the ip_addr with just two 16bit reads+writes.
> The only solution which would be slightly more efficient is to copy
> hdr->sipaddr to a 32bit register using two 16bit accesses, and then
> write the 32bit register to sipaddr. But since this is not a critical
> code path, it is more important to keep the code as clean as possible
> rather than trying to save one single memory access.
> The ip_addr2 solution makes the code nice and clean.
ip_addr2 is a gross hack, whereas memcpy is clean.
As you pointed out, this code is not in a critical path. If we cared
about efficiency (which here we don't), we could add an arch/cc macro
that copies 4 bytes regardless of alignment.
The ip_addr2 hack doesn't work on machines with 4-byte alignment
restrictions (ARM, MIPS); hence multiple instances of people having to
replace it with memcpy.
Regards,
Curt McDowell
Broadcom Corp.
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, (continued)
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Pedro Alves, 2006/04/25
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/25
- RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Curt McDowell, 2006/04/25
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/25
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Pedro Alves, 2006/04/25
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/26
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Derek Guerdon, 2006/04/27
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Leon Woestenberg, 2006/04/30
- RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Curt McDowell, 2006/04/25
- RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Leon Woestenberg, 2006/04/30
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access,
Curt McDowell <=
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Leon Woestenberg, 2006/04/23
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/24
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/22