2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
29 * Compiler-related stuff.
39 #include "util/macros.h"
41 #include "c99_compat.h" /* inline, __func__, etc. */
50 * Sun compilers define __i386 instead of the gcc-style __i386__
53 # if !defined(__i386__) && defined(__i386)
55 # elif !defined(__amd64__) && defined(__amd64)
57 # elif !defined(__sparc__) && defined(__sparc)
64 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.
65 * Do not use these unless absolutely necessary!
66 * Try to use a runtime test instead.
67 * For now, only used by some DRI hardware drivers for color/texel packing.
69 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
70 #if defined(__linux__)
72 #define CPU_TO_LE32( x ) bswap_32( x )
73 #elif defined(__APPLE__)
74 #include <CoreFoundation/CFByteOrder.h>
75 #define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x )
76 #elif defined(__OpenBSD__)
77 #include <sys/types.h>
78 #define CPU_TO_LE32( x ) htole32( x )
80 #include <sys/endian.h>
81 #define CPU_TO_LE32( x ) bswap32( x )
83 #define MESA_BIG_ENDIAN 1
85 #define CPU_TO_LE32( x ) ( x )
86 #define MESA_LITTLE_ENDIAN 1
88 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
92 #define IEEE_ONE 0x3f800000
100 #endif /* COMPILER_H */