Path: blob/21.2-virgl/src/gallium/include/pipe/p_compiler.h
4565 views
/**************************************************************************1*2* Copyright 2007-2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef P_COMPILER_H28#define P_COMPILER_H293031#include "c99_compat.h" /* inline, __func__, etc. */3233#include "p_config.h"3435#include "util/macros.h"3637#include <stdlib.h>38#include <string.h>39#include <stddef.h>40#include <stdarg.h>41#include <limits.h>424344#if defined(_WIN32) && !defined(__WIN32__)45#define __WIN32__46#endif4748#if defined(_MSC_VER)4950#include <intrin.h>5152/* Avoid 'expression is always true' warning */53#pragma warning(disable: 4296)5455#endif /* _MSC_VER */565758/*59* Alternative stdint.h and stdbool.h headers are supplied in include/c99 for60* systems that lack it.61*/62#include <stdint.h>63#include <stdbool.h>646566#ifdef __cplusplus67extern "C" {68#endif697071#if !defined(__HAIKU__) && !defined(__USE_MISC)72#if !defined(PIPE_OS_ANDROID)73typedef unsigned int uint;74#endif75typedef unsigned short ushort;76#endif77typedef unsigned char ubyte;7879typedef unsigned char boolean;80#ifndef TRUE81#define TRUE true82#endif83#ifndef FALSE84#define FALSE false85#endif8687#ifndef va_copy88#ifdef __va_copy89#define va_copy(dest, src) __va_copy((dest), (src))90#else91#define va_copy(dest, src) (dest) = (src)92#endif93#endif949596/* XXX: Use standard `__func__` instead */97#ifndef __FUNCTION__98# define __FUNCTION__ __func__99#endif100101102/* This should match linux gcc cdecl semantics everywhere, so that we103* just codegen one calling convention on all platforms.104*/105#ifdef _MSC_VER106#define PIPE_CDECL __cdecl107#else108#define PIPE_CDECL109#endif110111112113#if defined(__GNUC__)114#define PIPE_DEPRECATED __attribute__((__deprecated__))115#else116#define PIPE_DEPRECATED117#endif118119120121/* Macros for data alignment. */122#if defined(__GNUC__)123124/* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Attributes.html */125#define PIPE_ALIGN_TYPE(_alignment, _type) _type __attribute__((aligned(_alignment)))126127/* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Variable-Attributes.html */128#define PIPE_ALIGN_VAR(_alignment) __attribute__((aligned(_alignment)))129130#if defined(__GNUC__) && defined(PIPE_ARCH_X86)131#define PIPE_ALIGN_STACK __attribute__((force_align_arg_pointer))132#else133#define PIPE_ALIGN_STACK134#endif135136#elif defined(_MSC_VER)137138/* See http://msdn.microsoft.com/en-us/library/83ythb65.aspx */139#define PIPE_ALIGN_TYPE(_alignment, _type) __declspec(align(_alignment)) _type140#define PIPE_ALIGN_VAR(_alignment) __declspec(align(_alignment))141142#define PIPE_ALIGN_STACK143144#elif defined(SWIG)145146#define PIPE_ALIGN_TYPE(_alignment, _type) _type147#define PIPE_ALIGN_VAR(_alignment)148149#define PIPE_ALIGN_STACK150151#else152153#error "Unsupported compiler"154155#endif156157158#if defined(__GNUC__)159160#define PIPE_READ_WRITE_BARRIER() __asm__("":::"memory")161162#elif defined(_MSC_VER)163164#define PIPE_READ_WRITE_BARRIER() _ReadWriteBarrier()165166#else167168#warning "Unsupported compiler"169#define PIPE_READ_WRITE_BARRIER() /* */170171#endif172173#if defined(__cplusplus)174}175#endif176177178#endif /* P_COMPILER_H */179180181