Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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@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. #define PIPE_CC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
  57. #endif
  58.  
  59. /*
  60.  * Meaning of _MSC_VER value:
  61.  * - 1800: Visual Studio 2013
  62.  * - 1700: Visual Studio 2012
  63.  * - 1600: Visual Studio 2010
  64.  * - 1500: Visual Studio 2008
  65.  * - 1400: Visual C++ 2005
  66.  * - 1310: Visual C++ .NET 2003
  67.  * - 1300: Visual C++ .NET 2002
  68.  *
  69.  * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC
  70.  * versions.
  71.  */
  72. #if defined(_MSC_VER) || defined(__MSC__)
  73. #define PIPE_CC_MSVC
  74. #endif
  75.  
  76. #if defined(__ICL)
  77. #define PIPE_CC_ICL
  78. #endif
  79.  
  80. #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  81. #define PIPE_CC_SUNPRO
  82. #endif
  83.  
  84.  
  85. /*
  86.  * Processor architecture
  87.  */
  88.  
  89. #if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) || defined(__i386) /* Sun cc */
  90. #define PIPE_ARCH_X86
  91. #endif
  92.  
  93. #if defined(__x86_64__) /* gcc */ || defined(_M_X64) /* msvc */ || defined(_M_AMD64) /* msvc */ || defined(__x86_64) /* Sun cc */
  94. #define PIPE_ARCH_X86_64
  95. #endif
  96.  
  97. #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
  98. #if defined(PIPE_CC_GCC) && !defined(__SSE2__)
  99. /* #warning SSE2 support requires -msse -msse2 compiler options */
  100. #else
  101. #define PIPE_ARCH_SSE
  102. #endif
  103. #if defined(PIPE_CC_GCC) && !defined(__SSSE3__)
  104. /* #warning SSE3 support requires -msse3 compiler options */
  105. #else
  106. #define PIPE_ARCH_SSSE3
  107. #endif
  108. #endif
  109.  
  110. #if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__)
  111. #define PIPE_ARCH_PPC
  112. #if defined(__ppc64__) || defined(__PPC64__)
  113. #define PIPE_ARCH_PPC_64
  114. #endif
  115. #endif
  116.  
  117. #if defined(__s390x__)
  118. #define PIPE_ARCH_S390
  119. #endif
  120.  
  121. #if defined(__arm__)
  122. #define PIPE_ARCH_ARM
  123. #endif
  124.  
  125. #if defined(__aarch64__)
  126. #define PIPE_ARCH_AARCH64
  127. #endif
  128.  
  129. /*
  130.  * Endian detection.
  131.  */
  132.  
  133. #ifdef __GLIBC__
  134. #include <endian.h>
  135.  
  136. #if __BYTE_ORDER == __LITTLE_ENDIAN
  137. # define PIPE_ARCH_LITTLE_ENDIAN
  138. #elif __BYTE_ORDER == __BIG_ENDIAN
  139. # define PIPE_ARCH_BIG_ENDIAN
  140. #endif
  141.  
  142. #elif defined(__APPLE__)
  143. #include <machine/endian.h>
  144.  
  145. #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
  146. # define PIPE_ARCH_LITTLE_ENDIAN
  147. #elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
  148. # define PIPE_ARCH_BIG_ENDIAN
  149. #endif
  150.  
  151. #elif defined(__sun)
  152. #include <sys/isa_defs.h>
  153.  
  154. #if defined(_LITTLE_ENDIAN)
  155. # define PIPE_ARCH_LITTLE_ENDIAN
  156. #elif defined(_BIG_ENDIAN)
  157. # define PIPE_ARCH_BIG_ENDIAN
  158. #endif
  159.  
  160. #elif defined(__OpenBSD__) || defined(__NetBSD__)
  161. #include <sys/types.h>
  162. #include <machine/endian.h>
  163.  
  164. #if _BYTE_ORDER == _LITTLE_ENDIAN
  165. # define PIPE_ARCH_LITTLE_ENDIAN
  166. #elif _BYTE_ORDER == _BIG_ENDIAN
  167. # define PIPE_ARCH_BIG_ENDIAN
  168. #endif
  169.  
  170. #else
  171.  
  172. #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
  173. #define PIPE_ARCH_LITTLE_ENDIAN
  174. #elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390)
  175. #define PIPE_ARCH_BIG_ENDIAN
  176. #endif
  177.  
  178. #endif
  179.  
  180. #if !defined(PIPE_ARCH_LITTLE_ENDIAN) && !defined(PIPE_ARCH_BIG_ENDIAN)
  181. #error Unknown Endianness
  182. #endif
  183.  
  184. /*
  185.  * Auto-detect the operating system family.
  186.  *
  187.  * See subsystem below for a more fine-grained distinction.
  188.  */
  189.  
  190. #if defined(__linux__)
  191. #define PIPE_OS_LINUX
  192. #define PIPE_OS_UNIX
  193. #endif
  194.  
  195. /*
  196.  * Android defines __linux__ so PIPE_OS_LINUX and PIPE_OS_UNIX will also be
  197.  * defined.
  198.  */
  199. #if defined(ANDROID)
  200. #define PIPE_OS_ANDROID
  201. #endif
  202.  
  203. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  204. #define PIPE_OS_FREEBSD
  205. #define PIPE_OS_BSD
  206. #define PIPE_OS_UNIX
  207. #endif
  208.  
  209. #if defined(__OpenBSD__)
  210. #define PIPE_OS_OPENBSD
  211. #define PIPE_OS_BSD
  212. #define PIPE_OS_UNIX
  213. #endif
  214.  
  215. #if defined(__NetBSD__)
  216. #define PIPE_OS_NETBSD
  217. #define PIPE_OS_BSD
  218. #define PIPE_OS_UNIX
  219. #endif
  220.  
  221. #if defined(__DragonFly__)
  222. #define PIPE_OS_DRAGONFLY
  223. #define PIPE_OS_BSD
  224. #define PIPE_OS_UNIX
  225. #endif
  226.  
  227. #if defined(__GNU__)
  228. #define PIPE_OS_HURD
  229. #define PIPE_OS_UNIX
  230. #endif
  231.  
  232. #if defined(__sun)
  233. #define PIPE_OS_SOLARIS
  234. #define PIPE_OS_UNIX
  235. #endif
  236.  
  237. #if defined(__APPLE__)
  238. #define PIPE_OS_APPLE
  239. #define PIPE_OS_UNIX
  240. #endif
  241.  
  242. #if defined(_WIN32) || defined(WIN32)
  243. #define PIPE_OS_WINDOWS
  244. #endif
  245.  
  246. #if defined(__HAIKU__)
  247. #define PIPE_OS_HAIKU
  248. #define PIPE_OS_UNIX
  249. #endif
  250.  
  251. #if defined(__CYGWIN__)
  252. #define PIPE_OS_CYGWIN
  253. #define PIPE_OS_UNIX
  254. #endif
  255.  
  256. /*
  257.  * Try to auto-detect the subsystem.
  258.  *
  259.  * NOTE: There is no way to auto-detect most of these.
  260.  */
  261.  
  262. #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
  263. #define PIPE_SUBSYSTEM_DRI
  264. #endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
  265.  
  266. #if defined(PIPE_OS_WINDOWS)
  267. #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
  268. /* Windows User-space Library */
  269. #else
  270. #define PIPE_SUBSYSTEM_WINDOWS_USER
  271. #endif
  272. #endif /* PIPE_OS_WINDOWS */
  273.  
  274.  
  275. #endif /* P_CONFIG_H_ */
  276.