[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Endianness macros capitalization

From: Pavel Roskin
Subject: Re: Endianness macros capitalization
Date: Sun, 20 Jul 2008 19:31:50 -0400

On Sun, 2008-07-20 at 15:45 +0200, Christian Franke wrote:
> Christian Franke wrote:

> > But the function call in the 32-bit case requires only 5 bytes :-)
> >   
> Sorry, I was wrong here. The assumption about function call size was 
> only true for module-local calls. If a module calls a function in 
> kernel, each 5 byte call requires another 8 bytes for the ELF relocation 
> table entry.

Actually, the new versions of gcc have __builtin_bswap32 and
__builtin_bswap64, which are optimized even better.  There is no
__builtin_bswap16 because it is said that any correct implementation
will be optimized anyway:

gcc 4.3.0 from Fedora is working fine with them.  I'm not sure about gcc
4.2.  There is only one bug.  Suppose I use this:

#define grub_swap_bytes32(x) __builtin_bswap32(x)
#define grub_swap_bytes64(x) __builtin_bswap64(x)

Then I get this warning:

partmap/apple.c: In function 'apple_partition_map_iterate':
partmap/apple.c:133: warning: format '%x' expects type 'unsigned int',
but argument 8 has type 'unsigned int'
partmap/apple.c:133: warning: format '%x' expects type 'unsigned int',
but argument 9 has type 'unsigned int'

Those arguments are produced by grub_swap_bytes32().  But if I use
wrapper functions, then there are no warnings, and the code side is
approximately the same.  We'll need wrappers to support sparse.

Pavel Roskin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]