27#ifndef INCLUDED_BYTE_ORDER
28#define INCLUDED_BYTE_ORDER
34# define LITTLE_ENDIAN 0x4321
35# define BIG_ENDIAN 0x1234
36# if ARCH_IA32 || ARCH_IA64 || ARCH_AMD64 || ARCH_ALPHA || ARCH_ARM || ARCH_AARCH64 || ARCH_MIPS || ARCH_E2K || ARCH_PPC64 || defined(__LITTLE_ENDIAN__)
37# define BYTE_ORDER LITTLE_ENDIAN
39# define BYTE_ORDER BIG_ENDIAN
48#define FOURCC(a,b,c,d)
61#define FOURCC_BE(a,b,c,d) ( ((u32)(u8)a) << 24 | ((u32)(u8)b) << 16 | \
62 ((u32)(u8)c) << 8 | ((u32)(u8)d) << 0 )
65#define FOURCC_LE(a,b,c,d) ( ((u32)(u8)a) << 0 | ((u32)(u8)b) << 8 | \
66 ((u32)(u8)c) << 16 | ((u32)(u8)d) << 24 )
68#if BYTE_ORDER == BIG_ENDIAN
69# define FOURCC FOURCC_BE
71# define FOURCC FOURCC_LE
75#if BYTE_ORDER == BIG_ENDIAN
77# define to_le16(x) swap16(x)
78# define to_le32(x) swap32(x)
79# define to_le64(x) swap64(x)
81# define to_be16(x) (x)
82# define to_be32(x) (x)
83# define to_be64(x) (x)
86# define to_le16(x) (x)
87# define to_le32(x) (x)
88# define to_le64(x) (x)
90# define to_be16(x) swap16(x)
91# define to_be32(x) swap32(x)
92# define to_be64(x) swap64(x)
132#define swap64 _bswap64
134extern unsigned short _byteswap_ushort(
unsigned short);
135extern unsigned long _byteswap_ulong(
unsigned long);
136extern unsigned __int64 _byteswap_uint64(
unsigned __int64);
137#pragma intrinsic(_byteswap_ushort)
138#pragma intrinsic(_byteswap_ulong)
139#pragma intrinsic(_byteswap_uint64)
140# define swap16 _byteswap_ushort
141# define swap32 _byteswap_ulong
142# define swap64 _byteswap_uint64
144# include <asm/byteorder.h>
145# if defined(__arch__swab16) && !defined(swap16)
146# define swap16 __arch__swab16
148# if defined(__arch__swab32) && !defined(swap32)
149# define swap32 __arch__swab32
151# if defined(__arch__swab64) && !defined(swap64)
152# define swap64 __arch__swab64
u16 read_be16(const void *p)
see read_le16
Definition: byte_order.cpp:90
u16 read_le16(const void *p)
read a little-endian number from memory into native byte order.
Definition: byte_order.cpp:68
u64 read_be64(const void *p)
see read_be16
Definition: byte_order.cpp:104
void write_be16(void *p, u16 x)
see write_le16
Definition: byte_order.cpp:131
u64 movzx_le64(const u8 *p, size_t size)
see write_be16
Definition: byte_order.cpp:150
u64 movzx_be64(const u8 *p, size_t size)
Definition: byte_order.cpp:159
void write_be64(void *p, u64 x)
see write_be16
Definition: byte_order.cpp:143
u32 read_be32(const void *p)
Definition: byte_order.cpp:97
void write_le64(void *p, u64 x)
see write_le16
Definition: byte_order.cpp:124
void write_le32(void *p, u32 x)
Definition: byte_order.cpp:118
i64 movsx_le64(const u8 *p, size_t size)
sign-extend <size> (truncated to 8) bytes of little-endian data to i64, starting at address <p> (need...
Definition: byte_order.cpp:192
u32 swap32(const u32 x)
Definition: byte_order.cpp:42
void write_be32(void *p, u32 x)
Definition: byte_order.cpp:137
u16 swap16(const u16 x)
Definition: byte_order.cpp:35
u64 swap64(const u64 x)
Definition: byte_order.cpp:52
u64 read_le64(const void *p)
see read_le16
Definition: byte_order.cpp:82
void write_le16(void *p, u16 x)
see read_be16
Definition: byte_order.cpp:112
u32 read_le32(const void *p)
Definition: byte_order.cpp:75
i64 movsx_be64(const u8 *p, size_t size)
Definition: byte_order.cpp:198
uint64_t u64
Definition: types.h:40
int64_t i64
Definition: types.h:35
uint8_t u8
Definition: types.h:37
uint16_t u16
Definition: types.h:38
uint32_t u32
Definition: types.h:39