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
27 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
28 # define HAVE_STDINT 1
30 # if defined(__GNUC_PREREQ) && __GNUC_PREREQ(4,0)
31 # define HAVE_STDINT 1
33 # define HAVE_STDINT 0
43 typedef uint8_t uint8
;
44 typedef uint16_t uint16
;
45 typedef uint32_t uint32
;
49 typedef unsigned char uint8
;
50 typedef unsigned short uint16
;
51 typedef unsigned int uint32
;
55 /* endianism checking - this will break on a bunch of platforms, someone else tidy it up, love fuzzie */
60 #if __BYTE_ORDER == __LITTLE_ENDIAN || defined(_MSC_VER) || defined(__i386__)
61 #define __C2E_LITTLEENDIAN
63 #define __C2E_BIGENDIAN
66 #ifdef __C2E_LITTLEENDIAN
68 #define swapEndianShort(A) A
69 #define swapEndianLong(A) A
73 #define swapEndianShort(A) ((((uint16)(A) & 0xff00) >> 8) | \
74 (((uint16)(A) & 0x00ff) << 8))
75 #define swapEndianLong(A) ((((uint32)(A) & 0xff000000) >> 24) | \
76 (((uint32)(A) & 0x00ff0000) >> 8) | \
77 (((uint32)(A) & 0x0000ff00) << 8) | \
78 (((uint32)(A) & 0x000000ff) << 24))
82 #endif // _ENDIANLOVE_H