5 * Created by Alyssa Milburn on Sat May 22 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
23 #include <stdlib.h> // load the standard libraries for these defines
29 typedef uint8_t uint8
;
30 typedef uint16_t uint16
;
31 typedef uint32_t uint32
;
35 typedef unsigned char uint8
;
36 typedef unsigned short uint16
;
37 typedef unsigned int uint32
;
41 #ifndef OC2E_BIG_ENDIAN
45 # if __BYTE_ORDER == __LITTLE_ENDIAN || defined(_MSC_VER) || defined(__i386__)
46 # define OC2E_BIG_ENDIAN 0
48 # define OC2E_BIG_ENDIAN 1
57 static inline uint16
swapEndianShort(uint16 a
) {
61 static inline uint32
swapEndianLong(uint32 a
) {
65 # else // HAVE_BYTESWAP_H
67 static inline uint16
swapEndianShort(uint16 a
) {
68 return ((((uint16
)(a
) & 0xff00) >> 8) |
69 (((uint16
)(a
) & 0x00ff) << 8));
72 static inline uint32
swapEndianLong(uint32 a
) {
73 return ((((uint32
)(a
) & 0xff000000) >> 24) |
74 (((uint32
)(a
) & 0x00ff0000) >> 8) |
75 (((uint32
)(a
) & 0x0000ff00) << 8) |
76 (((uint32
)(a
) & 0x000000ff) << 24));
81 #else // OC2E_BIG_ENDIAN
83 static inline uint16
swapEndianShort(uint16 a
) {
87 static inline uint32
swapEndianLong(uint32 a
) {
93 #endif // _ENDIANLOVE_H