🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

311 lines
11 KiB

1 year ago
1 year ago
1 year ago
  1. #ifndef __khrplatform_h_
  2. #define __khrplatform_h_
  3. /*
  4. ** Copyright (c) 2008-2018 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. * The master copy of khrplatform.h is maintained in the Khronos EGL
  28. * Registry repository at https://github.com/KhronosGroup/EGL-Registry
  29. * The last semantic modification to khrplatform.h was at commit ID:
  30. * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
  31. *
  32. * Adopters may modify this file to suit their platform. Adopters are
  33. * encouraged to submit platform specific modifications to the Khronos
  34. * group so that they can be included in future versions of this file.
  35. * Please submit changes by filing pull requests or issues on
  36. * the EGL Registry repository linked above.
  37. *
  38. *
  39. * See the Implementer's Guidelines for information about where this file
  40. * should be located on your system and for more details of its use:
  41. * http://www.khronos.org/registry/implementers_guide.pdf
  42. *
  43. * This file should be included as
  44. * #include <KHR/khrplatform.h>
  45. * by Khronos client API header files that use its types and defines.
  46. *
  47. * The types in khrplatform.h should only be used to define API-specific types.
  48. *
  49. * Types defined in khrplatform.h:
  50. * khronos_int8_t signed 8 bit
  51. * khronos_uint8_t unsigned 8 bit
  52. * khronos_int16_t signed 16 bit
  53. * khronos_uint16_t unsigned 16 bit
  54. * khronos_int32_t signed 32 bit
  55. * khronos_uint32_t unsigned 32 bit
  56. * khronos_int64_t signed 64 bit
  57. * khronos_uint64_t unsigned 64 bit
  58. * khronos_intptr_t signed same number of bits as a pointer
  59. * khronos_uintptr_t unsigned same number of bits as a pointer
  60. * khronos_ssize_t signed size
  61. * khronos_usize_t unsigned size
  62. * khronos_float_t signed 32 bit floating point
  63. * khronos_time_ns_t unsigned 64 bit time in nanoseconds
  64. * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
  65. * nanoseconds
  66. * khronos_stime_nanoseconds_t signed time interval in nanoseconds
  67. * khronos_boolean_enum_t enumerated boolean type. This should
  68. * only be used as a base type when a client API's boolean type is
  69. * an enum. Client APIs which use an integer or other type for
  70. * booleans cannot use this as the base type for their boolean.
  71. *
  72. * Tokens defined in khrplatform.h:
  73. *
  74. * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
  75. *
  76. * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
  77. * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
  78. *
  79. * Calling convention macros defined in this file:
  80. * KHRONOS_APICALL
  81. * KHRONOS_APIENTRY
  82. * KHRONOS_APIATTRIBUTES
  83. *
  84. * These may be used in function prototypes as:
  85. *
  86. * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
  87. * int arg1,
  88. * int arg2) KHRONOS_APIATTRIBUTES;
  89. */
  90. #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
  91. # define KHRONOS_STATIC 1
  92. #endif
  93. /*-------------------------------------------------------------------------
  94. * Definition of KHRONOS_APICALL
  95. *-------------------------------------------------------------------------
  96. * This precedes the return type of the function in the function prototype.
  97. */
  98. #if defined(KHRONOS_STATIC)
  99. /* If the preprocessor constant KHRONOS_STATIC is defined, make the
  100. * header compatible with static linking. */
  101. # define KHRONOS_APICALL
  102. #elif defined(_WIN32)
  103. # define KHRONOS_APICALL __declspec(dllimport)
  104. #elif defined (__SYMBIAN32__)
  105. # define KHRONOS_APICALL IMPORT_C
  106. #elif defined(__ANDROID__)
  107. # define KHRONOS_APICALL __attribute__((visibility("default")))
  108. #else
  109. # define KHRONOS_APICALL
  110. #endif
  111. /*-------------------------------------------------------------------------
  112. * Definition of KHRONOS_APIENTRY
  113. *-------------------------------------------------------------------------
  114. * This follows the return type of the function and precedes the function
  115. * name in the function prototype.
  116. */
  117. #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
  118. /* Win32 but not WinCE */
  119. # define KHRONOS_APIENTRY __stdcall
  120. #else
  121. # define KHRONOS_APIENTRY
  122. #endif
  123. /*-------------------------------------------------------------------------
  124. * Definition of KHRONOS_APIATTRIBUTES
  125. *-------------------------------------------------------------------------
  126. * This follows the closing parenthesis of the function prototype arguments.
  127. */
  128. #if defined (__ARMCC_2__)
  129. #define KHRONOS_APIATTRIBUTES __softfp
  130. #else
  131. #define KHRONOS_APIATTRIBUTES
  132. #endif
  133. /*-------------------------------------------------------------------------
  134. * basic type definitions
  135. *-----------------------------------------------------------------------*/
  136. #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
  137. /*
  138. * Using <stdint.h>
  139. */
  140. #include <stdint.h>
  141. typedef int32_t khronos_int32_t;
  142. typedef uint32_t khronos_uint32_t;
  143. typedef int64_t khronos_int64_t;
  144. typedef uint64_t khronos_uint64_t;
  145. #define KHRONOS_SUPPORT_INT64 1
  146. #define KHRONOS_SUPPORT_FLOAT 1
  147. /*
  148. * To support platform where unsigned long cannot be used interchangeably with
  149. * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
  150. * Ideally, we could just use (u)intptr_t everywhere, but this could result in
  151. * ABI breakage if khronos_uintptr_t is changed from unsigned long to
  152. * unsigned long long or similar (this results in different C++ name mangling).
  153. * To avoid changes for existing platforms, we restrict usage of intptr_t to
  154. * platforms where the size of a pointer is larger than the size of long.
  155. */
  156. #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
  157. #if __SIZEOF_POINTER__ > __SIZEOF_LONG__
  158. #define KHRONOS_USE_INTPTR_T
  159. #endif
  160. #endif
  161. #elif defined(__VMS ) || defined(__sgi)
  162. /*
  163. * Using <inttypes.h>
  164. */
  165. #include <inttypes.h>
  166. typedef int32_t khronos_int32_t;
  167. typedef uint32_t khronos_uint32_t;
  168. typedef int64_t khronos_int64_t;
  169. typedef uint64_t khronos_uint64_t;
  170. #define KHRONOS_SUPPORT_INT64 1
  171. #define KHRONOS_SUPPORT_FLOAT 1
  172. #elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
  173. /*
  174. * Win32
  175. */
  176. typedef __int32 khronos_int32_t;
  177. typedef unsigned __int32 khronos_uint32_t;
  178. typedef __int64 khronos_int64_t;
  179. typedef unsigned __int64 khronos_uint64_t;
  180. #define KHRONOS_SUPPORT_INT64 1
  181. #define KHRONOS_SUPPORT_FLOAT 1
  182. #elif defined(__sun__) || defined(__digital__)
  183. /*
  184. * Sun or Digital
  185. */
  186. typedef int khronos_int32_t;
  187. typedef unsigned int khronos_uint32_t;
  188. #if defined(__arch64__) || defined(_LP64)
  189. typedef long int khronos_int64_t;
  190. typedef unsigned long int khronos_uint64_t;
  191. #else
  192. typedef long long int khronos_int64_t;
  193. typedef unsigned long long int khronos_uint64_t;
  194. #endif /* __arch64__ */
  195. #define KHRONOS_SUPPORT_INT64 1
  196. #define KHRONOS_SUPPORT_FLOAT 1
  197. #elif 0
  198. /*
  199. * Hypothetical platform with no float or int64 support
  200. */
  201. typedef int khronos_int32_t;
  202. typedef unsigned int khronos_uint32_t;
  203. #define KHRONOS_SUPPORT_INT64 0
  204. #define KHRONOS_SUPPORT_FLOAT 0
  205. #else
  206. /*
  207. * Generic fallback
  208. */
  209. #include <stdint.h>
  210. typedef int32_t khronos_int32_t;
  211. typedef uint32_t khronos_uint32_t;
  212. typedef int64_t khronos_int64_t;
  213. typedef uint64_t khronos_uint64_t;
  214. #define KHRONOS_SUPPORT_INT64 1
  215. #define KHRONOS_SUPPORT_FLOAT 1
  216. #endif
  217. /*
  218. * Types that are (so far) the same on all platforms
  219. */
  220. typedef signed char khronos_int8_t;
  221. typedef unsigned char khronos_uint8_t;
  222. typedef signed short int khronos_int16_t;
  223. typedef unsigned short int khronos_uint16_t;
  224. /*
  225. * Types that differ between LLP64 and LP64 architectures - in LLP64,
  226. * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
  227. * to be the only LLP64 architecture in current use.
  228. */
  229. #ifdef KHRONOS_USE_INTPTR_T
  230. typedef intptr_t khronos_intptr_t;
  231. typedef uintptr_t khronos_uintptr_t;
  232. #elif defined(_WIN64)
  233. typedef signed long long int khronos_intptr_t;
  234. typedef unsigned long long int khronos_uintptr_t;
  235. #else
  236. typedef signed long int khronos_intptr_t;
  237. typedef unsigned long int khronos_uintptr_t;
  238. #endif
  239. #if defined(_WIN64)
  240. typedef signed long long int khronos_ssize_t;
  241. typedef unsigned long long int khronos_usize_t;
  242. #else
  243. typedef signed long int khronos_ssize_t;
  244. typedef unsigned long int khronos_usize_t;
  245. #endif
  246. #if KHRONOS_SUPPORT_FLOAT
  247. /*
  248. * Float type
  249. */
  250. typedef float khronos_float_t;
  251. #endif
  252. #if KHRONOS_SUPPORT_INT64
  253. /* Time types
  254. *
  255. * These types can be used to represent a time interval in nanoseconds or
  256. * an absolute Unadjusted System Time. Unadjusted System Time is the number
  257. * of nanoseconds since some arbitrary system event (e.g. since the last
  258. * time the system booted). The Unadjusted System Time is an unsigned
  259. * 64 bit value that wraps back to 0 every 584 years. Time intervals
  260. * may be either signed or unsigned.
  261. */
  262. typedef khronos_uint64_t khronos_utime_nanoseconds_t;
  263. typedef khronos_int64_t khronos_stime_nanoseconds_t;
  264. #endif
  265. /*
  266. * Dummy value used to pad enum types to 32 bits.
  267. */
  268. #ifndef KHRONOS_MAX_ENUM
  269. #define KHRONOS_MAX_ENUM 0x7FFFFFFF
  270. #endif
  271. /*
  272. * Enumerated boolean type
  273. *
  274. * Values other than zero should be considered to be true. Therefore
  275. * comparisons should not be made against KHRONOS_TRUE.
  276. */
  277. typedef enum {
  278. KHRONOS_FALSE = 0,
  279. KHRONOS_TRUE = 1,
  280. KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
  281. } khronos_boolean_enum_t;
  282. #endif /* __khrplatform_h_ */