1bf215546Sopenharmony_ci#ifndef __khrplatform_h_
2bf215546Sopenharmony_ci#define __khrplatform_h_
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ci/*
5bf215546Sopenharmony_ci** Copyright (c) 2008-2018 The Khronos Group Inc.
6bf215546Sopenharmony_ci**
7bf215546Sopenharmony_ci** Permission is hereby granted, free of charge, to any person obtaining a
8bf215546Sopenharmony_ci** copy of this software and/or associated documentation files (the
9bf215546Sopenharmony_ci** "Materials"), to deal in the Materials without restriction, including
10bf215546Sopenharmony_ci** without limitation the rights to use, copy, modify, merge, publish,
11bf215546Sopenharmony_ci** distribute, sublicense, and/or sell copies of the Materials, and to
12bf215546Sopenharmony_ci** permit persons to whom the Materials are furnished to do so, subject to
13bf215546Sopenharmony_ci** the following conditions:
14bf215546Sopenharmony_ci**
15bf215546Sopenharmony_ci** The above copyright notice and this permission notice shall be included
16bf215546Sopenharmony_ci** in all copies or substantial portions of the Materials.
17bf215546Sopenharmony_ci**
18bf215546Sopenharmony_ci** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19bf215546Sopenharmony_ci** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21bf215546Sopenharmony_ci** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22bf215546Sopenharmony_ci** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
25bf215546Sopenharmony_ci*/
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci/* Khronos platform-specific types and definitions.
28bf215546Sopenharmony_ci *
29bf215546Sopenharmony_ci * The master copy of khrplatform.h is maintained in the Khronos EGL
30bf215546Sopenharmony_ci * Registry repository at https://github.com/KhronosGroup/EGL-Registry
31bf215546Sopenharmony_ci * The last semantic modification to khrplatform.h was at commit ID:
32bf215546Sopenharmony_ci *      67a3e0864c2d75ea5287b9f3d2eb74a745936692
33bf215546Sopenharmony_ci *
34bf215546Sopenharmony_ci * Adopters may modify this file to suit their platform. Adopters are
35bf215546Sopenharmony_ci * encouraged to submit platform specific modifications to the Khronos
36bf215546Sopenharmony_ci * group so that they can be included in future versions of this file.
37bf215546Sopenharmony_ci * Please submit changes by filing pull requests or issues on
38bf215546Sopenharmony_ci * the EGL Registry repository linked above.
39bf215546Sopenharmony_ci *
40bf215546Sopenharmony_ci *
41bf215546Sopenharmony_ci * See the Implementer's Guidelines for information about where this file
42bf215546Sopenharmony_ci * should be located on your system and for more details of its use:
43bf215546Sopenharmony_ci *    http://www.khronos.org/registry/implementers_guide.pdf
44bf215546Sopenharmony_ci *
45bf215546Sopenharmony_ci * This file should be included as
46bf215546Sopenharmony_ci *        #include <KHR/khrplatform.h>
47bf215546Sopenharmony_ci * by Khronos client API header files that use its types and defines.
48bf215546Sopenharmony_ci *
49bf215546Sopenharmony_ci * The types in khrplatform.h should only be used to define API-specific types.
50bf215546Sopenharmony_ci *
51bf215546Sopenharmony_ci * Types defined in khrplatform.h:
52bf215546Sopenharmony_ci *    khronos_int8_t              signed   8  bit
53bf215546Sopenharmony_ci *    khronos_uint8_t             unsigned 8  bit
54bf215546Sopenharmony_ci *    khronos_int16_t             signed   16 bit
55bf215546Sopenharmony_ci *    khronos_uint16_t            unsigned 16 bit
56bf215546Sopenharmony_ci *    khronos_int32_t             signed   32 bit
57bf215546Sopenharmony_ci *    khronos_uint32_t            unsigned 32 bit
58bf215546Sopenharmony_ci *    khronos_int64_t             signed   64 bit
59bf215546Sopenharmony_ci *    khronos_uint64_t            unsigned 64 bit
60bf215546Sopenharmony_ci *    khronos_intptr_t            signed   same number of bits as a pointer
61bf215546Sopenharmony_ci *    khronos_uintptr_t           unsigned same number of bits as a pointer
62bf215546Sopenharmony_ci *    khronos_ssize_t             signed   size
63bf215546Sopenharmony_ci *    khronos_usize_t             unsigned size
64bf215546Sopenharmony_ci *    khronos_float_t             signed   32 bit floating point
65bf215546Sopenharmony_ci *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
66bf215546Sopenharmony_ci *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
67bf215546Sopenharmony_ci *                                         nanoseconds
68bf215546Sopenharmony_ci *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
69bf215546Sopenharmony_ci *    khronos_boolean_enum_t      enumerated boolean type. This should
70bf215546Sopenharmony_ci *      only be used as a base type when a client API's boolean type is
71bf215546Sopenharmony_ci *      an enum. Client APIs which use an integer or other type for
72bf215546Sopenharmony_ci *      booleans cannot use this as the base type for their boolean.
73bf215546Sopenharmony_ci *
74bf215546Sopenharmony_ci * Tokens defined in khrplatform.h:
75bf215546Sopenharmony_ci *
76bf215546Sopenharmony_ci *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
77bf215546Sopenharmony_ci *
78bf215546Sopenharmony_ci *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
79bf215546Sopenharmony_ci *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
80bf215546Sopenharmony_ci *
81bf215546Sopenharmony_ci * Calling convention macros defined in this file:
82bf215546Sopenharmony_ci *    KHRONOS_APICALL
83bf215546Sopenharmony_ci *    KHRONOS_APIENTRY
84bf215546Sopenharmony_ci *    KHRONOS_APIATTRIBUTES
85bf215546Sopenharmony_ci *
86bf215546Sopenharmony_ci * These may be used in function prototypes as:
87bf215546Sopenharmony_ci *
88bf215546Sopenharmony_ci *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
89bf215546Sopenharmony_ci *                                  int arg1,
90bf215546Sopenharmony_ci *                                  int arg2) KHRONOS_APIATTRIBUTES;
91bf215546Sopenharmony_ci */
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_ci#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
94bf215546Sopenharmony_ci#   define KHRONOS_STATIC 1
95bf215546Sopenharmony_ci#endif
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci/*-------------------------------------------------------------------------
98bf215546Sopenharmony_ci * Definition of KHRONOS_APICALL
99bf215546Sopenharmony_ci *-------------------------------------------------------------------------
100bf215546Sopenharmony_ci * This precedes the return type of the function in the function prototype.
101bf215546Sopenharmony_ci */
102bf215546Sopenharmony_ci#if defined(KHRONOS_STATIC)
103bf215546Sopenharmony_ci    /* If the preprocessor constant KHRONOS_STATIC is defined, make the
104bf215546Sopenharmony_ci     * header compatible with static linking. */
105bf215546Sopenharmony_ci#   define KHRONOS_APICALL
106bf215546Sopenharmony_ci#elif defined(_WIN32)
107bf215546Sopenharmony_ci#   define KHRONOS_APICALL __declspec(dllimport)
108bf215546Sopenharmony_ci#elif defined (__SYMBIAN32__)
109bf215546Sopenharmony_ci#   define KHRONOS_APICALL IMPORT_C
110bf215546Sopenharmony_ci#elif (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \
111bf215546Sopenharmony_ci       || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
112bf215546Sopenharmony_ci/* KHRONOS_APIATTRIBUTES is not used by the client API headers yet */
113bf215546Sopenharmony_ci#   define KHRONOS_APICALL __attribute__((visibility("default")))
114bf215546Sopenharmony_ci#else
115bf215546Sopenharmony_ci#   define KHRONOS_APICALL
116bf215546Sopenharmony_ci#endif
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci/*-------------------------------------------------------------------------
119bf215546Sopenharmony_ci * Definition of KHRONOS_APIENTRY
120bf215546Sopenharmony_ci *-------------------------------------------------------------------------
121bf215546Sopenharmony_ci * This follows the return type of the function  and precedes the function
122bf215546Sopenharmony_ci * name in the function prototype.
123bf215546Sopenharmony_ci */
124bf215546Sopenharmony_ci#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC)
125bf215546Sopenharmony_ci    /* Win32 but not WinCE */
126bf215546Sopenharmony_ci#   define KHRONOS_APIENTRY __stdcall
127bf215546Sopenharmony_ci#else
128bf215546Sopenharmony_ci#   define KHRONOS_APIENTRY
129bf215546Sopenharmony_ci#endif
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci/*-------------------------------------------------------------------------
132bf215546Sopenharmony_ci * Definition of KHRONOS_APIATTRIBUTES
133bf215546Sopenharmony_ci *-------------------------------------------------------------------------
134bf215546Sopenharmony_ci * This follows the closing parenthesis of the function prototype arguments.
135bf215546Sopenharmony_ci */
136bf215546Sopenharmony_ci#if defined (__ARMCC_2__)
137bf215546Sopenharmony_ci#define KHRONOS_APIATTRIBUTES __softfp
138bf215546Sopenharmony_ci#else
139bf215546Sopenharmony_ci#define KHRONOS_APIATTRIBUTES
140bf215546Sopenharmony_ci#endif
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci/*-------------------------------------------------------------------------
143bf215546Sopenharmony_ci * basic type definitions
144bf215546Sopenharmony_ci *-----------------------------------------------------------------------*/
145bf215546Sopenharmony_ci#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci
148bf215546Sopenharmony_ci/*
149bf215546Sopenharmony_ci * Using <stdint.h>
150bf215546Sopenharmony_ci */
151bf215546Sopenharmony_ci#include <stdint.h>
152bf215546Sopenharmony_citypedef int32_t                 khronos_int32_t;
153bf215546Sopenharmony_citypedef uint32_t                khronos_uint32_t;
154bf215546Sopenharmony_citypedef int64_t                 khronos_int64_t;
155bf215546Sopenharmony_citypedef uint64_t                khronos_uint64_t;
156bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_INT64   1
157bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT   1
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci#elif defined(__VMS ) || defined(__sgi)
160bf215546Sopenharmony_ci
161bf215546Sopenharmony_ci/*
162bf215546Sopenharmony_ci * Using <inttypes.h>
163bf215546Sopenharmony_ci */
164bf215546Sopenharmony_ci#include <inttypes.h>
165bf215546Sopenharmony_citypedef int32_t                 khronos_int32_t;
166bf215546Sopenharmony_citypedef uint32_t                khronos_uint32_t;
167bf215546Sopenharmony_citypedef int64_t                 khronos_int64_t;
168bf215546Sopenharmony_citypedef uint64_t                khronos_uint64_t;
169bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_INT64   1
170bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT   1
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci/*
175bf215546Sopenharmony_ci * Win32
176bf215546Sopenharmony_ci */
177bf215546Sopenharmony_citypedef __int32                 khronos_int32_t;
178bf215546Sopenharmony_citypedef unsigned __int32        khronos_uint32_t;
179bf215546Sopenharmony_citypedef __int64                 khronos_int64_t;
180bf215546Sopenharmony_citypedef unsigned __int64        khronos_uint64_t;
181bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_INT64   1
182bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT   1
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci#elif defined(__sun__) || defined(__digital__)
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_ci/*
187bf215546Sopenharmony_ci * Sun or Digital
188bf215546Sopenharmony_ci */
189bf215546Sopenharmony_citypedef int                     khronos_int32_t;
190bf215546Sopenharmony_citypedef unsigned int            khronos_uint32_t;
191bf215546Sopenharmony_ci#if defined(__arch64__) || defined(_LP64)
192bf215546Sopenharmony_citypedef long int                khronos_int64_t;
193bf215546Sopenharmony_citypedef unsigned long int       khronos_uint64_t;
194bf215546Sopenharmony_ci#else
195bf215546Sopenharmony_citypedef long long int           khronos_int64_t;
196bf215546Sopenharmony_citypedef unsigned long long int  khronos_uint64_t;
197bf215546Sopenharmony_ci#endif /* __arch64__ */
198bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_INT64   1
199bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT   1
200bf215546Sopenharmony_ci
201bf215546Sopenharmony_ci#elif 0
202bf215546Sopenharmony_ci
203bf215546Sopenharmony_ci/*
204bf215546Sopenharmony_ci * Hypothetical platform with no float or int64 support
205bf215546Sopenharmony_ci */
206bf215546Sopenharmony_citypedef int                     khronos_int32_t;
207bf215546Sopenharmony_citypedef unsigned int            khronos_uint32_t;
208bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_INT64   0
209bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT   0
210bf215546Sopenharmony_ci
211bf215546Sopenharmony_ci#else
212bf215546Sopenharmony_ci
213bf215546Sopenharmony_ci/*
214bf215546Sopenharmony_ci * Generic fallback
215bf215546Sopenharmony_ci */
216bf215546Sopenharmony_ci#include <stdint.h>
217bf215546Sopenharmony_citypedef int32_t                 khronos_int32_t;
218bf215546Sopenharmony_citypedef uint32_t                khronos_uint32_t;
219bf215546Sopenharmony_citypedef int64_t                 khronos_int64_t;
220bf215546Sopenharmony_citypedef uint64_t                khronos_uint64_t;
221bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_INT64   1
222bf215546Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT   1
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci#endif
225bf215546Sopenharmony_ci
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ci/*
228bf215546Sopenharmony_ci * Types that are (so far) the same on all platforms
229bf215546Sopenharmony_ci */
230bf215546Sopenharmony_citypedef signed   char          khronos_int8_t;
231bf215546Sopenharmony_citypedef unsigned char          khronos_uint8_t;
232bf215546Sopenharmony_citypedef signed   short int     khronos_int16_t;
233bf215546Sopenharmony_citypedef unsigned short int     khronos_uint16_t;
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci/*
236bf215546Sopenharmony_ci * Types that differ between LLP64 and LP64 architectures - in LLP64,
237bf215546Sopenharmony_ci * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
238bf215546Sopenharmony_ci * to be the only LLP64 architecture in current use.
239bf215546Sopenharmony_ci */
240bf215546Sopenharmony_ci#ifdef _WIN64
241bf215546Sopenharmony_citypedef signed   long long int khronos_intptr_t;
242bf215546Sopenharmony_citypedef unsigned long long int khronos_uintptr_t;
243bf215546Sopenharmony_citypedef signed   long long int khronos_ssize_t;
244bf215546Sopenharmony_citypedef unsigned long long int khronos_usize_t;
245bf215546Sopenharmony_ci#else
246bf215546Sopenharmony_citypedef signed   long  int     khronos_intptr_t;
247bf215546Sopenharmony_citypedef unsigned long  int     khronos_uintptr_t;
248bf215546Sopenharmony_citypedef signed   long  int     khronos_ssize_t;
249bf215546Sopenharmony_citypedef unsigned long  int     khronos_usize_t;
250bf215546Sopenharmony_ci#endif
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci#if KHRONOS_SUPPORT_FLOAT
253bf215546Sopenharmony_ci/*
254bf215546Sopenharmony_ci * Float type
255bf215546Sopenharmony_ci */
256bf215546Sopenharmony_citypedef          float         khronos_float_t;
257bf215546Sopenharmony_ci#endif
258bf215546Sopenharmony_ci
259bf215546Sopenharmony_ci#if KHRONOS_SUPPORT_INT64
260bf215546Sopenharmony_ci/* Time types
261bf215546Sopenharmony_ci *
262bf215546Sopenharmony_ci * These types can be used to represent a time interval in nanoseconds or
263bf215546Sopenharmony_ci * an absolute Unadjusted System Time.  Unadjusted System Time is the number
264bf215546Sopenharmony_ci * of nanoseconds since some arbitrary system event (e.g. since the last
265bf215546Sopenharmony_ci * time the system booted).  The Unadjusted System Time is an unsigned
266bf215546Sopenharmony_ci * 64 bit value that wraps back to 0 every 584 years.  Time intervals
267bf215546Sopenharmony_ci * may be either signed or unsigned.
268bf215546Sopenharmony_ci */
269bf215546Sopenharmony_citypedef khronos_uint64_t       khronos_utime_nanoseconds_t;
270bf215546Sopenharmony_citypedef khronos_int64_t        khronos_stime_nanoseconds_t;
271bf215546Sopenharmony_ci#endif
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ci/*
274bf215546Sopenharmony_ci * Dummy value used to pad enum types to 32 bits.
275bf215546Sopenharmony_ci */
276bf215546Sopenharmony_ci#ifndef KHRONOS_MAX_ENUM
277bf215546Sopenharmony_ci#define KHRONOS_MAX_ENUM 0x7FFFFFFF
278bf215546Sopenharmony_ci#endif
279bf215546Sopenharmony_ci
280bf215546Sopenharmony_ci/*
281bf215546Sopenharmony_ci * Enumerated boolean type
282bf215546Sopenharmony_ci *
283bf215546Sopenharmony_ci * Values other than zero should be considered to be true.  Therefore
284bf215546Sopenharmony_ci * comparisons should not be made against KHRONOS_TRUE.
285bf215546Sopenharmony_ci */
286bf215546Sopenharmony_citypedef enum {
287bf215546Sopenharmony_ci    KHRONOS_FALSE = 0,
288bf215546Sopenharmony_ci    KHRONOS_TRUE  = 1,
289bf215546Sopenharmony_ci    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
290bf215546Sopenharmony_ci} khronos_boolean_enum_t;
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci#endif /* __khrplatform_h_ */
293