Purpose of using __be16 inside a data structure?
Kevin O'Gorman
kogorman at gmail.com
Mon Oct 24 15:54:41 EDT 2011
On Tue, Aug 9, 2011 at 12:25 AM, 陳國成 <gcchen.org at gmail.com> wrote:
> Hi all,
>
> Please tell me the difference between using unsigned short and __be16 to
> declear a variable in a data structure.
>
> The purpose of this and similar artificial types is to allow the code to be
written in an architecture-independent way. The name is chosen to reflect
the behavior (signedness, capacity, precision, etc) that is desired, and the
headers for each architecture typedef it to a standard C type that
accomplishes this goal. From the name, I expect this to be a 16-bit type.
It may have other attributes, such as a specific endianness (unusual except
in networking), or specific signedness. Except on unusual or antique
architectures, I would expect this one to resolve to "short" or "unsigned
short", but other possibilities exist.
What you should usually do is to find the typedef of __be16 in the headers
and see if there is a clue to what use this type is intended for.
--
Kevin O'Gorman, PhD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111024/6af5e1e4/attachment.html
More information about the Kernelnewbies
mailing list