mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-26 11:46:34 +01:00
fixed sysdep.h
This commit is contained in:
parent
79b83e78a5
commit
4fa7cffc37
@ -728,7 +728,7 @@ msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
|
||||
msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
|
||||
{
|
||||
if(l < 32) {
|
||||
unsigned char d = 0xa0 | l;
|
||||
unsigned char d = 0xa0 | (uint8_t)l;
|
||||
msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
|
||||
} else if(l < 65536) {
|
||||
unsigned char buf[3];
|
||||
|
@ -84,9 +84,9 @@ typedef unsigned int _msgpack_atomic_counter_t;
|
||||
# elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||
# define _msgpack_be16(x) ((uint16_t)_byteswap_ushort((unsigned short)x))
|
||||
# else
|
||||
# define _msgpack_be16(x) \
|
||||
( ((((uint16_t)x) << 8) ) | \
|
||||
((((uint16_t)x) >> 8) )
|
||||
# define _msgpack_be16(x) ( \
|
||||
((((uint16_t)x) << 8) ) | \
|
||||
((((uint16_t)x) >> 8) ) )
|
||||
# endif
|
||||
#else
|
||||
# define _msgpack_be16(x) ntohs(x)
|
||||
@ -126,10 +126,51 @@ typedef unsigned int _msgpack_atomic_counter_t;
|
||||
((((uint64_t)x) >> 56) ) )
|
||||
#endif
|
||||
|
||||
#define _msgpack_load16(cast, from) ((cast)( \
|
||||
(((uint16_t)((uint8_t*)(from))[0]) << 8) | \
|
||||
(((uint16_t)((uint8_t*)(from))[1]) ) ))
|
||||
|
||||
#define _msgpack_load32(cast, from) ((cast)( \
|
||||
(((uint32_t)((uint8_t*)(from))[0]) << 24) | \
|
||||
(((uint32_t)((uint8_t*)(from))[1]) << 16) | \
|
||||
(((uint32_t)((uint8_t*)(from))[2]) << 8) | \
|
||||
(((uint32_t)((uint8_t*)(from))[3]) ) ))
|
||||
|
||||
#define _msgpack_load64(cast, from) ((cast)( \
|
||||
(((uint64_t)((uint8_t*)(from))[0]) << 56) | \
|
||||
(((uint64_t)((uint8_t*)(from))[1]) << 48) | \
|
||||
(((uint64_t)((uint8_t*)(from))[2]) << 40) | \
|
||||
(((uint64_t)((uint8_t*)(from))[3]) << 32) | \
|
||||
(((uint64_t)((uint8_t*)(from))[4]) << 24) | \
|
||||
(((uint64_t)((uint8_t*)(from))[5]) << 16) | \
|
||||
(((uint64_t)((uint8_t*)(from))[6]) << 8) | \
|
||||
(((uint64_t)((uint8_t*)(from))[7]) ) ))
|
||||
|
||||
#else
|
||||
|
||||
#define _msgpack_be16(x) (x)
|
||||
#define _msgpack_be32(x) (x)
|
||||
#define _msgpack_be64(x) (x)
|
||||
|
||||
#define _msgpack_load16(cast, from) ((cast)( \
|
||||
(((uint16_t)((uint8_t*)from)[1]) << 8) | \
|
||||
(((uint16_t)((uint8_t*)from)[0]) ) ))
|
||||
|
||||
#define _msgpack_load32(cast, from) ((cast)( \
|
||||
(((uint32_t)((uint8_t*)from)[3]) << 24) | \
|
||||
(((uint32_t)((uint8_t*)from)[2]) << 16) | \
|
||||
(((uint32_t)((uint8_t*)from)[1]) << 8) | \
|
||||
(((uint32_t)((uint8_t*)from)[0]) ) ))
|
||||
|
||||
#define _msgpack_load64(cast, from) ((cast)( \
|
||||
(((uint64_t)((uint8_t*)from)[7]) << 56) | \
|
||||
(((uint64_t)((uint8_t*)from)[6]) << 48) | \
|
||||
(((uint64_t)((uint8_t*)from)[5]) << 40) | \
|
||||
(((uint64_t)((uint8_t*)from)[4]) << 32) | \
|
||||
(((uint64_t)((uint8_t*)from)[3]) << 24) | \
|
||||
(((uint64_t)((uint8_t*)from)[2]) << 16) | \
|
||||
(((uint64_t)((uint8_t*)from)[1]) << 8) | \
|
||||
(((uint64_t)((uint8_t*)from)[0]) ) ))
|
||||
#endif
|
||||
|
||||
|
||||
@ -140,26 +181,14 @@ typedef unsigned int _msgpack_atomic_counter_t;
|
||||
#define _msgpack_store64(to, num) \
|
||||
do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
|
||||
|
||||
|
||||
#define _msgpack_load16(cast, from) ((cast)_msgpack_be16( \
|
||||
(((uint8_t*)from)[1] << 8) | ((uint8_t*)from)[0]))
|
||||
|
||||
#define _msgpack_load32(cast, from) ((cast)_msgpack_be32( \
|
||||
(((uint8_t*)from)[3] << 24) | \
|
||||
(((uint8_t*)from)[2] << 16) | \
|
||||
(((uint8_t*)from)[1] << 8) | \
|
||||
(((uint8_t*)from)[0] ) ))
|
||||
|
||||
#define _msgpack_load64(cast, from) ((cast)_msgpack_be64( \
|
||||
(((uint64_t)(((uint8_t*)from)[7])) << 56) | \
|
||||
(((uint64_t)(((uint8_t*)from)[6])) << 48) | \
|
||||
(((uint64_t)(((uint8_t*)from)[5])) << 40) | \
|
||||
(((uint64_t)(((uint8_t*)from)[4])) << 32) | \
|
||||
(((uint64_t)((uint8_t*)from)[3]) << 24) | \
|
||||
(((uint64_t)((uint8_t*)from)[2]) << 16) | \
|
||||
(((uint64_t)((uint8_t*)from)[1]) << 8) | \
|
||||
(((uint8_t*)from)[0] )))
|
||||
|
||||
/*
|
||||
#define _msgpack_load16(cast, from) \
|
||||
({ cast val; memcpy(&val, (char*)from, 2); _msgpack_be16(val); })
|
||||
#define _msgpack_load32(cast, from) \
|
||||
({ cast val; memcpy(&val, (char*)from, 4); _msgpack_be32(val); })
|
||||
#define _msgpack_load64(cast, from) \
|
||||
({ cast val; memcpy(&val, (char*)from, 8); _msgpack_be64(val); })
|
||||
*/
|
||||
|
||||
|
||||
#endif /* msgpack/sysdep.h */
|
||||
|
Loading…
x
Reference in New Issue
Block a user