include/SDL_opengles2_khrplatform.h
author Ryan C. Gordon <icculus@icculus.org>
Sun, 12 Apr 2015 20:28:28 -0400
changeset 9553 75dca0c33be6
parent 8808 da1e1d6e84c4
permissions -rw-r--r--
Merged.
jorgen@8806
     1
#ifndef __khrplatform_h_
jorgen@8806
     2
#define __khrplatform_h_
jorgen@8806
     3
jorgen@8806
     4
/*
jorgen@8806
     5
** Copyright (c) 2008-2009 The Khronos Group Inc.
jorgen@8806
     6
**
jorgen@8806
     7
** Permission is hereby granted, free of charge, to any person obtaining a
jorgen@8806
     8
** copy of this software and/or associated documentation files (the
jorgen@8806
     9
** "Materials"), to deal in the Materials without restriction, including
jorgen@8806
    10
** without limitation the rights to use, copy, modify, merge, publish,
jorgen@8806
    11
** distribute, sublicense, and/or sell copies of the Materials, and to
jorgen@8806
    12
** permit persons to whom the Materials are furnished to do so, subject to
jorgen@8806
    13
** the following conditions:
jorgen@8806
    14
**
jorgen@8806
    15
** The above copyright notice and this permission notice shall be included
jorgen@8806
    16
** in all copies or substantial portions of the Materials.
jorgen@8806
    17
**
jorgen@8806
    18
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
jorgen@8806
    19
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
jorgen@8806
    20
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
jorgen@8806
    21
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
jorgen@8806
    22
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
jorgen@8806
    23
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
jorgen@8806
    24
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
jorgen@8806
    25
*/
jorgen@8806
    26
jorgen@8806
    27
/* Khronos platform-specific types and definitions.
jorgen@8808
    28
 *
jorgen@8808
    29
 * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
jorgen@8808
    30
 *
jorgen@8808
    31
 * Adopters may modify this file to suit their platform. Adopters are
jorgen@8808
    32
 * encouraged to submit platform specific modifications to the Khronos
jorgen@8808
    33
 * group so that they can be included in future versions of this file.
jorgen@8808
    34
 * Please submit changes by sending them to the public Khronos Bugzilla
jorgen@8808
    35
 * (http://khronos.org/bugzilla) by filing a bug against product
jorgen@8808
    36
 * "Khronos (general)" component "Registry".
jorgen@8808
    37
 *
jorgen@8808
    38
 * A predefined template which fills in some of the bug fields can be
jorgen@8808
    39
 * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
jorgen@8808
    40
 * must create a Bugzilla login first.
jorgen@8808
    41
 *
jorgen@8808
    42
 *
jorgen@8808
    43
 * See the Implementer's Guidelines for information about where this file
jorgen@8808
    44
 * should be located on your system and for more details of its use:
jorgen@8808
    45
 *    http://www.khronos.org/registry/implementers_guide.pdf
jorgen@8808
    46
 *
jorgen@8808
    47
 * This file should be included as
jorgen@8808
    48
 *        #include <KHR/khrplatform.h>
jorgen@8808
    49
 * by Khronos client API header files that use its types and defines.
jorgen@8808
    50
 *
jorgen@8808
    51
 * The types in khrplatform.h should only be used to define API-specific types.
jorgen@8808
    52
 *
jorgen@8808
    53
 * Types defined in khrplatform.h:
jorgen@8808
    54
 *    khronos_int8_t              signed   8  bit
jorgen@8808
    55
 *    khronos_uint8_t             unsigned 8  bit
jorgen@8808
    56
 *    khronos_int16_t             signed   16 bit
jorgen@8808
    57
 *    khronos_uint16_t            unsigned 16 bit
jorgen@8808
    58
 *    khronos_int32_t             signed   32 bit
jorgen@8808
    59
 *    khronos_uint32_t            unsigned 32 bit
jorgen@8808
    60
 *    khronos_int64_t             signed   64 bit
jorgen@8808
    61
 *    khronos_uint64_t            unsigned 64 bit
jorgen@8808
    62
 *    khronos_intptr_t            signed   same number of bits as a pointer
jorgen@8808
    63
 *    khronos_uintptr_t           unsigned same number of bits as a pointer
jorgen@8808
    64
 *    khronos_ssize_t             signed   size
jorgen@8808
    65
 *    khronos_usize_t             unsigned size
jorgen@8808
    66
 *    khronos_float_t             signed   32 bit floating point
jorgen@8808
    67
 *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
jorgen@8808
    68
 *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
jorgen@8808
    69
 *                                         nanoseconds
jorgen@8808
    70
 *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
jorgen@8808
    71
 *    khronos_boolean_enum_t      enumerated boolean type. This should
jorgen@8808
    72
 *      only be used as a base type when a client API's boolean type is
jorgen@8808
    73
 *      an enum. Client APIs which use an integer or other type for
jorgen@8808
    74
 *      booleans cannot use this as the base type for their boolean.
jorgen@8808
    75
 *
jorgen@8808
    76
 * Tokens defined in khrplatform.h:
jorgen@8808
    77
 *
jorgen@8808
    78
 *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
jorgen@8808
    79
 *
jorgen@8808
    80
 *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
jorgen@8808
    81
 *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
jorgen@8808
    82
 *
jorgen@8808
    83
 * Calling convention macros defined in this file:
jorgen@8808
    84
 *    KHRONOS_APICALL
jorgen@8808
    85
 *    KHRONOS_APIENTRY
jorgen@8808
    86
 *    KHRONOS_APIATTRIBUTES
jorgen@8808
    87
 *
jorgen@8808
    88
 * These may be used in function prototypes as:
jorgen@8808
    89
 *
jorgen@8808
    90
 *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
jorgen@8808
    91
 *                                  int arg1,
jorgen@8808
    92
 *                                  int arg2) KHRONOS_APIATTRIBUTES;
jorgen@8808
    93
 */
