1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef __khrplatform_h_
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define __khrplatform_h_
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** Copyright (c) 2008-2009 The Khronos Group Inc.
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman**
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** Permission is hereby granted, free of charge, to any person obtaining a
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** copy of this software and/or associated documentation files (the
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** "Materials"), to deal in the Materials without restriction, including
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** without limitation the rights to use, copy, modify, merge, publish,
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** distribute, sublicense, and/or sell copies of the Materials, and to
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** permit persons to whom the Materials are furnished to do so, subject to
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** the following conditions:
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman**
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** The above copyright notice and this permission notice shall be included
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** in all copies or substantial portions of the Materials.
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman**
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman*/
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* Khronos platform-specific types and definitions.
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
2962a3d37734adaa522571deb7f82ab2a04477d30eAlexis Hetu * $Revision: 32517 $ on $Date: 2016-03-11 02:41:19 -0800 (Fri, 11 Mar 2016) $
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Adopters may modify this file to suit their platform. Adopters are
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * encouraged to submit platform specific modifications to the Khronos
33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * group so that they can be included in future versions of this file.
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Please submit changes by sending them to the public Khronos Bugzilla
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * (http://khronos.org/bugzilla) by filing a bug against product
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * "Khronos (general)" component "Registry".
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * A predefined template which fills in some of the bug fields can be
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * must create a Bugzilla login first.
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * See the Implementer's Guidelines for information about where this file
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * should be located on your system and for more details of its use:
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    http://www.khronos.org/registry/implementers_guide.pdf
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This file should be included as
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *        #include <KHR/khrplatform.h>
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * by Khronos client API header files that use its types and defines.
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * The types in khrplatform.h should only be used to define API-specific types.
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Types defined in khrplatform.h:
54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_int8_t              signed   8  bit
55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_uint8_t             unsigned 8  bit
56894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_int16_t             signed   16 bit
57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_uint16_t            unsigned 16 bit
58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_int32_t             signed   32 bit
59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_uint32_t            unsigned 32 bit
60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_int64_t             signed   64 bit
61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_uint64_t            unsigned 64 bit
62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_intptr_t            signed   same number of bits as a pointer
63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_uintptr_t           unsigned same number of bits as a pointer
64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_ssize_t             signed   size
65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_usize_t             unsigned size
66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_float_t             signed   32 bit floating point
67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                                         nanoseconds
70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    khronos_boolean_enum_t      enumerated boolean type. This should
72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *      only be used as a base type when a client API's boolean type is
73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *      an enum. Client APIs which use an integer or other type for
74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *      booleans cannot use this as the base type for their boolean.
75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Tokens defined in khrplatform.h:
77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Calling convention macros defined in this file:
84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    KHRONOS_APICALL
85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    KHRONOS_APIENTRY
86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *    KHRONOS_APIATTRIBUTES
87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * These may be used in function prototypes as:
89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                                  int arg1,
92894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *                                  int arg2) KHRONOS_APIATTRIBUTES;
93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*-------------------------------------------------------------------------
96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Definition of KHRONOS_APICALL
97894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *-------------------------------------------------------------------------
98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This precedes the return type of the function in the function prototype.
99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#   define KHRONOS_APICALL __declspec(dllimport)
102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#elif defined (__SYMBIAN32__)
103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#   define KHRONOS_APICALL IMPORT_C
10462a3d37734adaa522571deb7f82ab2a04477d30eAlexis Hetu#elif defined(__ANDROID__)
10562a3d37734adaa522571deb7f82ab2a04477d30eAlexis Hetu#   define KHRONOS_APICALL __attribute__((visibility("default")))
106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#else
107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#   define KHRONOS_APICALL
108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*-------------------------------------------------------------------------
111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Definition of KHRONOS_APIENTRY
112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *-------------------------------------------------------------------------
113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This follows the return type of the function  and precedes the function
114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * name in the function prototype.
115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
117894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    /* Win32 but not WinCE */
118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#   define KHRONOS_APIENTRY __stdcall
119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#else
120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#   define KHRONOS_APIENTRY
121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*-------------------------------------------------------------------------
124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Definition of KHRONOS_APIATTRIBUTES
125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *-------------------------------------------------------------------------
126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * This follows the closing parenthesis of the function prototype arguments.
127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if defined (__ARMCC_2__)
129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_APIATTRIBUTES __softfp
130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#else
131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_APIATTRIBUTES
132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*-------------------------------------------------------------------------
135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * basic type definitions
136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *-----------------------------------------------------------------------*/
137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Using <stdint.h>
142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <stdint.h>
144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int32_t                 khronos_int32_t;
145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint32_t                khronos_uint32_t;
146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int64_t                 khronos_int64_t;
147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint64_t                khronos_uint64_t;
148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_INT64   1
149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_FLOAT   1
150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#elif defined(__VMS ) || defined(__sgi)
152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Using <inttypes.h>
155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <inttypes.h>
157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int32_t                 khronos_int32_t;
158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint32_t                khronos_uint32_t;
159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int64_t                 khronos_int64_t;
160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint64_t                khronos_uint64_t;
161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_INT64   1
162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_FLOAT   1
163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Win32
168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef __int32                 khronos_int32_t;
170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned __int32        khronos_uint32_t;
171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef __int64                 khronos_int64_t;
172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned __int64        khronos_uint64_t;
173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_INT64   1
174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_FLOAT   1
175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#elif defined(__sun__) || defined(__digital__)
177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Sun or Digital
180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int                     khronos_int32_t;
182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned int            khronos_uint32_t;
183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if defined(__arch64__) || defined(_LP64)
184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef long int                khronos_int64_t;
185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned long int       khronos_uint64_t;
186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#else
187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef long long int           khronos_int64_t;
188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned long long int  khronos_uint64_t;
189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif /* __arch64__ */
190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_INT64   1
191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_FLOAT   1
192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#elif 0
194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Hypothetical platform with no float or int64 support
197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int                     khronos_int32_t;
199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned int            khronos_uint32_t;
200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_INT64   0
201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_FLOAT   0
202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#else
204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Generic fallback
207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <stdint.h>
209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int32_t                 khronos_int32_t;
210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint32_t                khronos_uint32_t;
211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef int64_t                 khronos_int64_t;
212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef uint64_t                khronos_uint64_t;
213894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_INT64   1
214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_SUPPORT_FLOAT   1
215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Types that are (so far) the same on all platforms
221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef signed   char          khronos_int8_t;
223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned char          khronos_uint8_t;
224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef signed   short int     khronos_int16_t;
225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned short int     khronos_uint16_t;
226b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens
227b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens/*
22862a3d37734adaa522571deb7f82ab2a04477d30eAlexis Hetu * Types that differ between LLP64 and LP64 architectures - in LLP64,
229b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
230b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens * to be the only LLP64 architecture in current use.
231b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens */
232b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens#ifdef _WIN64
233b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capenstypedef signed   long long int khronos_intptr_t;
234b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capenstypedef unsigned long long int khronos_uintptr_t;
235b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capenstypedef signed   long long int khronos_ssize_t;
236b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capenstypedef unsigned long long int khronos_usize_t;
237b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens#else
238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef signed   long  int     khronos_intptr_t;
239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned long  int     khronos_uintptr_t;
240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef signed   long  int     khronos_ssize_t;
241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef unsigned long  int     khronos_usize_t;
242b0e93551e2f7b80ce37e46ebc5e3bd197687e369Nicolas Capens#endif
243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if KHRONOS_SUPPORT_FLOAT
245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Float type
247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef          float         khronos_float_t;
249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#if KHRONOS_SUPPORT_INT64
252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* Time types
253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * These types can be used to represent a time interval in nanoseconds or
255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * an absolute Unadjusted System Time.  Unadjusted System Time is the number
256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * of nanoseconds since some arbitrary system event (e.g. since the last
257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * time the system booted).  The Unadjusted System Time is an unsigned
258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * 64 bit value that wraps back to 0 every 584 years.  Time intervals
259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * may be either signed or unsigned.
260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef khronos_uint64_t       khronos_utime_nanoseconds_t;
262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef khronos_int64_t        khronos_stime_nanoseconds_t;
263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Dummy value used to pad enum types to 32 bits.
267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef KHRONOS_MAX_ENUM
269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define KHRONOS_MAX_ENUM 0x7FFFFFFF
270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*
273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Enumerated boolean type
274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman *
275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * Values other than zero should be considered to be true.  Therefore
276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman * comparisons should not be made against KHRONOS_TRUE.
277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman */
278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    KHRONOS_FALSE = 0,
280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    KHRONOS_TRUE  = 1,
281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} khronos_boolean_enum_t;
283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif /* __khrplatform_h_ */
285