* mingwex/math/trunc.c (trunc): Provide lvalue for memory input constraint.
* mingwex/math/truncf.c (truncf): Likewise. * mingwex/math/truncl.c (truncl): Likewise. * mingwex/math/modff.c (modff): Likewise. * mingwex/math/modfl.c (modfl): Likewise.
This commit is contained in:
parent
78b8a13965
commit
235f653a53
|
@ -1,3 +1,11 @@
|
||||||
|
2003-07-03 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
|
* mingwex/math/trunc.c (trunc): Provide lvalue for memory input constraint.
|
||||||
|
* mingwex/math/truncf.c (truncf): Likewise.
|
||||||
|
* mingwex/math/truncl.c (truncl): Likewise.
|
||||||
|
* mingwex/math/modff.c (modff): Likewise.
|
||||||
|
* mingwex/math/modfl.c (modfl): Likewise.
|
||||||
|
|
||||||
2003-07-03 Danny Smith <dannysmith@users.sourceforge.net>
|
2003-07-03 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
* include/search.h: New file.
|
* include/search.h: New file.
|
||||||
|
|
|
@ -9,10 +9,11 @@ modff (float value, float* iptr)
|
||||||
{
|
{
|
||||||
float int_part;
|
float int_part;
|
||||||
unsigned short saved_cw;
|
unsigned short saved_cw;
|
||||||
|
unsigned short tmp_cw;
|
||||||
/* truncate */
|
/* truncate */
|
||||||
asm ("fnstcw %0;" : "=m" (saved_cw)); /* save control word */
|
asm ("fnstcw %0;" : "=m" (saved_cw)); /* save control word */
|
||||||
asm ("fldcw %0;" : : "m" ((saved_cw & ~FE_ROUNDING_MASK)
|
tmp_cw = (saved_cw & ~FE_ROUNDING_MASK) | FE_TOWARDZERO;
|
||||||
| FE_TOWARDZERO));
|
asm ("fldcw %0;" : : "m" (tmp_cw));
|
||||||
asm ("frndint;" : "=t" (int_part) : "0" (value)); /* round */
|
asm ("frndint;" : "=t" (int_part) : "0" (value)); /* round */
|
||||||
asm ("fldcw %0;" : : "m" (saved_cw)); /* restore saved cw */
|
asm ("fldcw %0;" : : "m" (saved_cw)); /* restore saved cw */
|
||||||
if (iptr)
|
if (iptr)
|
||||||
|
|
|
@ -9,10 +9,11 @@ modfl (long double value, long double* iptr)
|
||||||
{
|
{
|
||||||
long double int_part;
|
long double int_part;
|
||||||
unsigned short saved_cw;
|
unsigned short saved_cw;
|
||||||
|
unsigned short tmp_cw;
|
||||||
/* truncate */
|
/* truncate */
|
||||||
asm ("fnstcw %0;" : "=m" (saved_cw)); /* save control word */
|
asm ("fnstcw %0;" : "=m" (saved_cw)); /* save control word */
|
||||||
asm ("fldcw %0;" : : "m" ((saved_cw & ~FE_ROUNDING_MASK)
|
tmp_cw = (saved_cw & ~FE_ROUNDING_MASK) | FE_TOWARDZERO;
|
||||||
| FE_TOWARDZERO));
|
asm ("fldcw %0;" : : "m" (tmp_cw));
|
||||||
asm ("frndint;" : "=t" (int_part) : "0" (value)); /* round */
|
asm ("frndint;" : "=t" (int_part) : "0" (value)); /* round */
|
||||||
asm ("fldcw %0;" : : "m" (saved_cw)); /* restore saved cw */
|
asm ("fldcw %0;" : : "m" (saved_cw)); /* restore saved cw */
|
||||||
if (iptr)
|
if (iptr)
|
||||||
|
|
|
@ -5,12 +5,11 @@ double
|
||||||
trunc (double _x){
|
trunc (double _x){
|
||||||
double retval;
|
double retval;
|
||||||
unsigned short saved_cw;
|
unsigned short saved_cw;
|
||||||
|
unsigned short tmp_cw;
|
||||||
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
||||||
__asm__ ("fldcw %0;"
|
tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||||
:
|
| FE_TOWARDZERO;
|
||||||
: "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD
|
__asm__ ("fldcw %0;" : : "m" (tmp_cw));
|
||||||
| FE_TOWARDZERO)) | FE_TOWARDZERO)
|
|
||||||
);
|
|
||||||
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
float
|
float
|
||||||
truncf (float _x){
|
truncf (float _x)
|
||||||
|
{
|
||||||
float retval;
|
float retval;
|
||||||
unsigned short saved_cw;
|
unsigned short saved_cw;
|
||||||
|
unsigned short tmp_cw;
|
||||||
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
||||||
__asm__ ("fldcw %0;"
|
tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||||
:
|
| FE_TOWARDZERO;
|
||||||
: "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD
|
__asm__ ("fldcw %0;" : : "m" (tmp_cw));
|
||||||
| FE_TOWARDZERO)) | FE_TOWARDZERO)
|
|
||||||
);
|
|
||||||
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -5,12 +5,11 @@ long double
|
||||||
truncl (long double _x){
|
truncl (long double _x){
|
||||||
long double retval;
|
long double retval;
|
||||||
unsigned short saved_cw;
|
unsigned short saved_cw;
|
||||||
|
unsigned short tmp_cw;
|
||||||
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
||||||
__asm__ ("fldcw %0;"
|
tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||||
:
|
| FE_TOWARDZERO;
|
||||||
: "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD
|
__asm__ ("fldcw %0;" : : "m" (tmp_cw));
|
||||||
| FE_TOWARDZERO)) | FE_TOWARDZERO)
|
|
||||||
);
|
|
||||||
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||||
return retval;
|
return retval;
|
||||||
|
|
Loading…
Reference in New Issue