summaryrefslogtreecommitdiff
path: root/src/fenv/fegetexceptflag.c
blob: ef8517f950f8a9097890ed2097cf9589d1466866 (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
#include <fenv.h>
#include "_fenv.h"

int fegetexceptflag(fexcept_t *flagp, int excepts)
{
	SIGNAL_SAFE(0);
	ASSERT_VALID_EXCEPTION_MASK(excepts);
	if (!(flagp->__impl >= __fenv_h.fexcept && flagp->__impl <= __fenv_h.fexcept + __fenv_h.nfexcept)) {
		struct __fexcept_t *tmp = realloc(__fenv_h.fexcept, sizeof(*__fenv_h.fexcept) * (__fenv_h.nfexcept + 1));
		if (tmp == NULL) {
			abort();
		}
		__fenv_h.fexcept = tmp;
		flagp->__impl = &(__fenv_h.fexcept[__fenv_h.nfexcept++]);
	}
	flagp->__impl->mask = excepts;
	return 0;
}

CHECK_2(int, 0, fegetexceptflag, fexcept_t *, int)

/*
The fegetexceptflag function stores an implementation-defined representation of
the states of the floating-point status flags indicated by the argument excepts in the
object pointed to by the argument flagp.
*/

/*
STDC(199901)
LINK(m)
*/