~kris/9p

9hist

ref: d2a38bfd2e8dedc6bfb69153bc5f7d6f39acf746 9hist/alphapc/fptrap.c -rw-r--r-- 707 bytes
d2a38bfd — David du Colombier Plan 9 from Bell Labs 2000-10-07 25 years ago
                                                                                
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
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"ureg.h"
#include	"io.h"
#include	"../port/error.h"

char *fpcause[] =
{
	"invalid operation",
	"division by zero",
	"overflow",
	"underflow",
	"inexact operation",
	"integer overflow",
};
char	*fpexcname(Ureg*, ulong, char*);

void
fptrap(Ureg *ur)
{
	char buf[ERRLEN];
	int i;
	ulong reason;

	ur->pc &= ~2;
	reason = (ulong)ur->a0;
	for (i = 1; i < 6; i++)
		if (reason & (1<<i)) {
			sprint(buf, "fp: %s", fpcause[i-1]);
			goto found;
		}
	sprint(buf, "fp: code 0x%lux", reason);

found:
	fataltrap(ur, buf);
}

char*
fpexcname(Ureg *ur, ulong fcr31, char *buf)
{
	USED(ur, fcr31, buf);
	return buf;
}