JD2022-TU1/main/extern/SK_iisu/PS4/include/HumanTrackingPlatform.h

374 lines
10 KiB
C++

/* COPYRIGHT AND CONFIDENTIALITY NOTICE
* SONY DEPTHSENSING SOLUTIONS CONFIDENTIAL INFORMATION
*
* All rights reserved to Sony Depthsensing Solutions SA/NV, a
* company incorporated and existing under the laws of Belgium, with
* its principal place of business at Boulevard de la Plainelaan 11,
* 1050 Brussels (Belgium), registered with the Crossroads bank for
* enterprises under company number 0811 784 189
*
* This file is part of the HumanTracking SDK, which is proprietary
* and confidential information of Sony Depthsensing Solutions SA/NV.
*
* Copyright (c) 2002-2019 Sony Depthsensing Solutions SA/NV
*/
/**
* \cond ENABLE_PLAT_SYMS
*/
/**
* \file HumanTrackingPlatform.h
* \brief API Platform specific definitions
*/
#ifndef HUMANTRACKING_PLATFORM_H
#define HUMANTRACKING_PLATFORM_H
#ifdef _WIN32
#pragma warning (push, 0)
#endif
//common std include
#include <assert.h>
//#include <limits>
//define NULL macro
#include <cstring>
// Supported compilers
#define HT_COMPILER_MSVC 314159u
#define HT_COMPILER_GCC 161803u
#define HT_COMPILER_INTEL 250290u
#define HT_COMPILER_ARMCC 466920u
#define HT_COMPILER_ANDROID 271828u
#define HT_COMPILER_CLANG 764223u
// Supported platform
#define HT_PLATFORM_WIN32 1
#define HT_PLATFORM_LINUX_x86 2
#define HT_PLATFORM_PS4 3
/* Finds the compiler type and version.
*/
#if defined( _MSC_VER )
#define HT_COMPILER HT_COMPILER_MSVC
#define HT_COMPILER_VERSION _MSC_VER
#elif defined(__arm__) && defined(__ARMCC_VERSION)
#define HT_COMPILER HT_COMPILER_ARMCC
/* the format is PVbbbb - P is the major version, V is the minor version,
bbbb is the build number*/
#define HT_COMPILER_VERSION (__ARMCC_VERSION)
#elif defined( __GNUC__ )
// gcc family of compilers: gcc, clang
#define HT_GEN_VERSION(major, minor, patch) (((major)*100) + \
((minor)*10) + \
(patch))
#define HT_COMPILER_VERSION HT_GEN_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#if defined(__clang__)
#define HT_COMPILER HT_COMPILER_CLANG
#undef HT_COMPILER_VERSION
#define HT_COMPILER_VERSION HT_GEN_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#else
#define HT_COMPILER HT_COMPILER_GCC
#endif
#else
#error "Compilation error: Unsupported compiler."
#endif
/* Finds the platform - architecture
*/
#if defined( __WIN32__ ) || defined( _WIN32 )
#define HT_PLATFORM HT_PLATFORM_WIN32
#elif defined(__linux__) || defined(__LINUX__)
#define HT_PLATFORM_LINUX (1)
#if (__TARGET_ARCH_ARM == 5 || __ARM_ARCH_5TEJ__ == 1 || __ARM_ARCH_5TE__ == 1 || __ARM_ARCH_5T__ == 1)
#define HT_PLATFORM HT_PLATFORM_LINUX_ARMv5
#elif (__TARGET_ARCH_ARM == 7 || __ARM_ARCH_7A__ == 1)
#define HT_PLATFORM HT_PLATFORM_LINUX_ARMv7
#elif defined(__x86) || defined(__x86__) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
#define HT_PLATFORM HT_PLATFORM_LINUX_x86
#define HT_ENABLE_SSE
#else
#error "Compilation error: Unsupported version of Linux platform."
#endif
#elif defined(__ORBIS__)
#define HT_PLATFORM HT_PLATFORM_PS4
#define HT_ENABLE_SSE
#else
#error "Compilation error: Unsupported platform."
#endif
//-------------------COMPILER SPECIFIC ---------------------------------------
// inlining
#if (HT_COMPILER == HT_COMPILER_MSVC)
#if (HT_COMPILER_VERSION >= 1200)
#define HT_ALWAYS_INLINE __forceinline
#else
#error "Compilation error: Unsupported compiler. Version must be >= VS 2005"
#endif
#else
#define HT_ALWAYS_INLINE __inline
#endif
#ifdef HT_DEBUG_
// no inline in debug excepted for HT_ALWAYS_INLINE
#define HT_INLINE
#define HT_FORCE_INLINE
#if HT_COMPILER == HT_COMPILER_MSVC
#if HT_COMPILER_VERSION >= 1200
#define HT_ALWAYS_INLINE __forceinline
#else
#error "Compilation error: Unsupported compiler. Version must be >= VS 2005"
#endif
#else
#define HT_ALWAYS_INLINE __inline
#endif
#else
#define HT_INLINE inline
/* See if we can use __forceinline or if we need to use __inline instead */
#if (HT_COMPILER == HT_COMPILER_MSVC)
#if (HT_COMPILER_VERSION >= 1200)
#define HT_FORCE_INLINE __forceinline
#else
#error "Compilation error: Unsupported compiler. Version must be >= VS 2005"
#endif
#else
#define HT_FORCE_INLINE __attribute__((always_inline)) inline
#endif
#endif
//////////////////////////////////////////////////////////////////////////
// override is a non standard extension to the C++. It triggers warning
// 4481 when using warning level 4. In order not to get the warning we
// prevent it with a pragma.
#if (HT_COMPILER == HT_COMPILER_MSVC)
#define HT_OVERRIDE \
override \
__pragma(warning(disable: 4481))
#else
#define HT_OVERRIDE
#endif
// ---------- FLOATING POINT MIN / MAX ----------------
#include <float.h>
typedef float float32_t;
typedef double float64_t;
// -------- CALLING CONVENTIONS ------------------------
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
#define HT_SDK_DECL __stdcall
#define HT_SDK_CDECL __cdecl
#else
#define HT_SDK_DECL
#define HT_SDK_CDECL
#endif
//-------------- DLL Export DEFINITIONS ------------
#if ((HT_PLATFORM == HT_PLATFORM_PS4) || (HT_COMPILER == HT_COMPILER_MSVC)) && !defined(STATIC_LIB)
#define HT_DLL_EXPORT __declspec(dllexport)
#define HT_DLL_IMPORT __declspec(dllimport)
#define HT_DLL_LOCAL
#define HT_DLL_PROTECTED
#elif (HT_COMPILER == HT_COMPILER_GCC || HT_COMPILER == HT_COMPILER_ARMCC || HT_COMPILER == HT_COMPILER_CLANG)
#if (HT_COMPILER_VERSION >= ((__GNUC__) * 100)) || (HT_COMPILER_VERSION >= (500000))
#define HT_DLL_EXPORT __attribute__ ((visibility ("default")))
#define HT_DLL_IMPORT __attribute__ ((visibility ("default")))
#define HT_DLL_LOCAL __attribute__ ((visibility ("hidden")))
#define HT_DLL_PROTECTED __attribute__ ((visibility ("protected")))
#else
#define HT_DLL_EXPORT
#define HT_DLL_IMPORT
#define HT_DLL_LOCAL
#define HT_DLL_PROTECTED
#endif
#else
#define HT_DLL_EXPORT
#define HT_DLL_IMPORT
#define HT_DLL_LOCAL
#define HT_DLL_PROTECTED
#endif
#if defined(HT_DLL_REGISTER)
#define HT_DLL_API HT_DLL_EXPORT
#elif defined (HT_HIDE_SYMBOLS)
#define HT_DLL_API
#else
#define HT_DLL_API HT_DLL_IMPORT
#endif
#if HT_PLATFORM == HT_PLATFORM_WIN32
#include <stdint.h>
#elif HT_PLATFORM == HT_PLATFORM_PS4
#include <sys/types.h>
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
#elif defined(HT_PLATFORM_LINUX)
#include <stdint.h>
#include <limits.h>
#define INT32_MAX (2147483647)
#define UINT32_MAX (4294967295U)
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
#else
#error "Compilation error: Unsupported platform"
#endif // HT_PLATFORM_LINUX == HT_PLATFORM_WIN32
#if (HT_COMPILER == HT_COMPILER_MSVC)
# define HT_DELETE
#else
# define HT_DELETE = delete
#endif
// avoid compiler warnings for unused arguments
//#define HT_ARG_NOT_USED(arg) ( (void)(arg) )
namespace SK
{
namespace HumanTracking
{
template<class T> void ignore_arg( const T& ) { }
}
}
#define HT_STRINGIZE0(text) #text
#define HT_STRINGIZE(text) HT_STRINGIZE0(text)
#define HT_CONCAT(arg1,arg2) CONCAT_1(arg1,arg2)
#define CONCAT_1(arg1,arg2) CONCAT_2(arg1,arg2)
#define CONCAT_2(arg1,arg2) CONCAT_3(arg1,arg2)
#define CONCAT_3(arg1,arg2) arg1##arg2
// enable/disable warnings; use sparingly and with caution
#if (HT_COMPILER == HT_COMPILER_MSVC)
# define HT_DISABLE_WARNING_UNUSED_FUNC \
__pragma(warning(push))
# define HT_DISABLE_WARNING_UNUSED_VAR \
__pragma(warning(push))
# define HT_DISABLE_WARNING_UNNEEDED_DECL \
__pragma(warning(push))
# define HT_DISABLE_WARNING_IGNORE_QUALIF \
__pragma(warning(push))
# define HT_DISABLE_WARNING_ALL \
__pragma(warning(push, 0))
# define HT_ENABLE_WARNING \
__pragma(warning(pop))
// enable/disable warnings
#elif (HT_COMPILER == HT_COMPILER_CLANG)
# define HT_DISABLE_WARNING_UNUSED_FUNC \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunused-function\"")
# define HT_DISABLE_WARNING_UNUSED_VAR \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunused-variable\"")
# define HT_DISABLE_WARNING_UNNEEDED_DECL \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunneeded-internal-declaration\"")
// use the following only for "const has no effect" situations
# define HT_DISABLE_WARNING_IGNORE_QUALIF \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wignored-qualifiers\"")
# define HT_DISABLE_WARNING_ALL \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wall\"")
# define HT_ENABLE_WARNING \
_Pragma("clang diagnostic pop")
#elif (HT_COMPILER == HT_COMPILER_GCC) || (HT_COMPILER == HT_COMPILER_ANDROID)
# define HT_DISABLE_WARNING_UNUSED_FUNC \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunused-function\"")
# define HT_DISABLE_WARNING_UNUSED_VAR \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
# define HT_DISABLE_WARNING_UNNEEDED_DECL \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunneeded-internal-declaration\"")
// use the following only for "const has no effect" situations
# define HT_DISABLE_WARNING_IGNORE_QUALIF \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wignored-qualifiers\"")
# define HT_DISABLE_WARNING_ALL \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wall\"")
# define HT_ENABLE_WARNING \
_Pragma("GCC diagnostic pop")
#else
# define HT_DISABLE_WARNING_UNUSED_FUNC
# define HT_DISABLE_WARNING_UNUSED_VAR
# define HT_DISABLE_WARNING_UNNEEDED_DECL
// use the following only for "const has no effect" situations
# define HT_DISABLE_WARNING_IGNORE_QUALIF
# define HT_DISABLE_WARNING_ALL
# define HT_ENABLE_WARNING
#endif
#if (HT_PLATFORM == HT_PLATFORM_WIN32)
/**
* Align data variable.
*
* \param declaration variable declaration
* \param alignment alignment in bytes
*/
#define HT_DATA_ALIGN(declaration, alignment) __declspec(align(alignment)) declaration
#define HT_RESTRICT __restrict
#else
/**
* Align data variable.
*
* \param declaration variable declaration
* \param alignment alignment in bytes
*/
#define HT_DATA_ALIGN(declaration, alignment) declaration __attribute__ ((aligned (alignment)))
#define HT_RESTRICT restrict
#endif
#ifdef _WIN32
#pragma warning (pop)
#endif
/**
* \endcond
*/
#endif // HUMANTRACKING_PLATFORM_H