Skip to content

Commit

Permalink
Merge pull request #962 from jrtc27/c-cheri
Browse files Browse the repository at this point in the history
Support building for CHERI/Morello
  • Loading branch information
redboltz authored Aug 17, 2021
2 parents 5d30e42 + 823caa8 commit 2ebe884
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cmake/sysdep.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
# if defined(_WIN64)
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
# else
typedef signed __int32 intptr_t;
typedef unsigned __int32 uintptr_t;
# endif
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
# include <stdint.h>
#else
Expand Down
6 changes: 3 additions & 3 deletions include/msgpack/zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size)
{
char* aligned =
(char*)(
(size_t)(
(uintptr_t)(
zone->chunk_list.ptr + (MSGPACK_ZONE_ALIGN - 1)
) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN
) & ~(uintptr_t)(MSGPACK_ZONE_ALIGN - 1)
);
size_t adjusted_size = size + (size_t)(aligned - zone->chunk_list.ptr);
if(zone->chunk_list.free >= adjusted_size) {
Expand All @@ -120,7 +120,7 @@ static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size)
{
void* ptr = msgpack_zone_malloc_expand(zone, size + (MSGPACK_ZONE_ALIGN - 1));
if (ptr) {
return (char*)((size_t)(ptr) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN);
return (char*)((uintptr_t)(ptr) & ~(uintptr_t)(MSGPACK_ZONE_ALIGN - 1));
}
}
return NULL;
Expand Down

0 comments on commit 2ebe884

Please sign in to comment.