FEATURES: document various missed changes
[unleashed/lotheac.git] / include / endian.h
blob78ca13cec4acf9daabcb405bb92da9837974f36b
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2016 Joyent, Inc.
16 #ifndef _ENDIAN_H
17 #define _ENDIAN_H
20 * Endian conversion routines, see endian(3C)
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
27 #include <sys/isa_defs.h>
28 #include <inttypes.h>
30 #define __LITTLE_ENDIAN 1234
31 #define __BIG_ENDIAN 4321
32 #define __PDP_ENDIAN 3412
34 #if defined(_LITTLE_ENDIAN)
35 #define __BYTE_ORDER LITTLE_ENDIAN
36 #elif defined(_BIG_ENDIAN)
37 #define __BYTE_ORDER BIG_ENDIAN
38 #else
39 #error "Unknown byte order"
40 #endif /* _LITTLE_ENDIAN */
42 #define LITTLE_ENDIAN __LITTLE_ENDIAN
43 #define BIG_ENDIAN __BIG_ENDIAN
44 #define BYTE_ORDER __BYTE_ORDER
46 extern uint16_t htobe16(uint16_t);
47 extern uint32_t htobe32(uint32_t);
48 extern uint64_t htobe64(uint64_t);
50 extern uint16_t htole16(uint16_t);
51 extern uint32_t htole32(uint32_t);
52 extern uint64_t htole64(uint64_t);
54 /* Supply both the old and new BSD names */
55 extern uint16_t betoh16(uint16_t);
56 extern uint16_t letoh16(uint16_t);
57 extern uint16_t be16toh(uint16_t);
58 extern uint16_t le16toh(uint16_t);
60 extern uint32_t betoh32(uint32_t);
61 extern uint32_t letoh32(uint32_t);
62 extern uint32_t be32toh(uint32_t);
63 extern uint32_t le32toh(uint32_t);
65 extern uint64_t betoh64(uint64_t);
66 extern uint64_t letoh64(uint64_t);
67 extern uint64_t be64toh(uint64_t);
68 extern uint64_t le64toh(uint64_t);
70 #ifdef __cplusplus
72 #endif
74 #endif /* _ENDIAN_H */