lkml.org 
[lkml]   [2015]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next 01/14] etherdevice: Add eth_<foo>_addr CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS code
From
Date
On Mon, 2015-03-02 at 19:54 -0800, Joe Perches wrote:
> Make the memset possibly more efficient with the appropriate
> CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS #ifdef
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> include/linux/etherdevice.h | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
> index 606563e..22ad94a 100644
> --- a/include/linux/etherdevice.h
> +++ b/include/linux/etherdevice.h
> @@ -192,7 +192,12 @@ static inline void eth_random_addr(u8 *addr)
> */
> static inline void eth_broadcast_addr(u8 *addr)
> {
> +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
> + *(u32 *)addr = 0xffffffff;
> + *(u16 *)(addr + 4) = 0xffff;
> +#else
> memset(addr, 0xff, ETH_ALEN);
> +#endif
> }
>

I am pretty sure compiler already does an inline, and might chose to
emit equivalent instructions for :
*(u16 *) addr = 0xffff;
*(u32 *)(addr + 2) = 0xffffffff;

if (addr % 4) is known to be 2




\
 
 \ /
  Last update: 2015-03-03 14:21    [W:0.121 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site