- Remove duplicated functions
- Fix MSVC amd64 build
- cleanup the cmake file a little
- creadit wine for their code

svn path=/trunk/; revision=53320
This commit is contained in:
Timo Kreuzer 2011-08-19 18:10:17 +00:00
parent a5d2894b75
commit c952a3638e
12 changed files with 163 additions and 211 deletions

View file

@ -1,3 +1,4 @@
list(APPEND CRT_SOURCE
conio/cgets.c
conio/cputs.c
@ -313,24 +314,6 @@ if(ARCH MATCHES i386)
float/i386/fpreset.c
float/i386/logb.c
float/i386/statfp.c
setjmp/i386/setjmp.s)
if(MSVC)
list(APPEND CRT_SOURCE
except/i386/cpp.s)
endif()
elseif(ARCH MATCHES amd64)
list(APPEND CRT_SOURCE
except/amd64/seh.s
float/i386/clearfp.c
float/i386/cntrlfp.c
float/i386/fpreset.c
float/i386/logb.c
float/i386/statfp.c
setjmp/amd64/setjmp.s)
endif()
if(ARCH MATCHES i386)
list(APPEND CRT_SOURCE
math/i386/alldiv_asm.s
math/i386/alldvrm_asm.s
math/i386/allmul_asm.s
@ -366,6 +349,7 @@ if(ARCH MATCHES i386)
mem/i386/memmove_asm.s
mem/i386/memset_asm.s
misc/i386/readcr4.S
setjmp/i386/setjmp.s
string/i386/strcat_asm.s
string/i386/strchr_asm.s
string/i386/strcmp_asm.s
@ -386,8 +370,43 @@ if(ARCH MATCHES i386)
string/i386/wcsncpy_asm.s
string/i386/wcsnlen_asm.s
string/i386/wcsrchr_asm.s)
else()
if(MSVC)
list(APPEND CRT_SOURCE
except/i386/cpp.s)
endif()
elseif(ARCH MATCHES amd64)
list(APPEND CRT_SOURCE
except/amd64/seh.s
float/amd64/clearfp.S
float/i386/cntrlfp.c
float/amd64/fpreset.S
float/amd64/logb.S
float/i386/statfp.c
math/amd64/alldiv.S
math/amd64/atan.S
math/amd64/atan2.S
math/amd64/ceil.S
math/amd64/ceilf.S
math/amd64/exp.S
math/amd64/fabs.S
math/amd64/floor.S
math/amd64/floorf.S
math/amd64/fmod.S
math/amd64/fmodf.S
math/amd64/ldexp.S
math/amd64/log.S
math/amd64/log10.S
math/amd64/pow.S
math/amd64/sqrt.S
math/amd64/sqrtf.S
math/amd64/tan.S
setjmp/amd64/setjmp.s)
endif()
if(NOT ARCH MATCHES i386)
list(APPEND CRT_SOURCE
math/cos.c
math/sin.c
math/stubs.c
mem/memchr.c
mem/memcpy.c
@ -415,30 +434,6 @@ else()
string/wcsrchr.c)
endif()
if(ARCH MATCHES amd64)
list(APPEND CRT_SOURCE
math/cos.c
math/sin.c
math/amd64/alldiv.S
math/amd64/atan.S
math/amd64/atan2.S
math/amd64/ceil.S
math/amd64/ceilf.S
math/amd64/exp.S
math/amd64/fabs.S
math/amd64/floor.S
math/amd64/floorf.S
math/amd64/fmod.S
math/amd64/fmodf.S
math/amd64/ldexp.S
math/amd64/log.S
math/amd64/log10.S
math/amd64/pow.S
math/amd64/sqrt.S
math/amd64/sqrtf.S
math/amd64/tan.S)
endif()
add_library(crt ${CRT_SOURCE})
target_link_libraries(crt chkstk)
set_property(TARGET crt PROPERTY COMPILE_DEFINITIONS __MINGW_IMPORT=extern USE_MSVCRT_PREFIX _MSVCRT_LIB_ _MSVCRT_ _MT)

View file

@ -0,0 +1,15 @@
#include <asm.inc>
.code64
PUBLIC _clearfp
FUNC _clearfp
.ENDPROLOG
fnclex
ENDFUNC _clearfp
END

View file

@ -0,0 +1,11 @@
#include <asm.inc>
.code64
FUNC _fpreset
.endprolog
fninit
ENDFUNC _fpreset
END

View file

@ -0,0 +1,16 @@
#include <asm.inc>
.code64
FUNC _logb
.endprolog
fld dword ptr [rsp + 8]
fxtract
fstp st
ret
ENDFUNC _logb
END

View file

@ -45,8 +45,10 @@ unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
/* Get fp control word */
#if defined(__GNUC__)
__asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
#else
#elif defined(_M_IX86)
__asm fstcw [fpword];
#else
#pragma message("FIXME: _control87 is halfplemented")
#endif
TRACE("Control word before : %08x\n", fpword);
@ -98,8 +100,10 @@ unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
/* Put fp control word */
#if defined(__GNUC__)
__asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
#else
#elif defined(_M_IX86)
__asm fldcw [fpword];
#else
#pragma message("FIXME: _control87 is halfplemented")
#endif
return flags;

View file

@ -28,8 +28,10 @@ unsigned int CDECL _statusfp(void)
unsigned int fpword;
#if defined(__GNUC__)
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
#else
#elif defined(_M_IX86)
__asm fstsw [fpword];
#else
#pragma message("FIXME: _statusfp is halfplemented")
#endif
if (fpword & 0x1) retVal |= _SW_INVALID;
if (fpword & 0x2) retVal |= _SW_DENORMAL;

View file

@ -15,11 +15,12 @@
.code64
PUBLIC ceilf
ceilf:
FUNC ceilf
sub rsp, 16
.ENDPROLOG
/* Put parameter on the stack */
movss [rsp], xmm0
movss dword ptr [rsp], xmm0
fld dword ptr [rsp]
/* Change fpu control word to round up */
@ -37,9 +38,10 @@ ceilf:
fldcw [rsp + 8]
fstp dword ptr [rsp]
movss xmm0, [rsp]
movss xmm0, dword ptr [rsp]
add rsp, 16
ret
ENDFUNC ceilf
END

View file

@ -15,18 +15,19 @@
.code64
PUBLIC floorf
floorf:
FUNC floorf
sub rsp, 16
.ENDPROLOG
/* Put parameter on the stack */
movss [rsp], xmm0
movss dword ptr [rsp], xmm0
fld dword ptr [rsp]
/* Change fpu control word to round down */
fstcw [rsp]
mov eax, [rsp]
or eax, 0x00400
and eax, 0x0f7ff
or eax, HEX(000400)
and eax, HEX(00f7ff)
mov [rsp + 8], eax
fldcw [rsp + 8]
@ -37,8 +38,9 @@ floorf:
fldcw [rsp]
fstp dword ptr [rsp]
movss xmm0, [rsp]
movss xmm0, dword ptr [rsp]
add rsp, 16
ret
ENDFUNC floorf
END

View file

@ -132,89 +132,3 @@ double CDECL _CIfmod(double x, double y)
return fmod(x, y);
}
/* The following functions are likely workarounds for the pentium fdiv bug */
void __stdcall _adj_fdiv_m32( unsigned int arg )
{
FIXME("_adj_fdiv_m32 stub\n");
}
void __stdcall _adj_fdiv_m32i( int arg )
{
FIXME("_adj_fdiv_m32i stub\n");
}
void __stdcall _adj_fdiv_m64( unsigned __int64 arg )
{
FIXME("_adj_fdiv_m64 stub\n");
}
void _adj_fdiv_r(void)
{
FIXME("_adj_fdiv_r stub\n");
}
void __stdcall _adj_fdivr_m32( unsigned int arg )
{
FIXME("_adj_fdivr_m32i stub\n");
}
void __stdcall _adj_fdivr_m32i( int arg )
{
FIXME("_adj_fdivr_m32i stub\n");
}
void __stdcall _adj_fdivr_m64( unsigned __int64 arg )
{
FIXME("_adj_fdivr_m64 stub\n");
}
void _adj_fpatan(void)
{
FIXME("_adj_fpatan stub\n");
}
void __stdcall _adj_fdiv_m16i( short arg )
{
FIXME("_adj_fdiv_m16i stub\n");
}
void __stdcall _adj_fdivr_m16i( short arg )
{
FIXME("_adj_fdivr_m16i stub\n");
}
void _adj_fprem(void)
{
FIXME("_adj_fprem stub\n");
}
void _adj_fprem1(void)
{
FIXME("_adj_fprem1 stub\n");
}
void _adj_fptan(void)
{
FIXME("_adj_fptan stub\n");
}
void _safe_fdiv(void)
{
FIXME("_safe_fdiv stub\n");
}
void _safe_fdivr(void)
{
FIXME("_safe_fdivr stub\n");
}
void _safe_fprem(void)
{
FIXME("_safe_fprem stub\n");
}
void _safe_fprem1(void)
{
FIXME("_safe_fprem1 stub\n");
}

View file

@ -1136,41 +1136,6 @@ int CDECL _fileno(FILE* file)
return file->_file;
}
/*********************************************************************
* _futime (MSVCRT.@)
*/
int CDECL _futime(int fd, struct _utimbuf *t)
{
HANDLE hand = fdtoh(fd);
FILETIME at, wt;
if (hand == INVALID_HANDLE_VALUE)
return -1;
if (!t)
{
time_t currTime;
time(&currTime);
RtlSecondsSince1970ToTime(currTime, (LARGE_INTEGER *)&at);
wt = at;
}
else
{
RtlSecondsSince1970ToTime(t->actime, (LARGE_INTEGER *)&at);
if (t->actime == t->modtime)
wt = at;
else
RtlSecondsSince1970ToTime(t->modtime, (LARGE_INTEGER *)&wt);
}
if (!SetFileTime(hand, NULL, &at, &wt))
{
_dosmaperr(GetLastError());
return -1 ;
}
return 0;
}
/*********************************************************************
* _get_osfhandle (MSVCRT.@)
*/
@ -1750,38 +1715,6 @@ int CDECL _umask(int umask)
return old_umask;
}
/*********************************************************************
* _utime (MSVCRT.@)
*/
int CDECL _utime(const char* path, struct _utimbuf *t)
{
int fd = _open(path, _O_WRONLY | _O_BINARY);
if (fd > 0)
{
int retVal = _futime(fd, t);
_close(fd);
return retVal;
}
return -1;
}
/*********************************************************************
* _wutime (MSVCRT.@)
*/
int CDECL _wutime(const wchar_t* path, struct _utimbuf *t)
{
int fd = _wopen(path, _O_WRONLY | _O_BINARY);
if (fd > 0)
{
int retVal = _futime(fd, t);
_close(fd);
return retVal;
}
return -1;
}
/*********************************************************************
* _write (MSVCRT.@)
*/

View file

@ -3,8 +3,37 @@
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/futime.c
* PURPOSE: Implementation of _futime
* PROGRAMERS: Timo Kreuzer
* PROGRAMERS: Wine team
*/
/*
* msvcrt.dll file functions
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
* Copyright 2004 Eric Pouech
* Copyright 2004 Juan Lang
*
* 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
*
* TODO
* Use the file flag hints O_SEQUENTIAL, O_RANDOM, O_SHORT_LIVED
*/
#include <precomp.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <time.h>
@ -16,7 +45,7 @@ HANDLE fdtoh(int fd);
/******************************************************************************
* \name _futime
* \brief Set a files modification time.
* \param [out] ptimeb Pointer to a structure of type struct _timeb that
* \param [out] ptimeb Pointer to a structure of type struct _timeb that
* recieves the current time.
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
*/

View file

@ -3,15 +3,44 @@
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/utime.c
* PURPOSE: Implementation of utime, _wutime
* PROGRAMERS: Timo Kreuzer
* PROGRAMERS: Wine team
*/
/*
* msvcrt.dll file functions
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
* Copyright 2004 Eric Pouech
* Copyright 2004 Juan Lang
*
* 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
*
* TODO
* Use the file flag hints O_SEQUENTIAL, O_RANDOM, O_SHORT_LIVED
*/
#include <precomp.h>
#include <tchar.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <sys/utime.h>
#include "bitsfixup.h"
int
int
_tutime(const _TCHAR* path, struct _utimbuf *t)
{
int fd = _topen(path, _O_WRONLY | _O_BINARY);