RFR: 8354811: clock_tics_per_sec code duplication between os_linux and os_posix

Lutz Schmidt lucy at openjdk.org
Fri Apr 25 11:16:00 UTC 2025


On Thu, 17 Apr 2025 11:23:28 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> Seems some of the clock_tics_per_sec code can be unified (e.g. in os_posix) between os_linux and os_posix.

Changes requested by lucy (Reviewer).

src/hotspot/os/linux/os_linux.cpp line 5133:

> 5131:                  &user_time, &sys_time);
> 5132:   if (count != 13) return -1;
> 5133:   double clock_tics_factor = 1000000000 / os::Posix::clock_tics_per_second();

Why use `double` here? The right hand side is an `int` expression and the use of `clock_ticks_factor` below is in a `jlong` expression yielding a `jlong` function result. If you want to avoid integer rounding, you have to cast at least one res operand to `double`.

-------------

PR Review: https://git.openjdk.org/jdk/pull/24720#pullrequestreview-2793778190
PR Review Comment: https://git.openjdk.org/jdk/pull/24720#discussion_r2060038774


More information about the hotspot-runtime-dev mailing list