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)
9 typedef __int64 int64_t;
10 typedef unsigned __int64 uint64_t;
11 typedef unsigned int uint32_t;
12 typedef int int32_t;
13 typedef unsigned short uint16_t;
14 typedef short int16_t;
15 typedef unsigned char uint8_t;
16 typedef signed char int8_t;
17#else
18 #include <stdint.h>
19#endif
20
21#ifdef _MSC_VER
22 #ifndef CYBOZU_DEFINED_SSIZE_T
23 #define CYBOZU_DEFINED_SSIZE_T
24 #ifdef _WIN64
25 typedef int64_t ssize_t;
26 #else
27 typedef int32_t ssize_t;
28 #endif
29 #endif
30#else
31 #include <unistd.h> // for ssize_t
32#endif
33
34#ifndef CYBOZU_ALIGN
35 #ifdef _MSC_VER
36 #define CYBOZU_ALIGN(x) __declspec(align(x))
37 #else
38 #define CYBOZU_ALIGN(x) __attribute__((aligned(x)))
39 #endif
40#endif
41#ifndef CYBOZU_ALLOCA
42 #ifdef _MSC_VER
43 #include <malloc.h>
44 #define CYBOZU_ALLOCA(x) _malloca(x)
45 #else
46 #define CYBOZU_ALLOCA_(x) __builtin_alloca(x)
47 #endif
48#endif
49#ifndef CYBOZU_FOREACH
50 // std::vector<int> v; CYBOZU_FOREACH(auto x, v) {...}
51 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
52 #define CYBOZU_FOREACH(type_x, xs) for each (type_x in xs)
53 #elif defined(__GNUC__)
54 #define CYBOZU_FOREACH(type_x, xs) for (type_x : xs)
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 #ifdef _MSC_VER
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>
116void disable_warning_unused_variable(const 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