Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
inttype.hpp
Go to the documentation of this file.
1#pragma once
8#if defined(_MSC_VER) && (MSC_VER <= 1500) && !defined(CYBOZU_DEFINED_INTXX)
9 #define CYBOZU_DEFINED_INTXX
10 typedef __int64 int64_t;
11 typedef unsigned __int64 uint64_t;
12 typedef unsigned int uint32_t;
13 typedef int int32_t;
14 typedef unsigned short uint16_t;
15 typedef short int16_t;
16 typedef unsigned char uint8_t;
17 typedef signed char int8_t;
18#else
19 #include <stdint.h>
20#endif
21
22#ifdef _MSC_VER
23 #ifndef CYBOZU_DEFINED_SSIZE_T
24 #define CYBOZU_DEFINED_SSIZE_T
25 #ifdef _WIN64
26 typedef int64_t ssize_t;
27 #else
28 typedef int32_t ssize_t;
29 #endif
30 #endif
31#else
32 #include <unistd.h> // for ssize_t
33#endif
34
35#ifndef CYBOZU_ALIGN
36 #ifdef _MSC_VER
37 #define CYBOZU_ALIGN(x) __declspec(align(x))
38 #else
39 #define CYBOZU_ALIGN(x) __attribute__((aligned(x)))
40 #endif
41#endif
42#ifndef CYBOZU_FORCE_INLINE
43 #ifdef _MSC_VER
44 #define CYBOZU_FORCE_INLINE __forceinline
45 #else
46 #define CYBOZU_FORCE_INLINE __attribute__((always_inline))
47 #endif
48#endif
49#ifndef CYBOZU_ALLOCA
50 #ifdef _MSC_VER
51 #include <malloc.h>
52 #define CYBOZU_ALLOCA(x) _malloca(x)
53 #else
54 #define CYBOZU_ALLOCA_(x) __builtin_alloca(x)
55 #endif
56#endif
57#ifndef CYBOZU_NUM_OF_ARRAY
58 #define CYBOZU_NUM_OF_ARRAY(x) (sizeof(x) / sizeof(*x))
59#endif
60#ifndef CYBOZU_SNPRINTF
61 #if defined(_MSC_VER) && (_MSC_VER < 1900)
62 #define CYBOZU_SNPRINTF(x, len, ...) (void)_snprintf_s(x, len, len - 1, __VA_ARGS__)
63 #else
64 #define CYBOZU_SNPRINTF(x, len, ...) (void)snprintf(x, len, __VA_ARGS__)
65 #endif
66#endif
67
68#define CYBOZU_CPP_VERSION_CPP03 0
69#define CYBOZU_CPP_VERSION_TR1 1
70#define CYBOZU_CPP_VERSION_CPP11 2
71
72#if (__cplusplus >= 201103) || (_MSC_VER >= 1500) || defined(__GXX_EXPERIMENTAL_CXX0X__)
73 #if defined(_MSC_VER) && (_MSC_VER <= 1600)
74 #define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_TR1
75 #else
76 #define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP11
77 #endif
78#elif (__GNUC__ >= 4 && __GNUC_MINOR__ >= 5) || (__clang_major__ >= 3)
79 #define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_TR1
80#else
81 #define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP03
82#endif
83
84#if (CYBOZU_CPP_VERSION == CYBOZU_CPP_VERSION_TR1)
85 #define CYBOZU_NAMESPACE_STD std::tr1
86 #define CYBOZU_NAMESPACE_TR1_BEGIN namespace tr1 {
87 #define CYBOZU_NAMESPACE_TR1_END }
88#else
89 #define CYBOZU_NAMESPACE_STD std
90 #define CYBOZU_NAMESPACE_TR1_BEGIN
91 #define CYBOZU_NAMESPACE_TR1_END
92#endif
93
94#ifndef CYBOZU_OS_BIT
95 #if defined(_WIN64) || defined(__x86_64__)
96 #define CYBOZU_OS_BIT 64
97 #else
98 #define CYBOZU_OS_BIT 32
99 #endif
100#endif
101
102
103#ifndef CYBOZU_ENDIAN
104 #define CYBOZU_ENDIAN_UNKNOWN 0
105 #define CYBOZU_ENDIAN_LITTLE 1
106 #define CYBOZU_ENDIAN_BIG 2
107 #if defined(_M_IX86) || defined(_M_AMD64) || defined(__x86_64__) || defined(__i386__)
108 #define CYBOZU_ENDIAN CYBOZU_ENDIAN_LITTLE
109 #else
110 #define CYBOZU_ENDIAN CYBOZU_ENDIAN_UNKNOWN
111 #endif
112#endif
113
114namespace cybozu {
115template<class T>
117template<class T, class S>
118T cast(const S* ptr) { return static_cast<T>(static_cast<const void*>(ptr)); }
119template<class T, class S>
120T cast(S* ptr) { return static_cast<T>(static_cast<void*>(ptr)); }
121} // cybozu
void disable_warning_unused_variable(const T &)
Definition inttype.hpp:116
T cast(const S *ptr)
Definition inttype.hpp:118
#define T(meth, val, expected)
signed short int16_t
Definition stdint.h:122
unsigned short uint16_t
Definition stdint.h:125
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
signed int int32_t
Definition stdint.h:123
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
signed char int8_t
Definition stdint.h:121