···11+#ifndef __khrplatform_h_
22+#define __khrplatform_h_
33+44+/*
55+** Copyright (c) 2008-2018 The Khronos Group Inc.
66+**
77+** Permission is hereby granted, free of charge, to any person obtaining a
88+** copy of this software and/or associated documentation files (the
99+** "Materials"), to deal in the Materials without restriction, including
1010+** without limitation the rights to use, copy, modify, merge, publish,
1111+** distribute, sublicense, and/or sell copies of the Materials, and to
1212+** permit persons to whom the Materials are furnished to do so, subject to
1313+** the following conditions:
1414+**
1515+** The above copyright notice and this permission notice shall be included
1616+** in all copies or substantial portions of the Materials.
1717+**
1818+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1919+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2020+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2121+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
2222+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2323+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2424+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
2525+*/
2626+2727+/* Khronos platform-specific types and definitions.
2828+ *
2929+ * The master copy of khrplatform.h is maintained in the Khronos EGL
3030+ * Registry repository at https://github.com/KhronosGroup/EGL-Registry
3131+ * The last semantic modification to khrplatform.h was at commit ID:
3232+ * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
3333+ *
3434+ * Adopters may modify this file to suit their platform. Adopters are
3535+ * encouraged to submit platform specific modifications to the Khronos
3636+ * group so that they can be included in future versions of this file.
3737+ * Please submit changes by filing pull requests or issues on
3838+ * the EGL Registry repository linked above.
3939+ *
4040+ *
4141+ * See the Implementer's Guidelines for information about where this file
4242+ * should be located on your system and for more details of its use:
4343+ * http://www.khronos.org/registry/implementers_guide.pdf
4444+ *
4545+ * This file should be included as
4646+ * #include <KHR/khrplatform.h>
4747+ * by Khronos client API header files that use its types and defines.
4848+ *
4949+ * The types in khrplatform.h should only be used to define API-specific types.
5050+ *
5151+ * Types defined in khrplatform.h:
5252+ * khronos_int8_t signed 8 bit
5353+ * khronos_uint8_t unsigned 8 bit
5454+ * khronos_int16_t signed 16 bit
5555+ * khronos_uint16_t unsigned 16 bit
5656+ * khronos_int32_t signed 32 bit
5757+ * khronos_uint32_t unsigned 32 bit
5858+ * khronos_int64_t signed 64 bit
5959+ * khronos_uint64_t unsigned 64 bit
6060+ * khronos_intptr_t signed same number of bits as a pointer
6161+ * khronos_uintptr_t unsigned same number of bits as a pointer
6262+ * khronos_ssize_t signed size
6363+ * khronos_usize_t unsigned size
6464+ * khronos_float_t signed 32 bit floating point
6565+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
6666+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
6767+ * nanoseconds
6868+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
6969+ * khronos_boolean_enum_t enumerated boolean type. This should
7070+ * only be used as a base type when a client API's boolean type is
7171+ * an enum. Client APIs which use an integer or other type for
7272+ * booleans cannot use this as the base type for their boolean.
7373+ *
7474+ * Tokens defined in khrplatform.h:
7575+ *
7676+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
7777+ *
7878+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
7979+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
8080+ *
8181+ * Calling convention macros defined in this file:
8282+ * KHRONOS_APICALL
8383+ * KHRONOS_APIENTRY
8484+ * KHRONOS_APIATTRIBUTES
8585+ *
8686+ * These may be used in function prototypes as:
8787+ *
8888+ * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
8989+ * int arg1,
9090+ * int arg2) KHRONOS_APIATTRIBUTES;
9191+ */
9292+9393+#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
9494+# define KHRONOS_STATIC 1
9595+#endif
9696+9797+/*-------------------------------------------------------------------------
9898+ * Definition of KHRONOS_APICALL
9999+ *-------------------------------------------------------------------------
100100+ * This precedes the return type of the function in the function prototype.
101101+ */
102102+#if defined(KHRONOS_STATIC)
103103+ /* If the preprocessor constant KHRONOS_STATIC is defined, make the
104104+ * header compatible with static linking. */
105105+# define KHRONOS_APICALL
106106+#elif defined(_WIN32)
107107+# define KHRONOS_APICALL __declspec(dllimport)
108108+#elif defined (__SYMBIAN32__)
109109+# define KHRONOS_APICALL IMPORT_C
110110+#elif defined(__ANDROID__)
111111+# define KHRONOS_APICALL __attribute__((visibility("default")))
112112+#else
113113+# define KHRONOS_APICALL
114114+#endif
115115+116116+/*-------------------------------------------------------------------------
117117+ * Definition of KHRONOS_APIENTRY
118118+ *-------------------------------------------------------------------------
119119+ * This follows the return type of the function and precedes the function
120120+ * name in the function prototype.
121121+ */
122122+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
123123+ /* Win32 but not WinCE */
124124+# define KHRONOS_APIENTRY __stdcall
125125+#else
126126+# define KHRONOS_APIENTRY
127127+#endif
128128+129129+/*-------------------------------------------------------------------------
130130+ * Definition of KHRONOS_APIATTRIBUTES
131131+ *-------------------------------------------------------------------------
132132+ * This follows the closing parenthesis of the function prototype arguments.
133133+ */
134134+#if defined (__ARMCC_2__)
135135+#define KHRONOS_APIATTRIBUTES __softfp
136136+#else
137137+#define KHRONOS_APIATTRIBUTES
138138+#endif
139139+140140+/*-------------------------------------------------------------------------
141141+ * basic type definitions
142142+ *-----------------------------------------------------------------------*/
143143+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
144144+145145+146146+/*
147147+ * Using <stdint.h>
148148+ */
149149+#include <stdint.h>
150150+typedef int32_t khronos_int32_t;
151151+typedef uint32_t khronos_uint32_t;
152152+typedef int64_t khronos_int64_t;
153153+typedef uint64_t khronos_uint64_t;
154154+#define KHRONOS_SUPPORT_INT64 1
155155+#define KHRONOS_SUPPORT_FLOAT 1
156156+/*
157157+ * To support platform where unsigned long cannot be used interchangeably with
158158+ * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
159159+ * Ideally, we could just use (u)intptr_t everywhere, but this could result in
160160+ * ABI breakage if khronos_uintptr_t is changed from unsigned long to
161161+ * unsigned long long or similar (this results in different C++ name mangling).
162162+ * To avoid changes for existing platforms, we restrict usage of intptr_t to
163163+ * platforms where the size of a pointer is larger than the size of long.
164164+ */
165165+#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
166166+#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
167167+#define KHRONOS_USE_INTPTR_T
168168+#endif
169169+#endif
170170+171171+#elif defined(__VMS ) || defined(__sgi)
172172+173173+/*
174174+ * Using <inttypes.h>
175175+ */
176176+#include <inttypes.h>
177177+typedef int32_t khronos_int32_t;
178178+typedef uint32_t khronos_uint32_t;
179179+typedef int64_t khronos_int64_t;
180180+typedef uint64_t khronos_uint64_t;
181181+#define KHRONOS_SUPPORT_INT64 1
182182+#define KHRONOS_SUPPORT_FLOAT 1
183183+184184+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
185185+186186+/*
187187+ * Win32
188188+ */
189189+typedef __int32 khronos_int32_t;
190190+typedef unsigned __int32 khronos_uint32_t;
191191+typedef __int64 khronos_int64_t;
192192+typedef unsigned __int64 khronos_uint64_t;
193193+#define KHRONOS_SUPPORT_INT64 1
194194+#define KHRONOS_SUPPORT_FLOAT 1
195195+196196+#elif defined(__sun__) || defined(__digital__)
197197+198198+/*
199199+ * Sun or Digital
200200+ */
201201+typedef int khronos_int32_t;
202202+typedef unsigned int khronos_uint32_t;
203203+#if defined(__arch64__) || defined(_LP64)
204204+typedef long int khronos_int64_t;
205205+typedef unsigned long int khronos_uint64_t;
206206+#else
207207+typedef long long int khronos_int64_t;
208208+typedef unsigned long long int khronos_uint64_t;
209209+#endif /* __arch64__ */
210210+#define KHRONOS_SUPPORT_INT64 1
211211+#define KHRONOS_SUPPORT_FLOAT 1
212212+213213+#elif 0
214214+215215+/*
216216+ * Hypothetical platform with no float or int64 support
217217+ */
218218+typedef int khronos_int32_t;
219219+typedef unsigned int khronos_uint32_t;
220220+#define KHRONOS_SUPPORT_INT64 0
221221+#define KHRONOS_SUPPORT_FLOAT 0
222222+223223+#else
224224+225225+/*
226226+ * Generic fallback
227227+ */
228228+#include <stdint.h>
229229+typedef int32_t khronos_int32_t;
230230+typedef uint32_t khronos_uint32_t;
231231+typedef int64_t khronos_int64_t;
232232+typedef uint64_t khronos_uint64_t;
233233+#define KHRONOS_SUPPORT_INT64 1
234234+#define KHRONOS_SUPPORT_FLOAT 1
235235+236236+#endif
237237+238238+239239+/*
240240+ * Types that are (so far) the same on all platforms
241241+ */
242242+typedef signed char khronos_int8_t;
243243+typedef unsigned char khronos_uint8_t;
244244+typedef signed short int khronos_int16_t;
245245+typedef unsigned short int khronos_uint16_t;
246246+247247+/*
248248+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
249249+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
250250+ * to be the only LLP64 architecture in current use.
251251+ */
252252+#ifdef KHRONOS_USE_INTPTR_T
253253+typedef intptr_t khronos_intptr_t;
254254+typedef uintptr_t khronos_uintptr_t;
255255+#elif defined(_WIN64)
256256+typedef signed long long int khronos_intptr_t;
257257+typedef unsigned long long int khronos_uintptr_t;
258258+#else
259259+typedef signed long int khronos_intptr_t;
260260+typedef unsigned long int khronos_uintptr_t;
261261+#endif
262262+263263+#if defined(_WIN64)
264264+typedef signed long long int khronos_ssize_t;
265265+typedef unsigned long long int khronos_usize_t;
266266+#else
267267+typedef signed long int khronos_ssize_t;
268268+typedef unsigned long int khronos_usize_t;
269269+#endif
270270+271271+#if KHRONOS_SUPPORT_FLOAT
272272+/*
273273+ * Float type
274274+ */
275275+typedef float khronos_float_t;
276276+#endif
277277+278278+#if KHRONOS_SUPPORT_INT64
279279+/* Time types
280280+ *
281281+ * These types can be used to represent a time interval in nanoseconds or
282282+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
283283+ * of nanoseconds since some arbitrary system event (e.g. since the last
284284+ * time the system booted). The Unadjusted System Time is an unsigned
285285+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
286286+ * may be either signed or unsigned.
287287+ */
288288+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
289289+typedef khronos_int64_t khronos_stime_nanoseconds_t;
290290+#endif
291291+292292+/*
293293+ * Dummy value used to pad enum types to 32 bits.
294294+ */
295295+#ifndef KHRONOS_MAX_ENUM
296296+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
297297+#endif
298298+299299+/*
300300+ * Enumerated boolean type
301301+ *
302302+ * Values other than zero should be considered to be true. Therefore
303303+ * comparisons should not be made against KHRONOS_TRUE.
304304+ */
305305+typedef enum {
306306+ KHRONOS_FALSE = 0,
307307+ KHRONOS_TRUE = 1,
308308+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
309309+} khronos_boolean_enum_t;
310310+311311+#endif /* __khrplatform_h_ */