Skip to content

Commit 3edd3dc

Browse files
committed
Ported msgpack#962 to C++.
Improved alignment calculation logic.
1 parent 76f5af0 commit 3edd3dc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/msgpack/sysdep.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
typedef unsigned __int32 uint32_t;
2727
typedef signed __int64 int64_t;
2828
typedef unsigned __int64 uint64_t;
29+
# if defined(_WIN64)
30+
typedef signed __int64 intptr_t;
31+
typedef unsigned __int64 uintptr_t;
32+
# else
33+
typedef signed __int32 intptr_t;
34+
typedef unsigned __int32 uintptr_t;
35+
# endif
2936
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
3037
# include <stdint.h>
3138
#else

include/msgpack/v1/detail/cpp11_zone.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ inline char* zone::get_aligned(char* ptr, size_t align)
232232
{
233233
return
234234
reinterpret_cast<char*>(
235-
reinterpret_cast<size_t>(
236-
(ptr + (align - 1))) / align * align);
235+
reinterpret_cast<uintptr_t>(
236+
(ptr + (align - 1))) & ~static_cast<uintptr_t>(align - 1));
237237
}
238238

239239
inline void* zone::allocate_align(size_t size, size_t align)

0 commit comments

Comments
 (0)