From 467c28b2d3c2bc209ed227e8947bb0b48f91ad00 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Fri, 10 Jun 2022 15:18:27 +0100 Subject: [PATCH] Add buffer append method for {,u}intptr_t Otherwise, on platforms for which {,u}intptr_t aren't just typedef-s of other scalar types, it's ambiguous which way an implicit cast should go. --- src/snmalloc/ds_core/helpers.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/snmalloc/ds_core/helpers.h b/src/snmalloc/ds_core/helpers.h index 693b734..7b2cca2 100644 --- a/src/snmalloc/ds_core/helpers.h +++ b/src/snmalloc/ds_core/helpers.h @@ -279,6 +279,30 @@ namespace snmalloc } } + /* + * TODO: This is not quite the right thing we want to check, but it + * suffices on all currently-supported platforms and CHERI. We'd rather + * compare UINTPTR_WIDTH and ULLONG_WIDTH, I think, but those don't + * exist until C's FP Ext 1 TS (merged into C2x). + */ +#ifdef __CHERI_PURE_CAPABILITY__ + /** + * Append an intptr_t to the buffer as a hex string + */ + void append(intptr_t v) + { + append(reinterpret_cast(v)); + } + + /** + * Append a uintptr_t to the buffer as a hex string + */ + void append(uintptr_t v) + { + append(reinterpret_cast(v)); + } +#endif + /** * Append a raw pointer to the buffer as a hex string. */