JDK using gettimeofday and not clock_gettime?
david.holmes at oracle.com
Fri Jul 23 13:40:21 UTC 2021
On 23/07/2021 10:16 pm, Rohit Mohta wrote:
> While developing an in-house tool on system time related manipulation, we
> learnt Java uses gettimeofday() on linux-x86_64 system call for fetching
It doesn't in the latest release. Historically we had issues with
clock_gettime being available at runtime so we used gettimeofday() when
necessary. That eventually got cleaned up and we assume clock_gettime is
always available on supported build and runtime platforms. I'm not sure
if this was fixed for 16 or 17 ... but not backported to 11u.
> I was wondering if we thought of using clock_gettime() system call on
> Linux? Or if there are plans to update them to align with the POSIX
> recommendation. From what I can see Golang, Rust are using clock_gettime().
> int status = gettimeofday(&time, NULL);
> Per https://man7.org/linux/man-pages/man2/settimeofday.2.html
> POSIX.1-2008 marks *gettimeofday*() as obsolete,
>> recommending the use of clock_gettime(2)
>> <https://man7.org/linux/man-pages/man2/clock_gettime.2.html> instead
More information about the jdk-dev