2
Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.com>
2
Copyright (c) 2008-2011 Gluster, Inc. <http://www.gluster.com>
3
3
This file is part of GlusterFS.
5
5
GlusterFS is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Affero General Public License as published
6
it under the terms of the GNU General Public License as published
7
7
by the Free Software Foundation; either version 3 of the License,
8
8
or (at your option) any later version.
10
10
GlusterFS is distributed in the hope that it will be useful, but
11
11
WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Affero General Public License for more details.
13
General Public License for more details.
15
You should have received a copy of the GNU Affero General Public License
15
You should have received a copy of the GNU General Public License
16
16
along with this program. If not, see
17
17
<http://www.gnu.org/licenses/>.
38
38
#define ntoh32 hton32
39
39
#define ntoh64 hton64
41
static uint16_t (*htole16) (uint16_t);
42
static uint32_t (*htole32) (uint32_t);
43
static uint64_t (*htole64) (uint64_t);
45
#define letoh16 htole16
46
#define letoh32 htole32
47
#define letoh64 htole64
49
static uint16_t (*htobe16) (uint16_t);
50
static uint32_t (*htobe32) (uint32_t);
51
static uint64_t (*htobe64) (uint64_t);
53
#define betoh16 htobe16
54
#define betoh32 htobe32
55
#define betoh64 htobe64
41
58
#define do_swap2(x) (((x&LS1) << 8)|(((x&MS1) >> 8)))
42
59
#define do_swap4(x) ((do_swap2(x&LS2) << 16)|(do_swap2((x&MS2) >> 16)))
43
60
#define do_swap8(x) ((do_swap4(x&LS4) << 32)|(do_swap4((x&MS4) >> 32)))
145
static uint16_t (*hton16) (uint16_t) = __byte_order_init16;
146
static uint32_t (*hton32) (uint32_t) = __byte_order_init32;
147
static uint64_t (*hton64) (uint64_t) = __byte_order_init64;
168
static uint16_t (*hton16) (uint16_t) = __byte_order_n16;
169
static uint32_t (*hton32) (uint32_t) = __byte_order_n32;
170
static uint64_t (*hton64) (uint64_t) = __byte_order_n64;
173
static inline uint16_t
174
__byte_order_le16 (uint16_t i)
178
if (((char *)(&num))[0] == 1) {
180
htole16 = __noswap16;
181
htole32 = __noswap32;
182
htole64 = __noswap64;
194
static inline uint32_t
195
__byte_order_le32 (uint32_t i)
199
if (((char *)(&num))[0] == 1) {
201
htole16 = __noswap16;
202
htole32 = __noswap32;
203
htole64 = __noswap64;
215
static inline uint64_t
216
__byte_order_le64 (uint64_t i)
220
if (((char *)(&num))[0] == 1) {
222
htole16 = __noswap16;
223
htole32 = __noswap32;
224
htole64 = __noswap64;
236
static uint16_t (*htole16) (uint16_t) = __byte_order_le16;
237
static uint32_t (*htole32) (uint32_t) = __byte_order_le32;
238
static uint64_t (*htole64) (uint64_t) = __byte_order_le64;
241
static inline uint16_t
242
__byte_order_be16 (uint16_t i)
246
if (((char *)(&num))[0] == 1) {
253
htobe16 = __noswap16;
254
htobe32 = __noswap32;
255
htobe64 = __noswap64;
262
static inline uint32_t
263
__byte_order_be32 (uint32_t i)
267
if (((char *)(&num))[0] == 1) {
274
htobe16 = __noswap16;
275
htobe32 = __noswap32;
276
htobe64 = __noswap64;
283
static inline uint64_t
284
__byte_order_be64 (uint64_t i)
288
if (((char *)(&num))[0] == 1) {
295
htobe16 = __noswap16;
296
htobe32 = __noswap32;
297
htobe64 = __noswap64;
304
static uint16_t (*htobe16) (uint16_t) = __byte_order_be16;
305
static uint32_t (*htobe32) (uint32_t) = __byte_order_be32;
306
static uint64_t (*htobe64) (uint64_t) = __byte_order_be64;
150
310
#endif /* _BYTE_ORDER_H */