khrplatform.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. #ifndef __khrplatform_h_
  2. #define __khrplatform_h_
  3. /*
  4. ** Copyright (c) 2008-2009 The Khronos Group Inc.
  5. **
  6. ** Permission is hereby granted, free of charge, to any person obtaining a
  7. ** copy of this software and/or associated documentation files (the
  8. ** "Materials"), to deal in the Materials without restriction, including
  9. ** without limitation the rights to use, copy, modify, merge, publish,
  10. ** distribute, sublicense, and/or sell copies of the Materials, and to
  11. ** permit persons to whom the Materials are furnished to do so, subject to
  12. ** the following conditions:
  13. **
  14. ** The above copyright notice and this permission notice shall be included
  15. ** in all copies or substantial portions of the Materials.
  16. **
  17. ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  21. ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
  24. */
  25. /* Khronos platform-specific types and definitions.
  26. *
  27. * $Revision: 32517 $ on $Date: 2016-03-11 02:41:19 -0800 (Fri, 11 Mar 2016) $
  28. *
  29. * Adopters may modify this file to suit their platform. Adopters are
  30. * encouraged to submit platform specific modifications to the Khronos
  31. * group so that they can be included in future versions of this file.
  32. * Please submit changes by sending them to the public Khronos Bugzilla
  33. * (http://khronos.org/bugzilla) by filing a bug against product
  34. * "Khronos (general)" component "Registry".
  35. *
  36. * A predefined template which fills in some of the bug fields can be
  37. * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
  38. * must create a Bugzilla login first.
  39. *
  40. *
  41. * See the Implementer's Guidelines for information about where this file
  42. * should be located on your system and for more details of its use:
  43. * http://www.khronos.org/registry/implementers_guide.pdf
  44. *
  45. * This file should be included as
  46. * #include <KHR/khrplatform.h>
  47. * by Khronos client API header files that use its types and defines.
  48. *
  49. * The types in khrplatform.h should only be used to define API-specific types.
  50. *
  51. * Types defined in khrplatform.h:
  52. * khronos_int8_t signed 8 bit
  53. * khronos_uint8_t unsigned 8 bit
  54. * khronos_int16_t signed 16 bit
  55. * khronos_uint16_t unsigned 16 bit
  56. * khronos_int32_t signed 32 bit
  57. * khronos_uint32_t unsigned 32 bit
  58. * khronos_int64_t signed 64 bit
  59. * khronos_uint64_t unsigned 64 bit
  60. * khronos_intptr_t signed same number of bits as a pointer
  61. * khronos_uintptr_t unsigned same number of bits as a pointer
  62. * khronos_ssize_t signed size
  63. * khronos_usize_t unsigned size
  64. * khronos_float_t signed 32 bit floating point
  65. * khronos_time_ns_t unsigned 64 bit time in nanoseconds
  66. * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
  67. * nanoseconds
  68. * khronos_stime_nanoseconds_t signed time interval in nanoseconds
  69. * khronos_boolean_enum_t enumerated boolean type. This should
  70. * only be used as a base type when a client API's boolean type is
  71. * an enum. Client APIs which use an integer or other type for
  72. * booleans cannot use this as the base type for their boolean.
  73. *
  74. * Tokens defined in khrplatform.h:
  75. *
  76. * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
  77. *
  78. * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
  79. * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
  80. *
  81. * Calling convention macros defined in this file:
  82. * KHRONOS_APICALL
  83. * KHRONOS_APIENTRY
  84. * KHRONOS_APIATTRIBUTES
  85. *
  86. * These may be used in function prototypes as:
  87. *
  88. * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
  89. * int arg1,
  90. * int arg2) KHRONOS_APIATTRIBUTES;
  91. */
  92. /*-------------------------------------------------------------------------
  93. * Definition of KHRONOS_APICALL
  94. *-------------------------------------------------------------------------
  95. * This precedes the return type of the function in the function prototype.
  96. */
  97. #if defined(_WIN32) && !defined(__SCITECH_SNAP__)
  98. # define KHRONOS_APICALL __declspec(dllimport)
  99. #elif defined (__SYMBIAN32__)
  100. # define KHRONOS_APICALL IMPORT_C
  101. #elif defined(__ANDROID__)
  102. # include <sys/cdefs.h>
  103. # define KHRONOS_APICALL __attribute__((visibility("default"))) __NDK_FPABI__
  104. #else
  105. # define KHRONOS_APICALL
  106. #endif
  107. /*-------------------------------------------------------------------------
  108. * Definition of KHRONOS_APIENTRY
  109. *-------------------------------------------------------------------------
  110. * This follows the return type of the function and precedes the function
  111. * name in the function prototype.
  112. */
  113. #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
  114. /* Win32 but not WinCE */
  115. # define KHRONOS_APIENTRY __stdcall
  116. #else
  117. # define KHRONOS_APIENTRY
  118. #endif
  119. /*-------------------------------------------------------------------------
  120. * Chromium-specific overrides of KHRONOS_APICALL and KHRONOS_APIENTRY
  121. *-----------------------------------------------------------------------*/
  122. #undef KHRONOS_APICALL
  123. #if defined(GLES2_USE_MOJO)
  124. #include "mojo/public/c/gles2/gles2_export.h"
  125. #define KHRONOS_APICALL MOJO_GLES2_EXPORT
  126. #else
  127. #include "gpu/command_buffer/client/gles2_c_lib_export.h"
  128. #define KHRONOS_APICALL GLES2_C_LIB_EXPORT
  129. #endif
  130. /*-------------------------------------------------------------------------
  131. * Definition of KHRONOS_APIATTRIBUTES
  132. *-------------------------------------------------------------------------
  133. * This follows the closing parenthesis of the function prototype arguments.
  134. */
  135. #if defined (__ARMCC_2__)
  136. #define KHRONOS_APIATTRIBUTES __softfp
  137. #else
  138. #define KHRONOS_APIATTRIBUTES
  139. #endif
  140. /*-------------------------------------------------------------------------
  141. * basic type definitions
  142. *-----------------------------------------------------------------------*/
  143. #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
  144. /*
  145. * Using <stdint.h>
  146. */
  147. #include <stdint.h>
  148. typedef int32_t khronos_int32_t;
  149. typedef uint32_t khronos_uint32_t;
  150. typedef int64_t khronos_int64_t;
  151. typedef uint64_t khronos_uint64_t;
  152. #define KHRONOS_SUPPORT_INT64 1
  153. #define KHRONOS_SUPPORT_FLOAT 1
  154. #elif defined(__VMS ) || defined(__sgi)
  155. /*
  156. * Using <inttypes.h>
  157. */
  158. #include <inttypes.h>
  159. typedef int32_t khronos_int32_t;
  160. typedef uint32_t khronos_uint32_t;
  161. typedef int64_t khronos_int64_t;
  162. typedef uint64_t khronos_uint64_t;
  163. #define KHRONOS_SUPPORT_INT64 1
  164. #define KHRONOS_SUPPORT_FLOAT 1
  165. #elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
  166. /*
  167. * Win32
  168. */
  169. typedef __int32 khronos_int32_t;
  170. typedef unsigned __int32 khronos_uint32_t;
  171. typedef __int64 khronos_int64_t;
  172. typedef unsigned __int64 khronos_uint64_t;
  173. #define KHRONOS_SUPPORT_INT64 1
  174. #define KHRONOS_SUPPORT_FLOAT 1
  175. #elif defined(__sun__) || defined(__digital__)
  176. /*
  177. * Sun or Digital
  178. */
  179. typedef int khronos_int32_t;
  180. typedef unsigned int khronos_uint32_t;
  181. #if defined(__arch64__) || defined(_LP64)
  182. typedef long int khronos_int64_t;
  183. typedef unsigned long int khronos_uint64_t;
  184. #else
  185. typedef long long int khronos_int64_t;
  186. typedef unsigned long long int khronos_uint64_t;
  187. #endif /* __arch64__ */
  188. #define KHRONOS_SUPPORT_INT64 1
  189. #define KHRONOS_SUPPORT_FLOAT 1
  190. #elif 0
  191. /*
  192. * Hypothetical platform with no float or int64 support
  193. */
  194. typedef int khronos_int32_t;
  195. typedef unsigned int khronos_uint32_t;
  196. #define KHRONOS_SUPPORT_INT64 0
  197. #define KHRONOS_SUPPORT_FLOAT 0
  198. #else
  199. /*
  200. * Generic fallback
  201. */
  202. #include <stdint.h>
  203. typedef int32_t khronos_int32_t;
  204. typedef uint32_t khronos_uint32_t;
  205. typedef int64_t khronos_int64_t;
  206. typedef uint64_t khronos_uint64_t;
  207. #define KHRONOS_SUPPORT_INT64 1
  208. #define KHRONOS_SUPPORT_FLOAT 1
  209. #endif
  210. /*
  211. * Types that are (so far) the same on all platforms
  212. */
  213. typedef signed char khronos_int8_t;
  214. typedef unsigned char khronos_uint8_t;
  215. typedef signed short int khronos_int16_t;
  216. typedef unsigned short int khronos_uint16_t;
  217. /*
  218. * Types that differ between LLP64 and LP64 architectures - in LLP64,
  219. * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
  220. * to be the only LLP64 architecture in current use.
  221. */
  222. #ifdef _WIN64
  223. typedef signed long long int khronos_intptr_t;
  224. typedef unsigned long long int khronos_uintptr_t;
  225. typedef signed long long int khronos_ssize_t;
  226. typedef unsigned long long int khronos_usize_t;
  227. #else
  228. typedef signed long int khronos_intptr_t;
  229. typedef unsigned long int khronos_uintptr_t;
  230. typedef signed long int khronos_ssize_t;
  231. typedef unsigned long int khronos_usize_t;
  232. #endif
  233. #if KHRONOS_SUPPORT_FLOAT
  234. /*
  235. * Float type
  236. */
  237. typedef float khronos_float_t;
  238. #endif
  239. #if KHRONOS_SUPPORT_INT64
  240. /* Time types
  241. *
  242. * These types can be used to represent a time interval in nanoseconds or
  243. * an absolute Unadjusted System Time. Unadjusted System Time is the number
  244. * of nanoseconds since some arbitrary system event (e.g. since the last
  245. * time the system booted). The Unadjusted System Time is an unsigned
  246. * 64 bit value that wraps back to 0 every 584 years. Time intervals
  247. * may be either signed or unsigned.
  248. */
  249. typedef khronos_uint64_t khronos_utime_nanoseconds_t;
  250. typedef khronos_int64_t khronos_stime_nanoseconds_t;
  251. #endif
  252. /*
  253. * Dummy value used to pad enum types to 32 bits.
  254. */
  255. #ifndef KHRONOS_MAX_ENUM
  256. #define KHRONOS_MAX_ENUM 0x7FFFFFFF
  257. #endif
  258. /*
  259. * Enumerated boolean type
  260. *
  261. * Values other than zero should be considered to be true. Therefore
  262. * comparisons should not be made against KHRONOS_TRUE.
  263. */
  264. typedef enum {
  265. KHRONOS_FALSE = 0,
  266. KHRONOS_TRUE = 1,
  267. KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
  268. } khronos_boolean_enum_t;
  269. #endif /* __khrplatform_h_ */