2007-02-23 15:18:15

by Allexio Ju

[permalink] [raw]
Subject: trivial question regarding byte ordering

Hi,

Is there a API (or macro) that checks CPU endianness and does byte
ordering conversion on given data (32-bit) if endianness is
big-endian?

Thank you in advance for your comment.

Regards,

Allexio


2007-02-23 15:25:27

by Frederik Deweerdt

[permalink] [raw]
Subject: Re: trivial question regarding byte ordering

On Fri, Feb 23, 2007 at 07:18:13AM -0800, Allexio Ju wrote:
> Is there a API (or macro) that checks CPU endianness and does byte
> ordering conversion on given data (32-bit) if endianness is
> big-endian?
including include/asm/byteorder.h will define the needed
cpu_to_{b,l}e{16,32,64} and {b,l}e{16,32,64}_to_cpu macros.

Regards,
Frederik

2007-02-23 15:26:48

by Robert P. J. Day

[permalink] [raw]
Subject: Re: trivial question regarding byte ordering

On Fri, 23 Feb 2007, Allexio Ju wrote:

> Hi,
>
> Is there a API (or macro) that checks CPU endianness and does byte
> ordering conversion on given data (32-bit) if endianness is
> big-endian?

#include <asm/byteorder.h>

each architecture is responsible for including the appropriate header
file for either big or little endianness.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

2007-02-23 18:00:25

by Allexio Ju

[permalink] [raw]
Subject: Re: trivial question regarding byte ordering

On 2/23/07, Robert P. J. Day <[email protected]> wrote:
> #include <asm/byteorder.h>
>
> each architecture is responsible for including the appropriate header
> file for either big or little endianness.
Thank you for answer, Robert.

Allexio

2007-02-23 18:02:01

by Allexio Ju

[permalink] [raw]
Subject: Re: trivial question regarding byte ordering

On 2/23/07, Frederik Deweerdt <[email protected]> wrote:
> including include/asm/byteorder.h will define the needed
> cpu_to_{b,l}e{16,32,64} and {b,l}e{16,32,64}_to_cpu macros.
Great, Thank you for your answer.

Regards,

Allexio