Skip to content

Commit 2ebe884

Browse files
authored
Merge pull request #962 from jrtc27/c-cheri
Support building for CHERI/Morello
2 parents 5d30e42 + 823caa8 commit 2ebe884

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cmake/sysdep.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
typedef unsigned __int32 uint32_t;
3434
typedef signed __int64 int64_t;
3535
typedef unsigned __int64 uint64_t;
36+
# if defined(_WIN64)
37+
typedef signed __int64 intptr_t;
38+
typedef unsigned __int64 uintptr_t;
39+
# else
40+
typedef signed __int32 intptr_t;
41+
typedef unsigned __int32 uintptr_t;
42+
# endif
3643
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
3744
# include <stdint.h>
3845
#else

include/msgpack/zone.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size)
107107
{
108108
char* aligned =
109109
(char*)(
110-
(size_t)(
110+
(uintptr_t)(
111111
zone->chunk_list.ptr + (MSGPACK_ZONE_ALIGN - 1)
112-
) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN
112+
) & ~(uintptr_t)(MSGPACK_ZONE_ALIGN - 1)
113113
);
114114
size_t adjusted_size = size + (size_t)(aligned - zone->chunk_list.ptr);
115115
if(zone->chunk_list.free >= adjusted_size) {
@@ -120,7 +120,7 @@ static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size)
120120
{
121121
void* ptr = msgpack_zone_malloc_expand(zone, size + (MSGPACK_ZONE_ALIGN - 1));
122122
if (ptr) {
123-
return (char*)((size_t)(ptr) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN);
123+
return (char*)((uintptr_t)(ptr) & ~(uintptr_t)(MSGPACK_ZONE_ALIGN - 1));
124124
}
125125
}
126126
return NULL;

0 commit comments

Comments
 (0)