From b6644658560c19d97f9b55aecfe938973803d46e Mon Sep 17 00:00:00 2001 From: Gengchen Tuo Date: Wed, 22 Nov 2023 10:31:42 -0500 Subject: [PATCH] Make omrsysinfo_get_CPU_load() return another error code on first call This is to help getSystemCpuLoad() determine if it's the first call. Related: https://github.com/eclipse-openj9/openj9/pull/18451 Signed-off-by: Gengchen Tuo --- include_core/omrporterror.h | 1 + port/common/omrsysinfo.c | 2 +- port/unix/omrsysinfo.c | 4 ++-- port/win32/omrsysinfo.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include_core/omrporterror.h b/include_core/omrporterror.h index feeeee5ba06..c5e8fb0ad34 100644 --- a/include_core/omrporterror.h +++ b/include_core/omrporterror.h @@ -67,6 +67,7 @@ #define OMRPORT_ERROR_INVALID_HANDLE (OMRPORT_ERROR_BASE-17) #define OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM (OMRPORT_ERROR_BASE-18) #define OMRPORT_ERROR_INVALID_ARGUMENTS (OMRPORT_ERROR_BASE-19) +#define OMRPORT_ERROR_INSUFFICIENT_DATA (OMRPORT_ERROR_BASE-20) /** @} */ /** diff --git a/port/common/omrsysinfo.c b/port/common/omrsysinfo.c index 02e1beda9c1..82c47d5a19c 100644 --- a/port/common/omrsysinfo.c +++ b/port/common/omrsysinfo.c @@ -652,7 +652,7 @@ omrsysinfo_get_CPU_utilization(struct OMRPortLibrary *portLibrary, struct J9Sysi * * @return * - 0 on success - * - \arg OMRPORT_ERROR_OPFAILED on the first two invocations of this API + * - \arg OMRPORT_ERROR_INSUFFICIENT_DATA on the first two invocations of this API * - \arg OMRPORT_ERROR_OPFAILED if less than 10ns have passed since the second call to this API * - negative portable error code on other failures */ diff --git a/port/unix/omrsysinfo.c b/port/unix/omrsysinfo.c index 2fa15bd651f..5b0832320a4 100644 --- a/port/unix/omrsysinfo.c +++ b/port/unix/omrsysinfo.c @@ -4642,7 +4642,7 @@ omrsysinfo_get_CPU_load(struct OMRPortLibrary *portLibrary, double *cpuLoad) if (oldestCPUTime->timestamp == 0) { *oldestCPUTime = currentCPUTime; *latestCPUTime = currentCPUTime; - return OMRPORT_ERROR_OPFAILED; + return OMRPORT_ERROR_INSUFFICIENT_DATA; } /* Calculate using the most recent value in the history */ @@ -4674,7 +4674,7 @@ omrsysinfo_get_CPU_load(struct OMRPortLibrary *portLibrary, double *cpuLoad) if (oldestCPUTime->timestamp == 0) { *oldestCPUTime = currentCPUTime; *latestCPUTime = currentCPUTime; - return OMRPORT_ERROR_OPFAILED; + return OMRPORT_ERROR_INSUFFICIENT_DATA; } /* Calculate using the most recent value in the history */ diff --git a/port/win32/omrsysinfo.c b/port/win32/omrsysinfo.c index fd81f8730f9..baf108f15ed 100644 --- a/port/win32/omrsysinfo.c +++ b/port/win32/omrsysinfo.c @@ -1271,7 +1271,7 @@ omrsysinfo_get_CPU_load(struct OMRPortLibrary *portLibrary, double *cpuLoad) if (oldestCPUTime->timestamp == 0) { *oldestCPUTime = currentCPUTime; *latestCPUTime = currentCPUTime; - return OMRPORT_ERROR_OPFAILED; + return OMRPORT_ERROR_INSUFFICIENT_DATA; } /* Calculate using the most recent value in the history */