1
/* gmp_errno, __gmp_exception -- exception handling and reporting.
3
Copyright 2000, 2001 Free Software Foundation, Inc.
5
This file is part of the GNU MP Library.
7
The GNU MP Library is free software; you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation; either version 2.1 of the License, or (at your
10
option) any later version.
12
The GNU MP Library is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15
License for more details.
17
You should have received a copy of the GNU Lesser General Public License
18
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20
MA 02111-1307, USA. */
29
/* The deliberate divide by zero triggers an exception on most systems. On
30
those where it doesn't, for example power and powerpc, use abort instead.
32
Enhancement: Perhaps raise(SIGFPE) (or the same with kill()) would be
33
better than abort. Perhaps it'd be possible to get the BSD style
34
FPE_INTDIV_TRAP parameter in there too. */
37
__gmp_exception (int error_bit)
39
gmp_errno |= error_bit;
40
__gmp_junk = 10 / __gmp_0;
45
/* These functions minimize the amount of code required in functions raising
46
exceptions. Since they're "noreturn" and don't take any parameters, a
47
test and call might even come out as a simple conditional jump. */
49
__gmp_sqrt_of_negative (void)
51
__gmp_exception (GMP_ERROR_SQRT_OF_NEGATIVE);
54
__gmp_divide_by_zero (void)
56
__gmp_exception (GMP_ERROR_DIVISION_BY_ZERO);