From 62a8d400ce448f1ab8557735c65526068783f7be Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Thu, 14 Jan 2021 00:52:53 +0700 Subject: [PATCH] Use sig_atomic_t for FP_error when using FP exceptions. (#220) `sig_atomic_t` is usually `int`, but is the typedef that one should use for flags written to from a signal handler. --- inc/medleyfp.h | 3 ++- src/timer.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/medleyfp.h b/inc/medleyfp.h index e2d162f..295e912 100644 --- a/inc/medleyfp.h +++ b/inc/medleyfp.h @@ -27,7 +27,8 @@ -------------------------------------------------- */ #ifdef FLTINT -volatile extern int FP_error; +#include +extern volatile sig_atomic_t FP_error; /* Note that a compiler may very likely move code around the arithmetic operation, causing this test (set by an interrupt handler) to be diff --git a/src/timer.c b/src/timer.c index d1bdd5a..2592f51 100644 --- a/src/timer.c +++ b/src/timer.c @@ -644,7 +644,7 @@ void int_unblock() { /************************************************************************/ /* The global used to signal floating-point errors */ -volatile int FP_error = 0; +volatile sig_atomic_t FP_error = 0; void int_fp_service(int sig, siginfo_t *info, void *context) {