dbb1f8cf37
671fc805 update test/cybozu 8ca86231 remove mutable in Address 8b93498f add cmpsb/scasb/... 7eb62750 avoid core_sharing_data_cache = 0 for some cloud envrionment 85767e95 support mingw64 59573e6e add PROTECT_RE mode for protect() 71b75f65 fix push(qword[mem]) 811f4959 Merge branch 'rsdubtso-master' 8e3cb711 Account for potentially zero 0xb leaf when parsing cache/topology via cpuid a816249f update version fe083912 fix to avoid zero division for some virtual machine f0a8f7fa update version cac09b7a Merge pull request #62 from mgouicem/master 1f96b5e0 Fixes an error raised by clang < 3.9 c0f885ac Merge pull request #61 from mgouicem/master bfe2d201 Change default value for n_cores in setCacheHierarchy. fd587b55 change format and add getter for data_cache_size 80b3c7b9 remove macro 88189609 Merge branch 'mgouicem-master' e6b79723 Adding queries to get the cpu topology on Intel architectures. 221384f0 vmov* supports [mem]|k|z c04141ef define XBYAK_NO_OP_NAMES for test af7f05ee add const for Label git-subtree-dir: externals/xbyak git-subtree-split: 671fc805d09d075f48d4625f183ef2e1ef725106
163 lines
4.5 KiB
C++
163 lines
4.5 KiB
C++
#pragma once
|
|
/**
|
|
@file
|
|
@brief int type definition and macros
|
|
@author MITSUNARI Shigeo(@herumi)
|
|
*/
|
|
|
|
#if defined(_MSC_VER) && (MSC_VER <= 1500) && !defined(CYBOZU_DEFINED_INTXX)
|
|
#define CYBOZU_DEFINED_INTXX
|
|
typedef __int64 int64_t;
|
|
typedef unsigned __int64 uint64_t;
|
|
typedef unsigned int uint32_t;
|
|
typedef int int32_t;
|
|
typedef unsigned short uint16_t;
|
|
typedef short int16_t;
|
|
typedef unsigned char uint8_t;
|
|
typedef signed char int8_t;
|
|
#else
|
|
#include <stdint.h>
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
#ifndef CYBOZU_DEFINED_SSIZE_T
|
|
#define CYBOZU_DEFINED_SSIZE_T
|
|
#ifdef _WIN64
|
|
typedef int64_t ssize_t;
|
|
#else
|
|
typedef int32_t ssize_t;
|
|
#endif
|
|
#endif
|
|
#else
|
|
#include <unistd.h> // for ssize_t
|
|
#endif
|
|
|
|
#ifndef CYBOZU_ALIGN
|
|
#ifdef _MSC_VER
|
|
#define CYBOZU_ALIGN(x) __declspec(align(x))
|
|
#else
|
|
#define CYBOZU_ALIGN(x) __attribute__((aligned(x)))
|
|
#endif
|
|
#endif
|
|
#ifndef CYBOZU_FORCE_INLINE
|
|
#ifdef _MSC_VER
|
|
#define CYBOZU_FORCE_INLINE __forceinline
|
|
#else
|
|
#define CYBOZU_FORCE_INLINE __attribute__((always_inline))
|
|
#endif
|
|
#endif
|
|
#ifndef CYBOZU_UNUSED
|
|
#ifdef __GNUC__
|
|
#define CYBOZU_UNUSED __attribute__((unused))
|
|
#else
|
|
#define CYBOZU_UNUSED
|
|
#endif
|
|
#endif
|
|
#ifndef CYBOZU_ALLOCA
|
|
#ifdef _MSC_VER
|
|
#include <malloc.h>
|
|
#define CYBOZU_ALLOCA(x) _malloca(x)
|
|
#else
|
|
#define CYBOZU_ALLOCA(x) __builtin_alloca(x)
|
|
#endif
|
|
#endif
|
|
#ifndef CYBOZU_NUM_OF_ARRAY
|
|
#define CYBOZU_NUM_OF_ARRAY(x) (sizeof(x) / sizeof(*x))
|
|
#endif
|
|
#ifndef CYBOZU_SNPRINTF
|
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
|
#define CYBOZU_SNPRINTF(x, len, ...) (void)_snprintf_s(x, len, len - 1, __VA_ARGS__)
|
|
#else
|
|
#define CYBOZU_SNPRINTF(x, len, ...) (void)snprintf(x, len, __VA_ARGS__)
|
|
#endif
|
|
#endif
|
|
|
|
#define CYBOZU_CPP_VERSION_CPP03 0
|
|
#define CYBOZU_CPP_VERSION_TR1 1
|
|
#define CYBOZU_CPP_VERSION_CPP11 2
|
|
#define CYBOZU_CPP_VERSION_CPP14 3
|
|
#define CYBOZU_CPP_VERSION_CPP17 4
|
|
|
|
#ifdef __GNUC__
|
|
#define CYBOZU_GNUC_PREREQ(major, minor) ((__GNUC__) * 100 + (__GNUC_MINOR__) >= (major) * 100 + (minor))
|
|
#else
|
|
#define CYBOZU_GNUC_PREREQ(major, minor) 0
|
|
#endif
|
|
|
|
#if (__cplusplus >= 201703)
|
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP17
|
|
#elif (__cplusplus >= 201402)
|
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP14
|
|
#elif (__cplusplus >= 201103) || (_MSC_VER >= 1500) || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
|
#if defined(_MSC_VER) && (_MSC_VER <= 1600)
|
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_TR1
|
|
#else
|
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP11
|
|
#endif
|
|
#elif CYBOZU_GNUC_PREREQ(4, 5) || (CYBOZU_GNUC_PREREQ(4, 2) && __GLIBCXX__ >= 20070719) || defined(__INTEL_COMPILER) || (__clang_major__ >= 3)
|
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_TR1
|
|
#else
|
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP03
|
|
#endif
|
|
|
|
#ifdef CYBOZU_USE_BOOST
|
|
#define CYBOZU_NAMESPACE_STD boost
|
|
#define CYBOZU_NAMESPACE_TR1_BEGIN
|
|
#define CYBOZU_NAMESPACE_TR1_END
|
|
#elif (CYBOZU_CPP_VERSION == CYBOZU_CPP_VERSION_TR1) && !defined(__APPLE__)
|
|
#define CYBOZU_NAMESPACE_STD std::tr1
|
|
#define CYBOZU_NAMESPACE_TR1_BEGIN namespace tr1 {
|
|
#define CYBOZU_NAMESPACE_TR1_END }
|
|
#else
|
|
#define CYBOZU_NAMESPACE_STD std
|
|
#define CYBOZU_NAMESPACE_TR1_BEGIN
|
|
#define CYBOZU_NAMESPACE_TR1_END
|
|
#endif
|
|
|
|
#ifndef CYBOZU_OS_BIT
|
|
#if defined(_WIN64) || defined(__x86_64__) || defined(__AARCH64EL__) || defined(__EMSCRIPTEN__)
|
|
#define CYBOZU_OS_BIT 64
|
|
#else
|
|
#define CYBOZU_OS_BIT 32
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef CYBOZU_HOST
|
|
#define CYBOZU_HOST_UNKNOWN 0
|
|
#define CYBOZU_HOST_INTEL 1
|
|
#define CYBOZU_HOST_ARM 2
|
|
#if defined(_M_IX86) || defined(_M_AMD64) || defined(__x86_64__) || defined(__i386__)
|
|
#define CYBOZU_HOST CYBOZU_HOST_INTEL
|
|
#elif defined(__arm__) || defined(__AARCH64EL__)
|
|
#define CYBOZU_HOST CYBOZU_HOST_ARM
|
|
#else
|
|
#define CYBOZU_HOST CYBOZU_HOST_UNKNOWN
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef CYBOZU_ENDIAN
|
|
#define CYBOZU_ENDIAN_UNKNOWN 0
|
|
#define CYBOZU_ENDIAN_LITTLE 1
|
|
#define CYBOZU_ENDIAN_BIG 2
|
|
#if (CYBOZU_HOST == CYBOZU_HOST_INTEL)
|
|
#define CYBOZU_ENDIAN CYBOZU_ENDIAN_LITTLE
|
|
#elif (CYBOZU_HOST == CYBOZU_HOST_ARM) && (defined(__ARM_EABI__) || defined(__AARCH64EL__))
|
|
#define CYBOZU_ENDIAN CYBOZU_ENDIAN_LITTLE
|
|
#else
|
|
#define CYBOZU_ENDIAN CYBOZU_ENDIAN_UNKNOWN
|
|
#endif
|
|
#endif
|
|
|
|
#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11
|
|
#define CYBOZU_NOEXCEPT noexcept
|
|
#else
|
|
#define CYBOZU_NOEXCEPT throw()
|
|
#endif
|
|
namespace cybozu {
|
|
template<class T>
|
|
void disable_warning_unused_variable(const T&) { }
|
|
template<class T, class S>
|
|
T cast(const S* ptr) { return static_cast<T>(static_cast<const void*>(ptr)); }
|
|
template<class T, class S>
|
|
T cast(S* ptr) { return static_cast<T>(static_cast<void*>(ptr)); }
|
|
} // cybozu
|