From a94c5d7e2805d048fdb0db231955c86e26311cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 23 Apr 2003 22:58:02 +0000 Subject: [PATCH] Fix _ftol() and move it to NTDLL i386 subdir svn path=/trunk/; revision=4568 --- reactos/lib/msvcrt/Makefile | 3 +-- reactos/lib/msvcrt/math/ftol.c | 6 ------ reactos/lib/msvcrt/msvcrt.def | 4 ++-- reactos/lib/ntdll/makefile | 5 +++-- reactos/lib/ntdll/rtl/i386/ftol.c | 35 +++++++++++++++++++++++++++++++ reactos/lib/ntdll/rtl/math.c | 6 ------ 6 files changed, 41 insertions(+), 18 deletions(-) delete mode 100644 reactos/lib/msvcrt/math/ftol.c create mode 100644 reactos/lib/ntdll/rtl/i386/ftol.c diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index 1aac2e5c6e1..153a9d3aa9d 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.32 2003/04/06 12:40:55 gvg Exp $ +# $Id: Makefile,v 1.33 2003/04/23 22:58:02 gvg Exp $ PATH_TO_TOP = ../.. @@ -174,7 +174,6 @@ MATH_OBJECTS = \ math/floor.o \ math/fmod.o \ math/frexp.o \ - math/ftol.o \ math/huge_val.o \ math/hypot.o \ math/j0_y0.o \ diff --git a/reactos/lib/msvcrt/math/ftol.c b/reactos/lib/msvcrt/math/ftol.c deleted file mode 100644 index 17530906fe5..00000000000 --- a/reactos/lib/msvcrt/math/ftol.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -long _ftol(double fl) -{ - return (long)fl; -} diff --git a/reactos/lib/msvcrt/msvcrt.def b/reactos/lib/msvcrt/msvcrt.def index f4d5ce9b328..a76a541bfde 100644 --- a/reactos/lib/msvcrt/msvcrt.def +++ b/reactos/lib/msvcrt/msvcrt.def @@ -1,4 +1,4 @@ -; $Id: msvcrt.def,v 1.19 2003/04/06 12:40:55 gvg Exp $ +; $Id: msvcrt.def,v 1.20 2003/04/23 22:58:02 gvg Exp $ ; ; ReactOS MSVCRT Compatibility Library ; @@ -253,7 +253,7 @@ _fsopen _fstat _fstati64 ; _ftime -_ftol +_ftol=NTDLL._ftol _fullpath _futime _gcvt diff --git a/reactos/lib/ntdll/makefile b/reactos/lib/ntdll/makefile index 77b61786840..5e9215f779d 100644 --- a/reactos/lib/ntdll/makefile +++ b/reactos/lib/ntdll/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.80 2003/04/05 09:37:44 chorns Exp $ +# $Id: makefile,v 1.81 2003/04/23 22:58:02 gvg Exp $ PATH_TO_TOP = ../.. @@ -28,7 +28,8 @@ DBG_OBJECTS = dbg/brkpoint.o dbg/debug.o dbg/print.o #dbg/winedbg.o RTL_I386_OBJECTS = \ rtl/i386/exception.o \ - rtl/i386/except.o + rtl/i386/except.o \ + rtl/i386/ftol.o RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \ rtl/math.o rtl/mem.o rtl/nls.o rtl/process.o rtl/sd.o \ diff --git a/reactos/lib/ntdll/rtl/i386/ftol.c b/reactos/lib/ntdll/rtl/i386/ftol.c new file mode 100644 index 00000000000..c487300150d --- /dev/null +++ b/reactos/lib/ntdll/rtl/i386/ftol.c @@ -0,0 +1,35 @@ +/* $Id: ftol.c,v 1.1 2003/04/23 22:58:02 gvg Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Security manager + * FILE: lib/ntdll/rtl/i386/ftol.c + * PROGRAMER: Ge van Geldorp (ge@gse.nl) + * REVISION HISTORY: 2003/04/24 Created + */ + +/* + * This routine is called by MSVC-generated code to convert from floating point + * to integer representation. The floating point number to be converted is + * on the top of the floating point stack. + */ +long long __cdecl _ftol(void) +{ + unsigned short cw_orig; + unsigned short cw_round_chop; + long long ll; + + /* Set "round towards zero" mode */ + __asm__("fstcw %0\n\t" : "=m" (cw_orig)); + __asm__("fwait\n\t"); + cw_round_chop = cw_orig | 0x0c00; + __asm__("fldcw %0\n\t" : : "m" (cw_round_chop)); + + /* Do the actual conversion */ + __asm__("fistpq %0\n\t" : "=m" (ll) ); + + /* And restore the rounding mode */ + __asm__("fldcw %0\n\t" : : "m" (cw_orig)); + + return ll; +} diff --git a/reactos/lib/ntdll/rtl/math.c b/reactos/lib/ntdll/rtl/math.c index 028951b0ec5..bb098e61c6a 100644 --- a/reactos/lib/ntdll/rtl/math.c +++ b/reactos/lib/ntdll/rtl/math.c @@ -24,7 +24,6 @@ double ceil (double __x); double cos (double __x); double fabs (double __x); double floor (double __x); -long _ftol (double fl); double log (double __x); double __log2 (double __x); double pow (double __x, double __y); @@ -92,11 +91,6 @@ double floor (double __x) return __value; } -long _ftol (double fl) -{ - return (long)fl; -} - double log (double __x) { register double __value;