Home | History | Annotate | Download | only in pipe
      1 /**************************************************************************
      2  *
      3  * Copyright 2008 VMware, Inc.
      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 VMWARE 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 /**
     29  * @file
     30  * Gallium configuration defines.
     31  *
     32  * This header file sets several defines based on the compiler, processor
     33  * architecture, and operating system being used. These defines should be used
     34  * throughout the code to facilitate porting to new platforms. It is likely that
     35  * this file is auto-generated by an autoconf-like tool at some point, as some
     36  * things cannot be determined by pre-defined environment alone.
     37  *
     38  * See also:
     39  * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
     40  * - echo | gcc -dM -E - | sort
     41  * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx
     42  *
     43  * @author Jos Fonseca <jfonseca (at) vmware.com>
     44  */
     45 
     46 #ifndef P_CONFIG_H_
     47 #define P_CONFIG_H_
     48 
     49 #include <limits.h>
     50 /*
     51  * Compiler
     52  */
     53 
     54 #if defined(__GNUC__)
     55 #define PIPE_CC_GCC
     56 #endif
     57 
     58 /*
     59  * Meaning of _MSC_VER value:
     60  * - 1800: Visual Studio 2013
     61  * - 1700: Visual Studio 2012
     62  * - 1600: Visual Studio 2010
     63  * - 1500: Visual Studio 2008
     64  * - 1400: Visual C++ 2005
     65  * - 1310: Visual C++ .NET 2003
     66  * - 1300: Visual C++ .NET 2002
     67  *
     68  * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC
     69  * versions.
     70  */
     71 #if defined(_MSC_VER) || defined(__MSC__)
     72 #define PIPE_CC_MSVC
     73 #endif
     74 
     75 #if defined(__ICL)
     76 #define PIPE_CC_ICL
     77 #endif
     78 
     79 
     80 /*
     81  * Processor architecture
     82  */
     83 
     84 #if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) || defined(__i386) /* Sun cc */
     85 #define PIPE_ARCH_X86
     86 #endif
     87 
     88 #if defined(__x86_64__) /* gcc */ || defined(_M_X64) /* msvc */ || defined(_M_AMD64) /* msvc */ || defined(__x86_64) /* Sun cc */
     89 #define PIPE_ARCH_X86_64
     90 #endif
     91 
     92 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
     93 #if defined(PIPE_CC_GCC) && !defined(__SSE2__)
     94 /* #warning SSE2 support requires -msse -msse2 compiler options */
     95 #else
     96 #define PIPE_ARCH_SSE
     97 #endif
     98 #if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 && !defined(__SSSE3__)
     99 /* #warning SSE3 support requires -msse3 compiler options before GCC 4.9 */
    100 #else
    101 #define PIPE_ARCH_SSSE3
    102 #endif
    103 #endif
    104 
    105 #if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__)
    106 #define PIPE_ARCH_PPC
    107 #if defined(__ppc64__) || defined(__PPC64__)
    108 #define PIPE_ARCH_PPC_64
    109 #endif
    110 #endif
    111 
    112 #if defined(__s390x__)
    113 #define PIPE_ARCH_S390
    114 #endif
    115 
    116 #if defined(__arm__)
    117 #define PIPE_ARCH_ARM
    118 #endif
    119 
    120 #if defined(__aarch64__)
    121 #define PIPE_ARCH_AARCH64
    122 #endif
    123 
    124 /*
    125  * Endian detection.
    126  */
    127 
    128 #include "util/u_endian.h"
    129 #if !defined(PIPE_ARCH_LITTLE_ENDIAN) && !defined(PIPE_ARCH_BIG_ENDIAN)
    130 
    131 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
    132 #define PIPE_ARCH_LITTLE_ENDIAN
    133 #elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390)
    134 #define PIPE_ARCH_BIG_ENDIAN
    135 #endif
    136 
    137 #endif
    138 
    139 #if !defined(PIPE_ARCH_LITTLE_ENDIAN) && !defined(PIPE_ARCH_BIG_ENDIAN)
    140 #error Unknown Endianness
    141 #endif
    142 
    143 /*
    144  * Auto-detect the operating system family.
    145  *
    146  * See subsystem below for a more fine-grained distinction.
    147  */
    148 
    149 #if defined(__linux__)
    150 #define PIPE_OS_LINUX
    151 #define PIPE_OS_UNIX
    152 #endif
    153 
    154 /*
    155  * Android defines __linux__ so PIPE_OS_LINUX and PIPE_OS_UNIX will also be
    156  * defined.
    157  */
    158 #if defined(ANDROID)
    159 #define PIPE_OS_ANDROID
    160 #endif
    161 
    162 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    163 #define PIPE_OS_FREEBSD
    164 #define PIPE_OS_BSD
    165 #define PIPE_OS_UNIX
    166 #endif
    167 
    168 #if defined(__OpenBSD__)
    169 #define PIPE_OS_OPENBSD
    170 #define PIPE_OS_BSD
    171 #define PIPE_OS_UNIX
    172 #endif
    173 
    174 #if defined(__NetBSD__)
    175 #define PIPE_OS_NETBSD
    176 #define PIPE_OS_BSD
    177 #define PIPE_OS_UNIX
    178 #endif
    179 
    180 #if defined(__DragonFly__)
    181 #define PIPE_OS_DRAGONFLY
    182 #define PIPE_OS_BSD
    183 #define PIPE_OS_UNIX
    184 #endif
    185 
    186 #if defined(__GNU__)
    187 #define PIPE_OS_HURD
    188 #define PIPE_OS_UNIX
    189 #endif
    190 
    191 #if defined(__sun)
    192 #define PIPE_OS_SOLARIS
    193 #define PIPE_OS_UNIX
    194 #endif
    195 
    196 #if defined(__APPLE__)
    197 #define PIPE_OS_APPLE
    198 #define PIPE_OS_UNIX
    199 #endif
    200 
    201 #if defined(_WIN32) || defined(WIN32)
    202 #define PIPE_OS_WINDOWS
    203 #endif
    204 
    205 #if defined(__HAIKU__)
    206 #define PIPE_OS_HAIKU
    207 #define PIPE_OS_UNIX
    208 #endif
    209 
    210 #if defined(__CYGWIN__)
    211 #define PIPE_OS_CYGWIN
    212 #define PIPE_OS_UNIX
    213 #endif
    214 
    215 /*
    216  * Try to auto-detect the subsystem.
    217  *
    218  * NOTE: There is no way to auto-detect most of these.
    219  */
    220 
    221 #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
    222 #define PIPE_SUBSYSTEM_DRI
    223 #endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
    224 
    225 #if defined(PIPE_OS_WINDOWS)
    226 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
    227 /* Windows User-space Library */
    228 #else
    229 #define PIPE_SUBSYSTEM_WINDOWS_USER
    230 #endif
    231 #endif /* PIPE_OS_WINDOWS */
    232 
    233 
    234 #endif /* P_CONFIG_H_ */
    235