mailing list of musl libc
 help / color / mirror / code / Atom feed
739420b7b93aeabf1b1549a1e461f3cee4277545 blob 1106 bytes (raw)

 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
68
 
#define _GNU_SOURCE
#include <fenv.h>

static inline double get_fpscr_f(void)
{
	double d;
	__asm__ __volatile__("mffs %0" : "=d"(d));
	return d;
}

static inline long get_fpscr(void)
{
	return (union {double f; long i;}) {get_fpscr_f()}.i;
}

static inline void set_fpscr_f(double fpscr)
{
	__asm__ __volatile__("mtfsf 255, %0" : : "d"(fpscr));
}

static void set_fpscr(long fpscr)
{
	set_fpscr_f((union {long i; double f;}) {fpscr}.f);
}

int feclearexcept(int mask)
{
	mask &= FE_ALL_EXCEPT;
	if (mask & FE_INVALID) mask |= FE_ALL_INVALID;
	set_fpscr(get_fpscr() & ~mask);
	return 0;
}

int feraiseexcept(int mask)
{
	mask &= FE_ALL_EXCEPT;
	if (mask & FE_INVALID) mask |= FE_INVALID_SOFTWARE;
	set_fpscr(get_fpscr() | mask);
	return 0;
}

int fetestexcept(int mask)
{
	return get_fpscr() & mask & FE_ALL_EXCEPT;
}

int fegetround(void)
{
	return get_fpscr() & 3;
}

int __fesetround(int r)
{
	set_fpscr(get_fpscr() & ~3L | r);
	return 0;
}

int fegetenv(fenv_t *envp)
{
	*envp = get_fpscr_f();
	return 0;
}

int fesetenv(const fenv_t *envp)
{
	set_fpscr_f(envp != FE_DFL_ENV ? *envp : 0);
	return 0;
}
debug log:

solving 739420b ...
found 739420b in https://git.vuxu.org/mirror/musl/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).