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