kernel - CAM cleanup 1/N - Remove ancient scsi pccard drivers ncv, nsp, stg
[dragonfly.git] / contrib / gmp / errno.c
blobe5e160dbe2f3026df01ac13f9291293553647513
1 /* gmp_errno, __gmp_exception -- exception handling and reporting.
3 THE FUNCTIONS IN THIS FILE, APART FROM gmp_errno, ARE FOR INTERNAL USE
4 ONLY. THEY'RE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR
5 DISAPPEAR COMPLETELY IN FUTURE GNU MP RELEASES.
7 Copyright 2000, 2001, 2003 Free Software Foundation, Inc.
9 This file is part of the GNU MP Library.
11 The GNU MP Library is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 The GNU MP Library is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 License for more details.
21 You should have received a copy of the GNU Lesser General Public License
22 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
24 #include <stdlib.h>
25 #include "gmp.h"
26 #include "gmp-impl.h"
28 int gmp_errno = 0;
31 /* The deliberate divide by zero triggers an exception on most systems. On
32 those where it doesn't, for example power and powerpc, use abort instead.
34 Enhancement: Perhaps raise(SIGFPE) (or the same with kill()) would be
35 better than abort. Perhaps it'd be possible to get the BSD style
36 FPE_INTDIV_TRAP parameter in there too. */
38 void
39 __gmp_exception (int error_bit)
41 gmp_errno |= error_bit;
42 __gmp_junk = 10 / __gmp_0;
43 abort ();
47 /* These functions minimize the amount of code required in functions raising
48 exceptions. Since they're "noreturn" and don't take any parameters, a
49 test and call might even come out as a simple conditional jump. */
50 void
51 __gmp_sqrt_of_negative (void)
53 __gmp_exception (GMP_ERROR_SQRT_OF_NEGATIVE);
55 void
56 __gmp_divide_by_zero (void)
58 __gmp_exception (GMP_ERROR_DIVISION_BY_ZERO);