dec21140A ethernet driver for virtualpc, contributed by nicolas tittley.
[minix.git] / lib / i386 / math / fesetround.c
blob131d64446daf5054e9daff1bfaa8bf5c2ffe2eb7
1 #include <errno.h>
2 #include <fenv.h>
4 #include "fpu_cw.h"
6 int fesetround(int round)
8 u16_t cw;
10 /* read and update FPUCW */
11 cw = fpu_cw_get() & ~FPUCW_ROUNDING_CONTROL;
12 switch (round)
14 case FE_TONEAREST: cw |= FPUCW_ROUNDING_CONTROL_NEAREST; break;
15 case FE_DOWNWARD: cw |= FPUCW_ROUNDING_CONTROL_DOWN; break;
16 case FE_UPWARD: cw |= FPUCW_ROUNDING_CONTROL_UP; break;
17 case FE_TOWARDZERO: cw |= FPUCW_ROUNDING_CONTROL_TRUNC; break;
19 default:
20 errno = EINVAL;
21 return -1;
24 /* set FPUCW to the updated value */
25 fpu_cw_set(cw);
26 return 0;