File: ieee_sun.c

package info (click to toggle)
yorick 1.4-14
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,948 kB
  • ctags: 6,609
  • sloc: ansic: 63,898; yacc: 889; makefile: 605; sh: 65; lisp: 60; fortran: 19
file content (48 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download | duplicates (3)
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
/*
   IEEE_SUN.C
   Hack for Sun/Solaris with gcc, but no sunmath library.
   I don't really understand this.  It fails with -O.
   Compile separately and place in libyor.a.
   If you fix it, let me know.

   $Id$
 */

extern void nonstandard_arithmetic(void);
extern int ieee_handler(char *action, char *exception, void (*hdl)(int));

static unsigned int sparc_get_fsr(void);
static void sparc_set_fsr(unsigned int fsr);

/* ------------------------------------------------------------------------ */

void nonstandard_arithmetic(void)
{
  /* just set the fsr flags */
  sparc_set_fsr(sparc_get_fsr() | 0x400000);
}

int ieee_handler(char *action, char *exception, void (*hdl)(int))
{
  /* just set the fsr flags */
  unsigned int fsr= sparc_get_fsr();
  fsr&= ~0xf800000;
  sparc_set_fsr(fsr | 0xd000000);
  return 0;
}

/* ------------------------------------------------------------------------ */

static unsigned int sparc_get_fsr(void)
{
  unsigned int fsr;
  asm("st  %%fsr, %0" : "=Q" (fsr));
  return fsr;
}

static void sparc_set_fsr(unsigned int fsr)
{
  asm("ld  %0, %%fsr" : : "Q" (fsr));
}

/* ------------------------------------------------------------------------ */