CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/* gmp_errno, __gmp_exception -- exception handling and reporting.
2
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.
6
7
Copyright 2000, 2001, 2003 Free Software Foundation, Inc.
8
9
This file is part of the GNU MP Library.
10
11
The GNU MP Library is free software; you can redistribute it and/or modify
12
it under the terms of either:
13
14
* the GNU Lesser General Public License as published by the Free
15
Software Foundation; either version 3 of the License, or (at your
16
option) any later version.
17
18
or
19
20
* the GNU General Public License as published by the Free Software
21
Foundation; either version 2 of the License, or (at your option) any
22
later version.
23
24
or both in parallel, as here.
25
26
The GNU MP Library is distributed in the hope that it will be useful, but
27
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
28
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29
for more details.
30
31
You should have received copies of the GNU General Public License and the
32
GNU Lesser General Public License along with the GNU MP Library. If not,
33
see https://www.gnu.org/licenses/. */
34
35
#include <stdlib.h>
36
#include "gmp.h"
37
#include "gmp-impl.h"
38
39
int gmp_errno = 0;
40
41
42
/* The deliberate divide by zero triggers an exception on most systems. On
43
those where it doesn't, for example power and powerpc, use abort instead.
44
45
Enhancement: Perhaps raise(SIGFPE) (or the same with kill()) would be
46
better than abort. Perhaps it'd be possible to get the BSD style
47
FPE_INTDIV_TRAP parameter in there too. */
48
49
void
50
__gmp_exception (int error_bit)
51
{
52
gmp_errno |= error_bit;
53
__gmp_junk = 10 / __gmp_0;
54
abort ();
55
}
56
57
58
/* These functions minimize the amount of code required in functions raising
59
exceptions. Since they're "noreturn" and don't take any parameters, a
60
test and call might even come out as a simple conditional jump. */
61
void
62
__gmp_sqrt_of_negative (void)
63
{
64
__gmp_exception (GMP_ERROR_SQRT_OF_NEGATIVE);
65
}
66
void
67
__gmp_divide_by_zero (void)
68
{
69
__gmp_exception (GMP_ERROR_DIVISION_BY_ZERO);
70
}
71
72