jorgen@8806
    94
jorgen@8806
    95
/*-------------------------------------------------------------------------
jorgen@8808
    96
 * Definition of KHRONOS_APICALL
jorgen@8808
    97
 *-------------------------------------------------------------------------
jorgen@8808
    98
 * This precedes the return type of the function in the function prototype.
jorgen@8808
    99
 */
jorgen@8806
   100
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
jorgen@8806
   101
#   define KHRONOS_APICALL __declspec(dllimport)
jorgen@8806
   102
#elif defined (__SYMBIAN32__)
jorgen@8806
   103
#   define KHRONOS_APICALL IMPORT_C
jorgen@8806
   104
#else
jorgen@8806
   105
#   define KHRONOS_APICALL
jorgen@8806
   106
#endif
jorgen@8806
   107
jorgen@8806
   108
/*-------------------------------------------------------------------------
jorgen@8808
   109
 * Definition of KHRONOS_APIENTRY
jorgen@8808
   110
 *-------------------------------------------------------------------------
jorgen@8808
   111
 * This follows the return type of the function  and precedes the function
jorgen@8808
   112
 * name in the function prototype.
jorgen@8808
   113
 */
jorgen@8806
   114
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
jorgen@8808
   115
    /* Win32 but not WinCE */
jorgen@8806
   116
#   define KHRONOS_APIENTRY __stdcall
jorgen@8806
   117
#else
jorgen@8806
   118
#   define KHRONOS_APIENTRY
jorgen@8806
   119
#endif
jorgen@8806
   120
jorgen@8806
   121
/*-------------------------------------------------------------------------
jorgen@8808
   122
 * Definition of KHRONOS_APIATTRIBUTES
jorgen@8808
   123
 *-------------------------------------------------------------------------
jorgen@8808
   124
 * This follows the closing parenthesis of the function prototype arguments.
jorgen@8808
   125
 */
jorgen@8806
   126
#if defined (__ARMCC_2__)
jorgen@8806
   127
#define KHRONOS_APIATTRIBUTES __softfp
jorgen@8806
   128
#else
jorgen@8806
   129
#define KHRONOS_APIATTRIBUTES
jorgen@8806
   130
#endif
jorgen@8806
   131
jorgen@8806
   132
/*-------------------------------------------------------------------------
jorgen@8808
   133
 * basic type definitions
jorgen@8808
   134
 *-----------------------------------------------------------------------*/
jorgen@8806
   135
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
jorgen@8806
   136
jorgen@8806
   137
jorgen@8806
   138
