8311145: Remove check_with_errno duplicates

Reviewed-by: rehn, stuefe
This commit is contained in:
Daohan Qu 2023-07-01 08:45:24 +00:00 committed by Thomas Stuefe
parent 8abb9f590f
commit 09a4924015
5 changed files with 13 additions and 38 deletions

View File

@ -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
}

View File

@ -25,19 +25,11 @@
#include "precompiled.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "waitBarrier_linux.hpp"
#include <sys/syscall.h>
#include <linux/futex.h>
#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)

View File

@ -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;

View File

@ -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 <semaphore.h>
#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);

View File

@ -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; \