summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--errno.c17
2 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 3a22a7e03..6e43ed912 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-27 Niels Möller <nisse@lysator.liu.se>
+
+ * errno.c (__gmp_exception): Use raise(SIGFPE) when available.
+
2016-01-15 Torbjörn Granlund <torbjorng@google.com>
* config.guess (s390): Don't assume /proc/cpuinfo exists.
diff --git a/errno.c b/errno.c
index d3c02ef4b..c82e8277b 100644
--- a/errno.c
+++ b/errno.c
@@ -33,24 +33,27 @@ GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdlib.h>
+
+#include <signal.h>
+
#include "gmp.h"
#include "gmp-impl.h"
int gmp_errno = 0;
-/* The deliberate divide by zero triggers an exception on most systems. On
- those where it doesn't, for example power and powerpc, use abort instead.
-
- Enhancement: Perhaps raise(SIGFPE) (or the same with kill()) would be
- better than abort. Perhaps it'd be possible to get the BSD style
- FPE_INTDIV_TRAP parameter in there too. */
-
+/* Use SIGFPE on systems which have it. Otherwise, deliberate divide
+ by zero, which triggers an exception on most systems. On those
+ where it doesn't, for example power and powerpc, use abort instead. */
void
__gmp_exception (int error_bit)
{
gmp_errno |= error_bit;
+#ifdef SIGFPE
+ raise (SIGFPE);
+#else
__gmp_junk = 10 / __gmp_0;
+#endif
abort ();
}