/*
jorgen@8808
   139
 * Using <stdint.h>
jorgen@8808
   140
 */
jorgen@8806
   141
#include <stdint.h>
jorgen@8806
   142
typedef int32_t                 khronos_int32_t;
jorgen@8806
   143
typedef uint32_t                khronos_uint32_t;
jorgen@8806
   144
typedef int64_t                 khronos_int64_t;
jorgen@8806
   145
typedef uint64_t                khronos_uint64_t;
jorgen@8806
   146
#define KHRONOS_SUPPORT_INT64   1
jorgen@8806
   147
#define KHRONOS_SUPPORT_FLOAT   1
jorgen@8806
   148
jorgen@8806
   149
#elif defined(__VMS ) || defined(__sgi)
jorgen@8806
   150
jorgen@8806
   151
/*
jorgen@8808
   152
 * Using <inttypes.h>
jorgen@8808
   153
 */
jorgen@8806
   154
#include <inttypes.h>
jorgen@8806
   155
typedef int32_t                 khronos_int32_t;
jorgen@8806
   156
typedef uint32_t                khronos_uint32_t;
jorgen@8806
   157
typedef int64_t                 khronos_int64_t;
jorgen@8806
   158
typedef uint64_t                khronos_uint64_t;
jorgen@8806
   159
#define KHRONOS_SUPPORT_INT64   1
jorgen@8806
   160
#define KHRONOS_SUPPORT_FLOAT   1
jorgen@8806
   161
jorgen@8806
   162
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
jorgen@8806
   163
jorgen@8806
   164
/*
jorgen@8808
   165
 * Win32
jorgen@8808
   166
 */
jorgen@8806
   167
typedef __int32                 khronos_int32_t;
jorgen@8806
   168
typedef unsigned __int32        khronos_uint32_t;
jorgen@8806
   169
typedef __int64                 khronos_int64_t;
jorgen@8806
   170
typedef unsigned __int64        khronos_uint64_t;
jorgen@8806
   171
#define KHRONOS_SUPPORT_INT64   1
jorgen@8806
   172
#define KHRONOS_SUPPORT_FLOAT   1
jorgen@8806
   173
jorgen@8806
   174
#elif defined(__sun__) || defined(__digital__)
jorgen@8806
   175
jorgen@8806
   176
/*
jorgen@8808
   177
 * Sun or Digital
jorgen@8808
   178
 */
jorgen@8806
   179
typedef int                     khronos_int32_t;
jorgen@8806
   180
typedef unsigned int            khronos_uint32_t;
jorgen@8806
   181
#if defined(__arch64__) || defined(_LP64)
jorgen@8806
   182
typedef long int                khronos_int64_t;
jorgen@8806
   183
typedef unsigned long int       khronos_uint64_t;
jorgen@8806
   184
#else
jorgen@8806
   185
typedef long long int           khronos_int64_t;
jorgen@8806
   186
typedef unsigned long long int  khronos_uint64_t;
jorgen@8806
   187
#endif /* __arch64__ */
jorgen@8806
   188
#define KHRONOS_SUPPORT_INT64   1
jorgen@8806
   189
#define KHRONOS_SUPPORT_FLOAT   1
jorgen@8806
   190
jorgen@8806
   191
#elif 0
jorgen@8806
   192
jorgen@8806
   193
/*
jorgen@8808
   194
 * Hypothetical platform with no float or int64 support
jorgen@8808
   195
 */
jorgen@8806
   196
typedef int                     khronos_int32_t;
jorgen@8806
   197
typedef unsigned int            khronos_uint32_t;
jorgen@8806
   198
#define KHRONOS_SUPPORT_INT64   0
jorgen@8806
   199
#define KHRONOS_SUPPORT_FLOAT   0
jorgen@8806
   200
jorgen@8806
   201
#else
jorgen@8806
   202
jorgen@8806
   203
/*
jorgen@8808
   204
 * Generic fallback
jorgen@8808
   205
 */
jorgen@8806
   206
#include <stdint.h>
jorgen@8806
   207
typedef int32_t                 khronos_int32_t;
jorgen@8806
   208
typedef uint32_t                khronos_uint32_t;
jorgen@8806
   209
typedef int64_t                 khronos_int64_t;
jorgen@8806
   210
typedef uint64_t                khronos_uint64_t;
jorgen@8806
   211
