aboutsummaryrefslogtreecommitdiff
path: root/ic-reals-6.3/math-lib/init.c
blob: be3e6ecf6fe80b26eb139c4e00b1d7ee8655544d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * Copyright (C) 2000, Imperial College
 *
 * This file is part of the Imperial College Exact Real Arithmetic Library.
 * See the copyright notice included in the distribution for conditions
 * of use.
 */

#include <stdio.h>
#include "real.h"
#include "real-impl.h"
#include "math-lib.h"

/*
 * Temporary storage for use in the math library
 */
mpz_t tmpw_z, tmpx_z, tmpy_z, tmpz_z;

Real E;

void
initReals()
{
	void initRealBase();
	void stdTensorCont();
	void failCls();

	initRealBase();

	mpz_init(tmpw_z);
	mpz_init(tmpx_z);
	mpz_init(tmpy_z);
	mpz_init(tmpz_z);

	registerForceFunc(stdTensorCont, "stdTensorCont", 2);
	registerForceFunc(failCls, "failCls", 2);

	initPi();
	E = exp_QInt(1, 1);	/* there is better way but this will come later */
}

Real
realError(char *p)
{
	void failCls();
	Cls *cls;

	cls = allocCls(failCls, (void *) p);
	cls->tag.isSigned = FALSE;

	return  (Real) cls;
}

void
failCls()
{
	Cls *cls;
	char *p;

	cls = (Cls *) POP;
	p = (char *) cls->userData;
	
	if (p != NULL)
		Error(FATAL, E_INT, "failCls", p);
	else
		Error(FATAL, E_INT, "failCls", "failure closure activated");
}