RFR: 8292981: Unify and restructure integer printing format specifiers [v2]
Stefan Karlsson
stefank at openjdk.org
Mon Aug 29 08:24:10 UTC 2022
On Mon, 29 Aug 2022 07:40:40 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
> (And yes we have to cast the ptrs to int using p2i but that is just because of compiler limitations/issues ... which raises the recurring old question of "have we finally reached a point where we can use %p cross-platform?")
One motivation for using PTR_FORMAT instead of %p, is to get consistent output on all platforms. I ran the following on different OSes:
tty->print_cr("%p " PTR_FORMAT, (void*)0x12345678, (uintptr_t)0x12345678);
And the result is:
Linux: 0x12345678 0x0000000012345678
macOS: 0x12345678 0x0000000012345678
Win: 0x0000000012345678 0x0000000012345678
I also tested getting zero padding on Linux, but the compiler informs me that that's not allowed: `error: '0' flag used with '%p' gnu_printf format"`.
-------------
PR: https://git.openjdk.org/jdk/pull/10042
More information about the hotspot-dev
mailing list