#define KHRONOS_SUPPORT_INT64   1
jorgen@8806
   212
#define KHRONOS_SUPPORT_FLOAT   1
jorgen@8806
   213
jorgen@8806
   214
#endif
jorgen@8806
   215
jorgen@8806
   216
jorgen@8806
   217
/*
jorgen@8808
   218
 * Types that are (so far) the same on all platforms
jorgen@8808
   219
 */
jorgen@8806
   220
typedef signed   char          khronos_int8_t;
jorgen@8806
   221
typedef unsigned char          khronos_uint8_t;
jorgen@8806
   222
typedef signed   short int     khronos_int16_t;
jorgen@8806
   223
typedef unsigned short int     khronos_uint16_t;
jorgen@8806
   224
jorgen@8806
   225
/*
jorgen@8808
   226
 * Types that differ between LLP64 and LP64 architectures - in LLP64, 
jorgen@8808
   227
 * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
jorgen@8808
   228
 * to be the only LLP64 architecture in current use.
jorgen@8808
   229
 */
jorgen@8806
   230
#ifdef _WIN64
jorgen@8806
   231
typedef signed   long long int khronos_intptr_t;
jorgen@8806
   232
typedef unsigned long long int khronos_uintptr_t;
jorgen@8806
   233
typedef signed   long long int khronos_ssize_t;
jorgen@8806
   234
typedef unsigned long long int khronos_usize_t;
jorgen@8806
   235
#else
jorgen@8806
   236
typedef signed   long  int     khronos_intptr_t;
jorgen@8806
   237
typedef unsigned long  int     khronos_uintptr_t;
jorgen@8806
   238
typedef signed   long  int     khronos_ssize_t;
jorgen@8806
   239
typedef unsigned long  int     khronos_usize_t;
jorgen@8806
   240
#endif
jorgen@8806
   241
jorgen@8806
   242
#if KHRONOS_SUPPORT_FLOAT
jorgen@8806
   243
/*
jorgen@8808
   244
 * Float type
jorgen@8808
   245
 */
jorgen@8806
   246
typedef          float         khronos_float_t;
jorgen@8806
   247
#endif
jorgen@8806
   248
jorgen@8806
   249
#if KHRONOS_SUPPORT_INT64
jorgen@8806
   250
/* Time types
jorgen@8808
   251
 *
jorgen@8808
   252
 * These types can be used to represent a time interval in nanoseconds or
jorgen@8808
   253
 * an absolute Unadjusted System Time.  Unadjusted System Time is the number
jorgen@8808
   254
 * of nanoseconds since some arbitrary system event (e.g. since the last
jorgen@8808
   255
 * time the system booted).  The Unadjusted System Time is an unsigned
jorgen@8808
   256
 * 64 bit value that wraps back to 0 every 584 years.  Time intervals
jorgen@8808
   257
 * may be either signed or unsigned.
jorgen@8808
   258
 */
jorgen@8806
   259
typedef khronos_uint64_t       khronos_utime_nanoseconds_t;
jorgen@8806
   260
typedef khronos_int64_t        khronos_stime_nanoseconds_t;
jorgen@8806
   261
#endif
jorgen@8806
   262
jorgen@8806
   263
/*
jorgen@8808
   264
 * Dummy value used to pad enum types to 32 bits.
jorgen@8808
   265
 */
jorgen@8806
   266
#ifndef KHRONOS_MAX_ENUM
jorgen@8806
   267
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
jorgen@8806
   268
#endif
jorgen@8806
   269
jorgen@8806
   270
/*
jorgen@8808
   271
 * Enumerated boolean type
jorgen@8808
   272
 *
jorgen@8808
   273
 * Values other than zero should be considered to be true.  Therefore
jorgen@8808
   274
 * comparisons should not be made against KHRONOS_TRUE.
jorgen@8808
   275
 */
jorgen@8806
   276
typedef enum {
jorgen@8806
   277
    KHRONOS_FALSE = 0,
jorgen@8808
   278
    KHRONOS_TRUE  = 1,
jorgen@8806
   279
    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
jorgen@8806
   280
} khronos_boolean_enum_t;
jorgen@8806
   281
jorgen@8806
   282
#endif /* __khrplatform_h_ */