Atlas - openxr_platform_defines.h
Home / ext / SDL / src / video / khronos / openxr Lines: 1 | Size: 3912 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2** Copyright (c) 2017-2025 The Khronos Group Inc. 3** 4** SPDX-License-Identifier: Apache-2.0 OR MIT 5*/ 6 7#ifndef OPENXR_PLATFORM_DEFINES_H_ 8#define OPENXR_PLATFORM_DEFINES_H_ 1 9 10#ifdef __cplusplus 11extern "C" { 12#endif 13 14/* Platform-specific calling convention macros. 15 * 16 * Platforms should define these so that OpenXR clients call OpenXR functions 17 * with the same calling conventions that the OpenXR implementation expects. 18 * 19 * XRAPI_ATTR - Placed before the return type in function declarations. 20 * Useful for C++11 and GCC/Clang-style function attribute syntax. 21 * XRAPI_CALL - Placed after the return type in function declarations. 22 * Useful for MSVC-style calling convention syntax. 23 * XRAPI_PTR - Placed between the '(' and '*' in function pointer types. 24 * 25 * Function declaration: XRAPI_ATTR void XRAPI_CALL xrFunction(void); 26 * Function pointer type: typedef void (XRAPI_PTR *PFN_xrFunction)(void); 27 */ 28#if defined(_WIN32) 29#define XRAPI_ATTR 30// On Windows, functions use the stdcall convention 31#define XRAPI_CALL __stdcall 32#define XRAPI_PTR XRAPI_CALL 33#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 34#error "API not supported for the 'armeabi' NDK ABI" 35#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) 36// On Android 32-bit ARM targets, functions use the "hardfloat" 37// calling convention, i.e. float parameters are passed in registers. This 38// is true even if the rest of the application passes floats on the stack, 39// as it does by default when compiling for the armeabi-v7a NDK ABI. 40#define XRAPI_ATTR __attribute__((pcs("aapcs-vfp"))) 41#define XRAPI_CALL 42#define XRAPI_PTR XRAPI_ATTR 43#else 44// On other platforms, use the default calling convention 45#define XRAPI_ATTR 46#define XRAPI_CALL 47#define XRAPI_PTR 48#endif 49 50#include <stddef.h> 51 52#if !defined(XR_NO_STDINT_H) 53#if defined(_MSC_VER) && (_MSC_VER < 1600) 54typedef signed __int8 int8_t; 55typedef unsigned __int8 uint8_t; 56typedef signed __int16 int16_t; 57typedef unsigned __int16 uint16_t; 58typedef signed __int32 int32_t; 59typedef unsigned __int32 uint32_t; 60typedef signed __int64 int64_t; 61typedef unsigned __int64 uint64_t; 62#else 63#include <stdint.h> 64#endif 65#endif // !defined( XR_NO_STDINT_H ) 66 67// XR_PTR_SIZE (in bytes) 68#if (defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)) 69#define XR_PTR_SIZE 8 70#else 71#define XR_PTR_SIZE 4 72#endif 73 74// Needed so we can use clang __has_feature portably. 75#if !defined(XR_COMPILER_HAS_FEATURE) 76#if defined(__clang__) 77#define XR_COMPILER_HAS_FEATURE(x) __has_feature(x) 78#else 79#define XR_COMPILER_HAS_FEATURE(x) 0 80#endif 81#endif 82 83// Identifies if the current compiler has C++11 support enabled. 84// Does not by itself identify if any given C++11 feature is present. 85#if !defined(XR_CPP11_ENABLED) && defined(__cplusplus) 86#if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) 87#define XR_CPP11_ENABLED 1 88#elif defined(_MSC_VER) && (_MSC_VER >= 1600) 89#define XR_CPP11_ENABLED 1 90#elif (__cplusplus >= 201103L) // 201103 is the first C++11 version. 91#define XR_CPP11_ENABLED 1 92#endif 93#endif 94 95// Identifies if the current compiler supports C++11 nullptr. 96#if !defined(XR_CPP_NULLPTR_SUPPORTED) 97#if defined(XR_CPP11_ENABLED) && \ 98 ((defined(__clang__) && XR_COMPILER_HAS_FEATURE(cxx_nullptr)) || \ 99 (defined(__GNUC__) && (((__GNUC__ * 1000) + __GNUC_MINOR__) >= 4006)) || \ 100 (defined(_MSC_VER) && (_MSC_VER >= 1600)) || \ 101 (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) 102#define XR_CPP_NULLPTR_SUPPORTED 1 103#endif 104#endif 105 106#if !defined(XR_CPP_NULLPTR_SUPPORTED) 107#define XR_CPP_NULLPTR_SUPPORTED 0 108#endif // !defined(XR_CPP_NULLPTR_SUPPORTED) 109 110#ifdef __cplusplus 111} 112#endif 113 114#endif 115[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.