1 #ifndef __khrplatform_h_
\r
2 #define __khrplatform_h_
\r
5 ** Copyright (c) 2008-2009 The Khronos Group Inc.
\r
7 ** Permission is hereby granted, free of charge, to any person obtaining a
\r
8 ** copy of this software and/or associated documentation files (the
\r
9 ** "Materials"), to deal in the Materials without restriction, including
\r
10 ** without limitation the rights to use, copy, modify, merge, publish,
\r
11 ** distribute, sublicense, and/or sell copies of the Materials, and to
\r
12 ** permit persons to whom the Materials are furnished to do so, subject to
\r
13 ** the following conditions:
\r
15 ** The above copyright notice and this permission notice shall be included
\r
16 ** in all copies or substantial portions of the Materials.
\r
18 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
19 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
20 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
\r
21 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
\r
22 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
\r
23 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
\r
24 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
\r
27 /* Khronos platform-specific types and definitions.
\r
29 * $Revision: #2 $ on $Date: 2013/02/09 $
\r
31 * Adopters may modify this file to suit their platform. Adopters are
\r
32 * encouraged to submit platform specific modifications to the Khronos
\r
33 * group so that they can be included in future versions of this file.
\r
34 * Please submit changes by sending them to the public Khronos Bugzilla
\r
35 * (http://khronos.org/bugzilla) by filing a bug against product
\r
36 * "Khronos (general)" component "Registry".
\r
38 * A predefined template which fills in some of the bug fields can be
\r
39 * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
\r
40 * must create a Bugzilla login first.
\r
43 * See the Implementer's Guidelines for information about where this file
\r
44 * should be located on your system and for more details of its use:
\r
45 * http://www.khronos.org/registry/implementers_guide.pdf
\r
47 * This file should be included as
\r
48 * #include <KHR/khrplatform.h>
\r
49 * by Khronos client API header files that use its types and defines.
\r
51 * The types in khrplatform.h should only be used to define API-specific types.
\r
53 * Types defined in khrplatform.h:
\r
54 * khronos_int8_t signed 8 bit
\r
55 * khronos_uint8_t unsigned 8 bit
\r
56 * khronos_int16_t signed 16 bit
\r
57 * khronos_uint16_t unsigned 16 bit
\r
58 * khronos_int32_t signed 32 bit
\r
59 * khronos_uint32_t unsigned 32 bit
\r
60 * khronos_int64_t signed 64 bit
\r
61 * khronos_uint64_t unsigned 64 bit
\r
62 * khronos_intptr_t signed same number of bits as a pointer
\r
63 * khronos_uintptr_t unsigned same number of bits as a pointer
\r
64 * khronos_ssize_t signed size
\r
65 * khronos_usize_t unsigned size
\r
66 * khronos_float_t signed 32 bit floating point
\r
67 * khronos_time_ns_t unsigned 64 bit time in nanoseconds
\r
68 * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
\r
70 * khronos_stime_nanoseconds_t signed time interval in nanoseconds
\r
71 * khronos_boolean_enum_t enumerated boolean type. This should
\r
72 * only be used as a base type when a client API's boolean type is
\r
73 * an enum. Client APIs which use an integer or other type for
\r
74 * booleans cannot use this as the base type for their boolean.
\r
76 * Tokens defined in khrplatform.h:
\r
78 * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
\r
80 * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
\r
81 * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
\r
83 * Calling convention macros defined in this file:
\r
86 * KHRONOS_APIATTRIBUTES
\r
88 * These may be used in function prototypes as:
\r
90 * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
\r
92 * int arg2) KHRONOS_APIATTRIBUTES;
\r
95 /*-------------------------------------------------------------------------
\r
96 * Definition of KHRONOS_APICALL
\r
97 *-------------------------------------------------------------------------
\r
98 * This precedes the return type of the function in the function prototype.
\r
100 #if defined(_WIN32) && !defined(__SCITECH_SNAP__)
\r
101 # define KHRONOS_APICALL __declspec(dllimport)
\r
102 #elif defined (__SYMBIAN32__)
\r
103 # define KHRONOS_APICALL IMPORT_C
\r
105 # define KHRONOS_APICALL
\r
108 /*-------------------------------------------------------------------------
\r
109 * Definition of KHRONOS_APIENTRY
\r
110 *-------------------------------------------------------------------------
\r
111 * This follows the return type of the function and precedes the function
\r
112 * name in the function prototype.
\r
114 #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
\r
115 /* Win32 but not WinCE */
\r
116 # define KHRONOS_APIENTRY __stdcall
\r
118 # define KHRONOS_APIENTRY
\r
121 /*-------------------------------------------------------------------------
\r
122 * Definition of KHRONOS_APIATTRIBUTES
\r
123 *-------------------------------------------------------------------------
\r
124 * This follows the closing parenthesis of the function prototype arguments.
\r
126 #if defined (__ARMCC_2__)
\r
127 #define KHRONOS_APIATTRIBUTES __softfp
\r
129 #define KHRONOS_APIATTRIBUTES
\r
132 /*-------------------------------------------------------------------------
\r
133 * basic type definitions
\r
134 *-----------------------------------------------------------------------*/
\r
135 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
\r
141 #include <stdint.h>
\r
142 typedef int32_t khronos_int32_t;
\r
143 typedef uint32_t khronos_uint32_t;
\r
144 typedef int64_t khronos_int64_t;
\r
145 typedef uint64_t khronos_uint64_t;
\r
146 #define KHRONOS_SUPPORT_INT64 1
\r
147 #define KHRONOS_SUPPORT_FLOAT 1
\r
149 #elif defined(__VMS ) || defined(__sgi)
\r
152 * Using <inttypes.h>
\r
154 #include <inttypes.h>
\r
155 typedef int32_t khronos_int32_t;
\r
156 typedef uint32_t khronos_uint32_t;
\r
157 typedef int64_t khronos_int64_t;
\r
158 typedef uint64_t khronos_uint64_t;
\r
159 #define KHRONOS_SUPPORT_INT64 1
\r
160 #define KHRONOS_SUPPORT_FLOAT 1
\r
162 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
\r
167 typedef __int32 khronos_int32_t;
\r
168 typedef unsigned __int32 khronos_uint32_t;
\r
169 typedef __int64 khronos_int64_t;
\r
170 typedef unsigned __int64 khronos_uint64_t;
\r
171 #define KHRONOS_SUPPORT_INT64 1
\r
172 #define KHRONOS_SUPPORT_FLOAT 1
\r
174 #elif defined(__sun__) || defined(__digital__)
\r
179 typedef int khronos_int32_t;
\r
180 typedef unsigned int khronos_uint32_t;
\r
181 #if defined(__arch64__) || defined(_LP64)
\r
182 typedef long int khronos_int64_t;
\r
183 typedef unsigned long int khronos_uint64_t;
\r
185 typedef long long int khronos_int64_t;
\r
186 typedef unsigned long long int khronos_uint64_t;
\r
187 #endif /* __arch64__ */
\r
188 #define KHRONOS_SUPPORT_INT64 1
\r
189 #define KHRONOS_SUPPORT_FLOAT 1
\r
194 * Hypothetical platform with no float or int64 support
\r
196 typedef int khronos_int32_t;
\r
197 typedef unsigned int khronos_uint32_t;
\r
198 #define KHRONOS_SUPPORT_INT64 0
\r
199 #define KHRONOS_SUPPORT_FLOAT 0
\r
206 #include <stdint.h>
\r
207 typedef int32_t khronos_int32_t;
\r
208 typedef uint32_t khronos_uint32_t;
\r
209 typedef int64_t khronos_int64_t;
\r
210 typedef uint64_t khronos_uint64_t;
\r
211 #define KHRONOS_SUPPORT_INT64 1
\r
212 #define KHRONOS_SUPPORT_FLOAT 1
\r
218 * Types that are (so far) the same on all platforms
\r
220 typedef signed char khronos_int8_t;
\r
221 typedef unsigned char khronos_uint8_t;
\r
222 typedef signed short int khronos_int16_t;
\r
223 typedef unsigned short int khronos_uint16_t;
\r
224 typedef signed long int khronos_intptr_t;
\r
225 typedef unsigned long int khronos_uintptr_t;
\r
226 typedef signed long int khronos_ssize_t;
\r
227 typedef unsigned long int khronos_usize_t;
\r
229 #if KHRONOS_SUPPORT_FLOAT
\r
233 typedef float khronos_float_t;
\r
236 #if KHRONOS_SUPPORT_INT64
\r
239 * These types can be used to represent a time interval in nanoseconds or
\r
240 * an absolute Unadjusted System Time. Unadjusted System Time is the number
\r
241 * of nanoseconds since some arbitrary system event (e.g. since the last
\r
242 * time the system booted). The Unadjusted System Time is an unsigned
\r
243 * 64 bit value that wraps back to 0 every 584 years. Time intervals
\r
244 * may be either signed or unsigned.
\r
246 typedef khronos_uint64_t khronos_utime_nanoseconds_t;
\r
247 typedef khronos_int64_t khronos_stime_nanoseconds_t;
\r
251 * Dummy value used to pad enum types to 32 bits.
\r
253 #ifndef KHRONOS_MAX_ENUM
\r
254 #define KHRONOS_MAX_ENUM 0x7FFFFFFF
\r
258 * Enumerated boolean type
\r
260 * Values other than zero should be considered to be true. Therefore
\r
261 * comparisons should not be made against KHRONOS_TRUE.
\r
266 KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
\r
267 } khronos_boolean_enum_t;
\r
269 #endif /* __khrplatform_h_ */
\r