Re: Big and little indian valid in a byte??

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

 



Jan Hudec <bulb@ucw.cz> 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@uga.edu        |   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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux