10 #ifndef MSGPACK_SYSDEP_H 11 #define MSGPACK_SYSDEP_H 17 #if defined(_MSC_VER) && _MSC_VER < 1600 18 typedef signed __int8 int8_t;
19 typedef unsigned __int8 uint8_t;
20 typedef signed __int16 int16_t;
21 typedef unsigned __int16 uint16_t;
22 typedef signed __int32 int32_t;
23 typedef unsigned __int32 uint32_t;
24 typedef signed __int64 int64_t;
25 typedef unsigned __int64 uint64_t;
26 #elif defined(_MSC_VER) // && _MSC_VER >= 1600 33 #if !defined(MSGPACK_DLLEXPORT) 35 # define MSGPACK_DLLEXPORT __declspec(dllexport) 37 # define MSGPACK_DLLEXPORT 42 # define _msgpack_atomic_counter_header <windows.h> 44 # define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr) 45 # define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr) 46 #elif defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41) 48 # if defined(__cplusplus) 49 # define _msgpack_atomic_counter_header "gcc_atomic.hpp" 51 # define _msgpack_atomic_counter_header "gcc_atomic.h" 56 # define _msgpack_sync_decr_and_fetch(ptr) __sync_sub_and_fetch(ptr, 1) 57 # define _msgpack_sync_incr_and_fetch(ptr) __sync_add_and_fetch(ptr, 1) 74 #include <arpa/inet.h> 76 # include <byteswap.h> 81 #if MSGPACK_ENDIAN_LITTLE_BYTE 85 # define _msgpack_be16(x) ntohs(x) 86 # elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400) 87 # define _msgpack_be16(x) ((uint16_t)_byteswap_ushort((unsigned short)x)) 89 # define _msgpack_be16(x) ( \ 90 ((((uint16_t)x) << 8) ) | \ 91 ((((uint16_t)x) >> 8) ) ) 94 # define _msgpack_be16(x) ntohs(x) 99 # define _msgpack_be32(x) ntohl(x) 100 # elif defined(_byteswap_ulong) || (defined(_MSC_VER) && _MSC_VER >= 1400) 101 # define _msgpack_be32(x) ((uint32_t)_byteswap_ulong((unsigned long)x)) 103 # define _msgpack_be32(x) \ 104 ( ((((uint32_t)x) << 24) ) | \ 105 ((((uint32_t)x) << 8) & 0x00ff0000U ) | \ 106 ((((uint32_t)x) >> 8) & 0x0000ff00U ) | \ 107 ((((uint32_t)x) >> 24) ) ) 110 # define _msgpack_be32(x) ntohl(x) 113 # if defined(_byteswap_uint64) || (defined(_MSC_VER) && _MSC_VER >= 1400) 114 # define _msgpack_be64(x) (_byteswap_uint64(x)) 115 # elif defined(bswap_64) 116 # define _msgpack_be64(x) bswap_64(x) 117 # elif defined(__DARWIN_OSSwapInt64) 118 # define _msgpack_be64(x) __DARWIN_OSSwapInt64(x) 120 # define _msgpack_be64(x) \ 121 ( ((((uint64_t)x) << 56) ) | \ 122 ((((uint64_t)x) << 40) & 0x00ff000000000000ULL ) | \ 123 ((((uint64_t)x) << 24) & 0x0000ff0000000000ULL ) | \ 124 ((((uint64_t)x) << 8) & 0x000000ff00000000ULL ) | \ 125 ((((uint64_t)x) >> 8) & 0x00000000ff000000ULL ) | \ 126 ((((uint64_t)x) >> 24) & 0x0000000000ff0000ULL ) | \ 127 ((((uint64_t)x) >> 40) & 0x000000000000ff00ULL ) | \ 128 ((((uint64_t)x) >> 56) ) ) 131 #elif MSGPACK_ENDIAN_BIG_BYTE 133 # define _msgpack_be16(x) (x) 134 # define _msgpack_be32(x) (x) 135 # define _msgpack_be64(x) (x) 138 # error msgpack-c supports only big endian and little endian 141 #define _msgpack_load16(cast, from, to) do { \ 142 memcpy((cast*)(to), (from), sizeof(cast)); \ 143 *(to) = _msgpack_be16(*(to)); \ 146 #define _msgpack_load32(cast, from, to) do { \ 147 memcpy((cast*)(to), (from), sizeof(cast)); \ 148 *(to) = _msgpack_be32(*(to)); \ 150 #define _msgpack_load64(cast, from, to) do { \ 151 memcpy((cast*)(to), (from), sizeof(cast)); \ 152 *(to) = _msgpack_be64(*(to)); \ 155 #define _msgpack_store16(to, num) \ 156 do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0) 157 #define _msgpack_store32(to, num) \ 158 do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0) 159 #define _msgpack_store64(to, num) \ 160 do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0) 172 #if !defined(__cplusplus) && defined(_MSC_VER) 177 # define TRUE (!FALSE) 179 # if _MSC_VER >= 1800 180 # include <stdbool.h> 186 # define inline __inline 190 # include <TargetConditionals.h> unsigned int _msgpack_atomic_counter_t
Definition: sysdep.h:55