mirror of
https://github.com/reactos/reactos.git
synced 2025-02-21 16:04:57 +00:00
[CRT]
- Add #pragma function to a number of intrisics that we implement to avoid a compiler error of MSVC - Add a workaround to prevent some functions from being inlined - Move sqrtf out of i386 directory - Convert a number of inline assembly functions to raw assembly svn path=/branches/cmake-bringup/; revision=49534
This commit is contained in:
parent
5e6639c9b2
commit
84b1635034
19 changed files with 130 additions and 175 deletions
|
@ -56,6 +56,7 @@ list(APPEND CRT_SOURCE
|
|||
math/logf.c
|
||||
math/modf.c
|
||||
math/rand.c
|
||||
math/sqrtf.c
|
||||
math/s_modf.c
|
||||
math/sinf.c
|
||||
math/sinh.c
|
||||
|
@ -327,13 +328,12 @@ list(APPEND CRT_SOURCE
|
|||
math/i386/sin_asm.s
|
||||
math/i386/sqrt_asm.s
|
||||
math/i386/tan_asm.s
|
||||
math/i386/atan2.c
|
||||
math/i386/atan2_asm.s
|
||||
math/i386/ci.c
|
||||
math/i386/exp.c
|
||||
math/i386/fmod.c
|
||||
math/i386/fmodf.c
|
||||
math/i386/exp_asm.s
|
||||
math/i386/fmod_asm.s
|
||||
math/i386/fmodf_asm.s
|
||||
math/i386/ldexp.c
|
||||
math/i386/sqrtf.c
|
||||
mem/i386/memchr_asm.s
|
||||
mem/i386/memmove_asm.s
|
||||
mem/i386/memset_asm.s
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma function(acos)
|
||||
#endif
|
||||
|
||||
double acos(double __x)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma function(asin)
|
||||
#endif
|
||||
|
||||
double asin(double __x)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#define cosf _dummy_cosf
|
||||
#include <math.h>
|
||||
#undef cosf
|
||||
|
||||
float cosf(float _X)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma function(cosh)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
double atan2 (double __y, double __x);
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
double atan2 (double __y, double __x)
|
||||
{
|
||||
register double __val;
|
||||
#ifdef __GNUC__
|
||||
__asm __volatile__
|
||||
("fpatan\n\t"
|
||||
"fld %%st(0)"
|
||||
: "=t" (__val) : "0" (__x), "u" (__y));
|
||||
#else
|
||||
__asm
|
||||
{
|
||||
fld __y
|
||||
fld __x
|
||||
fpatan
|
||||
fstp __val
|
||||
}
|
||||
#endif /*__GNUC__*/
|
||||
return __val;
|
||||
}
|
18
lib/sdk/crt/math/i386/atan2_asm.s
Normal file
18
lib/sdk/crt/math/i386/atan2_asm.s
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
#include <reactos/asm.h>
|
||||
|
||||
PUBLIC _atan2
|
||||
|
||||
.code
|
||||
_atan2:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld qword ptr [ebp + 8]
|
||||
fld qword ptr [ebp + 16]
|
||||
fpatan
|
||||
|
||||
pop ebp
|
||||
retn
|
||||
|
||||
END
|
|
@ -1,64 +0,0 @@
|
|||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <bowman@ipp-garching.mpg.de>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double exp (double __x);
|
||||
|
||||
double exp (double __x)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
register double __value, __exponent;
|
||||
__asm __volatile__
|
||||
("fldl2e # e^x = 2^(x * log2(e))\n\t"
|
||||
"fmul %%st(1) # x * log2(e)\n\t"
|
||||
"fst %%st(1)\n\t"
|
||||
"frndint # int(x * log2(e))\n\t"
|
||||
"fxch\n\t"
|
||||
"fsub %%st(1) # fract(x * log2(e))\n\t"
|
||||
"f2xm1 # 2^(fract(x * log2(e))) - 1\n\t"
|
||||
: "=t" (__value), "=u" (__exponent) : "0" (__x));
|
||||
__value += 1.0;
|
||||
__asm __volatile__
|
||||
("fscale"
|
||||
: "=t" (__value) : "0" (__value), "u" (__exponent));
|
||||
|
||||
return __value;
|
||||
#else
|
||||
register double __val;
|
||||
__asm
|
||||
{
|
||||
fld1 // store 1.0 for later use
|
||||
fld __x
|
||||
fldl2e // e^x = 2^(x * log2(e))
|
||||
fmul st,st(1) // x * log2(e)
|
||||
fld st(0)
|
||||
frndint // int(x * log2(e))
|
||||
fsub st,st(1) // fract(x * log2(e))
|
||||
fxch
|
||||
f2xm1 // 2^(fract(x * log2(e))) - 1
|
||||
fadd st,st(3) // + 1.0
|
||||
fscale
|
||||
fstp __val
|
||||
}
|
||||
return __val;
|
||||
#endif /*__GNUC__*/
|
||||
}
|
29
lib/sdk/crt/math/i386/exp_asm.s
Normal file
29
lib/sdk/crt/math/i386/exp_asm.s
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
#include <reactos/asm.h>
|
||||
|
||||
PUBLIC _exp
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_exp:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld qword ptr [ebp + 8]
|
||||
fldl2e
|
||||
fmul st, st(1)
|
||||
fst st(1)
|
||||
frndint
|
||||
fxch st(1)
|
||||
fsub st, st(1)
|
||||
f2xm1
|
||||
fld1
|
||||
faddp st(1), st
|
||||
fscale
|
||||
fstp st(1)
|
||||
|
||||
pop ebp
|
||||
retn
|
||||
|
||||
END
|
|
@ -1,49 +0,0 @@
|
|||
/* Math functions for i387.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by John C. Bowman <bowman@ipp-garching.mpg.de>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double fmod (double __x, double __y);
|
||||
|
||||
double fmod (double __x, double __y)
|
||||
{
|
||||
register double __val;
|
||||
#ifdef __GNUC__
|
||||
__asm __volatile__
|
||||
("1: fprem\n\t"
|
||||
"fstsw %%ax\n\t"
|
||||
"sahf\n\t"
|
||||
"jp 1b"
|
||||
: "=t" (__val) : "0" (__x), "u" (__y) : "ax", "cc");
|
||||
#else
|
||||
__asm
|
||||
{
|
||||
fld __y
|
||||
fld __x
|
||||
L1: fprem1
|
||||
fstsw ax
|
||||
sahf
|
||||
jp L1
|
||||
fstp __val
|
||||
}
|
||||
#endif /*__GNUC__*/
|
||||
return __val;
|
||||
}
|
26
lib/sdk/crt/math/i386/fmod_asm.s
Normal file
26
lib/sdk/crt/math/i386/fmod_asm.s
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include <reactos/asm.h>
|
||||
|
||||
PUBLIC _fmod
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_fmod:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld qword ptr [ebp + 8]
|
||||
fld qword ptr [ebp + 16]
|
||||
fxch st(1)
|
||||
l1:
|
||||
fprem
|
||||
fstsw ax
|
||||
sahf
|
||||
jp l1
|
||||
fstp st(1)
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*
|
||||
* Adapted for float type by Danny Smith
|
||||
* <dannysmith@users.sourceforge.net>.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fmodf (float x, float y)
|
||||
{
|
||||
float res = 0.0F;
|
||||
|
||||
asm ("1:\tfprem\n\t"
|
||||
"fstsw %%ax\n\t"
|
||||
"sahf\n\t"
|
||||
"jp 1b\n\t"
|
||||
"fstp %%st(1)"
|
||||
: "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)");
|
||||
return res;
|
||||
}
|
26
lib/sdk/crt/math/i386/fmodf_asm.s
Normal file
26
lib/sdk/crt/math/i386/fmodf_asm.s
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include <reactos/asm.h>
|
||||
|
||||
PUBLIC _fmodf
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_fmodf:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld dword ptr [esp + 4]
|
||||
fld dword ptr [esp + 8]
|
||||
fxch st(1)
|
||||
l1:
|
||||
fprem
|
||||
fstsw ax
|
||||
sahf
|
||||
jp l1
|
||||
fstp st(1)
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
|
@ -3,7 +3,9 @@
|
|||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#define logf _dummy_logf
|
||||
#include <math.h>
|
||||
#undef logf
|
||||
|
||||
float logf(float _X)
|
||||
{
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
#define modfl _dummy_modfl
|
||||
#include <precomp.h>
|
||||
#undef modfl
|
||||
|
||||
//static const double one = 1.0;
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#define sinf _dummy_sinf
|
||||
#include <math.h>
|
||||
#undef sinf
|
||||
|
||||
float sinf(float _X)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma function(sinh)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <math.h>
|
||||
|
||||
float
|
||||
sqrtf(float x)
|
||||
_sqrtf(float x)
|
||||
{
|
||||
return ((float)sqrt((double)x));
|
||||
}
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma function(tanh)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue