diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | errno.c | 17 |
2 files changed, 14 insertions, 7 deletions
@@ -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. @@ -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 (); } |