diff --git a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp index 609967128fb..afa17e0ade8 100644 --- a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp +++ b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp @@ -56,15 +56,6 @@ enum membarrier_cmd { MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = (1 << 4), }; -#define check_with_errno(check_type, cond, msg) \ - do { \ - int err = errno; \ - check_type(cond, "%s: error='%s' (errno=%s)", msg, os::strerror(err), \ - os::errno_name(err)); \ -} while (false) - -#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) - static int membarrier(int cmd, unsigned int flags, int cpu_id) { return syscall(SYS_membarrier, cmd, flags, cpu_id); // cpu_id only on >= 5.10 } diff --git a/src/hotspot/os/linux/waitBarrier_linux.cpp b/src/hotspot/os/linux/waitBarrier_linux.cpp index 0399f7b7a44..de36dd60e49 100644 --- a/src/hotspot/os/linux/waitBarrier_linux.cpp +++ b/src/hotspot/os/linux/waitBarrier_linux.cpp @@ -25,19 +25,11 @@ #include "precompiled.hpp" #include "runtime/orderAccess.hpp" #include "runtime/os.hpp" +#include "utilities/debug.hpp" #include "waitBarrier_linux.hpp" #include #include -#define check_with_errno(check_type, cond, msg) \ - do { \ - int err = errno; \ - check_type(cond, "%s: error='%s' (errno=%s)", msg, os::strerror(err), \ - os::errno_name(err)); \ -} while (false) - -#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) - // 32-bit RISC-V has no SYS_futex syscall. #ifdef RISCV32 #if !defined(SYS_futex) && defined(SYS_futex_time64) diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 893ca3a7b73..74929c982a6 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -42,6 +42,7 @@ #include "runtime/park.hpp" #include "runtime/perfMemory.hpp" #include "utilities/align.hpp" +#include "utilities/debug.hpp" #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" #include "utilities/formatBuffer.hpp" @@ -86,16 +87,6 @@ #define MAP_ANONYMOUS MAP_ANON #endif -#define check_with_errno(check_type, cond, msg) \ - do { \ - int err = errno; \ - check_type(cond, "%s; error='%s' (errno=%s)", msg, os::strerror(err), \ - os::errno_name(err)); \ -} while (false) - -#define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg) -#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) - static jlong initial_time_count = 0; static int clock_tics_per_sec = 100; diff --git a/src/hotspot/os/posix/semaphore_posix.cpp b/src/hotspot/os/posix/semaphore_posix.cpp index f0caaaafb06..625abdf335b 100644 --- a/src/hotspot/os/posix/semaphore_posix.cpp +++ b/src/hotspot/os/posix/semaphore_posix.cpp @@ -26,20 +26,11 @@ #ifndef __APPLE__ #include "os_posix.hpp" #include "runtime/os.hpp" +#include "utilities/debug.hpp" // POSIX unnamed semaphores are not supported on OS X. #include "semaphore_posix.hpp" #include -#define check_with_errno(check_type, cond, msg) \ - do { \ - int err = errno; \ - check_type(cond, "%s; error='%s' (errno=%s)", msg, os::strerror(err), \ - os::errno_name(err)); \ -} while (false) - -#define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg) -#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) - PosixSemaphore::PosixSemaphore(uint value) { int ret = sem_init(&_semaphore, 0, value); diff --git a/src/hotspot/share/utilities/debug.hpp b/src/hotspot/share/utilities/debug.hpp index 65051a24d7d..baa3013c059 100644 --- a/src/hotspot/share/utilities/debug.hpp +++ b/src/hotspot/share/utilities/debug.hpp @@ -209,6 +209,16 @@ do { report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, __VA_ARGS__); \ } while (0) +#define check_with_errno(check_type, cond, msg) \ + do { \ + int err = errno; \ + check_type(cond, "%s; error='%s' (errno=%s)", msg, os::strerror(err), \ + os::errno_name(err)); \ +} while (false) + +#define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg) +#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) + #define ShouldNotCallThis() \ do { \ TOUCH_ASSERT_POISON; \