eglcompiler.h revision f2001df508fda599a18b3586d2775e970a3db13a
1/************************************************************************** 2 * 3 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> 4 * Copyright 2010 LunarG, Inc. 5 * All Rights Reserved. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the 9 * "Software"), to deal in the Software without restriction, including 10 * without limitation the rights to use, copy, modify, merge, publish, 11 * distribute, sub license, and/or sell copies of the Software, and to 12 * permit persons to whom the Software is furnished to do so, subject to 13 * the following conditions: 14 * 15 * The above copyright notice and this permission notice (including the 16 * next paragraph) shall be included in all copies or substantial portions 17 * of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 * DEALINGS IN THE SOFTWARE. 26 * 27 **************************************************************************/ 28 29 30#ifndef EGLCOMPILER_INCLUDED 31#define EGLCOMPILER_INCLUDED 32 33 34/** 35 * Get standard integer types 36 */ 37#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) 38# include <stdint.h> 39#elif defined(_MSC_VER) 40 typedef __int8 int8_t; 41 typedef unsigned __int8 uint8_t; 42 typedef __int16 int16_t; 43 typedef unsigned __int16 uint16_t; 44 typedef __int32 int32_t; 45 typedef unsigned __int32 uint32_t; 46 typedef __int64 int64_t; 47 typedef unsigned __int64 uint64_t; 48 49# if defined(_WIN64) 50 typedef __int64 intptr_t; 51 typedef unsigned __int64 uintptr_t; 52# else 53 typedef __int32 intptr_t; 54 typedef unsigned __int32 uintptr_t; 55# endif 56 57# define INT64_C(__val) __val##i64 58# define UINT64_C(__val) __val##ui64 59#else 60/* hope the best instead of adding a bunch of ifdef's */ 61# include <stdint.h> 62#endif 63 64 65/** 66 * Function inlining 67 */ 68#if defined(__GNUC__) 69# define INLINE __inline__ 70#elif defined(__MSC__) 71# define INLINE __inline 72#elif defined(_MSC_VER) 73# define INLINE __inline 74#elif defined(__ICL) 75# define INLINE __inline 76#elif defined(__INTEL_COMPILER) 77# define INLINE inline 78#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) 79# define INLINE __inline 80#elif defined(__SUNPRO_C) && defined(__C99FEATURES__) 81# define INLINE inline 82# define __inline inline 83# define __inline__ inline 84#elif (__STDC_VERSION__ >= 199901L) /* C99 */ 85# define INLINE inline 86#else 87# define INLINE 88#endif 89 90 91/** 92 * Function visibility 93 */ 94#ifndef PUBLIC 95# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) 96# define PUBLIC __attribute__((visibility("default"))) 97# elif defined(_MSC_VER) 98# define PUBLIC __declspec(dllexport) 99# else 100# define PUBLIC 101# endif 102#endif 103 104/** 105 * The __FUNCTION__ gcc variable is generally only used for debugging. 106 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. 107 * Don't define it if using a newer Windows compiler. 108 */ 109#ifndef __FUNCTION__ 110# if defined(__VMS) 111# define __FUNCTION__ "VMS$NL:" 112# elif (!defined __GNUC__) && (!defined __xlC__) && \ 113 (!defined(_MSC_VER) || _MSC_VER < 1300) 114# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ 115 (defined(__SUNPRO_C) && defined(__C99FEATURES__)) 116# define __FUNCTION__ __func__ 117# else 118# define __FUNCTION__ "<unknown>" 119# endif 120# endif 121#endif 122 123#endif /* EGLCOMPILER_INCLUDED */ 124