#ifndef __khrplatform_h_1#define __khrplatform_h_23/*4** Copyright (c) 2008-2018 The Khronos Group Inc.5**6** Permission is hereby granted, free of charge, to any person obtaining a7** copy of this software and/or associated documentation files (the8** "Materials"), to deal in the Materials without restriction, including9** without limitation the rights to use, copy, modify, merge, publish,10** distribute, sublicense, and/or sell copies of the Materials, and to11** permit persons to whom the Materials are furnished to do so, subject to12** the following conditions:13**14** The above copyright notice and this permission notice shall be included15** in all copies or substantial portions of the Materials.16**17** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.20** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY21** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.24*/2526/* Khronos platform-specific types and definitions.27*28* The master copy of khrplatform.h is maintained in the Khronos EGL29* Registry repository at https://github.com/KhronosGroup/EGL-Registry30* The last semantic modification to khrplatform.h was at commit ID:31* 67a3e0864c2d75ea5287b9f3d2eb74a74593669232*33* Adopters may modify this file to suit their platform. Adopters are34* encouraged to submit platform specific modifications to the Khronos35* group so that they can be included in future versions of this file.36* Please submit changes by filing pull requests or issues on37* the EGL Registry repository linked above.38*39*40* See the Implementer's Guidelines for information about where this file41* should be located on your system and for more details of its use:42* http://www.khronos.org/registry/implementers_guide.pdf43*44* This file should be included as45* #include <KHR/khrplatform.h>46* by Khronos client API header files that use its types and defines.47*48* The types in khrplatform.h should only be used to define API-specific types.49*50* Types defined in khrplatform.h:51* khronos_int8_t signed 8 bit52* khronos_uint8_t unsigned 8 bit53* khronos_int16_t signed 16 bit54* khronos_uint16_t unsigned 16 bit55* khronos_int32_t signed 32 bit56* khronos_uint32_t unsigned 32 bit57* khronos_int64_t signed 64 bit58* khronos_uint64_t unsigned 64 bit59* khronos_intptr_t signed same number of bits as a pointer60* khronos_uintptr_t unsigned same number of bits as a pointer61* khronos_ssize_t signed size62* khronos_usize_t unsigned size63* khronos_float_t signed 32 bit floating point64* khronos_time_ns_t unsigned 64 bit time in nanoseconds65* khronos_utime_nanoseconds_t unsigned time interval or absolute time in66* nanoseconds67* khronos_stime_nanoseconds_t signed time interval in nanoseconds68* khronos_boolean_enum_t enumerated boolean type. This should69* only be used as a base type when a client API's boolean type is70* an enum. Client APIs which use an integer or other type for71* booleans cannot use this as the base type for their boolean.72*73* Tokens defined in khrplatform.h:74*75* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.76*77* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.78* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.79*80* Calling convention macros defined in this file:81* KHRONOS_APICALL82* KHRONOS_APIENTRY83* KHRONOS_APIATTRIBUTES84*85* These may be used in function prototypes as:86*87* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(88* int arg1,89* int arg2) KHRONOS_APIATTRIBUTES;90*/9192#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)93# define KHRONOS_STATIC 194#endif9596/*-------------------------------------------------------------------------97* Definition of KHRONOS_APICALL98*-------------------------------------------------------------------------99* This precedes the return type of the function in the function prototype.100*/101#if defined(KHRONOS_STATIC)102/* If the preprocessor constant KHRONOS_STATIC is defined, make the103* header compatible with static linking. */104# define KHRONOS_APICALL105#elif defined(_WIN32)106# define KHRONOS_APICALL __declspec(dllimport)107#elif defined (__SYMBIAN32__)108# define KHRONOS_APICALL IMPORT_C109#elif defined(__ANDROID__)110# define KHRONOS_APICALL __attribute__((visibility("default")))111#else112# define KHRONOS_APICALL113#endif114115/*-------------------------------------------------------------------------116* Definition of KHRONOS_APIENTRY117*-------------------------------------------------------------------------118* This follows the return type of the function and precedes the function119* name in the function prototype.120*/121#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)122/* Win32 but not WinCE */123# define KHRONOS_APIENTRY __stdcall124#else125# define KHRONOS_APIENTRY126#endif127128/*-------------------------------------------------------------------------129* Definition of KHRONOS_APIATTRIBUTES130*-------------------------------------------------------------------------131* This follows the closing parenthesis of the function prototype arguments.132*/133#if defined (__ARMCC_2__)134#define KHRONOS_APIATTRIBUTES __softfp135#else136#define KHRONOS_APIATTRIBUTES137#endif138139/*-------------------------------------------------------------------------140* basic type definitions141*-----------------------------------------------------------------------*/142#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)143144145/*146* Using <stdint.h>147*/148#include <stdint.h>149typedef int32_t khronos_int32_t;150typedef uint32_t khronos_uint32_t;151typedef int64_t khronos_int64_t;152typedef uint64_t khronos_uint64_t;153#define KHRONOS_SUPPORT_INT64 1154#define KHRONOS_SUPPORT_FLOAT 1155/*156* To support platform where unsigned long cannot be used interchangeably with157* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.158* Ideally, we could just use (u)intptr_t everywhere, but this could result in159* ABI breakage if khronos_uintptr_t is changed from unsigned long to160* unsigned long long or similar (this results in different C++ name mangling).161* To avoid changes for existing platforms, we restrict usage of intptr_t to162* platforms where the size of a pointer is larger than the size of long.163*/164#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)165#if __SIZEOF_POINTER__ > __SIZEOF_LONG__166#define KHRONOS_USE_INTPTR_T167#endif168#endif169170#elif defined(__VMS ) || defined(__sgi)171172/*173* Using <inttypes.h>174*/175#include <inttypes.h>176typedef int32_t khronos_int32_t;177typedef uint32_t khronos_uint32_t;178typedef int64_t khronos_int64_t;179typedef uint64_t khronos_uint64_t;180#define KHRONOS_SUPPORT_INT64 1181#define KHRONOS_SUPPORT_FLOAT 1182183#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)184185/*186* Win32187*/188typedef __int32 khronos_int32_t;189typedef unsigned __int32 khronos_uint32_t;190typedef __int64 khronos_int64_t;191typedef unsigned __int64 khronos_uint64_t;192#define KHRONOS_SUPPORT_INT64 1193#define KHRONOS_SUPPORT_FLOAT 1194195#elif defined(__sun__) || defined(__digital__)196197/*198* Sun or Digital199*/200typedef int khronos_int32_t;201typedef unsigned int khronos_uint32_t;202#if defined(__arch64__) || defined(_LP64)203typedef long int khronos_int64_t;204typedef unsigned long int khronos_uint64_t;205#else206typedef long long int khronos_int64_t;207typedef unsigned long long int khronos_uint64_t;208#endif /* __arch64__ */209#define KHRONOS_SUPPORT_INT64 1210#define KHRONOS_SUPPORT_FLOAT 1211212#elif 0213214/*215* Hypothetical platform with no float or int64 support216*/217typedef int khronos_int32_t;218typedef unsigned int khronos_uint32_t;219#define KHRONOS_SUPPORT_INT64 0220#define KHRONOS_SUPPORT_FLOAT 0221222#else223224/*225* Generic fallback226*/227#include <stdint.h>228typedef int32_t khronos_int32_t;229typedef uint32_t khronos_uint32_t;230typedef int64_t khronos_int64_t;231typedef uint64_t khronos_uint64_t;232#define KHRONOS_SUPPORT_INT64 1233#define KHRONOS_SUPPORT_FLOAT 1234235#endif236237238/*239* Types that are (so far) the same on all platforms240*/241typedef signed char khronos_int8_t;242typedef unsigned char khronos_uint8_t;243typedef signed short int khronos_int16_t;244typedef unsigned short int khronos_uint16_t;245246/*247* Types that differ between LLP64 and LP64 architectures - in LLP64,248* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears249* to be the only LLP64 architecture in current use.250*/251#ifdef KHRONOS_USE_INTPTR_T252typedef intptr_t khronos_intptr_t;253typedef uintptr_t khronos_uintptr_t;254#elif defined(_WIN64)255typedef signed long long int khronos_intptr_t;256typedef unsigned long long int khronos_uintptr_t;257#else258typedef signed long int khronos_intptr_t;259typedef unsigned long int khronos_uintptr_t;260#endif261262#if defined(_WIN64)263typedef signed long long int khronos_ssize_t;264typedef unsigned long long int khronos_usize_t;265#else266typedef signed long int khronos_ssize_t;267typedef unsigned long int khronos_usize_t;268#endif269270#if KHRONOS_SUPPORT_FLOAT271/*272* Float type273*/274typedef float khronos_float_t;275#endif276277#if KHRONOS_SUPPORT_INT64278/* Time types279*280* These types can be used to represent a time interval in nanoseconds or281* an absolute Unadjusted System Time. Unadjusted System Time is the number282* of nanoseconds since some arbitrary system event (e.g. since the last283* time the system booted). The Unadjusted System Time is an unsigned284* 64 bit value that wraps back to 0 every 584 years. Time intervals285* may be either signed or unsigned.286*/287typedef khronos_uint64_t khronos_utime_nanoseconds_t;288typedef khronos_int64_t khronos_stime_nanoseconds_t;289#endif290291/*292* Dummy value used to pad enum types to 32 bits.293*/294#ifndef KHRONOS_MAX_ENUM295#define KHRONOS_MAX_ENUM 0x7FFFFFFF296#endif297298/*299* Enumerated boolean type300*301* Values other than zero should be considered to be true. Therefore302* comparisons should not be made against KHRONOS_TRUE.303*/304typedef enum {305KHRONOS_FALSE = 0,306KHRONOS_TRUE = 1,307KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM308} khronos_boolean_enum_t;309310#endif /* __khrplatform_h_ */311312313