8347267: [macOS]: UnixOperatingSystem.c:67:40: runtime error: division by zero

Reviewed-by: kevinw, cjplummer
This commit is contained in:
Matthias Baesken 2025-01-10 10:02:24 +00:00
parent 55c6904e8f
commit 5e92a4ceaf

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,6 +63,9 @@ Java_com_sun_management_internal_OperatingSystemImpl_getCpuLoad0
jlong used_delta = used - last_used;
jlong total_delta = total - last_total;
if (total_delta == 0) {
return 0;
}
jdouble cpu = (jdouble) used_delta / total_delta;