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.
 
 
 
 
 
 

283 regels
9.8 KiB

  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: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
  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. #else
  102. # define KHRONOS_APICALL
  103. #endif
  104. /*-------------------------------------------------------------------------
  105. * Definition of KHRONOS_APIENTRY
  106. *-------------------------------------------------------------------------
  107. * This follows the return type of the function and precedes the function
  108. * name in the function prototype.
  109. */
  110. #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
  111. /* Win32 but not WinCE */
  112. # define KHRONOS_APIENTRY __stdcall
  113. #else
  114. # define KHRONOS_APIENTRY
  115. #endif
  116. /*-------------------------------------------------------------------------
  117. * Definition of KHRONOS_APIATTRIBUTES
  118. *-------------------------------------------------------------------------
  119. * This follows the closing parenthesis of the function prototype arguments.
  120. */
  121. #if defined (__ARMCC_2__)
  122. #define KHRONOS_APIATTRIBUTES __softfp
  123. #else
  124. #define KHRONOS_APIATTRIBUTES
  125. #endif
  126. /*-------------------------------------------------------------------------
  127. * basic type definitions
  128. *-----------------------------------------------------------------------*/
  129. #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
  130. /*
  131. * Using <stdint.h>
  132. */
  133. #include <stdint.h>
  134. typedef int32_t khronos_int32_t;
  135. typedef uint32_t khronos_uint32_t;
  136. typedef int64_t khronos_int64_t;
  137. typedef uint64_t khronos_uint64_t;
  138. #define KHRONOS_SUPPORT_INT64 1
  139. #define KHRONOS_SUPPORT_FLOAT 1
  140. #elif defined(__VMS ) || defined(__sgi)
  141. /*
  142. * Using <inttypes.h>
  143. */
  144. #include <inttypes.h>
  145. typedef int32_t khronos_int32_t;
  146. typedef uint32_t khronos_uint32_t;
  147. typedef int64_t khronos_int64_t;
  148. typedef uint64_t khronos_uint64_t;
  149. #define KHRONOS_SUPPORT_INT64 1
  150. #define KHRONOS_SUPPORT_FLOAT 1
  151. #elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
  152. /*
  153. * Win32
  154. */
  155. typedef __int32 khronos_int32_t;
  156. typedef unsigned __int32 khronos_uint32_t;
  157. typedef __int64 khronos_int64_t;
  158. typedef unsigned __int64 khronos_uint64_t;
  159. #define KHRONOS_SUPPORT_INT64 1
  160. #define KHRONOS_SUPPORT_FLOAT 1
  161. #elif defined(__sun__) || defined(__digital__)
  162. /*
  163. * Sun or Digital
  164. */
  165. typedef int khronos_int32_t;
  166. typedef unsigned int khronos_uint32_t;
  167. #if defined(__arch64__) || defined(_LP64)
  168. typedef long int khronos_int64_t;
  169. typedef unsigned long int khronos_uint64_t;
  170. #else
  171. typedef long long int khronos_int64_t;
  172. typedef unsigned long long int khronos_uint64_t;
  173. #endif /* __arch64__ */
  174. #define KHRONOS_SUPPORT_INT64 1
  175. #define KHRONOS_SUPPORT_FLOAT 1
  176. #elif 0
  177. /*
  178. * Hypothetical platform with no float or int64 support
  179. */
  180. typedef int khronos_int32_t;
  181. typedef unsigned int khronos_uint32_t;
  182. #define KHRONOS_SUPPORT_INT64 0
  183. #define KHRONOS_SUPPORT_FLOAT 0
  184. #else
  185. /*
  186. * Generic fallback
  187. */
  188. #include <stdint.h>
  189. typedef int32_t khronos_int32_t;
  190. typedef uint32_t khronos_uint32_t;
  191. typedef int64_t khronos_int64_t;
  192. typedef uint64_t khronos_uint64_t;
  193. #define KHRONOS_SUPPORT_INT64 1
  194. #define KHRONOS_SUPPORT_FLOAT 1
  195. #endif
  196. /*
  197. * Types that are (so far) the same on all platforms
  198. */
  199. typedef signed char khronos_int8_t;
  200. typedef unsigned char khronos_uint8_t;
  201. typedef signed short int khronos_int16_t;
  202. typedef unsigned short int khronos_uint16_t;
  203. /*
  204. * Types that differ between LLP64 and LP64 architectures - in LLP64,
  205. * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
  206. * to be the only LLP64 architecture in current use.
  207. */
  208. #ifdef _WIN64
  209. typedef signed long long int khronos_intptr_t;
  210. typedef unsigned long long int khronos_uintptr_t;
  211. typedef signed long long int khronos_ssize_t;
  212. typedef unsigned long long int khronos_usize_t;
  213. #else
  214. typedef signed long int khronos_intptr_t;
  215. typedef unsigned long int khronos_uintptr_t;
  216. typedef signed long int khronos_ssize_t;
  217. typedef unsigned long int khronos_usize_t;
  218. #endif
  219. #if KHRONOS_SUPPORT_FLOAT
  220. /*
  221. * Float type
  222. */
  223. typedef float khronos_float_t;
  224. #endif
  225. #if KHRONOS_SUPPORT_INT64
  226. /* Time types
  227. *
  228. * These types can be used to represent a time interval in nanoseconds or
  229. * an absolute Unadjusted System Time. Unadjusted System Time is the number
  230. * of nanoseconds since some arbitrary system event (e.g. since the last
  231. * time the system booted). The Unadjusted System Time is an unsigned
  232. * 64 bit value that wraps back to 0 every 584 years. Time intervals
  233. * may be either signed or unsigned.
  234. */
  235. typedef khronos_uint64_t khronos_utime_nanoseconds_t;
  236. typedef khronos_int64_t khronos_stime_nanoseconds_t;
  237. #endif
  238. /*
  239. * Dummy value used to pad enum types to 32 bits.
  240. */
  241. #ifndef KHRONOS_MAX_ENUM
  242. #define KHRONOS_MAX_ENUM 0x7FFFFFFF
  243. #endif
  244. /*
  245. * Enumerated boolean type
  246. *
  247. * Values other than zero should be considered to be true. Therefore
  248. * comparisons should not be made against KHRONOS_TRUE.
  249. */
  250. typedef enum {
  251. KHRONOS_FALSE = 0,
  252. KHRONOS_TRUE = 1,
  253. KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
  254. } khronos_boolean_enum_t;
  255. #endif /* __khrplatform_h_ */