ntdll: Move math functions to a separate file.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-10-26 10:33:25 +02:00
parent bbff12381e
commit c7454eef0b
3 changed files with 178 additions and 153 deletions

View file

@ -22,6 +22,7 @@ C_SRCS = \
large_int.c \
loader.c \
locale.c \
math.c \
misc.c \
path.c \
printf.c \

177
dlls/ntdll/math.c Normal file
View file

@ -0,0 +1,177 @@
/*
* Math functions
*
* Copyright 2021 Alexandre Julliard
*
* This 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.
*
* This 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <math.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "ntdll_misc.h"
/*********************************************************************
* abs (NTDLL.@)
*/
int CDECL abs( int i )
{
return i >= 0 ? i : -i;
}
/*********************************************************************
* atan (NTDLL.@)
*/
double CDECL atan( double d )
{
return unix_funcs->atan( d );
}
/*********************************************************************
* ceil (NTDLL.@)
*/
double CDECL ceil( double d )
{
return unix_funcs->ceil( d );
}
/*********************************************************************
* cos (NTDLL.@)
*/
double CDECL cos( double d )
{
return unix_funcs->cos( d );
}
/*********************************************************************
* fabs (NTDLL.@)
*/
double CDECL fabs( double d )
{
return unix_funcs->fabs( d );
}
/*********************************************************************
* floor (NTDLL.@)
*/
double CDECL floor( double d )
{
return unix_funcs->floor( d );
}
/*********************************************************************
* log (NTDLL.@)
*/
double CDECL log( double d )
{
return unix_funcs->log( d );
}
/*********************************************************************
* pow (NTDLL.@)
*/
double CDECL pow( double x, double y )
{
return unix_funcs->pow( x, y );
}
/*********************************************************************
* sin (NTDLL.@)
*/
double CDECL sin( double d )
{
return unix_funcs->sin( d );
}
/*********************************************************************
* sqrt (NTDLL.@)
*/
double CDECL sqrt( double d )
{
return unix_funcs->sqrt( d );
}
/*********************************************************************
* tan (NTDLL.@)
*/
double CDECL tan( double d )
{
return unix_funcs->tan( d );
}
#if (defined(__GNUC__) || defined(__clang__)) && defined(__i386__)
#define FPU_DOUBLE(var) double var; \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
#define FPU_DOUBLES(var1,var2) double var1,var2; \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
/*********************************************************************
* _CIcos (NTDLL.@)
*/
double CDECL _CIcos(void)
{
FPU_DOUBLE(x);
return cos(x);
}
/*********************************************************************
* _CIlog (NTDLL.@)
*/
double CDECL _CIlog(void)
{
FPU_DOUBLE(x);
return log(x);
}
/*********************************************************************
* _CIpow (NTDLL.@)
*/
double CDECL _CIpow(void)
{
FPU_DOUBLES(x,y);
return pow(x,y);
}
/*********************************************************************
* _CIsin (NTDLL.@)
*/
double CDECL _CIsin(void)
{
FPU_DOUBLE(x);
return sin(x);
}
/*********************************************************************
* _CIsqrt (NTDLL.@)
*/
double CDECL _CIsqrt(void)
{
FPU_DOUBLE(x);
return sqrt(x);
}
/*********************************************************************
* _ftol (NTDLL.@)
*/
LONGLONG CDECL _ftol(void)
{
FPU_DOUBLE(x);
return (LONGLONG)x;
}
#endif /* (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) */

View file

@ -20,7 +20,6 @@
*/
#include <time.h>
#include <math.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
@ -38,158 +37,6 @@ LPCSTR debugstr_us( const UNICODE_STRING *us )
return debugstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
}
/*********************************************************************
* abs (NTDLL.@)
*/
int CDECL abs( int i )
{
return i >= 0 ? i : -i;
}
/*********************************************************************
* atan (NTDLL.@)
*/
double CDECL atan( double d )
{
return unix_funcs->atan( d );
}
/*********************************************************************
* ceil (NTDLL.@)
*/
double CDECL ceil( double d )
{
return unix_funcs->ceil( d );
}
/*********************************************************************
* cos (NTDLL.@)
*/
double CDECL cos( double d )
{
return unix_funcs->cos( d );
}
/*********************************************************************
* fabs (NTDLL.@)
*/
double CDECL fabs( double d )
{
return unix_funcs->fabs( d );
}
/*********************************************************************
* floor (NTDLL.@)
*/
double CDECL floor( double d )
{
return unix_funcs->floor( d );
}
/*********************************************************************
* log (NTDLL.@)
*/
double CDECL log( double d )
{
return unix_funcs->log( d );
}
/*********************************************************************
* pow (NTDLL.@)
*/
double CDECL pow( double x, double y )
{
return unix_funcs->pow( x, y );
}
/*********************************************************************
* sin (NTDLL.@)
*/
double CDECL sin( double d )
{
return unix_funcs->sin( d );
}
/*********************************************************************
* sqrt (NTDLL.@)
*/
double CDECL sqrt( double d )
{
return unix_funcs->sqrt( d );
}
/*********************************************************************
* tan (NTDLL.@)
*/
double CDECL tan( double d )
{
return unix_funcs->tan( d );
}
#if (defined(__GNUC__) || defined(__clang__)) && defined(__i386__)
#define FPU_DOUBLE(var) double var; \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
#define FPU_DOUBLES(var1,var2) double var1,var2; \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
/*********************************************************************
* _CIcos (NTDLL.@)
*/
double CDECL _CIcos(void)
{
FPU_DOUBLE(x);
return cos(x);
}
/*********************************************************************
* _CIlog (NTDLL.@)
*/
double CDECL _CIlog(void)
{
FPU_DOUBLE(x);
return log(x);
}
/*********************************************************************
* _CIpow (NTDLL.@)
*/
double CDECL _CIpow(void)
{
FPU_DOUBLES(x,y);
return pow(x,y);
}
/*********************************************************************
* _CIsin (NTDLL.@)
*/
double CDECL _CIsin(void)
{
FPU_DOUBLE(x);
return sin(x);
}
/*********************************************************************
* _CIsqrt (NTDLL.@)
*/
double CDECL _CIsqrt(void)
{
FPU_DOUBLE(x);
return sqrt(x);
}
/*********************************************************************
* _ftol (NTDLL.@)
*/
LONGLONG CDECL _ftol(void)
{
FPU_DOUBLE(x);
return (LONGLONG)x;
}
#endif /* (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) */
static void
NTDLL_mergesort( void *arr, void *barr, size_t elemsize, int(__cdecl *compar)(const void *, const void *),
size_t left, size_t right )