khrplatform.h 9.0 KB

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