[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20071003121211.GA14628@linux-mips.org>
Date: Wed, 3 Oct 2007 13:12:11 +0100
From: Ralf Baechle <ralf@...ux-mips.org>
To: Heiko Carstens <heiko.carstens@...ibm.com>
Cc: Kyle McMartin <kyle@...artin.ca>, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [COMPAT] Add compat_merge64 helper
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists