mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Delete unnecessary test for sa_sigaction field.
configure.ac:
Delete check for sa_sigaction field. If a call to sigaction()
has the SA_SIGINFO flag set then the handler must be specified in
the sa_sigaction field, not the sa_handler field.
runtime/mercury_conf.h.in:
Delete MR_SIGACTION_FIELD macro.
runtime/mercury_signal.c:
Don't use MR_SIGACTION_FIELD macro.
Don't define dummy value for SA_SIGINFO.
tools/configure_mingw_cross:
Don't set now-unused variable.
This commit is contained in:
70
configure.ac
70
configure.ac
@@ -2,7 +2,7 @@
|
||||
# vim: ts=4 sw=4 expandtab
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Copyright (C) 1995-2012 The University of Melbourne.
|
||||
# Copyright (C) 2013-2018 The Mercury team.
|
||||
# Copyright (C) 2013-2020 The Mercury team.
|
||||
# This file may only be copied under the terms of the GNU General
|
||||
# Public Licence - see the file COPYING in the Mercury distribution.
|
||||
#-----------------------------------------------------------------------------#
|
||||
@@ -1529,63 +1529,12 @@ AC_SUBST(HAVE_GETOPT)
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
#
|
||||
# Check the basics of sigaction
|
||||
# Check the basics of SA_SIGINFO and siginfo_t
|
||||
#
|
||||
|
||||
if test "$ac_cv_func_sigaction" = yes; then
|
||||
AC_MSG_CHECKING(for \`sigaction' field name)
|
||||
AC_CACHE_VAL(mercury_cv_sigaction_field,
|
||||
AC_TRY_RUN(
|
||||
[
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FAULT_ADDRESS ((int *)112)
|
||||
|
||||
extern void handler(int signum, siginfo_t *info, void *context);
|
||||
|
||||
int main() {
|
||||
struct sigaction act;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.sa_sigaction = handler;
|
||||
if (sigemptyset(&act.sa_mask) != 0)
|
||||
exit(1);
|
||||
if (sigaction(SIGSEGV, &act, NULL) != 0)
|
||||
exit(1);
|
||||
/* provoke a SIGSEGV */
|
||||
(*FAULT_ADDRESS)++;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void handler(int signum, siginfo_t *info, void *context) {
|
||||
if (signum == SIGSEGV &&
|
||||
info->si_signo == SIGSEGV &&
|
||||
info->si_code > 0 &&
|
||||
(int *)info->si_addr == FAULT_ADDRESS)
|
||||
{
|
||||
exit(0);
|
||||
} else {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
],
|
||||
[mercury_cv_sigaction_field=sa_sigaction],
|
||||
[mercury_cv_sigaction_field=sa_handler]))
|
||||
AC_MSG_RESULT($mercury_cv_sigaction_field)
|
||||
AC_DEFINE_UNQUOTED(MR_SIGACTION_FIELD,$mercury_cv_sigaction_field)
|
||||
if test "$mercury_cv_sigaction_field" = sa_sigaction; then
|
||||
AC_DEFINE([MR_HAVE_SIGINFO])
|
||||
fi
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
#
|
||||
# Check the basics of siginfo_t
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING(for \`siginfo_t')
|
||||
AC_MSG_CHECKING(for SA_SIGINFO and siginfo_t)
|
||||
AC_CACHE_VAL(mercury_cv_siginfo_t,
|
||||
mercury_cv_siginfo_t=no
|
||||
AC_TRY_RUN(
|
||||
[
|
||||
#include <stdio.h>
|
||||
@@ -1609,7 +1558,7 @@ AC_TRY_RUN(
|
||||
int main() {
|
||||
struct sigaction act;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.$mercury_cv_sigaction_field = handler;
|
||||
act.sa_sigaction = handler;
|
||||
if (sigemptyset(&act.sa_mask) != 0)
|
||||
exit(1);
|
||||
if (sigaction(SIGSEGV, &act, NULL) != 0)
|
||||
@@ -1626,8 +1575,11 @@ AC_TRY_RUN(
|
||||
}
|
||||
],
|
||||
[mercury_cv_siginfo_t=yes],
|
||||
[true]))
|
||||
[mercury_cv_siginfo_t=no]))
|
||||
AC_MSG_RESULT($mercury_cv_siginfo_t)
|
||||
else
|
||||
mercury_cv_siginfo_t=no
|
||||
fi
|
||||
if test "$mercury_cv_siginfo_t" = yes; then
|
||||
AC_DEFINE(MR_HAVE_SIGINFO_T)
|
||||
AC_DEFINE(MR_HAVE_SIGINFO)
|
||||
@@ -1654,7 +1606,7 @@ if test "$mercury_cv_siginfo_t" = yes; then
|
||||
int main() {
|
||||
struct sigaction act;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.$mercury_cv_sigaction_field = handler;
|
||||
act.sa_sigaction = handler;
|
||||
if (sigemptyset(&act.sa_mask) != 0)
|
||||
exit(1);
|
||||
if (sigaction(SIGSEGV, &act, NULL) != 0)
|
||||
@@ -1695,7 +1647,7 @@ if test "$mercury_cv_siginfo_t" = yes; then
|
||||
int main() {
|
||||
struct sigaction act;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.$mercury_cv_sigaction_field = handler;
|
||||
act.sa_sigaction = handler;
|
||||
if (sigemptyset(&act.sa_mask) != 0)
|
||||
exit(1);
|
||||
if (sigaction(SIGSEGV, &act, NULL) != 0)
|
||||
@@ -1734,7 +1686,7 @@ if test "$mercury_cv_siginfo_t" = yes; then
|
||||
int main() {
|
||||
struct sigaction act;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.$mercury_cv_sigaction_field = handler;
|
||||
act.sa_sigaction = handler;
|
||||
if (sigemptyset(&act.sa_mask) != 0)
|
||||
exit(1);
|
||||
if (sigaction(SIGSEGV, &act, NULL) != 0)
|
||||
|
||||
@@ -410,12 +410,6 @@
|
||||
#undef MR_PC_ACCESS
|
||||
#undef MR_PC_ACCESS_GREG
|
||||
|
||||
// MR_SIGACTION_FIELD: the name of the field in the sigaction struct
|
||||
// (either sa_handler or sa_sigaction). Defined only if MR_HAVE_SIGACTION
|
||||
// is defined.
|
||||
|
||||
#undef MR_SIGACTION_FIELD
|
||||
|
||||
// Configuration parameters for multithreaded execution support.
|
||||
//
|
||||
// MR_THREAD_LOCAL_STORAGE is defined if the thread-local storage extension
|
||||
|
||||
@@ -39,18 +39,13 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// If we don't have SA_RESTART or SA_SIGINFO, defined them as 0.
|
||||
// It would be nice to have them, but it is still better to use
|
||||
// sigaction without SA_RESTART or SA_SIGINFO than to use signal.
|
||||
// If we don't have SA_RESTART define it as 0. It is still better to use
|
||||
// sigaction without SA_RESTART than to use signal.
|
||||
|
||||
#if !defined(SA_RESTART)
|
||||
#define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
#if !defined(SA_SIGINFO)
|
||||
#define SA_SIGINFO 0
|
||||
#endif
|
||||
|
||||
static void MR_do_setup_signal(int sig, MR_Code *handler, MR_bool need_info,
|
||||
MR_bool restart, const char *error_message);
|
||||
|
||||
@@ -109,7 +104,16 @@ MR_init_signal_action(MR_signal_action *act, MR_Code *handler,
|
||||
if (need_info) {
|
||||
#ifdef MR_HAVE_SIGINFO_T
|
||||
act->sa_flags |= SA_SIGINFO;
|
||||
act->sa_sigaction = handler;
|
||||
#else
|
||||
// This branch should be unreachable in practice.
|
||||
// The caller must check that MR_HAVE_SIGINFO_T is defined
|
||||
// before calling this function with need_info=TRUE,
|
||||
// otherwise the handler will have the wrong type.
|
||||
act->sa_handler = handler;
|
||||
#endif
|
||||
} else {
|
||||
act->sa_handler = handler;
|
||||
}
|
||||
|
||||
if (sigemptyset(&(act->sa_mask)) != 0) {
|
||||
@@ -118,8 +122,6 @@ MR_init_signal_action(MR_signal_action *act, MR_Code *handler,
|
||||
}
|
||||
errno = 0;
|
||||
|
||||
act->MR_SIGACTION_FIELD = handler;
|
||||
|
||||
#else // not MR_HAVE_SIGACTION
|
||||
|
||||
*act = handler;
|
||||
|
||||
@@ -66,7 +66,6 @@ fi
|
||||
# Taken from the config.cache file after running configure -C in msys.
|
||||
|
||||
mercury_cv_cc_type=gcc \
|
||||
mercury_cv_sigaction_field=no \
|
||||
mercury_cv_siginfo_t=no \
|
||||
mercury_cv_is_bigender=no \
|
||||
mercury_cv_is_littleender=yes \
|
||||
|
||||
Reference in New Issue
Block a user