[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Big and little indian valid in a byte??
Jan Hudec <bulb@xxxxxx> writes:
> On Fri, Apr 30, 2004 at 14:37:59 +0530, syedk wrote:
>> Hi All,
>>
>> This is the structure declaration of IP Header. Can you tell me how
>> little endian and big endian come into picture in the case of a
>> byte. U can find this declaration in
>> /usr/src/linux-2.4.18-14/include/linux/ip.h.
>>
>> struct iphdr {
>> #if defined(__LITTLE_ENDIAN_BITFIELD)
>> __u8 ihl:4,
>> version:4;
>> #elif defined (__BIG_ENDIAN_BITFIELD)
>> __u8 version:4,
>> ihl:4;
>
> You sure know, what the :4 modifier means.
It seems like although it is just a feature of C, many people don't
know about bitfields. It's part of the syntax for a bitfield -- four
bits in this case: a "nibble".
> So you should know, what's
> the difference between these two declaratinons. And thus know, what in
> the compiler is affected by endianity.
OP, note the order or the nibbles.
--
--Ed L Cashin | PGP public key:
ecashin@xxxxxxx | http://noserose.net/e/pgp/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/