Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/libs/pari/pari_err.h
4084 views
1
#include <pari/pari.h>
2
#include "interrupt.h"
3
4
5
// global catch variable !
6
// this means that the code is not reentrant -- beware !
7
// THAT MEANS NO CALLING TO PARI from inside the trap....
8
// Should replace by a stack, that would work.
9
static long __catcherr = 0;
10
11
#define _pari_raise(errno) { \
12
PyErr_SetObject(PyExc_PariError, PyInt_FromLong(errno)); \
13
}
14
15
#define _pari_endcatch { err_leave(__catcherr); }
16
17
/* Careful with pari_retries !
18
* It should not be in a register, we flag it as "volatile".
19
*/
20
#define _pari_catch { \
21
long pari_errno; \
22
long volatile pari_retries = 0; \
23
jmp_buf __env; \
24
__catcherr = 0; \
25
if ((pari_errno=setjmp(__env))) { \
26
_pari_trap(pari_errno, pari_retries); \
27
if(PyErr_Occurred()) { \
28
_pari_endcatch; \
29
return NULL; \
30
} \
31
pari_retries++; \
32
} \
33
__catcherr = err_catch(CATCH_ALL, &__env); \
34
}
35
36