Skip to content

Commit

Permalink
Add buffer append method for {,u}intptr_t
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nwf-msr committed Jun 21, 2022
1 parent c560a9a commit 467c28b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/snmalloc/ds_core/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(v));
}

/**
* Append a uintptr_t to the buffer as a hex string
*/
void append(uintptr_t v)
{
append(reinterpret_cast<void*>(v));
}
#endif

/**
* Append a raw pointer to the buffer as a hex string.
*/
Expand Down

0 comments on commit 467c28b

Please sign in to comment.