8294594: Fix cast-function-type warnings in signal handling code

Reviewed-by: dholmes, kbarrett
This commit is contained in:
Aleksey Shipilev 2022-10-18 08:45:28 +00:00
parent 71aa821091
commit b06f1b149c
4 changed files with 8 additions and 10 deletions

View File

@ -102,7 +102,6 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBJVM, \
CFLAGS_macosx := -DGTEST_OS_MAC=1, \
DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc) \
undef stringop-overflow, \
DISABLED_WARNINGS_gcc_test_signals.cpp := cast-function-type, \
DISABLED_WARNINGS_gcc_test_threadCpuLoad.cpp := address, \
DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang) \
undef switch format-nonliteral tautological-undefined-compare \

View File

@ -173,7 +173,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1_riscv.cpp := misleading-indentation, \
DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1_x86.cpp := misleading-indentation, \
DISABLED_WARNINGS_gcc_shenandoahBarrierSetC1.cpp := misleading-indentation, \
DISABLED_WARNINGS_gcc_signals_posix.cpp := cast-function-type, \
DISABLED_WARNINGS_gcc_templateTable.cpp := cast-function-type, \
DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \
DISABLED_WARNINGS_clang_arguments.cpp := missing-field-initializers, \

View File

@ -795,7 +795,7 @@ static address get_signal_handler(const struct sigaction* action) {
typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *);
static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context);
static void SR_handler(int sig, siginfo_t* siginfo, void* ucVoid);
// Semantically compare two sigaction structures. Return true if they are referring to
// the same handler, using the same flags.
@ -1597,8 +1597,8 @@ static void resume_clear_context(OSThread *osthread) {
osthread->set_siginfo(NULL);
}
static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontext_t* context) {
osthread->set_ucontext(context);
static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, void* ucVoid) {
osthread->set_ucontext((ucontext_t*)ucVoid);
osthread->set_siginfo(siginfo);
}
@ -1615,7 +1615,7 @@ static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontex
//
// Currently only ever called on the VMThread and JavaThreads (PC sampling)
//
static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
static void SR_handler(int sig, siginfo_t* siginfo, void* ucVoid) {
// Save and restore errno to avoid confusing native code with EINTR
// after sigsuspend.
@ -1658,7 +1658,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
SuspendResume::State current = osthread->sr.state();
if (current == SuspendResume::SR_SUSPEND_REQUEST) {
suspend_save_context(osthread, siginfo, context);
suspend_save_context(osthread, siginfo, ucVoid);
// attempt to switch the state, we assume we had a SUSPEND_REQUEST
SuspendResume::State state = osthread->sr.suspended();
@ -1724,7 +1724,7 @@ int SR_initialize() {
// Set up signal handler for suspend/resume
act.sa_flags = SA_RESTART|SA_SIGINFO;
act.sa_handler = (void (*)(int)) SR_handler;
act.sa_sigaction = SR_handler;
// SR_signum is blocked when the handler runs.
pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);

View File

@ -34,7 +34,7 @@
#include <string.h>
extern "C" {
static void sig_handler(int sig, siginfo_t *info, ucontext_t *context) {
static void sig_handler(int sig) {
printf( " HANDLER (1) " );
}
}
@ -44,7 +44,7 @@ class PosixSignalTest : public ::testing::Test {
static void check_handlers() {
struct sigaction act, old_SIGFPE_act, old_SIGILL_act;
act.sa_handler = (void (*)(int))sig_handler;
act.sa_handler = sig_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
ASSERT_NE(sigaction(SIGFPE, &act, &old_SIGFPE_act), -1) << "Setting SIGFPE handler failed: " << os::strerror(errno) << " (" << errno << ")";