mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>,
	Nathan Lynch <nathan_lynch@mentor.com>,
	Will Deacon <will.deacon@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, marek@goldelico.com
Subject: Re: [PATCH v3] ARM: fix vdsomunge not to depend on glibc specific byteswap.h
Date: Thu, 15 Oct 2015 18:03:07 +0100	[thread overview]
Message-ID: <20151015170306.GF32532@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <160a66a415cdb49174bc7d05b3e4dda9bba0e9d6.1444888374.git.hns@goldelico.com>

On Thu, Oct 15, 2015 at 07:52:56AM +0200, H. Nikolaus Schaller wrote:
> If the host toolchain is not glibc based then the arm kernel build
> fails with
> 
>   HOSTCC  arch/arm/vdso/vdsomunge
>   arch/arm/vdso/vdsomunge.c:48:22: fatal error: byteswap.h: No such file or directory
> 
> Observed: with omap2plus_defconfig and compile on Mac OS X with arm ELF
> cross-compiler.
> 
> Reason: byteswap.h is a glibc only header.
> 
> Solution: replace by private byte-swapping macros (taken from
> arch/mips/boot/elf2ecoff.c)
> 
> Tested to compile on Mac OS X 10.9.5 host.
> 
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
>  arch/arm/vdso/vdsomunge.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/vdso/vdsomunge.c b/arch/arm/vdso/vdsomunge.c
> index aedec81..513f9eb 100644
> --- a/arch/arm/vdso/vdsomunge.c
> +++ b/arch/arm/vdso/vdsomunge.c
> @@ -45,7 +45,6 @@
>   * it does.
>   */
>  
> -#include <byteswap.h>
>  #include <elf.h>
>  #include <errno.h>
>  #include <fcntl.h>
> @@ -59,6 +58,18 @@
>  #include <sys/types.h>
>  #include <unistd.h>
>  
> +#define swab16(x) \
> +	((unsigned short)( \
> +		(((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \
> +		(((unsigned short)(x) & (unsigned short)0xff00U) >> 8)))

		((((x) & 0x00ff) << 8) | \
		 (((x) & 0xff00) >> 8))

> +
> +#define swab32(x) \
> +	((unsigned int)( \
> +		(((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \
> +		(((unsigned int)(x) & (unsigned int)0x0000ff00UL) <<  8) | \
> +		(((unsigned int)(x) & (unsigned int)0x00ff0000UL) >>  8) | \
> +		(((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24)))

		((((x) & 0x000000ff) << 24) | \
		 (((x) & 0x0000ff00) <<  8) | \
		 (((x) & 0x00ff0000) >>  8) | \
		 (((x) & 0xff000000) << 24))

We can get rid of all the casts because we know what size 'x' is in
both cases.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

      reply	other threads:[~2015-10-15 17:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-15  5:52 H. Nikolaus Schaller
2015-10-15 17:03 ` Russell King - ARM Linux [this message]

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=20151015170306.GF32532@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=hns@goldelico.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek@goldelico.com \
    --cc=nathan_lynch@mentor.com \
    --cc=szabolcs.nagy@arm.com \
    --cc=will.deacon@arm.com \
    /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

all inboxes | Powered by JetHome®