linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [COMPAT] Add compat_merge64 helper
Date: Wed, 3 Oct 2007 13:12:11 +0100	[thread overview]
Message-ID: <20071003121211.GA14628@linux-mips.org> (raw)
In-Reply-To: <20070929094852.GA7715@osiris.boeblingen.de.ibm.com>

On Sat, Sep 29, 2007 at 11:48:52AM +0200, Heiko Carstens wrote:

> > +static inline u64 compat_merge64(u32 left, u32 right)
> > +{
> > +#if defined(__BIG_ENDIAN)
> > +	return ((u64)left << 32) | right;
> > +#else /* defined (__LITTLE_ENDIAN) */
> 
> Could you change that to an #elif please and #error out if none is defined?
> Should safe us from subtle bugs caused by missing includes.

This funny macro gets away without any extra headers or #ifdef messiness:

#define merge_64(r1,r2)							\
({									\
	union {								\
		int __words[2];						\
		long long	__dword;				\
	} __u = {							\
		.__words = { (r1), (r2) }				\
	};								\
									\
	__u.__dword;							\
})

Thanks to gcc doing bogus sign and zero extensions it compiles into
slightly larger code for MIPS but that may not be an issue on other
architectures.

   Ralf

      reply	other threads:[~2007-10-03 12:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-28 22:33 [COMPAT] Add compat_merge64 helper Kyle McMartin
2007-09-28 22:33 ` [PATCH] Generic compat_sys_fallocate Kyle McMartin
2007-09-29  9:11   ` Geert Uytterhoeven
2007-09-28 23:38 ` [COMPAT] Add compat_merge64 helper Arnd Bergmann
2007-09-29  0:01   ` Kyle McMartin
2007-09-28 23:52     ` Arnd Bergmann
2007-09-29  0:02     ` Kyle McMartin
2007-09-29  7:23       ` Paul Mundt
2007-09-29  9:48 ` Heiko Carstens
2007-10-03 12:12   ` Ralf Baechle [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=20071003121211.GA14628@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kyle@mcmartin.ca \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).