| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
|
| 12 |
#if !defined(_CPU_ENDIAN_BIG) && !defined(_CPU_ENDIAN_SMALL) |
| 13 |
|
| 14 |
#define _CPU_ENDIAN_SMALL |
| 15 |
#endif |
| 16 |
|
| 17 |
#if defined(_CPU_ENDIAN_BIG) && defined(_CPU_ENDIAN_SMALL) |
| 18 |
#error "_CPU_ENDIAN_BIG and _CPU_ENDIAN_SMALL cannot be defined at the same time." |
| 19 |
#endif |
| 20 |
|
| 21 |
#include "hal/byteops.h" |
| 22 |
|
| 23 |
#if defined(_CPU_ENDIAN_SMALL) |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#ifndef __KERNEL__ |
| 28 |
#define constant_cpu_to_le64(x) ((_u64)(x)) |
| 29 |
#define constant_le64_to_cpu(x) ((_u64)(x)) |
| 30 |
#define constant_cpu_to_le32(x) ((_u32)(x)) |
| 31 |
#define constant_le32_to_cpu(x) ((_u32)(x)) |
| 32 |
#define constant_cpu_to_le16(x) ((_u16)(x)) |
| 33 |
#define constant_le16_to_cpu(x) ((_u16)(x)) |
| 34 |
#define constant_cpu_to_be64(x) (__static_byteswap_64((x))) |
| 35 |
#define constant_be64_to_cpu(x) __static_byteswap_64((_u64)(x)) |
| 36 |
#define constant_cpu_to_be32(x) (__static_byteswap_32((x))) |
| 37 |
#define constant_be32_to_cpu(x) __static_byteswap_32((_u32)(x)) |
| 38 |
#define constant_cpu_to_be16(x) (__static_byteswap_16((x))) |
| 39 |
#define constant_be16_to_cpu(x) __static_byteswap_16((_u16)(x)) |
| 40 |
|
| 41 |
#define cpu_to_le64(x) ((_u64)(x)) |
| 42 |
#define le64_to_cpu(x) ((_u64)(x)) |
| 43 |
#define cpu_to_le32(x) ((_u32)(x)) |
| 44 |
#define le32_to_cpu(x) ((_u32)(x)) |
| 45 |
#define cpu_to_le16(x) ((_u16)(x)) |
| 46 |
#define le16_to_cpu(x) ((_u16)(x)) |
| 47 |
#define cpu_to_be64(x) (__byteswap_64((x))) |
| 48 |
#define be64_to_cpu(x) __byteswap_64((_u64)(x)) |
| 49 |
#define cpu_to_be32(x) (__byteswap_32((x))) |
| 50 |
#define be32_to_cpu(x) __byteswap_32((_u32)(x)) |
| 51 |
#define cpu_to_be16(x) (__byteswap_16((x))) |
| 52 |
#define be16_to_cpu(x) __byteswap_16((_u16)(x)) |
| 53 |
#endif |
| 54 |
|
| 55 |
#define cpu_to_float_le(x) ((float)x) |
| 56 |
#define float_le_to_cpu(x) ((float)x) |
| 57 |
|
| 58 |
#define cpu_to_float_be(x) __byteswap_float(x) |
| 59 |
#define float_be_to_cpu(x) __byteswap_float(x) |
| 60 |
|
| 61 |
#define cpu_to_double_le(x) ((double)x) |
| 62 |
#define double_le_to_cpu(x) ((double)x) |
| 63 |
|
| 64 |
#define cpu_to_double_be(x) __byteswap_double(x) |
| 65 |
#define double_be_to_cpu(x) __byteswap_double(x) |
| 66 |
|
| 67 |
#else |
| 68 |
|
| 69 |
|
| 70 |
#ifndef __KERNEL__ |
| 71 |
#define constant_cpu_to_le64(x) (__static_byteswap_64((x))) |
| 72 |
#define constant_le64_to_cpu(x) __static_byteswap_64((_u64)(x)) |
| 73 |
#define constant_cpu_to_le32(x) (__static_byteswap_32((x))) |
| 74 |
#define constant_le32_to_cpu(x) __static_byteswap_32((_u32)(x)) |
| 75 |
#define constant_cpu_to_le16(x) (__static_byteswap_16((x))) |
| 76 |
#define constant_le16_to_cpu(x) __static_byteswap_16((_u16)(x)) |
| 77 |
#define constant_cpu_to_be64(x) ((_u64)(x)) |
| 78 |
#define constant_be64_to_cpu(x) ((_u64)(x)) |
| 79 |
#define constant_cpu_to_be32(x) ((_u32)(x)) |
| 80 |
#define constant_be32_to_cpu(x) ((_u32)(x)) |
| 81 |
#define constant_cpu_to_be16(x) ((_u16)(x)) |
| 82 |
#define constant_be16_to_cpu(x) ((_u16)(x)) |
| 83 |
|
| 84 |
#define cpu_to_le64(x) (__byteswap_64((x))) |
| 85 |
#define le64_to_cpu(x) __byteswap_64((_u64)(x)) |
| 86 |
#define cpu_to_le32(x) (__byteswap_32((x))) |
| 87 |
#define le32_to_cpu(x) __byteswap_32((_u32)(x)) |
| 88 |
#define cpu_to_le16(x) (__byteswap_16((x))) |
| 89 |
#define le16_to_cpu(x) __byteswap_16((_u16)(x)) |
| 90 |
#define cpu_to_be64(x) ((_u64)(x)) |
| 91 |
#define be64_to_cpu(x) ((_u64)(x)) |
| 92 |
#define cpu_to_be32(x) ((_u32)(x)) |
| 93 |
#define be32_to_cpu(x) ((_u32)(x)) |
| 94 |
#define cpu_to_be16(x) ((_u16)(x)) |
| 95 |
#define be16_to_cpu(x) ((_u16)(x)) |
| 96 |
#endif |
| 97 |
|
| 98 |
|
| 99 |
#define cpu_to_float_le(x) __byteswap_float(x) |
| 100 |
#define float_le_to_cpu(x) __byteswap_float(x) |
| 101 |
|
| 102 |
#define cpu_to_float_be(x) ((float)x) |
| 103 |
#define float_be_to_cpu(x) ((float)x) |
| 104 |
|
| 105 |
|
| 106 |
#define cpu_to_double_le(x) __byteswap_double(x) |
| 107 |
#define double_le_to_cpu(x) __byteswap_double(x) |
| 108 |
|
| 109 |
#define cpu_to_double_be(x) ((double)x) |
| 110 |
#define double_be_to_cpu(x) ((double)x) |
| 111 |
|
| 112 |
#endif |