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
44 # if __BYTE_ORDER == __LITTLE_ENDIAN
45 # define OC2E_BIG_ENDIAN 0
47 # define OC2E_BIG_ENDIAN 1
50 # if defined(_MSC_VER) || defined(__i386__)
51 # define OC2E_BIG_ENDIAN 0
53 # define OC2E_BIG_ENDIAN 1
63 static inline uint16
swapEndianShort(uint16 a
) {
67 static inline uint32
swapEndianLong(uint32 a
) {
71 # else // HAVE_BYTESWAP_H
73 static inline uint16
swapEndianShort(uint16 a
) {
74 return ((((uint16
)(a
) & 0xff00) >> 8) |
75 (((uint16
)(a
) & 0x00ff) << 8));
78 static inline uint32
swapEndianLong(uint32 a
) {
79 return ((((uint32
)(a
) & 0xff000000) >> 24) |
80 (((uint32
)(a
) & 0x00ff0000) >> 8) |
81 (((uint32
)(a
) & 0x0000ff00) << 8) |
82 (((uint32
)(a
) & 0x000000ff) << 24));
87 #else // OC2E_BIG_ENDIAN
89 static inline uint16
swapEndianShort(uint16 a
) {
93 static inline uint32
swapEndianLong(uint32 a
) {
99 #endif // _ENDIANLOVE_H