mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
|
|
/* tag: byteorder prototypes
|
||
|
|
*
|
||
|
|
* Copyright (C) 2004 Stefan Reinauer
|
||
|
|
*
|
||
|
|
* see the file "COPYING" for further information about
|
||
|
|
* the copyright and warranty status of this work.
|
||
|
|
*/
|
||
|
|
#ifndef __BYTEORDER_H
|
||
|
|
#define __BYTEORDER_H
|
||
|
|
|
||
|
|
#define __bswap32(x) \
|
||
|
|
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
|
||
|
|
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
|
||
|
|
|
||
|
|
#define __bswap16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
|
||
|
|
|
||
|
|
|
||
|
|
#ifdef CONFIG_LITTLE_ENDIAN
|
||
|
|
#define __cpu_to_le32(x) ((u32) (x))
|
||
|
|
#define __le32_to_cpu(x) ((u32) (x))
|
||
|
|
#define __cpu_to_le16(x) ((u16) (x))
|
||
|
|
#define __le16_to_cpu(x) ((u16) (x))
|
||
|
|
#define __cpu_to_be32(x) (__bswap32((u32) (x)))
|
||
|
|
#define __be32_to_cpu(x) (__bswap32((u32) (x)))
|
||
|
|
#define __cpu_to_be16(x) (__bswap16((u16) (x)))
|
||
|
|
#define __be16_to_cpu(x) (__bswap16((u16) (x)))
|
||
|
|
#endif
|
||
|
|
#ifdef CONFIG_BIG_ENDIAN
|
||
|
|
#define __cpu_to_le32(x) (__bswap32((u32) (x)))
|
||
|
|
#define __le32_to_cpu(x) (__bswap32((u32) (x)))
|
||
|
|
#define __cpu_to_le16(x) (__bswap16((u16) (x)))
|
||
|
|
#define __le16_to_cpu(x) (__bswap16((u16) (x)))
|
||
|
|
#define __cpu_to_be32(x) ((u32) (x))
|
||
|
|
#define __be32_to_cpu(x) ((u32) (x))
|
||
|
|
#define __cpu_to_be16(x) ((u16) (x))
|
||
|
|
#define __be16_to_cpu(x) ((u16) (x))
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#endif
|
||
|
|
|