p_compiler.h revision 818fd6b10182931a0727819f275f7f1686df09f5
1/************************************************************************** 2 * 3 * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#ifndef P_COMPILER_H 29#define P_COMPILER_H 30 31 32#include "p_config.h" 33 34#ifndef XFree86Server 35#include <stdlib.h> 36#include <string.h> 37#else 38#include "xf86_ansic.h" 39#include "xf86_libc.h" 40#endif 41 42 43#if defined(_WIN32) && !defined(__WIN32__) 44#define __WIN32__ 45#endif 46 47#if defined(_MSC_VER) 48 49/* Avoid 'expression is always true' warning */ 50#pragma warning(disable: 4296) 51 52#endif /* _MSC_VER */ 53 54 55#if defined(_MSC_VER) 56 57typedef __int8 int8_t; 58typedef unsigned __int8 uint8_t; 59typedef __int16 int16_t; 60typedef unsigned __int16 uint16_t; 61#ifndef __eglplatform_h_ 62typedef __int32 int32_t; 63#endif 64typedef unsigned __int32 uint32_t; 65typedef __int64 int64_t; 66typedef unsigned __int64 uint64_t; 67 68#if defined(_WIN64) 69typedef __int64 intptr_t; 70typedef unsigned __int64 uintptr_t; 71#else 72typedef __int32 intptr_t; 73typedef unsigned __int32 uintptr_t; 74#endif 75 76#define INT64_C(__val) __val##i64 77#define UINT64_C(__val) __val##ui64 78 79#ifndef __cplusplus 80#define false 0 81#define true 1 82#define bool _Bool 83typedef int _Bool; 84#define __bool_true_false_are_defined 1 85#endif /* !__cplusplus */ 86 87#else 88#ifndef __STDC_LIMIT_MACROS 89#define __STDC_LIMIT_MACROS 1 90#endif 91#include <stdint.h> 92#include <stdbool.h> 93#endif 94 95 96#ifndef __HAIKU__ 97typedef unsigned int uint; 98typedef unsigned short ushort; 99#endif 100typedef unsigned char ubyte; 101 102#if 0 103#define boolean bool 104#else 105typedef unsigned char boolean; 106#endif 107#ifndef TRUE 108#define TRUE true 109#endif 110#ifndef FALSE 111#define FALSE false 112#endif 113 114 115/* Function inlining */ 116#ifndef INLINE 117# ifdef __cplusplus 118# define INLINE inline 119# elif defined(__GNUC__) 120# define INLINE __inline__ 121# elif defined(_MSC_VER) 122# define INLINE __inline 123# elif defined(__ICL) 124# define INLINE __inline 125# elif defined(__INTEL_COMPILER) 126# define INLINE inline 127# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) 128# define INLINE __inline 129# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) 130# define INLINE inline 131# elif (__STDC_VERSION__ >= 199901L) /* C99 */ 132# define INLINE inline 133# else 134# define INLINE 135# endif 136#endif 137 138/* The __FUNCTION__ gcc variable is generally only used for debugging. 139 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. 140 */ 141#ifndef __FUNCTION__ 142# if (!defined(__GNUC__) || (__GNUC__ < 2)) 143# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ 144 (defined(__SUNPRO_C) && defined(__C99FEATURES__)) 145# define __FUNCTION__ __func__ 146# else 147# define __FUNCTION__ "<unknown>" 148# endif 149# endif 150#endif 151 152 153 154/* This should match linux gcc cdecl semantics everywhere, so that we 155 * just codegen one calling convention on all platforms. 156 */ 157#ifdef _MSC_VER 158#define PIPE_CDECL __cdecl 159#else 160#define PIPE_CDECL 161#endif 162 163 164 165#if defined(__GNUC__) 166#define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) )) 167#define ALIGN16_ASSIGN(NAME) NAME##___aligned 168#define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) )) 169#define ALIGN8_ATTRIB __attribute__(( aligned( 8 ) )) 170#if (__GNUC__ > 4 || (__GNUC__ == 4 &&__GNUC_MINOR__>1)) && !defined(PIPE_ARCH_X86_64) 171#define ALIGN_STACK __attribute__((force_align_arg_pointer)) 172#else 173#define ALIGN_STACK 174#endif 175#else 176#define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1] 177#define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned) 178#define ALIGN16_ATTRIB 179#define ALIGN8_ATTRIB 180#define ALIGN_STACK 181#endif 182 183 184 185#endif /* P_COMPILER_H */ 186