author | koda |
Sun, 11 Oct 2009 16:03:56 +0000 | |
changeset 2415 | 35d09cbf819a |
parent 2261 | 57e99c908e7c |
permissions | -rw-r--r-- |
2191 | 1 |
/* |
2 |
* OpenAL Bridge - a simple portable library for OpenAL interface |
|
3 |
* Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2216
diff
changeset
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
2191 | 7 |
* the Free Software Foundation; version 2 of the License |
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2216
diff
changeset
|
12 |
* GNU Lesser General Public License for more details. |
2191 | 13 |
* |
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2216
diff
changeset
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
2191 | 15 |
* along with this program; if not, write to the Free Software |
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
2213 | 19 |
#ifndef _OALB_ENDIANNESS_H |
20 |
#define _OALB_ENDIANNESS_H |
|
21 |
||
2212 | 22 |
#include "globals.h" |
2200
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
23 |
|
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
24 |
|
2191 | 25 |
#ifdef __CPLUSPLUS |
26 |
extern "C" { |
|
27 |
#endif |
|
2415 | 28 |
|
29 |
||
30 |
/* check compiler requirements */ |
|
31 |
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
|
32 |
#error Do not know the endianess of this architecture |
|
33 |
#endif |
|
34 |
||
35 |
||
36 |
/* use byteswap macros from the host system, hopefully optimized ones ;-) |
|
37 |
* or define our own version, simple, stupid, straight-forward... */ |
|
38 |
#ifdef HAVE_BYTESWAP_H |
|
39 |
#include <byteswap.h> |
|
40 |
#else |
|
41 |
#define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) |
|
42 |
#define bswap_32(x) ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \ |
|
43 |
(((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) ) |
|
44 |
#endif /* HAVE_BYTESWAP_H */ |
|
45 |
||
46 |
||
47 |
/* swap numbers accordingly to architecture automatically */ |
|
48 |
#ifdef __LITTLE_ENDIAN__ |
|
49 |
#define ENDIAN_LITTLE_32(x) x |
|
50 |
#define ENDIAN_BIG_32(x) bswap_32(x) |
|
51 |
#define ENDIAN_LITTLE_16(x) x |
|
52 |
#define ENDIAN_BIG_16(x) bswap_16(x) |
|
53 |
#elif __BIG_ENDIAN__ |
|
54 |
#define ENDIAN_LITTLE_32(x) bswap_32(x) |
|
55 |
#define ENDIAN_BIG_32(x) x |
|
56 |
#define ENDIAN_LITTLE_16(x) bswap_16(x) |
|
57 |
#define ENDIAN_BIG_16(x) x |
|
58 |
#endif |
|
2261 | 59 |
|
2415 | 60 |
|
2191 | 61 |
#ifdef __CPLUSPLUS |
62 |
} |
|
2213 | 63 |
#endif |
64 |
||
65 |
#endif /*_OALB_ENDIANNESS_H*/ |