RFR: 8357086: os::xxx functions returning memory size should return size_t [v3]
David Holmes
dholmes at openjdk.org
Thu May 29 06:39:50 UTC 2025
On Wed, 28 May 2025 12:41:44 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
> I talked to Anton offline about the ptrdiff_t. That type has the correct signedness and number of bits on all our platforms, but to me that type carries a semantic meaning about what pointer diffs / indices. Because of that I found it inappropriate to use that type.
Those were my thoughts as well when I saw that change made. I don't have a good answer either. It is not at all clear how/why the swap functions were allowed to report errors when none of the others do. It is not documented in os.hpp nor required by the `OperatingSystemMXBean` API!
> we have paths through the container code that returns -2
I couldn't spot these - do you have a link please? It is annoying this prevents use of `ssize_t`.
> An alternative could be to let these functions return a compound value [size_t size, int error_code],
Or, as is done in other code, use an out-parameter e.g:
// Returns the amount of free swap. If an error occurs then `rc` is set to a negative value
// and we return zero.; otherwise `rc` is set to zero.
static size_t free_swap_space(int& rc);
?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25450#issuecomment-2918462323
More information about the hotspot-dev
mailing list