17777dab0Sopenharmony_ci#ifndef __khrplatform_h_ 27777dab0Sopenharmony_ci#define __khrplatform_h_ 37777dab0Sopenharmony_ci 47777dab0Sopenharmony_ci/* 57777dab0Sopenharmony_ci** Copyright (c) 2008-2018 The Khronos Group Inc. 67777dab0Sopenharmony_ci** 77777dab0Sopenharmony_ci** Permission is hereby granted, free of charge, to any person obtaining a 87777dab0Sopenharmony_ci** copy of this software and/or associated documentation files (the 97777dab0Sopenharmony_ci** "Materials"), to deal in the Materials without restriction, including 107777dab0Sopenharmony_ci** without limitation the rights to use, copy, modify, merge, publish, 117777dab0Sopenharmony_ci** distribute, sublicense, and/or sell copies of the Materials, and to 127777dab0Sopenharmony_ci** permit persons to whom the Materials are furnished to do so, subject to 137777dab0Sopenharmony_ci** the following conditions: 147777dab0Sopenharmony_ci** 157777dab0Sopenharmony_ci** The above copyright notice and this permission notice shall be included 167777dab0Sopenharmony_ci** in all copies or substantial portions of the Materials. 177777dab0Sopenharmony_ci** 187777dab0Sopenharmony_ci** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 197777dab0Sopenharmony_ci** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 207777dab0Sopenharmony_ci** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 217777dab0Sopenharmony_ci** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 227777dab0Sopenharmony_ci** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 237777dab0Sopenharmony_ci** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 247777dab0Sopenharmony_ci** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 257777dab0Sopenharmony_ci*/ 267777dab0Sopenharmony_ci 277777dab0Sopenharmony_ci/* Khronos platform-specific types and definitions. 287777dab0Sopenharmony_ci * 297777dab0Sopenharmony_ci * The master copy of khrplatform.h is maintained in the Khronos EGL 307777dab0Sopenharmony_ci * Registry repository at https://github.com/KhronosGroup/EGL-Registry 317777dab0Sopenharmony_ci * The last semantic modification to khrplatform.h was at commit ID: 327777dab0Sopenharmony_ci * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 337777dab0Sopenharmony_ci * 347777dab0Sopenharmony_ci * Adopters may modify this file to suit their platform. Adopters are 357777dab0Sopenharmony_ci * encouraged to submit platform specific modifications to the Khronos 367777dab0Sopenharmony_ci * group so that they can be included in future versions of this file. 377777dab0Sopenharmony_ci * Please submit changes by filing pull requests or issues on 387777dab0Sopenharmony_ci * the EGL Registry repository linked above. 397777dab0Sopenharmony_ci * 407777dab0Sopenharmony_ci * 417777dab0Sopenharmony_ci * See the Implementer's Guidelines for information about where this file 427777dab0Sopenharmony_ci * should be located on your system and for more details of its use: 437777dab0Sopenharmony_ci * http://www.khronos.org/registry/implementers_guide.pdf 447777dab0Sopenharmony_ci * 457777dab0Sopenharmony_ci * This file should be included as 467777dab0Sopenharmony_ci * #include <KHR/khrplatform.h> 477777dab0Sopenharmony_ci * by Khronos client API header files that use its types and defines. 487777dab0Sopenharmony_ci * 497777dab0Sopenharmony_ci * The types in khrplatform.h should only be used to define API-specific types. 507777dab0Sopenharmony_ci * 517777dab0Sopenharmony_ci * Types defined in khrplatform.h: 527777dab0Sopenharmony_ci * khronos_int8_t signed 8 bit 537777dab0Sopenharmony_ci * khronos_uint8_t unsigned 8 bit 547777dab0Sopenharmony_ci * khronos_int16_t signed 16 bit 557777dab0Sopenharmony_ci * khronos_uint16_t unsigned 16 bit 567777dab0Sopenharmony_ci * khronos_int32_t signed 32 bit 577777dab0Sopenharmony_ci * khronos_uint32_t unsigned 32 bit 587777dab0Sopenharmony_ci * khronos_int64_t signed 64 bit 597777dab0Sopenharmony_ci * khronos_uint64_t unsigned 64 bit 607777dab0Sopenharmony_ci * khronos_intptr_t signed same number of bits as a pointer 617777dab0Sopenharmony_ci * khronos_uintptr_t unsigned same number of bits as a pointer 627777dab0Sopenharmony_ci * khronos_ssize_t signed size 637777dab0Sopenharmony_ci * khronos_usize_t unsigned size 647777dab0Sopenharmony_ci * khronos_float_t signed 32 bit floating point 657777dab0Sopenharmony_ci * khronos_time_ns_t unsigned 64 bit time in nanoseconds 667777dab0Sopenharmony_ci * khronos_utime_nanoseconds_t unsigned time interval or absolute time in 677777dab0Sopenharmony_ci * nanoseconds 687777dab0Sopenharmony_ci * khronos_stime_nanoseconds_t signed time interval in nanoseconds 697777dab0Sopenharmony_ci * khronos_boolean_enum_t enumerated boolean type. This should 707777dab0Sopenharmony_ci * only be used as a base type when a client API's boolean type is 717777dab0Sopenharmony_ci * an enum. Client APIs which use an integer or other type for 727777dab0Sopenharmony_ci * booleans cannot use this as the base type for their boolean. 737777dab0Sopenharmony_ci * 747777dab0Sopenharmony_ci * Tokens defined in khrplatform.h: 757777dab0Sopenharmony_ci * 767777dab0Sopenharmony_ci * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. 777777dab0Sopenharmony_ci * 787777dab0Sopenharmony_ci * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. 797777dab0Sopenharmony_ci * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. 807777dab0Sopenharmony_ci * 817777dab0Sopenharmony_ci * Calling convention macros defined in this file: 827777dab0Sopenharmony_ci * KHRONOS_APICALL 837777dab0Sopenharmony_ci * KHRONOS_APIENTRY 847777dab0Sopenharmony_ci * KHRONOS_APIATTRIBUTES 857777dab0Sopenharmony_ci * 867777dab0Sopenharmony_ci * These may be used in function prototypes as: 877777dab0Sopenharmony_ci * 887777dab0Sopenharmony_ci * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( 897777dab0Sopenharmony_ci * int arg1, 907777dab0Sopenharmony_ci * int arg2) KHRONOS_APIATTRIBUTES; 917777dab0Sopenharmony_ci */ 927777dab0Sopenharmony_ci 937777dab0Sopenharmony_ci#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) 947777dab0Sopenharmony_ci# define KHRONOS_STATIC 1 957777dab0Sopenharmony_ci#endif 967777dab0Sopenharmony_ci 977777dab0Sopenharmony_ci/*------------------------------------------------------------------------- 987777dab0Sopenharmony_ci * Definition of KHRONOS_APICALL 997777dab0Sopenharmony_ci *------------------------------------------------------------------------- 1007777dab0Sopenharmony_ci * This precedes the return type of the function in the function prototype. 1017777dab0Sopenharmony_ci */ 1027777dab0Sopenharmony_ci#if defined(KHRONOS_STATIC) 1037777dab0Sopenharmony_ci /* If the preprocessor constant KHRONOS_STATIC is defined, make the 1047777dab0Sopenharmony_ci * header compatible with static linking. */ 1057777dab0Sopenharmony_ci# define KHRONOS_APICALL 1067777dab0Sopenharmony_ci#elif defined(_WIN32) 1077777dab0Sopenharmony_ci# define KHRONOS_APICALL __declspec(dllimport) 1087777dab0Sopenharmony_ci#elif defined (__SYMBIAN32__) 1097777dab0Sopenharmony_ci# define KHRONOS_APICALL IMPORT_C 1107777dab0Sopenharmony_ci#elif defined(__ANDROID__) 1117777dab0Sopenharmony_ci# define KHRONOS_APICALL __attribute__((visibility("default"))) 1127777dab0Sopenharmony_ci#else 1137777dab0Sopenharmony_ci# define KHRONOS_APICALL 1147777dab0Sopenharmony_ci#endif 1157777dab0Sopenharmony_ci 1167777dab0Sopenharmony_ci/*------------------------------------------------------------------------- 1177777dab0Sopenharmony_ci * Definition of KHRONOS_APIENTRY 1187777dab0Sopenharmony_ci *------------------------------------------------------------------------- 1197777dab0Sopenharmony_ci * This follows the return type of the function and precedes the function 1207777dab0Sopenharmony_ci * name in the function prototype. 1217777dab0Sopenharmony_ci */ 1227777dab0Sopenharmony_ci#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) 1237777dab0Sopenharmony_ci /* Win32 but not WinCE */ 1247777dab0Sopenharmony_ci# define KHRONOS_APIENTRY __stdcall 1257777dab0Sopenharmony_ci#else 1267777dab0Sopenharmony_ci# define KHRONOS_APIENTRY 1277777dab0Sopenharmony_ci#endif 1287777dab0Sopenharmony_ci 1297777dab0Sopenharmony_ci/*------------------------------------------------------------------------- 1307777dab0Sopenharmony_ci * Definition of KHRONOS_APIATTRIBUTES 1317777dab0Sopenharmony_ci *------------------------------------------------------------------------- 1327777dab0Sopenharmony_ci * This follows the closing parenthesis of the function prototype arguments. 1337777dab0Sopenharmony_ci */ 1347777dab0Sopenharmony_ci#if defined (__ARMCC_2__) 1357777dab0Sopenharmony_ci#define KHRONOS_APIATTRIBUTES __softfp 1367777dab0Sopenharmony_ci#else 1377777dab0Sopenharmony_ci#define KHRONOS_APIATTRIBUTES 1387777dab0Sopenharmony_ci#endif 1397777dab0Sopenharmony_ci 1407777dab0Sopenharmony_ci/*------------------------------------------------------------------------- 1417777dab0Sopenharmony_ci * basic type definitions 1427777dab0Sopenharmony_ci *-----------------------------------------------------------------------*/ 1437777dab0Sopenharmony_ci#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) 1447777dab0Sopenharmony_ci 1457777dab0Sopenharmony_ci 1467777dab0Sopenharmony_ci/* 1477777dab0Sopenharmony_ci * Using <stdint.h> 1487777dab0Sopenharmony_ci */ 1497777dab0Sopenharmony_ci#include <stdint.h> 1507777dab0Sopenharmony_citypedef int32_t khronos_int32_t; 1517777dab0Sopenharmony_citypedef uint32_t khronos_uint32_t; 1527777dab0Sopenharmony_citypedef int64_t khronos_int64_t; 1537777dab0Sopenharmony_citypedef uint64_t khronos_uint64_t; 1547777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_INT64 1 1557777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT 1 1567777dab0Sopenharmony_ci/* 1577777dab0Sopenharmony_ci * To support platform where unsigned long cannot be used interchangeably with 1587777dab0Sopenharmony_ci * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. 1597777dab0Sopenharmony_ci * Ideally, we could just use (u)intptr_t everywhere, but this could result in 1607777dab0Sopenharmony_ci * ABI breakage if khronos_uintptr_t is changed from unsigned long to 1617777dab0Sopenharmony_ci * unsigned long long or similar (this results in different C++ name mangling). 1627777dab0Sopenharmony_ci * To avoid changes for existing platforms, we restrict usage of intptr_t to 1637777dab0Sopenharmony_ci * platforms where the size of a pointer is larger than the size of long. 1647777dab0Sopenharmony_ci */ 1657777dab0Sopenharmony_ci#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) 1667777dab0Sopenharmony_ci#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ 1677777dab0Sopenharmony_ci#define KHRONOS_USE_INTPTR_T 1687777dab0Sopenharmony_ci#endif 1697777dab0Sopenharmony_ci#endif 1707777dab0Sopenharmony_ci 1717777dab0Sopenharmony_ci#elif defined(__VMS ) || defined(__sgi) 1727777dab0Sopenharmony_ci 1737777dab0Sopenharmony_ci/* 1747777dab0Sopenharmony_ci * Using <inttypes.h> 1757777dab0Sopenharmony_ci */ 1767777dab0Sopenharmony_ci#include <inttypes.h> 1777777dab0Sopenharmony_citypedef int32_t khronos_int32_t; 1787777dab0Sopenharmony_citypedef uint32_t khronos_uint32_t; 1797777dab0Sopenharmony_citypedef int64_t khronos_int64_t; 1807777dab0Sopenharmony_citypedef uint64_t khronos_uint64_t; 1817777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_INT64 1 1827777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT 1 1837777dab0Sopenharmony_ci 1847777dab0Sopenharmony_ci#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) 1857777dab0Sopenharmony_ci 1867777dab0Sopenharmony_ci/* 1877777dab0Sopenharmony_ci * Win32 1887777dab0Sopenharmony_ci */ 1897777dab0Sopenharmony_citypedef __int32 khronos_int32_t; 1907777dab0Sopenharmony_citypedef unsigned __int32 khronos_uint32_t; 1917777dab0Sopenharmony_citypedef __int64 khronos_int64_t; 1927777dab0Sopenharmony_citypedef unsigned __int64 khronos_uint64_t; 1937777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_INT64 1 1947777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT 1 1957777dab0Sopenharmony_ci 1967777dab0Sopenharmony_ci#elif defined(__sun__) || defined(__digital__) 1977777dab0Sopenharmony_ci 1987777dab0Sopenharmony_ci/* 1997777dab0Sopenharmony_ci * Sun or Digital 2007777dab0Sopenharmony_ci */ 2017777dab0Sopenharmony_citypedef int khronos_int32_t; 2027777dab0Sopenharmony_citypedef unsigned int khronos_uint32_t; 2037777dab0Sopenharmony_ci#if defined(__arch64__) || defined(_LP64) 2047777dab0Sopenharmony_citypedef long int khronos_int64_t; 2057777dab0Sopenharmony_citypedef unsigned long int khronos_uint64_t; 2067777dab0Sopenharmony_ci#else 2077777dab0Sopenharmony_citypedef long long int khronos_int64_t; 2087777dab0Sopenharmony_citypedef unsigned long long int khronos_uint64_t; 2097777dab0Sopenharmony_ci#endif /* __arch64__ */ 2107777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_INT64 1 2117777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT 1 2127777dab0Sopenharmony_ci 2137777dab0Sopenharmony_ci#elif 0 2147777dab0Sopenharmony_ci 2157777dab0Sopenharmony_ci/* 2167777dab0Sopenharmony_ci * Hypothetical platform with no float or int64 support 2177777dab0Sopenharmony_ci */ 2187777dab0Sopenharmony_citypedef int khronos_int32_t; 2197777dab0Sopenharmony_citypedef unsigned int khronos_uint32_t; 2207777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_INT64 0 2217777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT 0 2227777dab0Sopenharmony_ci 2237777dab0Sopenharmony_ci#else 2247777dab0Sopenharmony_ci 2257777dab0Sopenharmony_ci/* 2267777dab0Sopenharmony_ci * Generic fallback 2277777dab0Sopenharmony_ci */ 2287777dab0Sopenharmony_ci#include <stdint.h> 2297777dab0Sopenharmony_citypedef int32_t khronos_int32_t; 2307777dab0Sopenharmony_citypedef uint32_t khronos_uint32_t; 2317777dab0Sopenharmony_citypedef int64_t khronos_int64_t; 2327777dab0Sopenharmony_citypedef uint64_t khronos_uint64_t; 2337777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_INT64 1 2347777dab0Sopenharmony_ci#define KHRONOS_SUPPORT_FLOAT 1 2357777dab0Sopenharmony_ci 2367777dab0Sopenharmony_ci#endif 2377777dab0Sopenharmony_ci 2387777dab0Sopenharmony_ci 2397777dab0Sopenharmony_ci/* 2407777dab0Sopenharmony_ci * Types that are (so far) the same on all platforms 2417777dab0Sopenharmony_ci */ 2427777dab0Sopenharmony_citypedef signed char khronos_int8_t; 2437777dab0Sopenharmony_citypedef unsigned char khronos_uint8_t; 2447777dab0Sopenharmony_citypedef signed short int khronos_int16_t; 2457777dab0Sopenharmony_citypedef unsigned short int khronos_uint16_t; 2467777dab0Sopenharmony_ci 2477777dab0Sopenharmony_ci/* 2487777dab0Sopenharmony_ci * Types that differ between LLP64 and LP64 architectures - in LLP64, 2497777dab0Sopenharmony_ci * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears 2507777dab0Sopenharmony_ci * to be the only LLP64 architecture in current use. 2517777dab0Sopenharmony_ci */ 2527777dab0Sopenharmony_ci#ifdef KHRONOS_USE_INTPTR_T 2537777dab0Sopenharmony_citypedef intptr_t khronos_intptr_t; 2547777dab0Sopenharmony_citypedef uintptr_t khronos_uintptr_t; 2557777dab0Sopenharmony_ci#elif defined(_WIN64) 2567777dab0Sopenharmony_citypedef signed long long int khronos_intptr_t; 2577777dab0Sopenharmony_citypedef unsigned long long int khronos_uintptr_t; 2587777dab0Sopenharmony_ci#else 2597777dab0Sopenharmony_citypedef signed long int khronos_intptr_t; 2607777dab0Sopenharmony_citypedef unsigned long int khronos_uintptr_t; 2617777dab0Sopenharmony_ci#endif 2627777dab0Sopenharmony_ci 2637777dab0Sopenharmony_ci#if defined(_WIN64) 2647777dab0Sopenharmony_citypedef signed long long int khronos_ssize_t; 2657777dab0Sopenharmony_citypedef unsigned long long int khronos_usize_t; 2667777dab0Sopenharmony_ci#else 2677777dab0Sopenharmony_citypedef signed long int khronos_ssize_t; 2687777dab0Sopenharmony_citypedef unsigned long int khronos_usize_t; 2697777dab0Sopenharmony_ci#endif 2707777dab0Sopenharmony_ci 2717777dab0Sopenharmony_ci#if KHRONOS_SUPPORT_FLOAT 2727777dab0Sopenharmony_ci/* 2737777dab0Sopenharmony_ci * Float type 2747777dab0Sopenharmony_ci */ 2757777dab0Sopenharmony_citypedef float khronos_float_t; 2767777dab0Sopenharmony_ci#endif 2777777dab0Sopenharmony_ci 2787777dab0Sopenharmony_ci#if KHRONOS_SUPPORT_INT64 2797777dab0Sopenharmony_ci/* Time types 2807777dab0Sopenharmony_ci * 2817777dab0Sopenharmony_ci * These types can be used to represent a time interval in nanoseconds or 2827777dab0Sopenharmony_ci * an absolute Unadjusted System Time. Unadjusted System Time is the number 2837777dab0Sopenharmony_ci * of nanoseconds since some arbitrary system event (e.g. since the last 2847777dab0Sopenharmony_ci * time the system booted). The Unadjusted System Time is an unsigned 2857777dab0Sopenharmony_ci * 64 bit value that wraps back to 0 every 584 years. Time intervals 2867777dab0Sopenharmony_ci * may be either signed or unsigned. 2877777dab0Sopenharmony_ci */ 2887777dab0Sopenharmony_citypedef khronos_uint64_t khronos_utime_nanoseconds_t; 2897777dab0Sopenharmony_citypedef khronos_int64_t khronos_stime_nanoseconds_t; 2907777dab0Sopenharmony_ci#endif 2917777dab0Sopenharmony_ci 2927777dab0Sopenharmony_ci/* 2937777dab0Sopenharmony_ci * Dummy value used to pad enum types to 32 bits. 2947777dab0Sopenharmony_ci */ 2957777dab0Sopenharmony_ci#ifndef KHRONOS_MAX_ENUM 2967777dab0Sopenharmony_ci#define KHRONOS_MAX_ENUM 0x7FFFFFFF 2977777dab0Sopenharmony_ci#endif 2987777dab0Sopenharmony_ci 2997777dab0Sopenharmony_ci/* 3007777dab0Sopenharmony_ci * Enumerated boolean type 3017777dab0Sopenharmony_ci * 3027777dab0Sopenharmony_ci * Values other than zero should be considered to be true. Therefore 3037777dab0Sopenharmony_ci * comparisons should not be made against KHRONOS_TRUE. 3047777dab0Sopenharmony_ci */ 3057777dab0Sopenharmony_citypedef enum { 3067777dab0Sopenharmony_ci KHRONOS_FALSE = 0, 3077777dab0Sopenharmony_ci KHRONOS_TRUE = 1, 3087777dab0Sopenharmony_ci KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM 3097777dab0Sopenharmony_ci} khronos_boolean_enum_t; 3107777dab0Sopenharmony_ci 3117777dab0Sopenharmony_ci#endif /* __khrplatform_h_ */ 312