/*1* Mesa 3-D graphics library2*3* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.4* Copyright (C) 2009 VMware, Inc. All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* the rights to use, copy, modify, merge, publish, distribute, sublicense,10* and/or sell copies of the Software, and to permit persons to whom the11* Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice shall be included14* in all copies or substantial portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS17* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR20* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,21* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR22* OTHER DEALINGS IN THE SOFTWARE.23*/242526/**27* \file compiler.h28* Compiler-related stuff.29*/303132#ifndef COMPILER_H33#define COMPILER_H343536#include <assert.h>3738#include "util/macros.h"3940#include "c99_compat.h" /* inline, __func__, etc. */414243/**44* Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.45* Do not use these unless absolutely necessary!46* Try to use a runtime test instead.47* For now, only used by some DRI hardware drivers for color/texel packing.48*/49#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN50#if defined(__linux__)51#include <byteswap.h>52#define CPU_TO_LE32( x ) bswap_32( x )53#elif defined(__APPLE__)54#include <CoreFoundation/CFByteOrder.h>55#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x )56#elif defined(__OpenBSD__)57#include <sys/types.h>58#define CPU_TO_LE32( x ) htole32( x )59#else /*__linux__ */60#include <sys/endian.h>61#define CPU_TO_LE32( x ) bswap32( x )62#endif /*__linux__*/63#define MESA_BIG_ENDIAN 164#else65#define CPU_TO_LE32( x ) ( x )66#define MESA_LITTLE_ENDIAN 167#endif68#define LE32_TO_CPU( x ) CPU_TO_LE32( x )69707172#define IEEE_ONE 0x3f8000007374#ifndef __has_attribute75# define __has_attribute(x) 076#endif7778#if __cplusplus >= 201703L || __STDC_VERSION__ > 201710L79/* Standard C++17/C23 attribute */80#define FALLTHROUGH [[fallthrough]]81#elif __has_attribute(fallthrough)82/* Non-standard but supported by at least gcc and clang */83#define FALLTHROUGH __attribute__((fallthrough))84#else85#define FALLTHROUGH do { } while(0)86#endif8788#endif /* COMPILER_H */899091