Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * (C) Copyright IBM Corporation 2006, 2007 | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sub license, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice (including the next | |
13 | * paragraph) shall be included in all copies or substantial portions of the | |
14 | * Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE COPYRIGHT HOLDERS, THE AUTHORS, AND/OR THEIR SUPPLIERS BE LIABLE FOR | |
20 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
21 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
22 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | */ | |
24 | ||
25 | /** | |
26 | * \file glxbyteorder.h | |
27 | * Platform glue for handling byte-ordering issues in GLX protocol. | |
28 | * | |
29 | * \author Ian Romanick <idr@us.ibm.com> | |
30 | */ | |
31 | #if !defined(__GLXBYTEORDER_H__) | |
32 | #define __GLXBYTEORDER_H__ | |
33 | ||
34 | #ifdef HAVE_DIX_CONFIG_H | |
35 | #include <dix-config.h> | |
36 | #endif | |
37 | ||
38 | #if HAVE_BYTESWAP_H | |
39 | #include <byteswap.h> | |
40 | #elif defined(USE_SYS_ENDIAN_H) | |
41 | #include <sys/endian.h> | |
42 | #elif defined(__APPLE__) | |
43 | #include <libkern/OSByteOrder.h> | |
44 | #define bswap_16 OSSwapInt16 | |
45 | #define bswap_32 OSSwapInt32 | |
46 | #define bswap_64 OSSwapInt64 | |
47 | #else | |
48 | #define bswap_16(value) \ | |
49 | ((((value) & 0xff) << 8) | ((value) >> 8)) | |
50 | ||
51 | #define bswap_32(value) \ | |
52 | (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ | |
53 | (uint32_t)bswap_16((uint16_t)((value) >> 16))) | |
54 | ||
55 | #define bswap_64(value) \ | |
56 | (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ | |
57 | << 32) | \ | |
58 | (uint64_t)bswap_32((uint32_t)((value) >> 32))) | |
59 | #endif | |
60 | ||
61 | #endif /* !defined(__GLXBYTEORDER_H__) */ |