Skip to content

Commit 467c28b

Browse files
committed
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.
1 parent c560a9a commit 467c28b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/snmalloc/ds_core/helpers.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,30 @@ namespace snmalloc
279279
}
280280
}
281281

282+
/*
283+
* TODO: This is not quite the right thing we want to check, but it
284+
* suffices on all currently-supported platforms and CHERI. We'd rather
285+
* compare UINTPTR_WIDTH and ULLONG_WIDTH, I think, but those don't
286+
* exist until C's FP Ext 1 TS (merged into C2x).
287+
*/
288+
#ifdef __CHERI_PURE_CAPABILITY__
289+
/**
290+
* Append an intptr_t to the buffer as a hex string
291+
*/
292+
void append(intptr_t v)
293+
{
294+
append(reinterpret_cast<void*>(v));
295+
}
296+
297+
/**
298+
* Append a uintptr_t to the buffer as a hex string
299+
*/
300+
void append(uintptr_t v)
301+
{
302+
append(reinterpret_cast<void*>(v));
303+
}
304+
#endif
305+
282306
/**
283307
* Append a raw pointer to the buffer as a hex string.
284308
*/

0 commit comments

Comments
 (0)