source: trunk/third/gmp/errno.c @ 18191

Revision 18191, 1.8 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18190, which included commits to RCS files with non-trunk default branches.
RevLine 
[18190]1/* gmp_errno, __gmp_exception -- exception handling and reporting.
[15293]2
[18190]3Copyright 2000, 2001 Free Software Foundation, Inc.
[15293]4
5This file is part of the GNU MP Library.
6
7The GNU MP Library is free software; you can redistribute it and/or modify
8it under the terms of the GNU Lesser General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or (at your
10option) any later version.
11
12The GNU MP Library is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15License for more details.
16
17You should have received a copy of the GNU Lesser General Public License
18along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
19the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20MA 02111-1307, USA. */
21
[18190]22#include <stdlib.h>
[15293]23#include "gmp.h"
24#include "gmp-impl.h"
25
26int gmp_errno = 0;
[18190]27
28
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.
31
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.  */
35
36void
37__gmp_exception (int error_bit)
38{
39  gmp_errno |= error_bit;
40  __gmp_junk = 10 / __gmp_0;
41  abort ();
42}
43
44
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.  */
48void
49__gmp_sqrt_of_negative (void)
50{
51  __gmp_exception (GMP_ERROR_SQRT_OF_NEGATIVE);
52}
53void
54__gmp_divide_by_zero (void)
55{
56  __gmp_exception (GMP_ERROR_DIVISION_BY_ZERO);
57}
Note: See TracBrowser for help on using the repository browser.