diff options
Diffstat (limited to 'errno.c')
-rw-r--r-- | errno.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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 (); } |