Mercurial > mxe-octave
comparison src/build-msvctools/math/modff.c @ 3061:f8299bb6c872
Initial support for native MSVC compilation.
* add MSVC support files: compiler wrappers and support libraries
* adapt libiconv to work with MSVC
* adapt gettext to work with MSVC
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Mon, 17 Jun 2013 22:43:11 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3060:cbdf4575016d | 3061:f8299bb6c872 |
---|---|
1 #include <fenv.h> | |
2 #include <math.h> | |
3 #include <errno.h> | |
4 #define FE_ROUNDING_MASK \ | |
5 (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO) | |
6 | |
7 float | |
8 modff (float value, float* iptr) | |
9 { | |
10 float int_part; | |
11 unsigned short saved_cw; | |
12 unsigned short tmp_cw; | |
13 /* truncate */ | |
14 asm ("fnstcw %0;" : "=m" (saved_cw)); /* save control word */ | |
15 tmp_cw = (saved_cw & ~FE_ROUNDING_MASK) | FE_TOWARDZERO; | |
16 asm ("fldcw %0;" : : "m" (tmp_cw)); | |
17 asm ("frndint;" : "=t" (int_part) : "0" (value)); /* round */ | |
18 asm ("fldcw %0;" : : "m" (saved_cw)); /* restore saved cw */ | |
19 if (iptr) | |
20 *iptr = int_part; | |
21 return (isinf (value) ? 0.0F : value - int_part); | |
22 } |