1
/* -*- mode: c; c-basic-offset: 8; -*-
2
* vim: noexpandtab sw=8 ts=8 sts=0:
8
* Copyright (C) 2004 Oracle. All rights reserved.
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU General Public
12
* License, version 2, as published by the Free Software Foundation.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* General Public License for more details.
19
* You should have received a copy of the GNU General Public
20
* License along with this program; if not, write to the
21
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
* Boston, MA 021110-1307, USA.
24
* Authors: Joel Becker
36
* All OCFS2 on-disk values are in little endian, except for jbd's journal
37
* fields which it takes care of itself.
40
#if __BYTE_ORDER == __LITTLE_ENDIAN
41
#define cpu_is_little_endian 1
43
# define cpu_to_le16(x) ((uint16_t)(x))
46
# define le16_to_cpu(x) ((uint16_t)(x))
49
# define cpu_to_le32(x) ((uint32_t)(x))
52
# define le32_to_cpu(x) ((uint32_t)(x))
55
# define cpu_to_le64(x) ((uint64_t)(x))
58
# define le64_to_cpu(x) ((uint64_t)(x))
61
# define cpu_to_be16(x) ((uint16_t)bswap_16(x))
64
# define be16_to_cpu(x) ((uint16_t)bswap_16(x))
67
# define cpu_to_be32(x) ((uint32_t)bswap_32(x))
70
# define be32_to_cpu(x) ((uint32_t)bswap_32(x))
73
# define cpu_to_be64(x) ((uint64_t)bswap_64(x))
76
# define be64_to_cpu(x) ((uint64_t)bswap_64(x))
78
#elif __BYTE_ORDER == __BIG_ENDIAN
79
#define cpu_is_little_endian 0
81
# define cpu_to_le16(x) ((uint16_t)bswap_16(x))
84
# define le16_to_cpu(x) ((uint16_t)bswap_16(x))
87
# define cpu_to_le32(x) ((uint32_t)bswap_32(x))
90
# define le32_to_cpu(x) ((uint32_t)bswap_32(x))
93
# define cpu_to_le64(x) ((uint64_t)bswap_64(x))
96
# define le64_to_cpu(x) ((uint64_t)bswap_64(x))
99
# define cpu_to_be16(x) ((uint16_t)(x))
102
# define be16_to_cpu(x) ((uint16_t)(x))
105
# define cpu_to_be32(x) ((uint32_t)(x))
108
# define be32_to_cpu(x) ((uint32_t)(x))
111
# define cpu_to_be64(x) ((uint64_t)(x))
114
# define be64_to_cpu(x) ((uint64_t)(x))
117
# error Invalid byte order __BYTE_ORDER
118
#endif /* __BYTE_ORDER */
120
#define cpu_is_big_endian (!cpu_is_little_endian)
122
#endif /* _BYTEORDER_H */