michael@0: #ifndef __khrplatform_h_ michael@0: #define __khrplatform_h_ michael@0: michael@0: /* michael@0: ** Copyright (c) 2008-2009 The Khronos Group Inc. michael@0: ** michael@0: ** Permission is hereby granted, free of charge, to any person obtaining a michael@0: ** copy of this software and/or associated documentation files (the michael@0: ** "Materials"), to deal in the Materials without restriction, including michael@0: ** without limitation the rights to use, copy, modify, merge, publish, michael@0: ** distribute, sublicense, and/or sell copies of the Materials, and to michael@0: ** permit persons to whom the Materials are furnished to do so, subject to michael@0: ** the following conditions: michael@0: ** michael@0: ** The above copyright notice and this permission notice shall be included michael@0: ** in all copies or substantial portions of the Materials. michael@0: ** michael@0: ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, michael@0: ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF michael@0: ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. michael@0: ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY michael@0: ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, michael@0: ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE michael@0: ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. michael@0: */ michael@0: michael@0: /* Khronos platform-specific types and definitions. michael@0: * michael@0: * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ michael@0: * michael@0: * Adopters may modify this file to suit their platform. Adopters are michael@0: * encouraged to submit platform specific modifications to the Khronos michael@0: * group so that they can be included in future versions of this file. michael@0: * Please submit changes by sending them to the public Khronos Bugzilla michael@0: * (http://khronos.org/bugzilla) by filing a bug against product michael@0: * "Khronos (general)" component "Registry". michael@0: * michael@0: * A predefined template which fills in some of the bug fields can be michael@0: * reached using http://tinyurl.com/khrplatform-h-bugreport, but you michael@0: * must create a Bugzilla login first. michael@0: * michael@0: * michael@0: * See the Implementer's Guidelines for information about where this file michael@0: * should be located on your system and for more details of its use: michael@0: * http://www.khronos.org/registry/implementers_guide.pdf michael@0: * michael@0: * This file should be included as michael@0: * #include michael@0: * by Khronos client API header files that use its types and defines. michael@0: * michael@0: * The types in khrplatform.h should only be used to define API-specific types. michael@0: * michael@0: * Types defined in khrplatform.h: michael@0: * khronos_int8_t signed 8 bit michael@0: * khronos_uint8_t unsigned 8 bit michael@0: * khronos_int16_t signed 16 bit michael@0: * khronos_uint16_t unsigned 16 bit michael@0: * khronos_int32_t signed 32 bit michael@0: * khronos_uint32_t unsigned 32 bit michael@0: * khronos_int64_t signed 64 bit michael@0: * khronos_uint64_t unsigned 64 bit michael@0: * khronos_intptr_t signed same number of bits as a pointer michael@0: * khronos_uintptr_t unsigned same number of bits as a pointer michael@0: * khronos_ssize_t signed size michael@0: * khronos_usize_t unsigned size michael@0: * khronos_float_t signed 32 bit floating point michael@0: * khronos_time_ns_t unsigned 64 bit time in nanoseconds michael@0: * khronos_utime_nanoseconds_t unsigned time interval or absolute time in michael@0: * nanoseconds michael@0: * khronos_stime_nanoseconds_t signed time interval in nanoseconds michael@0: * khronos_boolean_enum_t enumerated boolean type. This should michael@0: * only be used as a base type when a client API's boolean type is michael@0: * an enum. Client APIs which use an integer or other type for michael@0: * booleans cannot use this as the base type for their boolean. michael@0: * michael@0: * Tokens defined in khrplatform.h: michael@0: * michael@0: * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. michael@0: * michael@0: * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. michael@0: * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. michael@0: * michael@0: * Calling convention macros defined in this file: michael@0: * KHRONOS_APICALL michael@0: * KHRONOS_APIENTRY michael@0: * KHRONOS_APIATTRIBUTES michael@0: * michael@0: * These may be used in function prototypes as: michael@0: * michael@0: * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( michael@0: * int arg1, michael@0: * int arg2) KHRONOS_APIATTRIBUTES; michael@0: */ michael@0: michael@0: /*------------------------------------------------------------------------- michael@0: * Definition of KHRONOS_APICALL michael@0: *------------------------------------------------------------------------- michael@0: * This precedes the return type of the function in the function prototype. michael@0: */ michael@0: #if defined(_WIN32) && !defined(__SCITECH_SNAP__) michael@0: # define KHRONOS_APICALL __declspec(dllimport) michael@0: #elif defined (__SYMBIAN32__) michael@0: # define KHRONOS_APICALL IMPORT_C michael@0: #else michael@0: # define KHRONOS_APICALL michael@0: #endif michael@0: michael@0: /*------------------------------------------------------------------------- michael@0: * Definition of KHRONOS_APIENTRY michael@0: *------------------------------------------------------------------------- michael@0: * This follows the return type of the function and precedes the function michael@0: * name in the function prototype. michael@0: */ michael@0: #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) michael@0: /* Win32 but not WinCE */ michael@0: # define KHRONOS_APIENTRY __stdcall michael@0: #else michael@0: # define KHRONOS_APIENTRY michael@0: #endif michael@0: michael@0: /*------------------------------------------------------------------------- michael@0: * Definition of KHRONOS_APIATTRIBUTES michael@0: *------------------------------------------------------------------------- michael@0: * This follows the closing parenthesis of the function prototype arguments. michael@0: */ michael@0: #if defined (__ARMCC_2__) michael@0: #define KHRONOS_APIATTRIBUTES __softfp michael@0: #else michael@0: #define KHRONOS_APIATTRIBUTES michael@0: #endif michael@0: michael@0: /*------------------------------------------------------------------------- michael@0: * basic type definitions michael@0: *-----------------------------------------------------------------------*/ michael@0: #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) michael@0: michael@0: michael@0: /* michael@0: * Using michael@0: */ michael@0: #include michael@0: typedef int32_t khronos_int32_t; michael@0: typedef uint32_t khronos_uint32_t; michael@0: typedef int64_t khronos_int64_t; michael@0: typedef uint64_t khronos_uint64_t; michael@0: #define KHRONOS_SUPPORT_INT64 1 michael@0: #define KHRONOS_SUPPORT_FLOAT 1 michael@0: michael@0: #elif defined(__VMS ) || defined(__sgi) michael@0: michael@0: /* michael@0: * Using michael@0: */ michael@0: #include michael@0: typedef int32_t khronos_int32_t; michael@0: typedef uint32_t khronos_uint32_t; michael@0: typedef int64_t khronos_int64_t; michael@0: typedef uint64_t khronos_uint64_t; michael@0: #define KHRONOS_SUPPORT_INT64 1 michael@0: #define KHRONOS_SUPPORT_FLOAT 1 michael@0: michael@0: #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) michael@0: michael@0: /* michael@0: * Win32 michael@0: */ michael@0: typedef __int32 khronos_int32_t; michael@0: typedef unsigned __int32 khronos_uint32_t; michael@0: typedef __int64 khronos_int64_t; michael@0: typedef unsigned __int64 khronos_uint64_t; michael@0: #define KHRONOS_SUPPORT_INT64 1 michael@0: #define KHRONOS_SUPPORT_FLOAT 1 michael@0: michael@0: #elif defined(__sun__) || defined(__digital__) michael@0: michael@0: /* michael@0: * Sun or Digital michael@0: */ michael@0: typedef int khronos_int32_t; michael@0: typedef unsigned int khronos_uint32_t; michael@0: #if defined(__arch64__) || defined(_LP64) michael@0: typedef long int khronos_int64_t; michael@0: typedef unsigned long int khronos_uint64_t; michael@0: #else michael@0: typedef long long int khronos_int64_t; michael@0: typedef unsigned long long int khronos_uint64_t; michael@0: #endif /* __arch64__ */ michael@0: #define KHRONOS_SUPPORT_INT64 1 michael@0: #define KHRONOS_SUPPORT_FLOAT 1 michael@0: michael@0: #elif 0 michael@0: michael@0: /* michael@0: * Hypothetical platform with no float or int64 support michael@0: */ michael@0: typedef int khronos_int32_t; michael@0: typedef unsigned int khronos_uint32_t; michael@0: #define KHRONOS_SUPPORT_INT64 0 michael@0: #define KHRONOS_SUPPORT_FLOAT 0 michael@0: michael@0: #else michael@0: michael@0: /* michael@0: * Generic fallback michael@0: */ michael@0: #include michael@0: typedef int32_t khronos_int32_t; michael@0: typedef uint32_t khronos_uint32_t; michael@0: typedef int64_t khronos_int64_t; michael@0: typedef uint64_t khronos_uint64_t; michael@0: #define KHRONOS_SUPPORT_INT64 1 michael@0: #define KHRONOS_SUPPORT_FLOAT 1 michael@0: michael@0: #endif michael@0: michael@0: michael@0: /* michael@0: * Types that are (so far) the same on all platforms michael@0: */ michael@0: typedef signed char khronos_int8_t; michael@0: typedef unsigned char khronos_uint8_t; michael@0: typedef signed short int khronos_int16_t; michael@0: typedef unsigned short int khronos_uint16_t; michael@0: typedef signed long int khronos_intptr_t; michael@0: typedef unsigned long int khronos_uintptr_t; michael@0: typedef signed long int khronos_ssize_t; michael@0: typedef unsigned long int khronos_usize_t; michael@0: michael@0: #if KHRONOS_SUPPORT_FLOAT michael@0: /* michael@0: * Float type michael@0: */ michael@0: typedef float khronos_float_t; michael@0: #endif michael@0: michael@0: #if KHRONOS_SUPPORT_INT64 michael@0: /* Time types michael@0: * michael@0: * These types can be used to represent a time interval in nanoseconds or michael@0: * an absolute Unadjusted System Time. Unadjusted System Time is the number michael@0: * of nanoseconds since some arbitrary system event (e.g. since the last michael@0: * time the system booted). The Unadjusted System Time is an unsigned michael@0: * 64 bit value that wraps back to 0 every 584 years. Time intervals michael@0: * may be either signed or unsigned. michael@0: */ michael@0: typedef khronos_uint64_t khronos_utime_nanoseconds_t; michael@0: typedef khronos_int64_t khronos_stime_nanoseconds_t; michael@0: #endif michael@0: michael@0: /* michael@0: * Dummy value used to pad enum types to 32 bits. michael@0: */ michael@0: #ifndef KHRONOS_MAX_ENUM michael@0: #define KHRONOS_MAX_ENUM 0x7FFFFFFF michael@0: #endif michael@0: michael@0: /* michael@0: * Enumerated boolean type michael@0: * michael@0: * Values other than zero should be considered to be true. Therefore michael@0: * comparisons should not be made against KHRONOS_TRUE. michael@0: */ michael@0: typedef enum { michael@0: KHRONOS_FALSE = 0, michael@0: KHRONOS_TRUE = 1, michael@0: KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM michael@0: } khronos_boolean_enum_t; michael@0: michael@0: #endif /* __khrplatform_h_ */