Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.

This commit is contained in:
Colin Finck 2017-10-03 07:45:34 +00:00
parent b94e2d8ca0
commit c2c66aff7d
24198 changed files with 0 additions and 37285 deletions

View file

@ -0,0 +1,84 @@
include_directories(include)
add_definitions(-D_CRTBLD)
if(ARCH STREQUAL "i386")
list(APPEND CHKSTK_ASM_SOURCE except/i386/chkstk_asm.s)
if(NOT MSVC)
list(APPEND CHKSTK_SOURCE except/i386/chkstk_ms.s)
endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND CHKSTK_ASM_SOURCE except/amd64/chkstk_asm.s)
if(NOT MSVC)
list(APPEND CHKSTK_SOURCE except/amd64/chkstk_ms.s)
endif()
elseif(ARCH STREQUAL "arm")
list(APPEND CHKSTK_ASM_SOURCE except/arm/chkstk_asm.s)
if(NOT MSVC)
list(APPEND CHKSTK_SOURCE except/arm/chkstk_ms.s)
endif()
elseif(ARCH STREQUAL "powerpc")
list(APPEND CHKSTK_ASM_SOURCE except/powerpc/chkstk_asm.s)
endif()
add_asm_files(chkstk_lib_asm ${CHKSTK_ASM_SOURCE})
add_library(chkstk ${CHKSTK_SOURCE} ${chkstk_lib_asm})
set_target_properties(chkstk PROPERTIES LINKER_LANGUAGE "C")
add_dependencies(chkstk asm)
include(crt.cmake)
include(libcntpr.cmake)
include(msvcrtex.cmake)
include(oldnames.cmake)
add_library(user32_wsprintf
printf/streamout.c
printf/wstreamout.c
printf/wsprintfA.c
printf/wsprintfW.c
printf/wvsprintfA.c
printf/wvsprintfW.c
printf/wvsnprintfA.c
printf/wvsnprintfW.c
string/strnlen.c
string/wcsnlen.c
string/mbstowcs_nt.c
string/wcstombs_nt.c)
add_dependencies(user32_wsprintf psdk)
add_target_compile_definitions(user32_wsprintf _USER32_WSPRINTF)
add_library(memcmp mem/memcmp.c)
add_dependencies(memcmp psdk)
add_library(getopt misc/getopt.c)
add_target_compile_definitions(getopt _DLL __USE_CRTIMP)
add_dependencies(getopt psdk)
add_library(strtol
string/ctype.c
string/iswctype.c
string/strtoi64.c
string/strtol.c
string/strtoul.c
string/strtoull.c
string/wctype.c)
add_target_compile_definitions(strtol _LIBCNT_)
add_dependencies(strtol psdk)
if(ARCH STREQUAL "i386")
list(APPEND ATAN2_ASM_SOURCE math/i386/atan2_asm.s)
elseif(ARCH STREQUAL "amd64")
list(APPEND ATAN2_ASM_SOURCE math/amd64/atan2.S)
elseif(ARCH STREQUAL "arm")
list(APPEND ATAN2_ASM_SOURCE math/arm/atan2.s)
endif()
add_asm_files(atan2_asm ${ATAN2_ASM_SOURCE})
add_library(atan2 ${atan2_asm})
set_target_properties(atan2 PROPERTIES LINKER_LANGUAGE "C")
add_dependencies(atan2 asm)

10
sdk/lib/crt/README.txt Normal file
View file

@ -0,0 +1,10 @@
Big chunks of this CRT library are taken from Wine's msvcrt implementation,
you can find a list of synced files in README.WINE file.
Notes:
1. When syncing, omit MSVCRT_ prefix where possible, Wine has to keep this
because they are linking with *both* original crt, and ms crt implementation.
ReactOS has the only CRT, so no need to make distinct functions.
2. ReactOS compiles two versions of the CRT library, one for usermode
(called just "crt"), and one version for kernelmode usage (called "libcntpr").
In order to separate the code, you can use #ifdef _LIBCNT_ for libcntpr code.

73
sdk/lib/crt/conio/cgets.c Normal file
View file

@ -0,0 +1,73 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/sdk/crt/conio/cgets.c
* PURPOSE: C Runtime
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
*/
#include <precomp.h>
/*
* @implemented
*/
char *_cgets(char *string)
{
unsigned len = 0;
unsigned int maxlen_wanted;
char *sp;
int c;
/*
* Be smart and check for NULL pointer.
* Don't know wether TURBOC does this.
*/
if (!string)
return(NULL);
maxlen_wanted = (unsigned int)((unsigned char)string[0]);
sp = &(string[2]);
/*
* Should the string be shorter maxlen_wanted including or excluding
* the trailing '\0' ? We don't take any risk.
*/
while(len < maxlen_wanted-1)
{
c=_getch();
/*
* shold we check for backspace here?
* TURBOC does (just checked) but doesn't in cscanf (thats harder
* or even impossible). We do the same.
*/
if (c == '\b')
{
if (len > 0)
{
_cputs("\b \b"); /* go back, clear char on screen with space
and go back again */
len--;
sp[len] = '\0'; /* clear the character in the string */
}
}
else if (c == '\r')
{
sp[len] = '\0';
break;
}
else if (c == 0)
{
/* special character ends input */
sp[len] = '\0';
_ungetch(c); /* keep the char for later processing */
break;
}
else
{
sp[len] = _putch(c);
len++;
}
}
sp[maxlen_wanted-1] = '\0';
string[1] = (char)((unsigned char)len);
return(sp);
}

29
sdk/lib/crt/conio/cputs.c Normal file
View file

@ -0,0 +1,29 @@
/* Imported from msvcrt/console.c */
#include <precomp.h>
/*********************************************************************
* _cputs (MSVCRT.@)
*/
int CDECL _cputs(const char* str)
{
DWORD count;
int len, retval = -1;
#ifdef __REACTOS__ /* r54651 */
HANDLE MSVCRT_console_out = GetStdHandle(STD_OUTPUT_HANDLE);
#endif
if (!MSVCRT_CHECK_PMT(str != NULL)) return -1;
len = strlen(str);
#ifndef __REACTOS__ /* r54651 */
LOCK_CONSOLE;
#endif
if (WriteConsoleA(MSVCRT_console_out, str, len, &count, NULL)
&& count == len)
retval = 0;
#ifndef __REACTOS__ /* r54651 */
UNLOCK_CONSOLE;
#endif
return retval;
}

55
sdk/lib/crt/conio/getch.c Normal file
View file

@ -0,0 +1,55 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/conio/getch.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @implemented
*/
int _getch(void)
{
DWORD NumberOfCharsRead = 0;
char c;
HANDLE ConsoleHandle;
BOOL RestoreMode;
DWORD ConsoleMode;
if (char_avail) {
c = ungot_char;
char_avail = 0;
} else {
/*
* _getch() is documented to NOT echo characters. Testing shows it
* doesn't wait for a CR either. So we need to switch off
* ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently
* switched on.
*/
ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file);
RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) &&
(0 != (ConsoleMode &
(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
if (RestoreMode) {
SetConsoleMode(ConsoleHandle,
ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
}
ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file),
&c,
1,
&NumberOfCharsRead,
NULL);
if (RestoreMode) {
SetConsoleMode(ConsoleHandle, ConsoleMode);
}
}
if (c == 10)
c = 13;
return c;
}

View file

@ -0,0 +1,29 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/conio/getche.c
* PURPOSE: Reads a character from stdin
* PROGRAMER: DJ Delorie
Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
int _getche(void)
{
if (char_avail)
/*
* We don't know, wether the ungot char was already echoed
* we assume yes (for example in cscanf, probably the only
* place where ungetch is ever called.
* There is no way to check for this really, because
* ungetch could have been called with a character that
* hasn't been got by a conio function.
* We don't echo again.
*/
return(_getch());
return (_putch(_getch()));
}

99
sdk/lib/crt/conio/kbhit.c Normal file
View file

@ -0,0 +1,99 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/conio/kbhit.c
* PURPOSE: Checks for keyboard hits
* PROGRAMERS: Ariadne, Russell
* UPDATE HISTORY:
* 28/12/98: Created
* 27/9/08: An almost 100% working version of _kbhit()
*/
#include <precomp.h>
static CRITICAL_SECTION CriticalSection;
volatile BOOL CriticalSectionInitialized=FALSE;
/*
* @implemented
*/
int _kbhit(void)
{
PINPUT_RECORD InputRecord = NULL;
DWORD NumberRead = 0;
DWORD EventsRead = 0;
DWORD RecordIndex = 0;
DWORD BufferIndex = 0;
HANDLE StdInputHandle = 0;
DWORD ConsoleInputMode = 0;
/* Attempt some thread safety */
if (!CriticalSectionInitialized)
{
InitializeCriticalSectionAndSpinCount(&CriticalSection, 0x80000400);
CriticalSectionInitialized = TRUE;
}
EnterCriticalSection(&CriticalSection);
if (char_avail)
{
LeaveCriticalSection(&CriticalSection);
return 1;
}
StdInputHandle = GetStdHandle(STD_INPUT_HANDLE);
/* Turn off processed input so we get key modifiers as well */
GetConsoleMode(StdInputHandle, &ConsoleInputMode);
SetConsoleMode(StdInputHandle, ConsoleInputMode & ~ENABLE_PROCESSED_INPUT);
/* Start the process */
if (!GetNumberOfConsoleInputEvents(StdInputHandle, &EventsRead))
{
LeaveCriticalSection(&CriticalSection);
return 0;
}
if (!EventsRead)
{
LeaveCriticalSection(&CriticalSection);
return 0;
}
if (!(InputRecord = (PINPUT_RECORD)malloc(EventsRead * sizeof(INPUT_RECORD))))
{
LeaveCriticalSection(&CriticalSection);
return 0;
}
if (!PeekConsoleInput(StdInputHandle, InputRecord, EventsRead, &NumberRead))
{
free(InputRecord);
LeaveCriticalSection(&CriticalSection);
return 0;
}
for (RecordIndex = 0; RecordIndex < NumberRead; RecordIndex++)
{
if (InputRecord[RecordIndex].EventType == KEY_EVENT &&
InputRecord[RecordIndex].Event.KeyEvent.bKeyDown)
{
BufferIndex = 1;
break;
}
}
free(InputRecord);
/* Restore console input mode */
SetConsoleMode(StdInputHandle, ConsoleInputMode);
LeaveCriticalSection(&CriticalSection);
return BufferIndex;
}

24
sdk/lib/crt/conio/putch.c Normal file
View file

@ -0,0 +1,24 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/conio/putch.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @implemented
*/
int _putch(int c)
{
DWORD NumberOfCharsWritten;
if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL)) {
return -1;
}
return NumberOfCharsWritten;
}

View file

@ -0,0 +1,29 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/conio/ungetch.c
* PURPOSE: Ungets a character from stdin
* PROGRAMER: DJ Delorie
Ariadne [ Adapted from djgpp libc ]
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
int char_avail = 0;
int ungot_char = 0;
/*
* @implemented
*/
int _ungetch(int c)
{
if (char_avail)
return(EOF);
ungot_char = c;
char_avail = 1;
return(c);
}

599
sdk/lib/crt/crt.cmake Normal file
View file

@ -0,0 +1,599 @@
list(APPEND CRT_SOURCE
conio/cgets.c
conio/cputs.c
conio/getch.c
conio/getche.c
conio/kbhit.c
conio/putch.c
conio/ungetch.c
direct/chdir.c
direct/chdrive.c
direct/getcwd.c
direct/getdcwd.c
direct/getdfree.c
direct/getdrive.c
direct/mkdir.c
direct/rmdir.c
direct/wchdir.c
direct/wgetcwd.c
direct/wgetdcwd.c
direct/wmkdir.c
direct/wrmdir.c
except/cpp.c
except/cppexcept.c
except/except.c
except/matherr.c
except/stack.c
except/xcptfil.c
float/chgsign.c
float/copysign.c
float/fpclass.c
float/fpecode.c
float/isnan.c
float/nafter.c
float/scalb.c
locale/locale.c
math/abs.c
math/acos.c
math/adjust.c
math/asin.c
math/cabs.c
math/cosf.c
math/cosh.c
math/div.c
math/fdivbug.c
math/frexp.c
math/huge_val.c
math/hypot.c
math/ieee754/j0_y0.c
math/ieee754/j1_y1.c
math/ieee754/jn_yn.c
math/j0_y0.c
math/j1_y1.c
math/jn_yn.c
math/labs.c
math/ldiv.c
math/logf.c
math/modf.c
math/powf.c
math/rand.c
math/s_modf.c
math/sinf.c
math/sinh.c
math/tanh.c
mbstring/_setmbcp.c
mbstring/hanzen.c
mbstring/ischira.c
mbstring/iskana.c
mbstring/iskmoji.c
mbstring/iskpun.c
mbstring/islead.c
mbstring/islwr.c
mbstring/ismbal.c
mbstring/ismbaln.c
mbstring/ismbc.c
mbstring/ismbgra.c
mbstring/ismbkaln.c
mbstring/ismblead.c
mbstring/ismbpri.c
mbstring/ismbpun.c
mbstring/ismbtrl.c
mbstring/isuppr.c
mbstring/jistojms.c
mbstring/jmstojis.c
mbstring/mbbtype.c
mbstring/mbccpy.c
mbstring/mbclen.c
mbstring/mbscat.c
mbstring/mbschr.c
mbstring/mbscmp.c
mbstring/mbscoll.c
mbstring/mbscpy.c
mbstring/mbscspn.c
mbstring/mbsdec.c
mbstring/mbsdup.c
mbstring/mbsicmp.c
mbstring/mbsicoll.c
mbstring/mbsinc.c
mbstring/mbslen.c
mbstring/mbslwr.c
mbstring/mbsncat.c
mbstring/mbsnccnt.c
mbstring/mbsncmp.c
mbstring/mbsncoll.c
mbstring/mbsncpy.c
mbstring/mbsnextc.c
mbstring/mbsnicmp.c
mbstring/mbsnicoll.c
mbstring/mbsninc.c
mbstring/mbsnset.c
mbstring/mbspbrk.c
mbstring/mbsrchr.c
mbstring/mbsrev.c
mbstring/mbsset.c
mbstring/mbsspn.c
mbstring/mbsspnp.c
mbstring/mbsstr.c
mbstring/mbstok.c
mbstring/mbstrlen.c
mbstring/mbsupr.c
mem/memcmp.c
mem/memccpy.c
mem/memicmp.c
misc/__crt_MessageBoxA.c
misc/amsg.c
misc/assert.c
misc/environ.c
misc/fltused.c
misc/getargs.c
misc/i10output.c
misc/initterm.c
misc/lock.c
misc/purecall.c
misc/stubs.c
misc/tls.c
printf/_cprintf.c
printf/_cwprintf.c
printf/_snprintf.c
printf/_snprintf_s.c
printf/_snwprintf.c
printf/_snwprintf_s.c
printf/_vcprintf.c
printf/_vcwprintf.c
printf/_vscprintf.c
printf/_vscwprintf.c
printf/_vsnprintf.c
printf/_vsnprintf_s.c
printf/_vsnwprintf.c
printf/_vsnwprintf_s.c
printf/_vsprintf_p.c
printf/fprintf.c
printf/fprintf_s.c
printf/fwprintf.c
printf/fwprintf_s.c
printf/printf.c
printf/printf_s.c
printf/sprintf.c
printf/sprintf_s.c
printf/streamout.c
printf/swprintf.c
printf/swprintf_s.c
printf/vfprintf.c
printf/vfprintf_s.c
printf/vfwprintf.c
printf/vfwprintf_s.c
printf/vprintf.c
printf/vprintf_s.c
printf/vsprintf.c
printf/vsprintf_s.c
printf/vswprintf.c
printf/vswprintf_s.c
printf/vwprintf.c
printf/vwprintf_s.c
printf/wprintf.c
printf/wprintf_s.c
printf/wstreamout.c
process/_cwait.c
process/_system.c
process/dll.c
process/process.c
process/procid.c
process/thread.c
process/threadid.c
process/threadx.c
process/wprocess.c
search/bsearch.c
search/lfind.c
search/lsearch.c
signal/signal.c
signal/xcptinfo.c
startup/crtexe.c
startup/wcrtexe.c
startup/crt_handler.c
startup/crtdll.c
startup/_newmode.c
startup/wildcard.c
startup/tlssup.c
startup/mingw_helpers.c
startup/natstart.c
startup/charmax.c
#startup/merr.c
#startup/atonexit.c
#startup/txtmode.c
startup/pesect.c
startup/tlsmcrt.c
startup/tlsthrd.c
startup/tlsmthread.c
startup/cinitexe.c
startup/gs_support.c
startup/dll_argv.c
startup/dllargv.c
startup/wdllargv.c
startup/crt0_c.c
startup/crt0_w.c
startup/dllentry.c
startup/reactos.c
stdio/_flsbuf.c
stdio/_flswbuf.c
stdio/access.c
stdio/file.c
stdio/find.c
stdio/find64.c
stdio/findi64.c
stdio/fmode.c
stdio/perror.c
stdio/popen.c
stdio/stat.c
stdio/stat64.c
stdio/waccess.c
stdio/wfind.c
stdio/wfind64.c
stdio/wfindi64.c
stdio/wpopen.c
stdio/wstat.c
stdio/wstat64.c
stdlib/_exit.c
stdlib/_set_abort_behavior.c
stdlib/abort.c
stdlib/atexit.c
stdlib/ecvt.c
stdlib/errno.c
stdlib/fcvt.c
stdlib/fcvtbuf.c
stdlib/fullpath.c
stdlib/gcvt.c
stdlib/getenv.c
stdlib/makepath.c
stdlib/makepath_s.c
stdlib/mbtowc.c
stdlib/mbstowcs.c
stdlib/obsol.c
stdlib/putenv.c
stdlib/qsort.c
stdlib/rot.c
stdlib/senv.c
stdlib/swab.c
stdlib/wfulpath.c
stdlib/wputenv.c
stdlib/wsenv.c
stdlib/wmakpath.c
stdlib/wmakpath_s.c
string/_mbsnlen.c
string/_mbstrnlen.c
string/_splitpath.c
string/_splitpath_s.c
string/_wcslwr_s.c
string/_wsplitpath.c
string/_wsplitpath_s.c
string/atof.c
string/atoi.c
string/atoi64.c
string/atol.c
string/ctype.c
string/iswctype.c
string/is_wctype.c
string/itoa.c
string/itow.c
string/mbstowcs_s.c
string/scanf.c
string/strcoll.c
string/strcspn.c
string/strdup.c
string/strerror.c
string/stricmp.c
string/string.c
string/strlwr.c
string/strncoll.c
string/strnicmp.c
string/strpbrk.c
string/strrev.c
string/strset.c
string/strspn.c
string/strstr.c
string/strtod.c
string/strtoi64.c
string/strtok.c
#string/strtok_s.c
string/strtol.c
string/strtoul.c
string/strtoull.c
string/strupr.c
string/strxfrm.c
string/wcs.c
string/wcstol.c
string/wcstombs_s.c
string/wcstoul.c
string/wctype.c
string/wtof.c
string/wtoi.c
string/wtoi64.c
string/wtol.c
string/winesup.c
sys_stat/systime.c
time/asctime.c
time/clock.c
time/ctime32.c
time/ctime64.c
time/ctime.c
time/difftime32.c
time/difftime64.c
time/difftime.c
time/ftime32.c
time/ftime64.c
time/ftime.c
time/futime32.c
time/futime64.c
time/futime.c
time/gmtime.c
time/localtime32.c
time/localtime64.c
time/localtime.c
time/mktime.c
time/strdate.c
time/strftime.c
time/strtime.c
time/time32.c
time/time64.c
time/time.c
time/timezone.c
time/utime32.c
time/utime64.c
time/utime.c
time/wasctime.c
time/wctime32.c
time/wctime64.c
time/wctime.c
time/wstrdate.c
time/wstrtime.c
time/wutime32.c
time/wutime64.c
time/wutime.c
wstring/wcscoll.c
wstring/wcscspn.c
wstring/wcsicmp.c
wstring/wcslwr.c
wstring/wcsnicmp.c
wstring/wcsspn.c
wstring/wcsstr.c
wstring/wcstok.c
wstring/wcsupr.c
wstring/wcsxfrm.c
wine/heap.c
wine/undname.c)
if(ARCH STREQUAL "i386")
list(APPEND CRT_ASM_SOURCE
except/i386/chkesp.s
except/i386/prolog.s
math/i386/alldiv_asm.s
math/i386/alldvrm_asm.s
math/i386/allmul_asm.s
math/i386/allrem_asm.s
math/i386/allshl_asm.s
math/i386/allshr_asm.s
math/i386/atan_asm.s
math/i386/aulldiv_asm.s
math/i386/aulldvrm_asm.s
math/i386/aullrem_asm.s
math/i386/aullshr_asm.s
math/i386/ceil_asm.s
math/i386/ceilf.S
math/i386/cos_asm.s
math/i386/fabs_asm.s
math/i386/floor_asm.s
math/i386/floorf.S
math/i386/ftol_asm.s
math/i386/ftol2_asm.s
math/i386/log_asm.s
math/i386/log10_asm.s
math/i386/pow_asm.s
math/i386/sin_asm.s
math/i386/sqrt_asm.s
math/i386/tan_asm.s
math/i386/atan2_asm.s
math/i386/exp_asm.s
math/i386/fmod_asm.s
math/i386/fmodf_asm.s
mem/i386/memchr_asm.s
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
string/i386/strcpy_asm.s
string/i386/strlen_asm.s
string/i386/strncat_asm.s
string/i386/strncmp_asm.s
string/i386/strncpy_asm.s
string/i386/strnlen_asm.s
string/i386/strrchr_asm.s
string/i386/wcscat_asm.s
string/i386/wcschr_asm.s
string/i386/wcscmp_asm.s
string/i386/wcscpy_asm.s
string/i386/wcslen_asm.s
string/i386/wcsncat_asm.s
string/i386/wcsncmp_asm.s
string/i386/wcsncpy_asm.s
string/i386/wcsnlen_asm.s
string/i386/wcsrchr_asm.s)
list(APPEND CRT_SOURCE
except/i386/unwind.c
float/i386/clearfp.c
float/i386/cntrlfp.c
float/i386/fpreset.c
float/i386/logb.c
float/i386/statfp.c
math/i386/ci.c
math/i386/cicos.c
math/i386/cilog.c
math/i386/cipow.c
math/i386/cisin.c
math/i386/cisqrt.c
math/i386/ldexp.c)
if(MSVC)
list(APPEND CRT_ASM_SOURCE
except/i386/cpp.s)
endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND CRT_ASM_SOURCE
except/amd64/seh.s
float/amd64/clearfp.S
float/amd64/getsetfpcw.S
float/amd64/fpreset.S
float/amd64/logb.S
# math/amd64/acos.S
# math/amd64/acosf.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)
list(APPEND CRT_SOURCE
except/amd64/ehandler.c
float/i386/cntrlfp.c
float/i386/statfp.c)
if(MSVC)
list(APPEND CRT_ASM_SOURCE
except/amd64/cpp.s)
endif()
elseif(ARCH STREQUAL "arm")
list(APPEND CRT_SOURCE
except/arm/ehandler.c
math/fabsf.c
math/sqrt.c
math/arm/__rt_sdiv.c
math/arm/__rt_sdiv64_worker.c
math/arm/__rt_udiv.c
math/arm/__rt_udiv64_worker.c
)
list(APPEND CRT_ASM_SOURCE
except/arm/_abnormal_termination.s
except/arm/_except_handler2.s
except/arm/_except_handler3.s
except/arm/_global_unwind2.s
except/arm/_local_unwind2.s
except/arm/chkstk_asm.s
float/arm/_clearfp.s
float/arm/_controlfp.s
float/arm/_fpreset.s
float/arm/_statusfp.s
math/arm/atan.s
math/arm/atan2.s
math/arm/ceil.s
math/arm/exp.s
math/arm/fabs.s
math/arm/fmod.s
math/arm/floor.s
math/arm/ldexp.s
math/arm/log.s
math/arm/log10.s
math/arm/pow.s
math/arm/tan.s
math/arm/_logb.s
math/arm/__dtoi64.s
math/arm/__dtou64.s
math/arm/__i64tod.s
math/arm/__i64tos.s
math/arm/__stoi64.s
math/arm/__stou64.s
math/arm/__u64tod.s
math/arm/__u64tos.s
math/arm/__rt_sdiv64.s
math/arm/__rt_srsh.s
math/arm/__rt_udiv64.s
setjmp/arm/setjmp.s
)
if(MSVC)
list(APPEND CRT_ASM_SOURCE
except/arm/cpp.s)
endif()
endif()
if(NOT ARCH STREQUAL "i386")
list(APPEND CRT_SOURCE
math/_chgsignf.c
math/_copysignf.c
math/_hypotf.c
math/acosf.c
math/asinf.c
math/atan2f.c
math/atanf.c
math/ceilf.c
math/cos.c
math/coshf.c
math/expf.c
math/floorf.c
math/fmodf.c
math/log10f.c
math/modff.c
math/sin.c
math/sinhf.c
math/sqrt.c
math/sqrtf.c
math/tanf.c
math/tanhf.c
math/stubs.c
mem/memchr.c
mem/memcpy.c
mem/memmove.c
mem/memset.c
string/strcat.c
string/strchr.c
string/strcmp.c
string/strcpy.c
string/strlen.c
string/strncat.c
string/strncmp.c
string/strncpy.c
string/strnlen.c
string/strrchr.c
string/wcscat.c
string/wcschr.c
string/wcscmp.c
string/wcscpy.c
string/wcslen.c
string/wcsncat.c
string/wcsncmp.c
string/wcsncpy.c
string/wcsnlen.c
string/wcsrchr.c)
endif()
set_source_files_properties(${CRT_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "__MINGW_IMPORT=extern;USE_MSVCRT_PREFIX;_MSVCRT_LIB_;_MSVCRT_;_MT;CRTDLL")
add_asm_files(crt_asm ${CRT_ASM_SOURCE})
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
#FIXME: http://llvm.org/bugs/show_bug.cgi?id=19027
set_property(SOURCE except/cpp.c APPEND_STRING PROPERTY COMPILE_FLAGS " -no-integrated-as")
endif()
add_library(crt ${CRT_SOURCE} ${crt_asm})
target_link_libraries(crt chkstk)
add_target_compile_definitions(crt
__MINGW_IMPORT=extern
USE_MSVCRT_PREFIX
_MSVCRT_LIB_
_MSVCRT_
_MT
CRTDLL)
#add_pch(crt precomp.h)
add_dependencies(crt psdk asm)

View file

@ -0,0 +1,29 @@
#include <precomp.h>
#include <tchar.h>
#include <process.h>
/*
* @implemented
*/
int _tchdir(const _TCHAR* _path)
{
WCHAR newdir[MAX_PATH];
if (!SetCurrentDirectory(_path))
{
_dosmaperr(_path ? GetLastError() : 0);
return -1;
}
/* Update the drive-specific current directory variable */
if (GetCurrentDirectoryW(MAX_PATH, newdir) >= 2)
{
if (newdir[1] == L':')
{
WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':', L'\0' };
SetEnvironmentVariableW(envvar, newdir);
}
}
return 0;
}

View file

@ -0,0 +1,45 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/direct/chdrive.c
* PURPOSE: Change the current drive.
* PROGRAMER: WINE
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
/*
* @implemented
*
* _chdrive (MSVCRT.@)
*
* Change the current drive.
*
* PARAMS
* newdrive [I] Drive number to change to (1 = 'A', 2 = 'B', ...)
*
* RETURNS
* Success: 0. The current drive is set to newdrive.
* Failure: -1. errno indicates the error.
*
* NOTES
* See SetCurrentDirectoryA.
*/
int _chdrive(int newdrive)
{
WCHAR buffer[] = L"A:";
buffer[0] += newdrive - 1;
if (!SetCurrentDirectoryW( buffer ))
{
_dosmaperr(GetLastError());
if (newdrive <= 0)
{
_set_errno(EACCES);
}
return -1;
}
return 0;
}

View file

@ -0,0 +1,33 @@
#include <precomp.h>
#include <direct.h>
#include <process.h>
#include <tchar.h>
/*
* @implemented
*/
_TCHAR* _tgetcwd(_TCHAR* buf, int size)
{
_TCHAR dir[MAX_PATH];
DWORD dir_len = GetCurrentDirectory(MAX_PATH,dir);
if (dir_len == 0)
{
_dosmaperr(GetLastError());
return NULL; /* FIXME: Real return value untested */
}
if (!buf)
{
return _tcsdup(dir);
}
if (dir_len >= (DWORD)size)
{
_set_errno(ERANGE);
return NULL; /* buf too small */
}
_tcscpy(buf,dir);
return buf;
}

View file

@ -0,0 +1,62 @@
#include <precomp.h>
#include <direct.h>
#include <tchar.h>
/*
* @implemented
*
* _getdcwd (MSVCRT.@)
*
* Get the current working directory on a given disk.
*
* PARAMS
* drive [I] Drive letter to get the current working directory from.
* buf [O] Destination for the current working directory.
* size [I] Length of drive in characters.
*
* RETURNS
* Success: If drive is NULL, returns an allocated string containing the path.
* Otherwise populates drive with the path and returns it.
* Failure: NULL. errno indicates the error.
*/
_TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size)
{
static _TCHAR* dummy;
TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
if (!drive || drive == _getdrive())
return _tgetcwd(buf,size); /* current */
else
{
_TCHAR dir[MAX_PATH];
_TCHAR drivespec[] = _T("A:");
int dir_len;
drivespec[0] += drive - 1;
if (GetDriveType(drivespec) < DRIVE_REMOVABLE)
{
_set_errno(EACCES);
return NULL;
}
/* GetFullPathName for X: means "get working directory on drive X",
* just like passing X: to SetCurrentDirectory means "switch to working
* directory on drive X". -Gunnar */
dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy);
if (dir_len >= size || dir_len < 1)
{
_set_errno(ERANGE);
return NULL; /* buf too small */
}
TRACE(":returning '%s'\n", dir);
if (!buf)
return _tcsdup(dir); /* allocate */
_tcscpy(buf,dir);
}
return buf;
}

View file

@ -0,0 +1,23 @@
#include <precomp.h>
#include <ctype.h>
#include <direct.h>
/*
* @implemented
*/
unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t* _diskspace)
{
char RootPathName[10];
RootPathName[0] = toupper(_drive +'@');
RootPathName[1] = ':';
RootPathName[2] = '\\';
RootPathName[3] = 0;
if (_diskspace == NULL)
return 0;
if (!GetDiskFreeSpaceA(RootPathName,(LPDWORD)&_diskspace->sectors_per_cluster,(LPDWORD)&_diskspace->bytes_per_sector,
(LPDWORD )&_diskspace->avail_clusters,(LPDWORD )&_diskspace->total_clusters))
return 0;
return _diskspace->avail_clusters;
}

View file

@ -0,0 +1,38 @@
#include <precomp.h>
#include <ctype.h>
#include <direct.h>
/*
* @implemented
*
* _getdrive (MSVCRT.@)
*
* Get the current drive number.
*
* PARAMS
* None.
*
* RETURNS
* Success: The drive letter number from 1 to 26 ("A:" to "Z:").
* Failure: 0.
*/
int _getdrive(void)
{
WCHAR buffer[MAX_PATH];
if (GetCurrentDirectoryW( MAX_PATH, buffer )>=2)
{
buffer[0]=towupper(buffer[0]);
if (buffer[0] >= L'A' && buffer[0] <= L'Z' && buffer[1] == L':')
return buffer[0] - L'A' + 1;
}
return 0;
}
/*
* @implemented
*/
unsigned long _getdrives(void)
{
return GetLogicalDrives();
}

View file

@ -0,0 +1,15 @@
#include <precomp.h>
#include <direct.h>
#include <tchar.h>
/*
* @implemented
*/
int _tmkdir(const _TCHAR* _path)
{
if (!CreateDirectory(_path, NULL)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -0,0 +1,15 @@
#include <precomp.h>
#include <direct.h>
#include <tchar.h>
/*
* @implemented
*/
int _trmdir(const _TCHAR* _path)
{
if (!RemoveDirectory(_path)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -0,0 +1,4 @@
#define UNICODE
#define _UNICODE
#include "chdir.c"

View file

@ -0,0 +1,5 @@
#define UNICODE
#define _UNICODE
#include "getcwd.c"

View file

@ -0,0 +1,5 @@
#define UNICODE
#define _UNICODE
#include "getdcwd.c"

View file

@ -0,0 +1,4 @@
#define UNICODE
#define _UNICODE
#include "mkdir.c"

View file

@ -0,0 +1,4 @@
#define UNICODE
#define _UNICODE
#include "rmdir.c"

View file

@ -0,0 +1,32 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* PURPOSE: Implementation of _chkstk and _alloca_probe
* FILE: lib/sdk/crt/except/amd64/chkstk_asm.s
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
/* CODE **********************************************************************/
.code64
MsgUnimplemented:
.ascii "Unimplemented", CR, LF, NUL
FUNC __chkstk
.endprolog
UNIMPLEMENTED chkstk
ret
ENDFUNC
FUNC __alloca_probe
.endprolog
UNIMPLEMENTED alloca_probe
ret
ENDFUNC
END
/* EOF */

View file

@ -0,0 +1,51 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* PURPOSE: Implementation of _chkstk and _alloca_probe
* PROGRAMMERS Richard Henderson <rth@redhat.com>
* Kai Tietz <kai.tietz@onevision.com>
* Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#define PAGE_SIZE 4096
/* CODE **********************************************************************/
.code64
PUBLIC ___chkstk_ms
//cfi_startproc()
___chkstk_ms:
push rcx /* save temps */
//cfi_push(%rcx)
push rax
//cfi_push(%rax)
cmp rax, PAGE_SIZE /* > 4k ?*/
lea rcx, [rsp + 24] /* point past return addr */
jb l_LessThanAPage
l_MoreThanAPage:
sub rcx, PAGE_SIZE /* yes, move pointer down 4k */
or byte ptr [rcx], 0 /* probe there */
sub rax, PAGE_SIZE /* decrement count */
cmp rax, PAGE_SIZE
ja l_MoreThanAPage /* and do it again */
l_LessThanAPage:
sub rcx, rax
or byte ptr [rcx], 0 /* less than 4k, just peek here */
pop rax
//cfi_pop(%rax)
pop rcx
//cfi_pop(%rcx)
ret
//cfi_endproc()
END
/* EOF */

View file

@ -0,0 +1,85 @@
#include <asm.inc>
.code64
.align 4
MACRO(START_VTABLE, shortname, cxxname)
EXTERN shortname&_rtti:PROC
EXTERN MSVCRT_&shortname&_vector_dtor:PROC
.double shortname&_rtti
PUBLIC MSVCRT_&shortname&_vtable
MSVCRT_&shortname&_vtable:
PUBLIC &cxxname
&cxxname:
.double MSVCRT_&shortname&_vector_dtor
ENDM
MACRO(DEFINE_EXCEPTION_VTABLE, shortname, cxxname)
START_VTABLE shortname, cxxname
EXTERN MSVCRT_what_exception:ABS
.double MSVCRT_what_exception
ENDM
START_VTABLE type_info, __dummyname_type_info
DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
MACRO(DEFINE_ALIAS, alias, orig)
EXTERN &orig:ABS
ALIAS <&alias> = <&orig>
ENDM
DEFINE_ALIAS ??3@YAXPEAX@Z, MSVCRT_operator_delete
DEFINE_ALIAS ??_U@YAPEAX_K@Z, MSVCRT_operator_new
DEFINE_ALIAS ??_V@YAXPEAX@Z, MSVCRT_operator_delete
DEFINE_ALIAS ??2@YAPEAX_K@Z, MSVCRT_operator_new
DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, MSVCRT__query_new_handler
DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, MSVCRT__set_new_handler
DEFINE_ALIAS ?set_new_handler@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_new_handler
DEFINE_ALIAS ?_query_new_mode@@YAHXZ, MSVCRT__query_new_mode
DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, MSVCRT__set_new_mode
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator
DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_terminate
DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_unexpected
DEFINE_ALIAS ?terminate@@YAXXZ, MSVCRT_terminate
DEFINE_ALIAS ?unexpected@@YAXXZ, MSVCRT_unexpected
DEFINE_ALIAS ?what@exception@@UEBAPEBDXZ, MSVCRT_what_exception
DEFINE_ALIAS ??0exception@@QEAA@AEBQEBDH@Z, MSVCRT_exception_ctor_noalloc
DEFINE_ALIAS ??0exception@@QEAA@AEBV0@@Z, MSVCRT_exception_copy_ctor
DEFINE_ALIAS ??0exception@@QEAA@XZ, MSVCRT_exception_default_ctor
DEFINE_ALIAS ??1exception@@UEAA@XZ, MSVCRT_exception_dtor
DEFINE_ALIAS ??4exception@@QEAAAEAV0@AEBV0@@Z, MSVCRT_exception_opequals
DEFINE_ALIAS ??1type_info@@UEAA@XZ, MSVCRT_type_info_dtor
DEFINE_ALIAS ??0__non_rtti_object@@QEAA@AEBV0@@Z, MSVCRT___non_rtti_object_copy_ctor
DEFINE_ALIAS ??0__non_rtti_object@@QEAA@PEBD@Z, MSVCRT___non_rtti_object_ctor
DEFINE_ALIAS ??0bad_cast@@AEAA@PEBQEBD@Z, MSVCRT_bad_cast_ctor
DEFINE_ALIAS ??0bad_cast@@QEAA@AEBQEBD@Z, MSVCRT_bad_cast_ctor
DEFINE_ALIAS ??0bad_cast@@QEAA@AEBV0@@Z, MSVCRT_bad_cast_copy_ctor
DEFINE_ALIAS ??0bad_cast@@QEAA@PEBD@Z, MSVCRT_bad_cast_ctor_charptr
DEFINE_ALIAS ??0bad_typeid@@QEAA@AEBV0@@Z, MSVCRT_bad_typeid_copy_ctor
DEFINE_ALIAS ??0bad_typeid@@QEAA@PEBD@Z, MSVCRT_bad_typeid_ctor
DEFINE_ALIAS ??0exception@@QEAA@AEBQEBD@Z, MSVCRT_exception_ctor
DEFINE_ALIAS ??1__non_rtti_object@@UEAA@XZ, MSVCRT___non_rtti_object_dtor
DEFINE_ALIAS ??1bad_cast@@UEAA@XZ, MSVCRT_bad_cast_dtor
DEFINE_ALIAS ??1bad_typeid@@UEAA@XZ, MSVCRT_bad_typeid_dtor
DEFINE_ALIAS ??4bad_cast@@QEAAAEAV0@AEBV0@@Z, MSVCRT_bad_cast_opequals
DEFINE_ALIAS ??4bad_typeid@@QEAAAEAV0@AEBV0@@Z, MSVCRT_bad_typeid_opequals
DEFINE_ALIAS ??8type_info@@QEBAHAEBV0@@Z, MSVCRT_type_info_opequals_equals
DEFINE_ALIAS ??9type_info@@QEBAHAEBV0@@Z, MSVCRT_type_info_opnot_equals
DEFINE_ALIAS ??_Fbad_cast@@QEAAXXZ, MSVCRT_bad_cast_default_ctor
DEFINE_ALIAS ??_Fbad_typeid@@QEAAXXZ, MSVCRT_bad_typeid_default_ctor
DEFINE_ALIAS ?_query_new_handler@@YAP6AH_K@ZXZ, MSVCRT__query_new_handler
DEFINE_ALIAS ?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z, MSVCRT__set_new_handler
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPEAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator
DEFINE_ALIAS ?before@type_info@@QEBAHAEBV1@@Z, MSVCRT_type_info_before
DEFINE_ALIAS ?name@type_info@@QEBAPEBDXZ, MSVCRT_type_info_name
DEFINE_ALIAS ?raw_name@type_info@@QEBAPEBDXZ, MSVCRT_type_info_raw_name
DEFINE_ALIAS ??4__non_rtti_object@@QEAAAEAV0@AEBV0@@Z, MSVCRT___non_rtti_object_opequals
END

View file

@ -0,0 +1,30 @@
#include <precomp.h>
_CRTIMP
EXCEPTION_DISPOSITION
__cdecl
__C_specific_handler(
struct _EXCEPTION_RECORD *_ExceptionRecord,
void *_EstablisherFrame,
struct _CONTEXT *_ContextRecord,
struct _DISPATCHER_CONTEXT *_DispatcherContext)
{
UNIMPLEMENTED;
__debugbreak();
return 0;
}
DWORD
__CxxFrameHandler(
PEXCEPTION_RECORD rec,
EXCEPTION_REGISTRATION_RECORD* ExceptionRegistrationFrame,
PCONTEXT context,
EXCEPTION_REGISTRATION_RECORD** _ExceptionRecord)
{
UNIMPLEMENTED;
__debugbreak();
return 0;
}

View file

@ -0,0 +1,65 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT
* FILE: lib/sdk/crt/except/amd64/seh.s
* PURPOSE: SEH Support for the CRT
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ksamd64.inc>
#define DISPOSITION_DISMISS 0
#define DISPOSITION_CONTINUE_SEARCH 1
#define DISPOSITION_COLLIDED_UNWIND 3
/* GLOBALS *******************************************************************/
PUBLIC _global_unwind2
PUBLIC _local_unwind
PUBLIC _local_unwind2
PUBLIC _abnormal_termination
PUBLIC _except_handler2
PUBLIC _except_handler3
/* CODE **********************************************************************/
.code64
FUNC _unwind_handler
.endprolog
ret
ENDFUNC
FUNC _global_unwind2
.endprolog
ret
ENDFUNC
FUNC _abnormal_termination
.endprolog
ret
ENDFUNC
FUNC _local_unwind
.endprolog
ret
ENDFUNC
FUNC _local_unwind2
.endprolog
ret
ENDFUNC
FUNC _except_handler2
.endprolog
ret
ENDFUNC
FUNC _except_handler3
.endprolog
ret
ENDFUNC
END

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT library
* PURPOSE: Implementation of __jump_unwind
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY __jump_unwind
__assertfail
bx lr
LEAF_END __jump_unwind
END
/* EOF */

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _abnormal_termination
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _abnormal_termination
__assertfail
bx lr
LEAF_END _abnormal_termination
END
/* EOF */

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _except_handler2
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _except_handler2
__assertfail
bx lr
LEAF_END _except_handler2
END
/* EOF */

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _except_handler3
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _except_handler3
__assertfail
bx lr
LEAF_END _except_handler3
END
/* EOF */

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _global_unwind2
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _global_unwind2
__assertfail
bx lr
LEAF_END _global_unwind2
END
/* EOF */

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _local_unwind2
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _local_unwind2
__assertfail
bx lr
LEAF_END _local_unwind2
END
/* EOF */

View file

@ -0,0 +1,27 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _chkstk and _alloca_probe
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
* Yuntian Zhang (yuntian.zh@gmail.com)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY __chkstk
__assertfail
bx lr
LEAF_END __chkstk
LEAF_ENTRY __alloca_probe
__assertfail
bx lr
LEAF_END __alloca_probe
END
/* EOF */

View file

@ -0,0 +1,27 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT librariy
* PURPOSE: Implementation of _chkstk and _alloca_probe
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
* Yuntian Zhang (yuntian.zh@gmail.com)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY ___chkstk_ms
__assertfail
bx lr
LEAF_END __chkstk_ms
LEAF_ENTRY __alloca_probe
__assertfail
bx lr
LEAF_END __alloca_probe
END
/* EOF */

View file

@ -0,0 +1,113 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT library
* PURPOSE: MSVC wrappers for C++ functions
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
MACRO
DEFINE_ALIAS $FuncName, $Target
LCLS _FuncName
LCLS _Target
_FuncName SETS "|$FuncName|"
_Target SETS "|$Target|"
IMPORT $_FuncName, WEAK $_Target
MEND
DEFINE_ALIAS ??0__non_rtti_object@@QAA@ABV0@@Z, MSVCRT___non_rtti_object_copy_ctor
DEFINE_ALIAS ??0__non_rtti_object@@QAA@PBD@Z, MSVCRT___non_rtti_object_ctor
DEFINE_ALIAS ??0bad_cast@@AAA@PBQBD@Z, MSVCRT_bad_cast_ctor // private: __cdecl bad_cast::bad_cast(char const * const *)
DEFINE_ALIAS ??0bad_cast@@QAA@ABV0@@Z, MSVCRT_bad_cast_copy_ctor // public: __cdecl bad_cast::bad_cast(class bad_cast const &)
DEFINE_ALIAS ??0bad_cast@@QAA@PBD@Z, MSVCRT_bad_cast_ctor // public: __cdecl bad_cast::bad_cast(char const *)
DEFINE_ALIAS ??0bad_typeid@@QAA@ABV0@@Z, MSVCRT_bad_typeid_copy_ctor // public: __cdecl bad_typeid::bad_typeid(class bad_typeid const &)
DEFINE_ALIAS ??0bad_typeid@@QAA@PBD@Z, MSVCRT_bad_typeid_ctor // public: __cdecl bad_typeid::bad_typeid(char const *)
DEFINE_ALIAS ??0exception@@QAA@ABQBD@Z, MSVCRT_exception_ctor // public: __cdecl exception::exception(char const * const &)
DEFINE_ALIAS ??0exception@@QAA@ABQBDH@Z, MSVCRT_exception_ctor_noalloc // public: __cdecl exception::exception(char const * const &,int)
DEFINE_ALIAS ??0exception@@QAA@ABV0@@Z, MSVCRT_exception_copy_ctor // public: __cdecl exception::exception(class exception const &)
DEFINE_ALIAS ??0exception@@QAA@XZ, MSVCRT_exception_default_ctor // public: __cdecl exception::exception(void)
DEFINE_ALIAS ??1__non_rtti_object@@UAA@XZ, MSVCRT___non_rtti_object_dtor // public: virtual __cdecl __non_rtti_object::~__non_rtti_object(void)
DEFINE_ALIAS ??1bad_cast@@UAA@XZ, MSVCRT_bad_cast_dtor // public: virtual __cdecl bad_cast::~bad_cast(void)
DEFINE_ALIAS ??1bad_typeid@@UAA@XZ, MSVCRT_bad_typeid_dtor // public: virtual __cdecl bad_typeid::~bad_typeid(void)
DEFINE_ALIAS ??1exception@@UAA@XZ, MSVCRT_exception_dtor // public: virtual __cdecl exception::~exception(void)
DEFINE_ALIAS ??1type_info@@UAA@XZ, MSVCRT_type_info_dtor // public: virtual __cdecl type_info::~type_info(void)
DEFINE_ALIAS ??2@YAPAXI@Z, MSVCRT_operator_new // void * __cdecl operator new(unsigned int)
DEFINE_ALIAS ??2@YAPAXIHPBDH@Z, MSVCRT_operator_new_dbg // void * __cdecl operator new(unsigned int,int,char const *,int)
DEFINE_ALIAS ??3@YAXPAX@Z, MSVCRT_operator_delete // void __cdecl operator delete(void *)
DEFINE_ALIAS ??4__non_rtti_object@@QAAAAV0@ABV0@@Z, MSVCRT___non_rtti_object_opequals // public: class __non_rtti_object & __cdecl __non_rtti_object::operator=(class __non_rtti_object const &)
DEFINE_ALIAS ??4bad_cast@@QAAAAV0@ABV0@@Z, MSVCRT_bad_cast_opequals // public: class bad_cast & __cdecl bad_cast::operator=(class bad_cast const &)
DEFINE_ALIAS ??4bad_typeid@@QAAAAV0@ABV0@@Z, MSVCRT_bad_typeid_opequals // public: class bad_typeid & __cdecl bad_typeid::operator=(class bad_typeid const &)
DEFINE_ALIAS ??4exception@@QAAAAV0@ABV0@@Z, MSVCRT_exception_opequals // public: class exception & __cdecl exception::operator=(class exception const &)
DEFINE_ALIAS ??8type_info@@QBAHABV0@@Z, MSVCRT_type_info_opequals_equals // public: int __cdecl type_info::operator==(class type_info const &)const
DEFINE_ALIAS ??9type_info@@QBAHABV0@@Z, MSVCRT_type_info_opnot_equals // public: int __cdecl type_info::operator!=(class type_info const &)const
DEFINE_ALIAS ??_Fbad_cast@@QAAXXZ, MSVCRT_bad_cast_default_ctor // public: void __cdecl bad_cast::`default constructor closure'(void)
DEFINE_ALIAS ??_Fbad_typeid@@QAAXXZ, MSVCRT_bad_typeid_default_ctor // public: void __cdecl bad_typeid::`default constructor closure'(void)
DEFINE_ALIAS ??_U@YAPAXI@Z, MSVCRT_operator_new // void * __cdecl operator new[](unsigned int)
DEFINE_ALIAS ??_U@YAPAXIHPBDH@Z, MSVCRT_operator_new_dbg // void * __cdecl operator new[](unsigned int,int,char const *,int)
DEFINE_ALIAS ??_V@YAXPAX@Z, MSVCRT_operator_delete // void __cdecl operator delete[](void *)
DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, MSVCRT__query_new_handler // int (__cdecl*__cdecl _query_new_handler(void))(unsigned int)
DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, MSVCRT__set_new_handler // int (__cdecl*__cdecl _set_new_handler(int (__cdecl*)(unsigned int)))(unsigned int)
DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, MSVCRT__set_new_mode // int __cdecl _set_new_mode(int)
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator // void (__cdecl*__cdecl _set_se_translator(void (__cdecl*)(unsigned int,struct _EXCEPTION_POINTERS *)))(unsigned int,struct _EXCEPTION_POINTERS *)
DEFINE_ALIAS ?before@type_info@@QBAHABV1@@Z, MSVCRT_type_info_before // public: int __cdecl type_info::before(class type_info const &)const
DEFINE_ALIAS ?name@type_info@@QBAPBDXZ, MSVCRT_type_info_name // public: char const * __cdecl type_info::name(void)const
DEFINE_ALIAS ?raw_name@type_info@@QBAPBDXZ, MSVCRT_type_info_raw_name // public: char const * __cdecl type_info::raw_name(void)const
DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_terminate // void (__cdecl*__cdecl set_terminate(void (__cdecl*)(void)))(void)
DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_unexpected // void (__cdecl*__cdecl set_unexpected(void (__cdecl*)(void)))(void)
DEFINE_ALIAS ?terminate@@YAXXZ, MSVCRT_terminate // void __cdecl terminate(void)
DEFINE_ALIAS ?unexpected@@YAXXZ, MSVCRT_unexpected // void __cdecl unexpected(void)
DEFINE_ALIAS ?what@exception@@UBAPBDXZ, MSVCRT_what_exception // public: virtual char const * __cdecl exception::what(void)const
#undef _MSVCRT_
MACRO
START_VTABLE $ShortName, $CxxName
LCLS RttiName
LCLS VtblName
LCLS DtorName
LCLS CxxLabel
CxxLabel SETS "|$CxxName|"
RttiName SETS "|$ShortName._rtti|"
VtblName SETS "|MSVCRT_":CC:"$ShortName._vtable|"
DtorName SETS "|MSVCRT_":CC:"$ShortName._vector_dtor|"
EXTERN $RttiName
DCD $RttiName
EXPORT $VtblName
$VtblName
EXPORT $CxxLabel
$CxxLabel
EXTERN $DtorName
DCD $DtorName
MEND
MACRO
DEFINE_EXCEPTION_VTABLE $ShortName, $CxxName
START_VTABLE $ShortName, $CxxName
EXTERN MSVCRT_what_exception
DCD MSVCRT_what_exception
MEND
START_VTABLE type_info, __dummyname_type_info
DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
GBLS FuncName
//EXTERN MSVCRT_operator_delete
//__ExportName ??3@YAXPAX@Z
//b MSVCRT_operator_delete
//EXTERN MSVCRT_operator_new
//__ExportName ??_U@YAPAXI@Z
//b MSVCRT_operator_new
END
/* EOF */

View file

@ -0,0 +1,38 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: lib/sdk/crt/except/arm/ehandler.c
* PURPOSE: Low level exception handler functions
* PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES *****************************************************************/
#include <precomp.h>
_CRTIMP
EXCEPTION_DISPOSITION
__cdecl
__C_specific_handler(
struct _EXCEPTION_RECORD *_ExceptionRecord,
void *_EstablisherFrame,
struct _CONTEXT *_ContextRecord,
struct _DISPATCHER_CONTEXT *_DispatcherContext)
{
UNIMPLEMENTED;
__debugbreak();
return 0;
}
DWORD
__CxxFrameHandler3(
PEXCEPTION_RECORD rec,
EXCEPTION_REGISTRATION_RECORD* ExceptionRegistrationFrame,
PCONTEXT context,
EXCEPTION_REGISTRATION_RECORD** _ExceptionRecord)
{
UNIMPLEMENTED;
__debugbreak();
return 0;
}

1266
sdk/lib/crt/except/cpp.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,596 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2002 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
*
* NOTES
* A good reference is the article "How a C++ compiler implements
* exception handling" by Vishal Kochhar, available on
* www.thecodeproject.com.
*/
#define __WINE_DEBUG_CHANNEL__
#include <precomp.h>
#include <stdarg.h>
#include <wine/exception.h>
#include <internal/wine/msvcrt.h>
#include <internal/wine/cppexcept.h>
#ifdef __i386__ /* CxxFrameHandler is not supported on non-i386 */
WINE_DEFAULT_DEBUG_CHANNEL(seh);
DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch,
const cxx_function_descr *descr,
EXCEPTION_REGISTRATION_RECORD* nested_frame, int nested_trylevel );
/* call a function with a given ebp */
#ifdef _MSC_VER
#pragma warning(disable:4731) // don't warn about modification of ebp
#endif
static inline void *call_ebp_func( void *func, void *_ebp )
{
void *result;
#ifdef _MSC_VER
__asm
{
mov eax, func
push ebx
push ebp
mov ebp, _ebp
call eax
pop ebp
pop ebx
mov result, eax
}
#else
int dummy;
__asm__ __volatile__ ("pushl %%ebx\n\t"
"pushl %%ebp\n\t"
"movl %4,%%ebp\n\t"
"call *%%eax\n\t"
"popl %%ebp\n\t"
"popl %%ebx"
: "=a" (result), "=S" (dummy), "=D" (dummy)
: "0" (func), "1" (_ebp) : "ecx", "edx", "memory" );
#endif
return result;
}
#ifdef _MSC_VER
#pragma warning(default:4731)
#endif
/* call a copy constructor */
static inline void call_copy_ctor( void *func, void *this, void *src, int has_vbase )
{
TRACE( "calling copy ctor %p object %p src %p\n", func, this, src );
#ifdef _MSC_VER
if (has_vbase)
{
__asm
{
mov ecx, this
push 1
push src
call func
}
}
else
{
__asm
{
mov ecx, this
push src
call func
}
}
#else
if (has_vbase)
/* in that case copy ctor takes an extra bool indicating whether to copy the base class */
__asm__ __volatile__("pushl $1; pushl %2; call *%0"
: : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" );
else
__asm__ __volatile__("pushl %2; call *%0"
: : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" );
#endif
}
/* call the destructor of the exception object */
static inline void call_dtor( void *func, void *object )
{
#ifdef _MSC_VER
__asm
{
mov ecx, object
call func
}
#else
__asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" );
#endif
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4731)
/* continue execution to the specified address after exception is caught */
__forceinline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{
__asm
{
mov eax, addr
mov edx, frame
mov esp, [edx-4]
lea ebp, [edx+12]
jmp eax
}
for (;;) ; /* unreached */
}
#pragma warning(pop)
#else
/* continue execution to the specified address after exception is caught */
static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{
__asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1"
: : "r" (frame), "a" (addr) );
for (;;) ; /* unreached */
}
#endif
static inline void dump_type( const cxx_type_info *type )
{
TRACE( "flags %x type %p %s offsets %d,%d,%d size %d copy ctor %p\n",
type->flags, type->type_info, dbgstr_type_info(type->type_info),
type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset,
type->size, type->copy_ctor );
}
static void dump_exception_type( const cxx_exception_type *type )
{
UINT i;
TRACE( "flags %x destr %p handler %p type info %p\n",
type->flags, type->destructor, type->custom_handler, type->type_info_table );
for (i = 0; i < type->type_info_table->count; i++)
{
TRACE( " %d: ", i );
dump_type( type->type_info_table->info[i] );
}
}
static void dump_function_descr( const cxx_function_descr *descr )
{
#ifndef WINE_NO_TRACE_MSGS
UINT i;
int j;
TRACE( "magic %x\n", descr->magic );
TRACE( "unwind table: %p %d\n", descr->unwind_table, descr->unwind_count );
for (i = 0; i < descr->unwind_count; i++)
{
TRACE( " %d: prev %d func %p\n", i,
descr->unwind_table[i].prev, descr->unwind_table[i].handler );
}
TRACE( "try table: %p %d\n", descr->tryblock, descr->tryblock_count );
for (i = 0; i < descr->tryblock_count; i++)
{
TRACE( " %d: start %d end %d catchlevel %d catch %p %d\n", i,
descr->tryblock[i].start_level, descr->tryblock[i].end_level,
descr->tryblock[i].catch_level, descr->tryblock[i].catchblock,
descr->tryblock[i].catchblock_count );
for (j = 0; j < descr->tryblock[i].catchblock_count; j++)
{
const catchblock_info *ptr = &descr->tryblock[i].catchblock[j];
TRACE( " %d: flags %x offset %d handler %p type %p %s\n",
j, ptr->flags, ptr->offset, ptr->handler,
ptr->type_info, dbgstr_type_info( ptr->type_info ) );
}
}
#endif
if (descr->magic <= CXX_FRAME_MAGIC_VC6) return;
TRACE( "expect list: %p\n", descr->expect_list );
if (descr->magic <= CXX_FRAME_MAGIC_VC7) return;
TRACE( "flags: %08x\n", descr->flags );
}
/* check if the exception type is caught by a given catch block, and return the type that matched */
static const cxx_type_info *find_caught_type( cxx_exception_type *exc_type,
const catchblock_info *catchblock )
{
UINT i;
for (i = 0; i < exc_type->type_info_table->count; i++)
{
const cxx_type_info *type = exc_type->type_info_table->info[i];
if (!catchblock->type_info) return type; /* catch(...) matches any type */
if (catchblock->type_info != type->type_info)
{
if (strcmp( catchblock->type_info->mangled, type->type_info->mangled )) continue;
}
/* type is the same, now check the flags */
if ((exc_type->flags & TYPE_FLAG_CONST) &&
!(catchblock->flags & TYPE_FLAG_CONST)) continue;
if ((exc_type->flags & TYPE_FLAG_VOLATILE) &&
!(catchblock->flags & TYPE_FLAG_VOLATILE)) continue;
return type; /* it matched */
}
return NULL;
}
/* copy the exception object where the catch block wants it */
static void copy_exception( void *object, cxx_exception_frame *frame,
const catchblock_info *catchblock, const cxx_type_info *type )
{
void **dest_ptr;
if (!catchblock->type_info || !catchblock->type_info->mangled[0]) return;
if (!catchblock->offset) return;
dest_ptr = (void **)((char *)&frame->ebp + catchblock->offset);
if (catchblock->flags & TYPE_FLAG_REFERENCE)
{
*dest_ptr = get_this_pointer( &type->offsets, object );
}
else if (type->flags & CLASS_IS_SIMPLE_TYPE)
{
memmove( dest_ptr, object, type->size );
/* if it is a pointer, adjust it */
if (type->size == sizeof(void *)) *dest_ptr = get_this_pointer( &type->offsets, *dest_ptr );
}
else /* copy the object */
{
if (type->copy_ctor)
call_copy_ctor( type->copy_ctor, dest_ptr, get_this_pointer(&type->offsets,object),
(type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS) );
else
memmove( dest_ptr, get_this_pointer(&type->offsets,object), type->size );
}
}
/* unwind the local function up to a given trylevel */
static void cxx_local_unwind( cxx_exception_frame* frame, const cxx_function_descr *descr, int last_level)
{
void (*handler)(void);
int trylevel = frame->trylevel;
while (trylevel != last_level)
{
if (trylevel < 0 || (unsigned)trylevel >= descr->unwind_count)
{
ERR( "invalid trylevel %d\n", trylevel );
MSVCRT_terminate();
}
handler = descr->unwind_table[trylevel].handler;
if (handler)
{
TRACE( "calling unwind handler %p trylevel %d last %d ebp %p\n",
handler, trylevel, last_level, &frame->ebp );
call_ebp_func( handler, &frame->ebp );
}
trylevel = descr->unwind_table[trylevel].prev;
}
frame->trylevel = last_level;
}
/* exception frame for nested exceptions in catch block */
struct catch_func_nested_frame
{
EXCEPTION_REGISTRATION_RECORD frame; /* standard exception frame */
EXCEPTION_RECORD *prev_rec; /* previous record to restore in thread data */
cxx_exception_frame *cxx_frame; /* frame of parent exception */
const cxx_function_descr *descr; /* descriptor of parent exception */
int trylevel; /* current try level */
EXCEPTION_RECORD *rec; /* rec associated with frame */
};
/* handler for exceptions happening while calling a catch function */
static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
{
struct catch_func_nested_frame *nested_frame = (struct catch_func_nested_frame *)frame;
if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
{
msvcrt_get_thread_data()->exc_record = nested_frame->prev_rec;
return ExceptionContinueSearch;
}
TRACE( "got nested exception in catch function\n" );
if(rec->ExceptionCode == CXX_EXCEPTION)
{
PEXCEPTION_RECORD prev_rec = nested_frame->rec;
if(rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0)
{
/* exception was rethrown */
rec->ExceptionInformation[1] = prev_rec->ExceptionInformation[1];
rec->ExceptionInformation[2] = prev_rec->ExceptionInformation[2];
TRACE("detect rethrow: re-propagate: obj: %lx, type: %lx\n",
rec->ExceptionInformation[1], rec->ExceptionInformation[2]);
}
else {
/* new exception in exception handler, destroy old */
void *object = (void*)prev_rec->ExceptionInformation[1];
cxx_exception_type *info = (cxx_exception_type*) prev_rec->ExceptionInformation[2];
TRACE("detect threw new exception in catch block - destroy old(obj: %p type: %p)\n",
object, info);
if(info && info->destructor)
call_dtor( info->destructor, object );
}
}
return cxx_frame_handler( rec, nested_frame->cxx_frame, context,
NULL, nested_frame->descr, &nested_frame->frame,
nested_frame->trylevel );
}
/* find and call the appropriate catch block for an exception */
/* returns the address to continue execution to after the catch block was called */
static inline void call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame *frame,
const cxx_function_descr *descr, int nested_trylevel,
cxx_exception_type *info )
{
UINT i;
int j;
void *addr, *object = (void *)rec->ExceptionInformation[1];
struct catch_func_nested_frame nested_frame;
int trylevel = frame->trylevel;
thread_data_t *thread_data = msvcrt_get_thread_data();
DWORD save_esp = ((DWORD*)frame)[-1];
for (i = 0; i < descr->tryblock_count; i++)
{
const tryblock_info *tryblock = &descr->tryblock[i];
if (trylevel < tryblock->start_level) continue;
if (trylevel > tryblock->end_level) continue;
/* got a try block */
for (j = 0; j < tryblock->catchblock_count; j++)
{
const catchblock_info *catchblock = &tryblock->catchblock[j];
if(info)
{
const cxx_type_info *type = find_caught_type( info, catchblock );
if (!type) continue;
TRACE( "matched type %p in tryblock %d catchblock %d\n", type, i, j );
/* copy the exception to its destination on the stack */
copy_exception( object, frame, catchblock, type );
}
else
{
/* no CXX_EXCEPTION only proceed with a catch(...) block*/
if(catchblock->type_info)
continue;
TRACE("found catch(...) block\n");
}
/* unwind the stack */
RtlUnwind( frame, 0, rec, 0 );
cxx_local_unwind( frame, descr, tryblock->start_level );
frame->trylevel = tryblock->end_level + 1;
/* call the catch block */
TRACE( "calling catch block %p addr %p ebp %p\n",
catchblock, catchblock->handler, &frame->ebp );
/* setup an exception block for nested exceptions */
nested_frame.frame.Handler = (PEXCEPTION_ROUTINE)catch_function_nested_handler;
nested_frame.prev_rec = thread_data->exc_record;
nested_frame.cxx_frame = frame;
nested_frame.descr = descr;
nested_frame.trylevel = nested_trylevel + 1;
nested_frame.rec = rec;
__wine_push_frame( &nested_frame.frame );
thread_data->exc_record = rec;
addr = call_ebp_func( catchblock->handler, &frame->ebp );
thread_data->exc_record = nested_frame.prev_rec;
__wine_pop_frame( &nested_frame.frame );
((DWORD*)frame)[-1] = save_esp;
if (info && info->destructor) call_dtor( info->destructor, object );
TRACE( "done, continuing at %p\n", addr );
continue_after_catch( frame, addr );
}
}
}
/*********************************************************************
* cxx_frame_handler
*
* Implementation of __CxxFrameHandler.
*/
DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch,
const cxx_function_descr *descr,
EXCEPTION_REGISTRATION_RECORD* nested_frame,
int nested_trylevel )
{
cxx_exception_type *exc_type;
if (descr->magic < CXX_FRAME_MAGIC_VC6 || descr->magic > CXX_FRAME_MAGIC_VC8)
{
ERR( "invalid frame magic %x\n", descr->magic );
return ExceptionContinueSearch;
}
if (descr->magic >= CXX_FRAME_MAGIC_VC8 &&
(descr->flags & FUNC_DESCR_SYNCHRONOUS) &&
(rec->ExceptionCode != CXX_EXCEPTION))
return ExceptionContinueSearch; /* handle only c++ exceptions */
if (rec->ExceptionFlags & (EH_UNWINDING|EH_EXIT_UNWIND))
{
if (descr->unwind_count && !nested_trylevel) cxx_local_unwind( frame, descr, -1 );
return ExceptionContinueSearch;
}
if (!descr->tryblock_count) return ExceptionContinueSearch;
if(rec->ExceptionCode == CXX_EXCEPTION)
{
exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
if (rec->ExceptionInformation[0] > CXX_FRAME_MAGIC_VC8 &&
exc_type->custom_handler)
{
return exc_type->custom_handler( rec, frame, context, dispatch,
descr, nested_trylevel, nested_frame, 0 );
}
if (TRACE_ON(seh))
{
TRACE("handling C++ exception rec %p frame %p trylevel %d descr %p nested_frame %p\n",
rec, frame, frame->trylevel, descr, nested_frame );
dump_exception_type( exc_type );
dump_function_descr( descr );
}
}
else
{
exc_type = NULL;
TRACE("handling C exception code %x rec %p frame %p trylevel %d descr %p nested_frame %p\n",
rec->ExceptionCode, rec, frame, frame->trylevel, descr, nested_frame );
}
call_catch_block( rec, frame, descr, frame->trylevel, exc_type );
return ExceptionContinueSearch;
}
/*********************************************************************
* __CxxFrameHandler (MSVCRT.@)
*/
extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch );
#ifdef _MSC_VER
DWORD _declspec(naked) __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch )
{
__asm
{
push 0
push 0
push eax
push [esp + 28]
push [esp + 28]
push [esp + 28]
push [esp + 28]
call cxx_frame_handler
add esp, 28
ret
}
}
#else
__ASM_GLOBAL_FUNC( __CxxFrameHandler,
"pushl $0\n\t" /* nested_trylevel */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl $0\n\t" /* nested_frame */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl %eax\n\t" /* descr */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* dispatch */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* context */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* frame */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* rec */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"call " __ASM_NAME("cxx_frame_handler") "\n\t"
"add $28,%esp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset -28\n\t")
"ret" )
#endif
/*********************************************************************
* __CxxLongjmpUnwind (MSVCRT.@)
*
* Callback meant to be used as UnwindFunc for setjmp/longjmp.
*/
void __stdcall __CxxLongjmpUnwind( const struct __JUMP_BUFFER *buf )
{
cxx_exception_frame *frame = (cxx_exception_frame *)buf->Registration;
const cxx_function_descr *descr = (const cxx_function_descr *)buf->UnwindData[0];
TRACE( "unwinding frame %p descr %p trylevel %ld\n", frame, descr, buf->TryLevel );
cxx_local_unwind( frame, descr, buf->TryLevel );
}
#endif /* __i386__ */
/*********************************************************************
* __CppXcptFilter (MSVCRT.@)
*/
int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
return _XcptFilter( ex, ptr );
}
/*********************************************************************
* _CxxThrowException (MSVCRT.@)
*/
void WINAPI _CxxThrowException( exception *object, const cxx_exception_type *type )
{
ULONG_PTR args[3];
args[0] = CXX_FRAME_MAGIC_VC6;
args[1] = (ULONG_PTR)object;
args[2] = (ULONG_PTR)type;
RaiseException( CXX_EXCEPTION, EH_NONCONTINUABLE, 3, args );
}
/*********************************************************************
* __CxxDetectRethrow (MSVCRT.@)
*/
BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
{
PEXCEPTION_RECORD rec;
if (!ptrs)
return FALSE;
rec = ptrs->ExceptionRecord;
if (rec->ExceptionCode == CXX_EXCEPTION &&
rec->NumberParameters == 3 &&
rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
rec->ExceptionInformation[2])
{
ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
return TRUE;
}
return (msvcrt_get_thread_data()->exc_record == rec);
}
/*********************************************************************
* __CxxQueryExceptionSize (MSVCRT.@)
*/
unsigned int CDECL __CxxQueryExceptionSize(void)
{
return sizeof(cxx_exception_type);
}

302
sdk/lib/crt/except/except.c Normal file
View file

@ -0,0 +1,302 @@
/*
* msvcrt.dll exception handling
*
* Copyright 2000 Jon Griffiths
* Copyright 2005 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
*
* FIXME: Incomplete support for nested exceptions/try block cleanup.
*/
#include <precomp.h>
#include "excpt.h"
#include <wine/exception.h>
void CDECL _global_unwind2(EXCEPTION_REGISTRATION_RECORD* frame);
typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
static MSVCRT_security_error_handler security_error_handler;
/* VC++ extensions to Win32 SEH */
typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
int (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
{
EXCEPTION_REGISTRATION_RECORD *prev;
void (*handler)(PEXCEPTION_RECORD, EXCEPTION_REGISTRATION_RECORD*,
PCONTEXT, PEXCEPTION_RECORD);
PSCOPETABLE scopetable;
int trylevel;
int _ebp;
PEXCEPTION_POINTERS xpointers;
} MSVCRT_EXCEPTION_FRAME;
typedef struct
{
int gs_cookie_offset;
ULONG gs_cookie_xor;
int eh_cookie_offset;
ULONG eh_cookie_xor;
SCOPETABLE entries[1];
} SCOPETABLE_V4;
#ifdef __i386__
static const SCOPETABLE_V4 *get_scopetable_v4( MSVCRT_EXCEPTION_FRAME *frame, ULONG_PTR cookie )
{
return (const SCOPETABLE_V4 *)((ULONG_PTR)frame->scopetable ^ cookie);
}
#if defined(__GNUC__)
static inline void call_finally_block( void *code_block, void *base_ptr )
{
__asm__ __volatile__ ("movl %1,%%ebp; call *%%eax"
: : "a" (code_block), "g" (base_ptr));
}
static inline int call_filter( int (*func)(PEXCEPTION_POINTERS), void *arg, void *ebp )
{
int ret;
__asm__ __volatile__ ("pushl %%ebp; pushl %3; movl %2,%%ebp; call *%%eax; popl %%ebp; popl %%ebp"
: "=a" (ret)
: "0" (func), "r" (ebp), "r" (arg)
: "ecx", "edx", "memory" );
return ret;
}
static inline int call_unwind_func( int (*func)(void), void *ebp )
{
int ret;
__asm__ __volatile__ ("pushl %%ebp\n\t"
"pushl %%ebx\n\t"
"pushl %%esi\n\t"
"pushl %%edi\n\t"
"movl %2,%%ebp\n\t"
"call *%0\n\t"
"popl %%edi\n\t"
"popl %%esi\n\t"
"popl %%ebx\n\t"
"popl %%ebp"
: "=a" (ret)
: "0" (func), "r" (ebp)
: "ecx", "edx", "memory" );
return ret;
}
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4731) // Don't complain about changing ebp
void __inline call_finally_block( void *code_block, void *base_ptr )
{
__asm
{
mov eax, code_block
mov ebp, base_ptr
call [eax]
}
}
int __inline call_filter( int (*func)(PEXCEPTION_POINTERS), void *arg, void *_ebp )
{
int _ret;
__asm
{
push ebp
mov eax, arg
push eax
mov ebp, _ebp
mov eax, func
call [eax]
mov _ret, eax
pop ebp
pop ebp
}
return _ret;
}
int __inline call_unwind_func( int (*func)(void), void *_ebp )
{
int _ret;
__asm
{
push ebp
push ebx
push esi
push edi
mov ebp, _ebp
call dword ptr [func]
mov _ret, eax
pop edi
pop esi
pop ebx
pop ebp
}
return _ret;
}
#pragma warning(pop)
#endif
static DWORD MSVCRT_nested_handler(PEXCEPTION_RECORD rec,
EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context,
EXCEPTION_REGISTRATION_RECORD** dispatch)
{
if (!(rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
return ExceptionContinueSearch;
*dispatch = frame;
return ExceptionCollidedUnwind;
}
void msvcrt_local_unwind4( ULONG *cookie, MSVCRT_EXCEPTION_FRAME* frame, int trylevel, void *ebp )
{
EXCEPTION_REGISTRATION_RECORD reg;
const SCOPETABLE_V4 *scopetable = get_scopetable_v4( frame, *cookie );
TRACE("(%p,%d,%d)\n",frame, frame->trylevel, trylevel);
/* Register a handler in case of a nested exception */
reg.Handler = (PEXCEPTION_ROUTINE)MSVCRT_nested_handler;
reg.Prev = NtCurrentTeb()->NtTib.ExceptionList;
__wine_push_frame(&reg);
while (frame->trylevel != -2 && frame->trylevel != trylevel)
{
int level = frame->trylevel;
frame->trylevel = scopetable->entries[level].previousTryLevel;
if (!scopetable->entries[level].lpfnFilter)
{
TRACE( "__try block cleanup level %d handler %p ebp %p\n",
level, scopetable->entries[level].lpfnHandler, ebp );
call_unwind_func( scopetable->entries[level].lpfnHandler, ebp );
}
}
__wine_pop_frame(&reg);
TRACE("unwound OK\n");
}
/*********************************************************************
* _except_handler4_common (MSVCRT.@)
*/
int CDECL _except_handler4_common( ULONG *cookie, void (*check_cookie)(void),
EXCEPTION_RECORD *rec, MSVCRT_EXCEPTION_FRAME *frame,
CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
{
int retval, trylevel;
EXCEPTION_POINTERS exceptPtrs;
const SCOPETABLE_V4 *scope_table = get_scopetable_v4( frame, *cookie );
TRACE( "exception %x flags=%x at %p handler=%p %p %p cookie=%x scope table=%p cookies=%d/%x,%d/%x\n",
rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
frame->handler, context, dispatcher, *cookie, scope_table,
scope_table->gs_cookie_offset, scope_table->gs_cookie_xor,
scope_table->eh_cookie_offset, scope_table->eh_cookie_xor );
/* FIXME: no cookie validation yet */
if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
{
/* Unwinding the current frame */
msvcrt_local_unwind4( cookie, frame, -2, &frame->_ebp );
TRACE("unwound current frame, returning ExceptionContinueSearch\n");
return ExceptionContinueSearch;
}
else
{
/* Hunting for handler */
exceptPtrs.ExceptionRecord = rec;
exceptPtrs.ContextRecord = context;
*((DWORD *)frame-1) = (DWORD)&exceptPtrs;
trylevel = frame->trylevel;
while (trylevel != -2)
{
TRACE( "level %d prev %d filter %p\n", trylevel,
scope_table->entries[trylevel].previousTryLevel,
scope_table->entries[trylevel].lpfnFilter );
if (scope_table->entries[trylevel].lpfnFilter)
{
retval = call_filter( scope_table->entries[trylevel].lpfnFilter, &exceptPtrs, &frame->_ebp );
TRACE("filter returned %s\n", retval == EXCEPTION_CONTINUE_EXECUTION ?
"CONTINUE_EXECUTION" : retval == EXCEPTION_EXECUTE_HANDLER ?
"EXECUTE_HANDLER" : "CONTINUE_SEARCH");
if (retval == EXCEPTION_CONTINUE_EXECUTION)
return ExceptionContinueExecution;
if (retval == EXCEPTION_EXECUTE_HANDLER)
{
/* Unwind all higher frames, this one will handle the exception */
_global_unwind2((EXCEPTION_REGISTRATION_RECORD*)frame);
msvcrt_local_unwind4( cookie, frame, trylevel, &frame->_ebp );
/* Set our trylevel to the enclosing block, and call the __finally
* code, which won't return
*/
frame->trylevel = scope_table->entries[trylevel].previousTryLevel;
TRACE("__finally block %p\n",scope_table->entries[trylevel].lpfnHandler);
call_finally_block(scope_table->entries[trylevel].lpfnHandler, &frame->_ebp);
ERR("Returned from __finally block - expect crash!\n");
}
}
trylevel = scope_table->entries[trylevel].previousTryLevel;
}
}
TRACE("reached -2, returning ExceptionContinueSearch\n");
return ExceptionContinueSearch;
}
/*******************************************************************
* _local_unwind4 (MSVCRT.@)
*/
void CDECL _local_unwind4( ULONG *cookie, MSVCRT_EXCEPTION_FRAME* frame, int trylevel )
{
msvcrt_local_unwind4( cookie, frame, trylevel, &frame->_ebp );
}
/*********************************************************************
* _seh_longjmp_unwind4 (MSVCRT.@)
*/
void __stdcall _seh_longjmp_unwind4(struct __JUMP_BUFFER *jmp)
{
msvcrt_local_unwind4( (void *)jmp->Cookie, (MSVCRT_EXCEPTION_FRAME *)jmp->Registration,
jmp->TryLevel, (void *)jmp->Ebp );
}
#endif
/******************************************************************
* __uncaught_exception
*/
BOOL CDECL __uncaught_exception(void)
{
return FALSE;
}
/* _set_security_error_handler - not exported in native msvcrt, added in msvcr70 */
MSVCRT_security_error_handler CDECL _set_security_error_handler(
MSVCRT_security_error_handler handler )
{
MSVCRT_security_error_handler old = security_error_handler;
TRACE("(%p)\n", handler);
security_error_handler = handler;
return old;
}

View file

@ -0,0 +1,36 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS C run time library
* PURPOSE: Stack checker
* PROGRAMMERS: Jérôme Gardou
*/
#include <asm.inc>
#include <ks386.inc>
/* Code is taken from wine 1.3.33,
* Copyright Jon Griffiths and Alexandre Julliard
*/
EXTERN __chkesp_failed:PROC
PUBLIC __chkesp
.code
__chkesp:
jnz .test_failed
ret
.test_failed:
push ebp
mov ebp, esp
sub esp, 12
push eax
push ecx
push edx
call __chkesp_failed
pop edx
pop ecx
pop eax
leave
ret
END

View file

@ -0,0 +1,100 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Stack checker
* FILE: lib/sdk/crt/except/i386/chkstk_asm.s
* PROGRAMER: KJK::Hyperion <noog@libero.it>
*/
#include <asm.inc>
#include <ks386.inc>
#define PAGE_SIZE 4096
PUBLIC __chkstk
PUBLIC __alloca_probe
PUBLIC __alloca_probe_16
.code
/* 16 byte aligned alloca probe
* EAX = size to be allocated */
__alloca_probe_16:
/* save the ECX register */
push ecx
/* ecx = top of the previous stack frame */
lea ecx, [esp + 8]
/* Calculate end of allocation */
sub ecx, eax
/* Get the misalignment */
and ecx, 15
/* Add the misalignment to the original alloc size */
add eax, ecx
/* Check for overflow */
jnc l1
/* Set maximum value */
mov eax, HEX(0ffffffff)
l1:
/* Restore ecx */
pop ecx
/* Fall through to __chkstk */
/*
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
stack in areas of 4 KB each, trying to access each area. This ensures that the
guard page for the stack is hit, and the stack growing triggered
*/
__chkstk:
__alloca_probe:
/* EAX = size to be allocated */
/* save the ECX register */
push ecx
/* ECX = top of the previous stack frame */
lea ecx, [esp + 8]
/* probe the desired memory, page by page */
cmp eax, PAGE_SIZE
jl .l_LessThanAPage
.l_MoreThanAPage:
/* raise the top of the stack by a page and probe */
sub ecx, PAGE_SIZE
test [ecx], eax
/* loop if still more than a page must be probed */
sub eax, PAGE_SIZE
cmp eax, PAGE_SIZE
jge .l_MoreThanAPage
.l_LessThanAPage:
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
sub ecx, eax
test [ecx], eax
/* EAX = top of the stack */
mov eax, esp
/* allocate the memory */
mov esp, ecx
/* restore ECX */
mov ecx, [eax]
/* restore the return address */
mov eax, [eax + 4]
push eax
/* return */
ret
/* EOF */
END

View file

@ -0,0 +1,59 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Stack checker
* PROGRAMERS: KJK::Hyperion <noog@libero.it>
* Richard Henderson <rth@redhat.com>
* Kai Tietz <kai.tietz@onevision.com>
* Timo Kreuzer <timo.kreuzer@reactos.org>
*/
#include <asm.inc>
#include <ks386.inc>
#define PAGE_SIZE 4096
PUBLIC ___chkstk_ms
.code
/* Special version, that does only probe and not allocate */
___chkstk_ms:
/* EAX = size to be allocated */
/* save the ECX and EAX register */
push ecx
push eax
/* ECX = top of the previous stack frame */
lea ecx, [esp + 12]
/* probe the desired memory, page by page */
cmp eax, PAGE_SIZE
jl .l_LessThanAPage
.l_MoreThanAPage:
/* raise the top of the stack by a page and probe */
sub ecx, PAGE_SIZE
test [ecx], eax
/* loop if still more than a page must be probed */
sub eax, PAGE_SIZE
cmp eax, PAGE_SIZE
jge .l_MoreThanAPage
.l_LessThanAPage:
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
sub ecx, eax
test [ecx], eax
/* restore ECX and EAX */
pop eax
pop ecx
/* return */
ret
/* EOF */
END

View file

@ -0,0 +1,112 @@
#include <asm.inc>
.code
.align 4
MACRO(DEFINE_THISCALL_WRAPPER, cxxname, stdcallname)
EXTERN &stdcallname:PROC
PUBLIC &cxxname
&cxxname:
pop eax
push ecx
push eax
jmp &stdcallname
ENDM
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@ABQBD@Z, _MSVCRT_exception_ctor@8
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@ABQBDH@Z, _MSVCRT_exception_ctor_noalloc@12
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@ABV0@@Z, _MSVCRT_exception_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@XZ, _MSVCRT_exception_default_ctor@4
DEFINE_THISCALL_WRAPPER ??1exception@@UAE@XZ, _MSVCRT_exception_dtor@4
DEFINE_THISCALL_WRAPPER ??4exception@@QAEAAV0@ABV0@@Z, _MSVCRT_exception_opequals@8
DEFINE_THISCALL_WRAPPER ??_Eexception@@UAEPAXI@Z, _MSVCRT_exception_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_Gexception@@UAEPAXI@Z, _MSVCRT_exception_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ?what@exception@@UBEPBDXZ, _MSVCRT_what_exception@4
DEFINE_THISCALL_WRAPPER ??0bad_typeid@@QAE@ABV0@@Z, _MSVCRT_bad_typeid_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_typeid@@QAE@PBD@Z, _MSVCRT_bad_typeid_ctor@8
DEFINE_THISCALL_WRAPPER ??_Fbad_typeid@@QAEXXZ, _MSVCRT_bad_typeid_default_ctor@4
DEFINE_THISCALL_WRAPPER ??1bad_typeid@@UAE@XZ, _MSVCRT_bad_typeid_dtor@4
DEFINE_THISCALL_WRAPPER ??4bad_typeid@@QAEAAV0@ABV0@@Z, _MSVCRT_bad_typeid_opequals@8
DEFINE_THISCALL_WRAPPER ??_Ebad_typeid@@UAEPAXI@Z, _MSVCRT_bad_typeid_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_Gbad_typeid@@UAEPAXI@Z, _MSVCRT_bad_typeid_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ??0__non_rtti_object@@QAE@ABV0@@Z, _MSVCRT___non_rtti_object_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0__non_rtti_object@@QAE@PBD@Z, _MSVCRT___non_rtti_object_ctor@8
DEFINE_THISCALL_WRAPPER ??1__non_rtti_object@@UAE@XZ, _MSVCRT___non_rtti_object_dtor@4
DEFINE_THISCALL_WRAPPER ??4__non_rtti_object@@QAEAAV0@ABV0@@Z, _MSVCRT___non_rtti_object_opequals@8
DEFINE_THISCALL_WRAPPER ??_E__non_rtti_object@@UAEPAXI@Z, _MSVCRT___non_rtti_object_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_G__non_rtti_object@@UAEPAXI@Z, _MSVCRT___non_rtti_object_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@AAE@PBQBD@Z, _MSVCRT_bad_cast_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@QAE@ABQBD@Z, _MSVCRT_bad_cast_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@QAE@ABV0@@Z, _MSVCRT_bad_cast_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@QAE@PBD@Z, _MSVCRT_bad_cast_ctor_charptr@8
DEFINE_THISCALL_WRAPPER ??_Fbad_cast@@QAEXXZ, _MSVCRT_bad_cast_default_ctor@4
DEFINE_THISCALL_WRAPPER ??1bad_cast@@UAE@XZ, _MSVCRT_bad_cast_dtor@4
DEFINE_THISCALL_WRAPPER ??4bad_cast@@QAEAAV0@ABV0@@Z, _MSVCRT_bad_cast_opequals@8
DEFINE_THISCALL_WRAPPER ??_Ebad_cast@@UAEPAXI@Z, _MSVCRT_bad_cast_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_Gbad_cast@@UAEPAXI@Z, _MSVCRT_bad_cast_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ??8type_info@@QBEHABV0@@Z, _MSVCRT_type_info_opequals_equals@8
DEFINE_THISCALL_WRAPPER ??9type_info@@QBEHABV0@@Z, _MSVCRT_type_info_opnot_equals@8
DEFINE_THISCALL_WRAPPER ?before@type_info@@QBEHABV1@@Z, _MSVCRT_type_info_before@8
DEFINE_THISCALL_WRAPPER ??1type_info@@UAE@XZ, _MSVCRT_type_info_dtor@4
DEFINE_THISCALL_WRAPPER ?name@type_info@@QBEPBDXZ, _MSVCRT_type_info_name@4
DEFINE_THISCALL_WRAPPER ?raw_name@type_info@@QBEPBDXZ, _MSVCRT_type_info_raw_name@4
#undef _MSVCRT_
MACRO(START_VTABLE, shortname, cxxname)
EXTERN _&shortname&_rtti:PROC
EXTERN ___thiscall_MSVCRT_&shortname&_vector_dtor:PROC
.long _&shortname&_rtti
PUBLIC _MSVCRT_&shortname&_vtable
_MSVCRT_&shortname&_vtable:
PUBLIC &cxxname
&cxxname:
.long ___thiscall_MSVCRT_&shortname&_vector_dtor
ENDM
MACRO(DEFINE_EXCEPTION_VTABLE, shortname, cxxname)
START_VTABLE shortname, cxxname
EXTERN ___thiscall_MSVCRT_what_exception:PROC
.long ___thiscall_MSVCRT_what_exception
ENDM
START_VTABLE type_info, __dummyname_type_info
DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
EXTERN _MSVCRT_operator_delete:PROC
PUBLIC ??3@YAXPAX@Z
??3@YAXPAX@Z:
jmp _MSVCRT_operator_delete
EXTERN _MSVCRT_operator_new:PROC
PUBLIC ??_U@YAPAXI@Z
??_U@YAPAXI@Z:
jmp _MSVCRT_operator_new
MACRO(DEFINE_ALIAS, alias, orig, type)
EXTERN &orig:&type
ALIAS <&alias> = <&orig>
ENDM
DEFINE_ALIAS ??_V@YAXPAX@Z, _MSVCRT_operator_delete, PROC
DEFINE_ALIAS ??2@YAPAXI@Z, _MSVCRT_operator_new, PROC
DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, _MSVCRT__query_new_handler, PROC
DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, _MSVCRT__set_new_handler, PROC
DEFINE_ALIAS ?set_new_handler@@YAP6AXXZP6AXXZ@Z, _MSVCRT_set_new_handler, PROC
DEFINE_ALIAS ?_query_new_mode@@YAHXZ, _MSVCRT__query_new_mode, PROC
DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, _MSVCRT__set_new_mode, PROC
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, _MSVCRT__set_se_translator, PROC
DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, _MSVCRT_set_terminate, PROC
DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, _MSVCRT_set_unexpected, PROC
DEFINE_ALIAS ?terminate@@YAXXZ, _MSVCRT_terminate, PROC
DEFINE_ALIAS ?unexpected@@YAXXZ, _MSVCRT_unexpected, PROC
END

View file

@ -0,0 +1,30 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT
* FILE: lib/sdk/crt/except/i386/prolog.s
* PURPOSE: SEH Support for the CRT
* PROGRAMMERS: Wine Development Team
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ks386.inc>
/* FUNCTIONS *****************************************************************/
.code
PUBLIC __EH_prolog
// Copied from Wine.
__EH_prolog:
push -1
push eax
push fs:0
mov fs:0, esp
mov eax, [esp + 12]
mov [esp + 12], ebp
lea ebp, [esp + 12]
push eax
ret
END

View file

@ -0,0 +1,39 @@
#define WIN32_NO_STATUS
#include <precomp.h>
#define NTOS_MODE_USER
#include <setjmp.h>
#include <ndk/umtypes.h>
#include <ndk/extypes.h>
#include <ndk/rtlfuncs.h>
/* VC++ extensions to Win32 SEH */
typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
int (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
{
PEXCEPTION_REGISTRATION_RECORD *prev;
void (*handler)(PEXCEPTION_RECORD, PEXCEPTION_REGISTRATION_RECORD,
PCONTEXT, PEXCEPTION_RECORD);
PSCOPETABLE scopetable;
int trylevel;
int _ebp;
PEXCEPTION_POINTERS xpointers;
} MSVCRT_EXCEPTION_FRAME;
void
_local_unwind2(MSVCRT_EXCEPTION_FRAME *RegistrationFrame,
LONG TryLevel);
/*
* @implemented
*/
void __stdcall _seh_longjmp_unwind(_JUMP_BUFFER *jmp)
{
_local_unwind2((MSVCRT_EXCEPTION_FRAME*) jmp->Registration, jmp->TryLevel);
}

View file

@ -0,0 +1,65 @@
#include <precomp.h>
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#include <math.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
#ifndef HAVE_FINITE
#ifndef finite /* Could be a macro */
#ifdef isfinite
#define finite(x) isfinite(x)
#else
#define finite(x) (!isnan(x)) /* At least catch some cases */
#endif
#endif
#endif
#ifndef signbit
#define signbit(x) 0
#endif
typedef int (*MSVCRT_matherr_func)(struct _exception *);
static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
int CDECL _matherr(struct _exception *e)
{
if (e)
TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
e->retval);
else
TRACE("(null)\n");
if (MSVCRT_default_matherr_func)
return MSVCRT_default_matherr_func(e);
ERR(":Unhandled math error!\n");
return 0;
}
/*********************************************************************
* __setusermatherr (MSVCRT.@)
*/
void CDECL __setusermatherr(MSVCRT_matherr_func func)
{
MSVCRT_default_matherr_func = func;
TRACE(":new matherr handler %p\n", func);
}
#define _FPIEEE_RECORD void
/*
* @unimplemented
*/
int _fpieee_flt(
unsigned long exception_code,
struct _EXCEPTION_POINTERS* ExceptionPointer,
int (*handler)(_FPIEEE_RECORD*)
)
{
FIXME("Unimplemented!\n");
return 0;
}

View file

@ -0,0 +1,22 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Stack checker
* FILE: lib/sdk/crt/except/powerpc/chkstk_asm.s
* PROGRAMER: arty
*/
.globl _chkstk
.globl _alloca_probe
/*
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
stack in areas of 4 KB each, trying to access each area. This ensures that the
guard page for the stack is hit, and the stack growing triggered
*/
_chkstk:
_alloca_probe:
/* return */
blr
/* EOF */

View file

@ -0,0 +1,75 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT
* FILE: lib/sdk/crt/except/powerpc/seh.s
* PURPOSE: SEH Support for the CRT
* PROGRAMMERS: arty
*/
/* INCLUDES ******************************************************************/
#include <ndk/asm.h>
#define DISPOSITION_DISMISS 0
#define DISPOSITION_CONTINUE_SEARCH 1
#define DISPOSITION_COLLIDED_UNWIND 3
/* GLOBALS *******************************************************************/
.globl _global_unwind2
.globl _local_unwind2
.globl _abnormal_termination
.globl _except_handler2
.globl _except_handler3
/* FUNCTIONS *****************************************************************/
unwind_handler:
blr
_global_unwind2:
blr
_local_unwind2:
blr
_except_handler2:
blr
_except_handler3:
blr
//
//
// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME
// sorry
//
//
.globl RtlpGetStackLimits
RtlpGetStackLimits:
stwu 1,16(1)
mflr 0
stw 0,4(1)
stw 3,8(1)
stw 4,12(1)
/* Get the current thread */
lwz 3,KPCR_CURRENT_THREAD(13)
/* Get the stack limits */
lwz 4,KTHREAD_STACK_LIMIT(3)
lwz 5,KTHREAD_INITIAL_STACK(3)
subi 5,5,SIZEOF_FX_SAVE_AREA
/* Return them */
lwz 3,8(1)
stw 4,0(3)
lwz 3,12(1)
stw 5,0(3)
addi 1,1,16
/* return */
blr

View file

@ -0,0 +1,45 @@
#include <precomp.h>
/*********************************************************************
* _chkesp (MSVCRT.@)
*
* Trap to a debugger if the value of the stack pointer has changed.
*
* PARAMS
* None.
*
* RETURNS
* Does not return.
*
* NOTES
* This function is available for iX86 only.
*
* When VC++ generates debug code, it stores the value of the stack pointer
* before calling any external function, and checks the value following
* the call. It then calls this function, which will trap if the values are
* not the same. Usually this means that the prototype used to call
* the function is incorrect. It can also mean that the .spec entry has
* the wrong calling convention or parameters.
*/
#ifdef __i386__
void _chkesp_failed(void)
{
ERR("stack got corrupted!\n");
__debugbreak();
}
#endif /* __i386__ */
/*********************************************************************
* _resetstkoflw (MSVCRT.@)
*/
int CDECL _resetstkoflw(void)
{
int stack_addr;
DWORD oldprot;
/* causes stack fault that updates NtCurrentTeb()->Tib.StackLimit */
return VirtualProtect(&stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, &oldprot);
}

View file

@ -0,0 +1,98 @@
#include <precomp.h>
#include "internal/wine/msvcrt.h"
#include "internal/wine/cppexcept.h"
typedef void (*sighandler_t)(int);
static sighandler_t sighandlers[NSIG] = { SIG_DFL };
/* The exception codes are actually NTSTATUS values */
static const struct
{
NTSTATUS status;
int signal;
} float_exception_map[] = {
{ EXCEPTION_FLT_DENORMAL_OPERAND, _FPE_DENORMAL },
{ EXCEPTION_FLT_DIVIDE_BY_ZERO, _FPE_ZERODIVIDE },
{ EXCEPTION_FLT_INEXACT_RESULT, _FPE_INEXACT },
{ EXCEPTION_FLT_INVALID_OPERATION, _FPE_INVALID },
{ EXCEPTION_FLT_OVERFLOW, _FPE_OVERFLOW },
{ EXCEPTION_FLT_STACK_CHECK, _FPE_STACKOVERFLOW },
{ EXCEPTION_FLT_UNDERFLOW, _FPE_UNDERFLOW },
};
/*
* @implemented
*/
int CDECL
_XcptFilter(NTSTATUS ExceptionCode,
struct _EXCEPTION_POINTERS * except)
{
LONG ret = EXCEPTION_CONTINUE_SEARCH;
sighandler_t handler;
if (!except || !except->ExceptionRecord)
return EXCEPTION_CONTINUE_SEARCH;
switch (except->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
if ((handler = sighandlers[SIGSEGV]) != SIG_DFL)
{
if (handler != SIG_IGN)
{
sighandlers[SIGSEGV] = SIG_DFL;
handler(SIGSEGV);
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
/* According to msdn,
* the FPE signal handler takes as a second argument the type of
* floating point exception.
*/
case EXCEPTION_FLT_DENORMAL_OPERAND:
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_FLT_INEXACT_RESULT:
case EXCEPTION_FLT_INVALID_OPERATION:
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_FLT_UNDERFLOW:
if ((handler = sighandlers[SIGFPE]) != SIG_DFL)
{
if (handler != SIG_IGN)
{
unsigned int i;
int float_signal = _FPE_INVALID;
sighandlers[SIGFPE] = SIG_DFL;
for (i = 0; i < sizeof(float_exception_map) /
sizeof(float_exception_map[0]); i++)
{
if (float_exception_map[i].status ==
except->ExceptionRecord->ExceptionCode)
{
float_signal = float_exception_map[i].signal;
break;
}
}
((float_handler)handler)(SIGFPE, float_signal);
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_PRIV_INSTRUCTION:
if ((handler = sighandlers[SIGILL]) != SIG_DFL)
{
if (handler != SIG_IGN)
{
sighandlers[SIGILL] = SIG_DFL;
handler(SIGILL);
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
}
return ret;
}

View file

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

View file

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

View file

@ -0,0 +1,24 @@
#include <asm.inc>
.code64
PUBLIC __getfpcw87
FUNC __getfpcw87
sub rsp, 8
.ENDPROLOG
stmxcsr [rsp]
mov rax, [rsp]
add rsp, 8
ret
ENDFUNC
PUBLIC __setfpcw87
FUNC __setfpcw87
mov qword ptr [rsp + 8], rcx
.ENDPROLOG
ldmxcsr [rsp + 8]
ret
ENDFUNC
END

View file

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

View file

@ -0,0 +1,24 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT library
* PURPOSE: Implementation of _clearfp
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _clearfp
__assertfail
bx lr
LEAF_END _clearfp
END
/* EOF */

View file

@ -0,0 +1,24 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT library
* PURPOSE: Implementation of _controlfp
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _controlfp
__assertfail
bx lr
LEAF_END _controlfp
END
/* EOF */

View file

@ -0,0 +1,24 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT library
* PURPOSE: Implementation of _fpreset
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _fpreset
__assertfail
bx lr
LEAF_END _fpreset
END
/* EOF */

View file

@ -0,0 +1,24 @@
/*
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
* PROJECT: ReactOS CRT library
* PURPOSE: Implementation of _statusfp
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <kxarm.h>
/* CODE **********************************************************************/
TEXTAREA
LEAF_ENTRY _statusfp
__assertfail
bx lr
LEAF_END _statusfp
END
/* EOF */

View file

@ -0,0 +1,33 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/chgsign.c
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <internal/ieee.h>
/*
* @implemented
*/
double _chgsign( double __x )
{
union
{
double* __x;
double_s *x;
} u;
u.__x = &__x;
if ( u.x->sign == 1 )
u.x->sign = 0;
else
u.x->sign = 1;
return __x;
}

View file

@ -0,0 +1,36 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/copysign.c
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <internal/ieee.h>
/*
* @implemented
*/
double _copysign (double __d, double __s)
{
union
{
double* __d;
double_s* d;
} d;
union
{
double* __s;
double_s* s;
} s;
d.__d = &__d;
s.__s = &__s;
d.d->sign = s.s->sign;
return __d;
}

View file

@ -0,0 +1,58 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/fpclass.c
* PURPOSE: Floating-point classes
* PROGRAMER: Pierre Schweitzer (pierre@reactos.org)
* REFERENCE: http://babbage.cs.qc.cuny.edu/IEEE-754/References.xhtml
*/
#include <precomp.h>
#include <float.h>
#include <internal/ieee.h>
/*
* @implemented
*/
int _fpclass(double __d)
{
union
{
double* __d;
double_s* d;
} d;
d.__d = &__d;
/* With 0x7ff, it can only be infinity or NaN */
if (d.d->exponent == 0x7ff)
{
if (d.d->mantissah == 0 && d.d->mantissal == 0)
{
return (d.d->sign == 0) ? _FPCLASS_PINF : _FPCLASS_NINF;
}
/* Windows will never return Signaling NaN */
else
{
return _FPCLASS_QNAN;
}
}
/* With 0, it can only be zero or denormalized number */
if (d.d->exponent == 0)
{
if (d.d->mantissah == 0 && d.d->mantissal == 0)
{
return (d.d->sign == 0) ? _FPCLASS_PZ : _FPCLASS_NZ;
}
else
{
return (d.d->sign == 0) ? _FPCLASS_PD : _FPCLASS_ND;
}
}
/* Only remain normalized numbers */
else
{
return (d.d->sign == 0) ? _FPCLASS_PN : _FPCLASS_NN;
}
}

View file

@ -0,0 +1,19 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/fpecode.c
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
/*
* @implemented
*/
int * __fpecode(void)
{
return &msvcrt_get_thread_data()->fpecode;
}

View file

@ -0,0 +1,28 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/i386/clearfp.c
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
unsigned int _statusfp( void );
/*********************************************************************
* _clearfp (MSVCRT.@)
*/
unsigned int CDECL _clearfp(void)
{
unsigned int retVal = _statusfp();
#if defined(__GNUC__)
__asm__ __volatile__( "fnclex" );
#else
__asm fnclex;
#endif
return retVal;
}

View file

@ -0,0 +1,137 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <precomp.h>
#include <float.h>
#define X87_CW_IM (1<<0) /* Invalid operation mask */
#define X87_CW_DM (1<<1) /* Denormal operand mask */
#define X87_CW_ZM (1<<2) /* Zero divide mask */
#define X87_CW_OM (1<<3) /* Overflow mask */
#define X87_CW_UM (1<<4) /* Underflow mask */
#define X87_CW_PM (1<<5) /* Precision mask */
#define X87_CW_PC_MASK (3<<8) /* precision control mask */
#define X87_CW_PC24 (0<<8) /* 24 bit precision */
#define X87_CW_PC53 (2<<8) /* 53 bit precision */
#define X87_CW_PC64 (3<<8) /* 64 bit precision */
#define X87_CW_RC_MASK (3<<10) /* rounding control mask */
#define X87_CW_RC_NEAREST (0<<10) /* round to nearest */
#define X87_CW_RC_DOWN (1<<10) /* round down */
#define X87_CW_RC_UP (2<<10) /* round up */
#define X87_CW_RC_ZERO (3<<10) /* round toward zero (chop) */
#define X87_CW_IC (1<<12) /* infinity control flag */
#ifdef _M_AMD64
unsigned int __getfpcw87(void);
void __setfpcw87(unsigned int);
#endif
/*
* @implemented
*/
unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask)
{
return _control87( newval, mask & ~_EM_DENORMAL );
}
/*********************************************************************
* _control87 (MSVCRT.@)
*/
unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
{
unsigned short fpword = 0;
unsigned int flags = 0;
TRACE("(%08x, %08x): Called\n", newval, mask);
/* Get fp control word */
#ifdef _M_AMD64
fpword = __getfpcw87();
#elif defined(__GNUC__)
__asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
#else
__asm fstcw [fpword];
#endif
TRACE("Control word before : %08x\n", fpword);
/* Convert into mask constants */
if (fpword & 0x1) flags |= _EM_INVALID;
if (fpword & 0x2) flags |= _EM_DENORMAL;
if (fpword & 0x4) flags |= _EM_ZERODIVIDE;
if (fpword & 0x8) flags |= _EM_OVERFLOW;
if (fpword & 0x10) flags |= _EM_UNDERFLOW;
if (fpword & 0x20) flags |= _EM_INEXACT;
switch(fpword & 0xC00) {
case 0xC00: flags |= _RC_UP|_RC_DOWN; break;
case 0x800: flags |= _RC_UP; break;
case 0x400: flags |= _RC_DOWN; break;
}
switch(fpword & 0x300) {
case 0x0: flags |= _PC_24; break;
case 0x200: flags |= _PC_53; break;
case 0x300: flags |= _PC_64; break;
}
if (fpword & 0x1000) flags |= _IC_AFFINE;
/* Mask with parameters */
flags = (flags & ~mask) | (newval & mask);
/* Convert (masked) value back to fp word */
fpword = 0;
if (flags & _EM_INVALID) fpword |= 0x1;
if (flags & _EM_DENORMAL) fpword |= 0x2;
if (flags & _EM_ZERODIVIDE) fpword |= 0x4;
if (flags & _EM_OVERFLOW) fpword |= 0x8;
if (flags & _EM_UNDERFLOW) fpword |= 0x10;
if (flags & _EM_INEXACT) fpword |= 0x20;
switch(flags & (_RC_UP | _RC_DOWN)) {
case _RC_UP|_RC_DOWN: fpword |= 0xC00; break;
case _RC_UP: fpword |= 0x800; break;
case _RC_DOWN: fpword |= 0x400; break;
}
switch (flags & (_PC_24 | _PC_53)) {
case _PC_64: fpword |= 0x300; break;
case _PC_53: fpword |= 0x200; break;
case _PC_24: fpword |= 0x0; break;
}
if (flags & _IC_AFFINE) fpword |= 0x1000;
TRACE("Control word after : %08x\n", fpword);
/* Put fp control word */
#ifdef _M_AMD64
__setfpcw87(fpword);
#elif defined(__GNUC__)
__asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
#else
__asm fldcw [fpword];
#endif
return flags;
}
/*********************************************************************
* _controlfp_s (MSVCRT.@)
*/
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
{
#ifdef __i386__
unsigned int val;
if (!MSVCRT_CHECK_PMT( !(newval & mask & ~(_MCW_EM | _MCW_IC | _MCW_RC | _MCW_PC | _MCW_DN))))
{
if (cur) *cur = _controlfp( 0, 0 ); /* retrieve it anyway */
return EINVAL;
}
val = _controlfp( newval, mask );
if (cur) *cur = val;
return 0;
#else
FIXME(":Not Implemented!\n");
return 0;
#endif
}

View file

@ -0,0 +1,31 @@
/*
* COPYRIGHT: See COPYING.LIB in the top level directory
* PROJECT: ReactOS system libraries
* PURPOSE: Resets FPU state to the default
* PROGRAMER: Thomas Faber <thomas.faber@reactos.org>
*/
#include <precomp.h>
/*********************************************************************
* _fpreset (MSVCRT.@)
*/
void CDECL _fpreset(void)
{
const unsigned short x86_cw = 0x27f;
#ifdef _MSC_VER
__asm { fninit }
__asm { fldcw [x86_cw] }
#else
__asm__ __volatile__( "fninit; fldcw %0" : : "m" (x86_cw) );
#endif
if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
{
const unsigned long sse2_cw = 0x1f80;
#ifdef _MSC_VER
__asm { ldmxcsr [sse2_cw] }
#else
__asm__ __volatile__( "ldmxcsr %0" : : "m" (sse2_cw) );
#endif
}
}

View file

@ -0,0 +1,40 @@
/* 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 <precomp.h>
double _logb (double __x)
{
register double __val;
#ifdef __GNUC__
register double __junk;
__asm __volatile__
("fxtract\n\t"
: "=t" (__junk), "=u" (__val) : "0" (__x));
#else
#pragma message ("REVIEW ME")
__asm fld [__x];
__asm fxtract;
__asm fstp st(0);
__asm fstp [__val];
#endif /*__GNUC__*/
return __val;
}

View file

@ -0,0 +1,44 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/i386/statfp.c
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include "float.h"
//WTF IS HAPPENING WITH float.h !??!?!
#define _SW_INVALID 0x00000010 /* invalid */
#define _SW_ZERODIVIDE 0x00000008 /* zero divide */
#define _SW_UNDERFLOW 0x00000002 /* underflow */
#define _SW_OVERFLOW 0x00000004 /* overflow */
#define _SW_INEXACT 0x00000001 /* inexact (precision) */
#define _SW_DENORMAL 0x00080000 /* denormal status bit */
/**********************************************************************
* _statusfp (MSVCRT.@)
*/
unsigned int CDECL _statusfp(void)
{
unsigned int retVal = 0;
unsigned short fpword;
#ifdef _M_AMD64
fpword = _mm_getcsr();
#elif defined(__GNUC__)
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
#else // _MSC_VER
__asm fstsw [fpword];
#endif
if (fpword & 0x1) retVal |= _SW_INVALID;
if (fpword & 0x2) retVal |= _SW_DENORMAL;
if (fpword & 0x4) retVal |= _SW_ZERODIVIDE;
if (fpword & 0x8) retVal |= _SW_OVERFLOW;
if (fpword & 0x10) retVal |= _SW_UNDERFLOW;
if (fpword & 0x20) retVal |= _SW_INEXACT;
return retVal;
}

54
sdk/lib/crt/float/isnan.c Normal file
View file

@ -0,0 +1,54 @@
/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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 <precomp.h>
#if defined(_MSC_VER) && defined(_M_ARM)
#pragma function(_isnan)
#endif /* _MSC_VER */
/*
* @implemented
*/
int CDECL _isnan(double __x)
{
union
{
double* __x;
double_s* x;
} x;
x.__x = &__x;
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
}
/*
* @implemented
*/
int CDECL _finite(double __x)
{
union
{
double* __x;
double_s* x;
} x;
x.__x = &__x;
return ((x.x->exponent & 0x7ff) != 0x7ff);
}

View file

@ -0,0 +1,26 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/nafter.c
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
/*
* @implemented
*/
double _nextafter( double x, double y )
{
WARN("This function is not implemented correctly\n");
if ( x == y)
return x;
if ( _isnan(x) || _isnan(y) )
return x;
return x;
}

17
sdk/lib/crt/float/scalb.c Normal file
View file

@ -0,0 +1,17 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/float/scalb.c
* PURPOSE: Floating-point number scaling
* PROGRAMER: Pierre Schweitzer (pierre@reactos.org)
*/
#include <precomp.h>
/*
* @implemented
*/
double _scalb(double x, long exp)
{
return ldexp(x, exp);
}

176
sdk/lib/crt/include/float.h Normal file
View file

@ -0,0 +1,176 @@
/*
* float.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Constants related to floating point arithmetic.
*
* Also included here are some non-ANSI bits for accessing the floating
* point controller.
*
* NOTE: GCC provides float.h, but it doesn't include the non-standard
* stuff for accessing the fp controller. We include_next the
* GCC-supplied header and just define the MS-specific extensions
* here.
*
*/
#ifdef __GNUC__
#include_next <float.h>
#endif
#ifndef _MINGW_FLOAT_H_
#define _MINGW_FLOAT_H_
/* All the headers include this file. */
#ifdef __GNUC__
#include <_mingw.h>
#endif
/*
* Functions and definitions for controlling the FPU.
*/
#ifndef __STRICT_ANSI__
/* TODO: These constants are only valid for x86 machines */
/* Control word masks for unMask */
#define _MCW_EM 0x0008001F /* Error masks */
#define _MCW_IC 0x00040000 /* Infinity */
#define _MCW_RC 0x00000300 /* Rounding */
#define _MCW_PC 0x00030000 /* Precision */
/* Control word values for unNew (use with related unMask above) */
#define _EM_INVALID 0x00000010
#define _EM_DENORMAL 0x00080000
#define _EM_ZERODIVIDE 0x00000008
#define _EM_OVERFLOW 0x00000004
#define _EM_UNDERFLOW 0x00000002
#define _EM_INEXACT 0x00000001
#define _IC_AFFINE 0x00040000
#define _IC_PROJECTIVE 0x00000000
#define _RC_CHOP 0x00000300
#define _RC_UP 0x00000200
#define _RC_DOWN 0x00000100
#define _RC_NEAR 0x00000000
#define _PC_24 0x00020000
#define _PC_53 0x00010000
#define _PC_64 0x00000000
/* These are also defined in Mingw math.h, needed to work around
GCC build issues. */
/* Return values for fpclass. */
#ifndef __MINGW_FPCLASS_DEFINED
#define __MINGW_FPCLASS_DEFINED 1
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
#define _FPCLASS_NN 0x0008 /* Negative Normal */
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
#define _FPCLASS_PN 0x0100 /* Positive Normal */
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
#endif /* __MINGW_FPCLASS_DEFINED */
/* _statusfp bit flags */
#define _SW_INEXACT 0x00000001 /* inexact (precision) */
#define _SW_UNDERFLOW 0x00000002 /* underflow */
#define _SW_OVERFLOW 0x00000004 /* overflow */
#define _SW_ZERODIVIDE 0x00000008 /* zero divide */
#define _SW_INVALID 0x00000010 /* invalid */
#define _SW_DENORMAL 0x00080000 /* denormal status bit */
#define _SW_UNEMULATED 0x00000040 /* unemulated instruction */
#define _SW_SQRTNEG 0x00000080 /* square root of a neg number */
#define _SW_STACKOVERFLOW 0x00000200 /* FP stack overflow */
#define _SW_STACKUNDERFLOW 0x00000400 /* FP stack underflow */
/* Floating point error signals and return codes */
#define _FPE_INVALID 0x81
#define _FPE_DENORMAL 0x82
#define _FPE_ZERODIVIDE 0x83
#define _FPE_OVERFLOW 0x84
#define _FPE_UNDERFLOW 0x85
#define _FPE_INEXACT 0x86
#define _FPE_UNEMULATED 0x87
#define _FPE_SQRTNEG 0x88
#define _FPE_STACKOVERFLOW 0x8a
#define _FPE_STACKUNDERFLOW 0x8b
#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
#ifndef DBL_MAX_10_EXP
#define DBL_MAX_10_EXP 308
#endif
#ifndef UINT64_MAX
#define UINT64_MAX 0xffffffffffffffff
#endif
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else
#define _CRTIMP
#endif /* _DLL */
#endif
/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
* i.e. change the bits in unMask to have the values they have in unNew,
* leaving other bits unchanged. */
_CRTIMP unsigned int __cdecl _controlfp (unsigned int unNew, unsigned int unMask);
_CRTIMP unsigned int __cdecl _control87 (unsigned int unNew, unsigned int unMask);
_CRTIMP unsigned int __cdecl _clearfp (void); /* Clear the FPU status word */
_CRTIMP unsigned int __cdecl _statusfp (void); /* Report the FPU status word */
#define _clear87 _clearfp
#define _status87 _statusfp
/*
MSVCRT.dll _fpreset initializes the control register to 0x27f,
the status register to zero and the tag word to 0FFFFh.
This differs from asm instruction finit/fninit which set control
word to 0x37f (64 bit mantissa precison rather than 53 bit).
By default, the mingw version of _fpreset sets fp control as
per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
building your application.
*/
void __cdecl _fpreset (void);
void __cdecl fpreset (void);
/* Global 'variable' for the current floating point error code. */
_CRTIMP int * __cdecl __fpecode(void);
#define _fpecode (*(__fpecode()))
/*
* IEEE recommended functions. MS puts them in float.h
* but they really belong in math.h.
*/
_CRTIMP double __cdecl _chgsign (double);
_CRTIMP double __cdecl _copysign (double, double);
_CRTIMP double __cdecl _logb (double);
_CRTIMP double __cdecl _nextafter (double, double);
_CRTIMP double __cdecl _scalb (double, long);
_CRTIMP int __cdecl _finite (double);
_CRTIMP int __cdecl _fpclass (double);
_CRTIMP int __cdecl _isnan (double);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not __STRICT_ANSI__ */
#endif /* _FLOAT_H_ */

View file

@ -0,0 +1,17 @@
#ifndef __CRT_INTERNAL_ATEXIT_H
#define __CRT_INTERNAL_ATEXIT_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
#define LOCK_EXIT _mlock(_EXIT_LOCK1)
#define UNLOCK_EXIT _munlock(_EXIT_LOCK1)
extern _onexit_t *atexit_table;
extern int atexit_table_size;
extern int atexit_registered; /* Points to free slot */
void __call_atexit(void);
#endif

View file

@ -0,0 +1,16 @@
/* console.h */
#ifndef __CRT_INTERNAL_CONSOLE_H
#define __CRT_INTERNAL_CONSOLE_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
extern int char_avail;
extern int ungot_char;
#endif
/* EOF */

View file

@ -0,0 +1,25 @@
#ifndef __CRT_INTERNAL_IEEE_H
#define __CRT_INTERNAL_IEEE_H
typedef struct {
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int sign:1;
} float_s;
typedef struct {
unsigned int mantissal:32;
unsigned int mantissah:20;
unsigned int exponent:11;
unsigned int sign:1;
} double_s;
typedef struct {
unsigned int mantissal:32;
unsigned int mantissah:32;
unsigned int exponent:15;
unsigned int sign:1;
unsigned int empty:16;
} long_double_s;
#endif

View file

@ -0,0 +1,92 @@
#ifndef __CRT_INTERNAL_LOCALE_H
#define __CRT_INTERNAL_LOCALE_H
typedef struct MSVCRT_threadlocaleinfostruct {
LONG refcount;
unsigned int lc_codepage;
unsigned int lc_collate_cp;
unsigned long lc_handle[6];
LC_ID lc_id[6];
struct {
char *locale;
wchar_t *wlocale;
int *refcount;
int *wrefcount;
} lc_category[6];
int lc_clike;
int mb_cur_max;
int *lconv_intl_refcount;
int *lconv_num_refcount;
int *lconv_mon_refcount;
struct lconv *lconv;
int *ctype1_refcount;
unsigned short *ctype1;
const unsigned short *pctype;
unsigned char *pclmap;
unsigned char *pcumap;
struct __lc_time_data *lc_time_curr;
} MSVCRT_threadlocinfo;
typedef struct MSVCRT_threadmbcinfostruct {
LONG refcount;
int mbcodepage;
int ismbcodepage;
int mblcid;
unsigned short mbulinfo[6];
unsigned char mbctype[257];
char mbcasemap[256];
} MSVCRT_threadmbcinfo;
#define MSVCRT_lconv lconv
typedef struct MSVCRT_threadlocaleinfostruct *MSVCRT_pthreadlocinfo;
typedef struct MSVCRT_threadmbcinfostruct *MSVCRT_pthreadmbcinfo;
typedef struct MSVCRT_localeinfo_struct
{
MSVCRT_pthreadlocinfo locinfo;
MSVCRT_pthreadmbcinfo mbcinfo;
} MSVCRT__locale_tstruct, *MSVCRT__locale_t;
typedef struct __lc_time_data {
union {
char *str[43];
struct {
char *short_wday[7];
char *wday[7];
char *short_mon[12];
char *mon[12];
char *am;
char *pm;
char *short_date;
char *date;
char *time;
} names;
} str;
LCID lcid;
int unk[2];
wchar_t *wstr[43];
char data[1];
} MSVCRT___lc_time_data;
int _setmbcp_l(int, LCID, MSVCRT_pthreadmbcinfo) DECLSPEC_HIDDEN;
MSVCRT_pthreadmbcinfo get_mbcinfo(void) DECLSPEC_HIDDEN;
LCID MSVCRT_locale_to_LCID(const char*, unsigned short*) DECLSPEC_HIDDEN;
void __init_global_locale();
extern MSVCRT__locale_t global_locale;
#define MSVCRT_locale __get_MSVCRT_locale()
FORCEINLINE MSVCRT__locale_t __get_MSVCRT_locale()
{
if(!global_locale)
__init_global_locale();
return global_locale;
}
MSVCRT_pthreadlocinfo get_locinfo(void);
void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);
void free_locinfo(MSVCRT_pthreadlocinfo);
void free_mbcinfo(MSVCRT_pthreadmbcinfo);
#endif //__CRT_INTERNAL_LOCALE_H

View file

@ -0,0 +1,26 @@
#ifndef __CRT_INTERNAL_MATH_H
#define __CRT_INTERNAL_MATH_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
int _isinf (double); /* not exported */
int _isnanl (long double); /* not exported */
int _isinfl (long double); /* not exported */
#if defined(__GNUC__)
#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) : )
#elif defined(_MSC_VER)
#define FPU_DOUBLE(var) double var; \
__asm { fstp [var] }; __asm { fwait };
#define FPU_DOUBLES(var1,var2) double var1,var2; \
__asm { fstp [var1] }; __asm { fwait }; \
__asm { fstp [var2] }; __asm { fwait };
#endif
#endif

View file

@ -0,0 +1,60 @@
#ifndef __CRT_INTERNAL_MBSTRING_H
#define __CRT_INTERNAL_MBSTRING_H
#define _MALPHA 0x01
#define _MBLANK 0x02
#define _MDIGIT 0x04
#define _MKMOJI 0x08
#define _MKPNCT 0x10
#define _MLEAD 0x20
#define _MPUNCT 0x40
#define _MTRAIL 0x80
#define _MBALNUM (_MALPHA | _MDIGIT | _MKPNCT | _MKMOJI)
#define _MBALPHA (_MALPHA | _MKPNCT | _MKMOJI)
#define _MBGRAPH (_MALPHA | _MDIGIT | _MPUNCT | _MKPNCT | _MKMOJI)
#define _MBKANA (_MKPNCT | _MKMOJI)
#define _MBPRINT (_MALPHA | _MDIGIT | _MPUNCT | _MBLANK | _MKPNCT | _MKMOJI)
#define _MBPUNCT (_MPUNCT | _MKPNCT)
#define _MBLMASK(c) ((c) & 255)
#define _MBHMASK(c) ((c) & ~255)
#define _MBGETL(c) ((c) & 255)
#define _MBGETH(c) (((c) >> 8) & 255)
#define _MBIS16(c) ((c) & 0xff00)
/* Macros */
#define B _MBLANK
#define D _MDIGIT
#define P _MPUNCT
#define T _MTRAIL
/* Macros */
#define AT (_MALPHA | _MTRAIL)
#define GT (_MKPNCT | _MTRAIL)
#define KT (_MKMOJI | _MTRAIL)
#define LT (_MLEAD | _MTRAIL)
#define PT (_MPUNCT | _MTRAIL)
#define MAX_LOCALE_LENGTH 256
extern unsigned char _mbctype[257];
extern char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH];
#if defined (_MSC_VER)
#undef _ismbbkana
#undef _ismbbkpunct
#undef _ismbbalpha
#undef _ismbbalnum
#undef _ismbbgraph
#undef _ismbbkalnum
#undef _ismbblead
#undef _ismbbprint
#undef _ismbbpunct
#undef _ismbbtrail
#endif
#endif

View file

@ -0,0 +1,197 @@
/**
* 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.
*/
#ifndef _INC_INTERNAL
#define _INC_INTERNAL
#include <crtdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <limits.h>
#include <windef.h>
#include <winbase.h>
#ifdef __REACTOS__
#include "malloc.h"
struct _exception;
__declspec(dllimport) void __cdecl __setusermatherr(int (__cdecl *)(struct _exception *));
#define __mingw_fprintf fprintf
#define __mingw_vfprintf vfprintf
#endif
#pragma pack(push,_CRT_PACKING)
#ifndef __INTERNAL_FUNC_DEFINED
#define __INTERNAL_FUNC_DEFINED
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
typedef void (__cdecl *_PVFI)(int);
#endif
#if defined (SPECIAL_CRTEXE) && (defined (_DLL) || defined (__GNUC__))
extern int _commode;
#else
_CRTIMP extern int _commode;
#endif
#define __IOINFO_TM_ANSI 0
#define __IOINFO_TM_UTF8 1
#define __IOINFO_TM_UTF16LE 2
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4214)
#pragma warning(disable:4820)
#endif
typedef struct {
intptr_t osfhnd;
char osfile;
char pipech;
int lockinitflag;
CRITICAL_SECTION lock;
char textmode : 7;
char unicode : 1;
char pipech2[2];
} ioinfo;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#define IOINFO_ARRAY_ELTS (1 << 5)
#define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
#define _osfile(i) (_pioinfo(i)->osfile)
#define _pipech2(i) (_pioinfo(i)->pipech2)
#define _textmode(i) (_pioinfo(i)->textmode)
#define _tm_unicode(i) (_pioinfo(i)->unicode)
#define _pioinfo_safe(i) ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)
#define _osfhnd_safe(i) (_pioinfo_safe(i)->osfhnd)
#define _osfile_safe(i) (_pioinfo_safe(i)->osfile)
#define _pipech_safe(i) (_pioinfo_safe(i)->pipech)
#define _pipech2_safe(i) (_pioinfo_safe(i)->pipech2)
#define _textmode_safe(i) (_pioinfo_safe(i)->textmode)
#define _tm_unicode_safe(i) (_pioinfo_safe(i)->unicode)
#ifndef __badioinfo
extern ioinfo ** __MINGW_IMP_SYMBOL(__badioinfo)[];
#define __badioinfo (* __MINGW_IMP_SYMBOL(__badioinfo))
#endif
#ifndef __pioinfo
extern ioinfo ** __MINGW_IMP_SYMBOL(__pioinfo)[];
#define __pioinfo (* __MINGW_IMP_SYMBOL(__pioinfo))
#endif
#define _NO_CONSOLE_FILENO (intptr_t)-2
#ifndef _FILE_DEFINED
#define _FILE_DEFINED
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
#endif
#if !defined (_FILEX_DEFINED) && defined (_WINDOWS_)
#define _FILEX_DEFINED
typedef struct {
FILE f;
CRITICAL_SECTION lock;
} _FILEX;
#endif
extern int _dowildcard;
extern int _newmode;
#ifndef __winitenv
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
#define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
#endif
#ifndef __initenv
extern char *** __MINGW_IMP_SYMBOL(__initenv);
#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
#endif
#ifndef _acmdln
extern char ** __MINGW_IMP_SYMBOL(_acmdln);
#define _acmdln (* __MINGW_IMP_SYMBOL(_acmdln))
/* _CRTIMP extern char *_acmdln; */
#endif
#ifndef _wcmdln
extern char ** __MINGW_IMP_SYMBOL(_wcmdln);
#define _wcmdln (* __MINGW_IMP_SYMBOL(_wcmdln))
/* __CRTIMP extern wchar_t *_wcmdln; */
#endif
_CRTIMP __declspec(noreturn) void __cdecl _amsg_exit(int);
int __CRTDECL _setargv(void);
int __CRTDECL __setargv(void);
int __CRTDECL _wsetargv(void);
int __CRTDECL __wsetargv(void);
int __CRTDECL main(int _Argc, char **_Argv, char **_Env);
int __CRTDECL wmain(int _Argc, wchar_t **_Argv, wchar_t **_Env);
#ifndef _STARTUP_INFO_DEFINED
#define _STARTUP_INFO_DEFINED
typedef struct {
int newmode;
} _startupinfo;
#endif
_CRTIMP int __cdecl __getmainargs(int * _Argc, char *** _Argv, char ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
_CRTIMP int __cdecl __wgetmainargs(int * _Argc, wchar_t ***_Argv, wchar_t ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
#define _CONSOLE_APP 1
#define _GUI_APP 2
typedef enum __enative_startup_state {
__uninitialized = 0, __initializing, __initialized
} __enative_startup_state;
extern volatile __enative_startup_state __native_startup_state;
extern volatile void *__native_startup_lock;
extern volatile unsigned int __native_dllmain_reason;
extern volatile unsigned int __native_vcclrit_reason;
_CRTIMP void __cdecl __set_app_type (int);
typedef LONG NTSTATUS;
#include <crtdbg.h>
#include <errno.h>
void * __cdecl _encode_pointer(void *);
void * __cdecl _encoded_null();
void * __cdecl _decode_pointer(void *);
BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);
PIMAGE_SECTION_HEADER __cdecl _FindPESection (PBYTE pImageBase, DWORD_PTR rva);
BOOL __cdecl _IsNonwritableInCurrentImage (PBYTE pTarget);
#ifdef __cplusplus
}
#endif
#pragma pack(pop)
#endif

View file

@ -0,0 +1,64 @@
/**
* 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.
*/
#ifndef _INC_OSCALLS
#define _INC_OSCALLS
#ifndef _CRTBLD
#error ERROR: Use of C runtime library internal header file.
#endif
#include <crtdefs.h>
#ifdef NULL
#undef NULL
#endif
#define NOMINMAX
#define _WIN32_FUSION 0x0100
//#include <windows.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4214)
#endif
typedef struct _FTIME
{
unsigned short twosecs : 5;
unsigned short minutes : 6;
unsigned short hours : 5;
} FTIME;
typedef FTIME *PFTIME;
typedef struct _FDATE
{
unsigned short day : 5;
unsigned short month : 4;
unsigned short year : 7;
} FDATE;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
typedef FDATE *PFDATE;
#endif

View file

@ -0,0 +1,72 @@
/**
* 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.
*/
#if defined(_MSC_VER)
#if defined(_M_IA64) || defined(_M_AMD64)
#define _ATTRIBUTES read
#else
#define _ATTRIBUTES read
#endif
/* Reference list of existing section for msvcrt. */
#pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
#pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
#pragma section(".CRTMP$XIA",long,_ATTRIBUTES)
#pragma section(".CRTMP$XIZ",long,_ATTRIBUTES)
#pragma section(".CRTMA$XCA",long,_ATTRIBUTES)
#pragma section(".CRTMA$XCZ",long,_ATTRIBUTES)
#pragma section(".CRTMA$XIA",long,_ATTRIBUTES)
#pragma section(".CRTMA$XIZ",long,_ATTRIBUTES)
#pragma section(".CRTVT$XCA",long,_ATTRIBUTES)
#pragma section(".CRTVT$XCZ",long,_ATTRIBUTES)
#pragma section(".CRT$XCA",long,_ATTRIBUTES)
#pragma section(".CRT$XCAA",long,_ATTRIBUTES)
#pragma section(".CRT$XCC",long,_ATTRIBUTES)
#pragma section(".CRT$XCZ",long,_ATTRIBUTES)
#pragma section(".CRT$XDA",long,_ATTRIBUTES)
#pragma section(".CRT$XDC",long,_ATTRIBUTES)
#pragma section(".CRT$XDZ",long,_ATTRIBUTES)
#pragma section(".CRT$XIA",long,_ATTRIBUTES)
#pragma section(".CRT$XIAA",long,_ATTRIBUTES)
#pragma section(".CRT$XIC",long,_ATTRIBUTES)
#pragma section(".CRT$XID",long,_ATTRIBUTES)
#pragma section(".CRT$XIY",long,_ATTRIBUTES)
#pragma section(".CRT$XIZ",long,_ATTRIBUTES)
#pragma section(".CRT$XLA",long,_ATTRIBUTES)
#pragma section(".CRT$XLC",long,_ATTRIBUTES)
#pragma section(".CRT$XLD",long,_ATTRIBUTES)
#pragma section(".CRT$XLZ",long,_ATTRIBUTES)
#pragma section(".CRT$XPA",long,_ATTRIBUTES)
#pragma section(".CRT$XPX",long,_ATTRIBUTES)
#pragma section(".CRT$XPXA",long,_ATTRIBUTES)
#pragma section(".CRT$XPZ",long,_ATTRIBUTES)
#pragma section(".CRT$XTA",long,_ATTRIBUTES)
#pragma section(".CRT$XTB",long,_ATTRIBUTES)
#pragma section(".CRT$XTX",long,_ATTRIBUTES)
#pragma section(".CRT$XTZ",long,_ATTRIBUTES)
#pragma section(".rdata$T",long,read)
#pragma section(".rtc$IAA",long,read)
#pragma section(".rtc$IZZ",long,read)
#pragma section(".rtc$TAA",long,read)
#pragma section(".rtc$TZZ",long,read)
/* for tlssup.c: */
#pragma section(".tls",long,read,write)
#pragma section(".tls$AAA",long,read,write)
#pragma section(".tls$ZZZ",long,read,write)
#endif /* _MSC_VER */
#if defined(_MSC_VER)
#define _CRTALLOC(x) __declspec(allocate(x))
#elif defined(__GNUC__)
#define _CRTALLOC(x) __attribute__ ((section (x) ))
#else
#error Your compiler is not supported.
#endif

View file

@ -0,0 +1,14 @@
extern int msvcrt_error_mode;
extern int __app_type;
#define _UNKNOWN_APP 0
#define _CONSOLE_APP 1
#define _GUI_APP 2
int
__cdecl
__crt_MessageBoxA (
_In_opt_ const char *pszText,
_In_ unsigned int uType);

View file

@ -0,0 +1,72 @@
/*
* Copyright (c) 2002, TransGaming Technologies Inc.
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __CRT_INTERNAL_WINE_MTDLL_H
#define __CRT_INTERNAL_WINE_MTDLL_H
#if defined(_MT)
#define _mlock(locknum) _lock(locknum)
#define _munlock(locknum) _unlock(locknum)
void _unlock( int locknum );
void _lock( int locknum );
#else
#define _mlock(locknum) do {} while(0)
#define _munlock(locknum) do {} while(0)
#endif
#define _SIGNAL_LOCK 1
#define _IOB_SCAN_LOCK 2
#define _TMPNAM_LOCK 3
#define _INPUT_LOCK 4
#define _OUTPUT_LOCK 5
#define _CSCANF_LOCK 6
#define _CPRINTF_LOCK 7
#define _CONIO_LOCK 8
#define _HEAP_LOCK 9
#define _BHEAP_LOCK 10 /* No longer used? */
#define _TIME_LOCK 11
#define _ENV_LOCK 12
#define _EXIT_LOCK1 13
#define _EXIT_LOCK2 14
#define _THREADDATA_LOCK 15 /* No longer used? */
#define _POPEN_LOCK 16
#define _LOCKTAB_LOCK 17
#define _OSFHND_LOCK 18
#define _SETLOCALE_LOCK 19
#define _LC_COLLATE_LOCK 20 /* No longer used? */
#define _LC_CTYPE_LOCK 21 /* No longer used? */
#define _LC_MONETARY_LOCK 22 /* No longer used? */
#define _LC_NUMERIC_LOCK 23 /* No longer used? */
#define _LC_TIME_LOCK 24 /* No longer used? */
#define _MB_CP_LOCK 25
#define _NLG_LOCK 26
#define _TYPEINFO_LOCK 27
#define _STREAM_LOCKS 28
/* Must match definition in msvcrt/stdio.h */
#define _IOB_ENTRIES 20
#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_IOB_ENTRIES-1)
#define _TOTAL_LOCKS (_LAST_STREAM_LOCK+1)
#endif /* WINE_MTDLL_H */

View file

@ -0,0 +1,15 @@
#ifndef __CRT_INTERNAL_POPEN_H
#define __CRT_INTERNAL_POPEN_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
struct popen_handle {
FILE *f;
HANDLE proc;
};
extern struct popen_handle *popen_handles;
extern DWORD popen_handles_size;
#endif

View file

@ -0,0 +1,33 @@
/* rterror.h */
#ifndef __CRT_INTERNAL_RTERROR_H
#define __CRT_INTERNAL_RTERROR_H
#define _RT_STACK 0 /* stack overflow */
#define _RT_NULLPTR 1 /* null pointer assignment */
#define _RT_FLOAT 2 /* floating point not loaded */
#define _RT_INTDIV 3 /* integer divide by 0 */
#define _RT_SPACEARG 4 /* not enough space for arguments */
#define _RT_SPACEENV 5 /* not enough space for environment */
#define _RT_ABORT 6 /* abnormal program termination */
#define _RT_THREAD 7 /* not enough space for thread data */
#define _RT_LOCK 8 /* unexpected multi-thread lock error */
#define _RT_HEAP 9 /* unexpected heap error */
#define _RT_OPENCON 10 /* unable to open console device */
#define _RT_NONCONT 11 /* non-continuable exception */
#define _RT_INVALDISP 12 /* invalid disposition of exception */
#define _RT_ONEXIT 13 /* insufficient heap to allocate
* initial table of function pointers
* used by _onexit()/atexit(). */
#define _RT_PUREVIRT 14 /* pure virtual function call attempted
* (C++ error) */
#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */
#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */
__declspec(noreturn) void _amsg_exit (int errnum);
/* not in any other header */
void _dosmaperr(unsigned long oserrcode);
#endif /* __MSVCRT_INTERNAL_RTERROR_H */

View file

@ -0,0 +1,22 @@
#include <errno.h>
extern void * __pInvalidArgHandler;
void _invalid_parameter(
const wchar_t * expression,
const wchar_t * function,
const wchar_t * file,
unsigned int line,
uintptr_t pReserved);
#ifndef _LIBCNT_
#define MSVCRT_INVALID_PMT(x,err) (*_errno() = (err), _invalid_parameter(NULL, NULL, NULL, 0, 0))
#define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), 0))
#define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), EINVAL)
#else
/* disable secure crt parameter checks */
#define MSVCRT_INVALID_PMT(x,err)
#define MSVCRT_CHECK_PMT_ERR(x,err)
#define MSVCRT_CHECK_PMT(x) (x)
#endif

View file

@ -0,0 +1,55 @@
#define DIFFTIME 0x19db1ded53e8000ULL
#define DIFFDAYS (3 * DAYSPER100YEARS + 17 * DAYSPER4YEARS + 1 * DAYSPERYEAR)
#define DAYSPERYEAR 365
#define DAYSPER4YEARS (4*DAYSPERYEAR+1)
#define DAYSPER100YEARS (25*DAYSPER4YEARS-1)
#define DAYSPER400YEARS (4*DAYSPER100YEARS+1)
#define SECONDSPERDAY (24*60*60)
#define SECONDSPERHOUR (60*60)
#define LEAPDAY 59
static __inline
__time64_t
FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
{
ULARGE_INTEGER ULargeInt;
__time64_t time;
ULargeInt.LowPart = FileTime->dwLowDateTime;
ULargeInt.HighPart = FileTime->dwHighDateTime;
ULargeInt.QuadPart -= DIFFTIME;
time = ULargeInt.QuadPart / 10000000;
if (millitm)
*millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000);
return time;
}
static __inline
long leapyears_passed(long days)
{
long quadcenturies, centuries, quadyears;
quadcenturies = days / DAYSPER400YEARS;
days -= quadcenturies;
centuries = days / DAYSPER100YEARS;
days += centuries;
quadyears = days / DAYSPER4YEARS;
return quadyears - centuries + quadcenturies;
}
static __inline
long leapdays_passed(long days)
{
return leapyears_passed(days + DAYSPERYEAR - LEAPDAY + 1);
}
static __inline
long years_passed(long days)
{
return (days - leapdays_passed(days)) / 365;
}
extern long dst_begin;
extern long dst_end;

View file

@ -0,0 +1,70 @@
/* tls.h */
#ifndef __CRT_INTERNAL_TLS_H
#define __CRT_INTERNAL_TLS_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
#include <stddef.h>
#include <time.h>
#include <locale.h>
#include <windef.h>
#include <winbase.h>
#include <winnt.h>
#include <internal/wine/eh.h>
/* TLS data */
extern DWORD tls_index;
struct __thread_data {
DWORD tid;
HANDLE handle;
int thread_errno;
unsigned long thread_doserrno;
int unk1;
unsigned int random_seed; /* seed for rand() */
char *strtok_next; /* next ptr for strtok() */
wchar_t *wcstok_next; /* next ptr for wcstok() */
unsigned char *mbstok_next; /* next ptr for mbstok() */
char *strerror_buffer; /* buffer for strerror */
wchar_t *wcserror_buffer; /* buffer for wcserror */
char *tmpnam_buffer; /* buffer for tmpname() */
wchar_t *wtmpnam_buffer; /* buffer for wtmpname() */
void *unk2[2];
char *asctime_buffer; /* buffer for asctime */
wchar_t *wasctime_buffer; /* buffer for wasctime */
struct tm *time_buffer; /* buffer for localtime/gmtime */
char *efcvt_buffer; /* buffer for ecvt/fcvt */
int unk3[2];
void *unk4[3];
EXCEPTION_POINTERS *xcptinfo;
int fpecode;
struct MSVCRT_threadmbcinfostruct *mbcinfo;
struct MSVCRT_threadlocaleinfostruct *locinfo;
BOOL have_locale;
int unk5[1];
terminate_function terminate_handler;
unexpected_function unexpected_handler;
_se_translator_function se_translator;
void *unk6[3];
int unk7;
EXCEPTION_RECORD *exc_record;
void *unk8[100];
};
typedef struct __thread_data thread_data_t;
extern BOOL msvcrt_init_tls(void);
extern BOOL msvcrt_free_tls(void);
extern thread_data_t *msvcrt_get_thread_data(void);
extern void msvcrt_free_tls_mem(void);
#define MSVCRT_ENABLE_PER_THREAD_LOCALE 1
#define MSVCRT_DISABLE_PER_THREAD_LOCALE 2
#endif /* __MSVCRT_INTERNAL_TLS_H */
/* EOF */

View file

@ -0,0 +1,184 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2002 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
*/
#ifndef __MSVCRT_CPPEXCEPT_H
#define __MSVCRT_CPPEXCEPT_H
#include <pseh/pseh2.h>
#define CXX_FRAME_MAGIC_VC6 0x19930520
#define CXX_FRAME_MAGIC_VC7 0x19930521
#define CXX_FRAME_MAGIC_VC8 0x19930522
#define CXX_EXCEPTION 0xe06d7363
/* Macros to define assembler functions somewhat portably */
#define EH_NONCONTINUABLE 0x01
#define EH_UNWINDING 0x02
#define EH_EXIT_UNWIND 0x04
#define EH_STACK_INVALID 0x08
#define EH_NESTED_CALL 0x10
typedef void (*vtable_ptr)();
/* type_info object, see cpp.c for inplementation */
typedef struct __type_info
{
const vtable_ptr *vtable;
char *name; /* Unmangled name, allocated lazily */
char mangled[32]; /* Variable length, but we declare it large enough for static RTTI */
} type_info;
/* exception object */
typedef struct __exception
{
const vtable_ptr *vtable;
char *name; /* Name of this exception, always a new copy for each object */
int do_free; /* Whether to free 'name' in our dtor */
} exception;
/* the exception frame used by CxxFrameHandler */
typedef struct __cxx_exception_frame
{
EXCEPTION_REGISTRATION_RECORD frame; /* the standard exception frame */
int trylevel;
DWORD ebp;
} cxx_exception_frame;
/* info about a single catch {} block */
typedef struct __catchblock_info
{
UINT flags; /* flags (see below) */
const type_info *type_info; /* C++ type caught by this block */
int offset; /* stack offset to copy exception object to */
void (*handler)(void);/* catch block handler code */
} catchblock_info;
#define TYPE_FLAG_CONST 1
#define TYPE_FLAG_VOLATILE 2
#define TYPE_FLAG_REFERENCE 8
/* info about a single try {} block */
typedef struct __tryblock_info
{
int start_level; /* start trylevel of that block */
int end_level; /* end trylevel of that block */
int catch_level; /* initial trylevel of the catch block */
int catchblock_count; /* count of catch blocks in array */
const catchblock_info *catchblock; /* array of catch blocks */
} tryblock_info;
/* info about the unwind handler for a given trylevel */
typedef struct __unwind_info
{
int prev; /* prev trylevel unwind handler, to run after this one */
void (*handler)(void);/* unwind handler */
} unwind_info;
/* descriptor of all try blocks of a given function */
typedef struct __cxx_function_descr
{
UINT magic; /* must be CXX_FRAME_MAGIC */
UINT unwind_count; /* number of unwind handlers */
const unwind_info *unwind_table; /* array of unwind handlers */
UINT tryblock_count; /* number of try blocks */
const tryblock_info *tryblock; /* array of try blocks */
UINT ipmap_count;
const void *ipmap;
const void *expect_list; /* expected exceptions list when magic >= VC7 */
UINT flags; /* flags when magic >= VC8 */
} cxx_function_descr;
#define FUNC_DESCR_SYNCHRONOUS 1 /* synchronous exceptions only (built with /EHs) */
typedef void (*cxx_copy_ctor)(void);
/* offsets for computing the this pointer */
typedef struct
{
int this_offset; /* offset of base class this pointer from start of object */
int vbase_descr; /* offset of virtual base class descriptor */
int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
} this_ptr_offsets;
/* complete information about a C++ type */
typedef struct __cxx_type_info
{
UINT flags; /* flags (see CLASS_* flags below) */
const type_info *type_info; /* C++ type info */
this_ptr_offsets offsets; /* offsets for computing the this pointer */
unsigned int size; /* object size */
cxx_copy_ctor copy_ctor; /* copy constructor */
} cxx_type_info;
#define CLASS_IS_SIMPLE_TYPE 1
#define CLASS_HAS_VIRTUAL_BASE_CLASS 4
/* table of C++ types that apply for a given object */
typedef struct __cxx_type_info_table
{
UINT count; /* number of types */
const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */
} cxx_type_info_table;
typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*,
PCONTEXT, EXCEPTION_REGISTRATION_RECORD**,
const cxx_function_descr*, int nested_trylevel,
EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 );
/* type information for an exception object */
typedef struct __cxx_exception_type
{
UINT flags; /* TYPE_FLAG flags */
void (*destructor)(void);/* exception object destructor */
cxx_exc_custom_handler custom_handler; /* custom handler for this exception */
const cxx_type_info_table *type_info_table; /* list of types for this exception object */
} cxx_exception_type;
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
int CDECL _XcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
int CDECL __CppXcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
static inline const char *dbgstr_type_info( const type_info *info )
{
if (!info) return "{}";
return wine_dbg_sprintf( "{vtable=%p name=%s (%s)}",
info->vtable, info->mangled, info->name ? info->name : "" );
}
/* compute the this pointer for a base class of a given type */
static inline void *get_this_pointer( const this_ptr_offsets *off, void *object )
{
if (!object) return NULL;
if (off->vbase_descr >= 0)
{
int *offset_ptr;
/* move this ptr to vbase descriptor */
object = (char *)object + off->vbase_descr;
/* and fetch additional offset from vbase descriptor */
offset_ptr = (int *)(*(char **)object + off->vbase_offset);
object = (char *)object + *offset_ptr;
}
object = (char *)object + off->this_offset;
return object;
}
#endif /* __MSVCRT_CPPEXCEPT_H */

View file

@ -0,0 +1,53 @@
/*
* C++ exception handling facility
*
* Copyright 2000 Francois Gouget.
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __WINE_EH_H
#define __WINE_EH_H
#ifndef __WINE_USE_MSVCRT
#define __WINE_USE_MSVCRT
#endif
#if !defined(__cplusplus) && !defined(USE_MSVCRT_PREFIX)
#error "eh.h is meant only for C++ applications"
#endif
#ifndef MSVCRT
# ifdef USE_MSVCRT_PREFIX
# define MSVCRT(x) MSVCRT_##x
# else
# define MSVCRT(x) x
# endif
#endif
struct _EXCEPTION_POINTERS;
typedef void (*terminate_handler)();
typedef void (*terminate_function)();
typedef void (*unexpected_handler)();
typedef void (*unexpected_function)();
typedef void (*_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
terminate_function MSVCRT(set_terminate)(terminate_function func);
unexpected_function MSVCRT(set_unexpected)(unexpected_function func);
_se_translator_function MSVCRT(_set_se_translator)(_se_translator_function func);
void MSVCRT(terminate)();
void MSVCRT(unexpected)();
#endif /* __WINE_EH_H */

View file

@ -0,0 +1,156 @@
/*
* Copyright 2001 Jon Griffiths
* Copyright 2004 Dimitrie O. Paun
*
* 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
*
* NOTES
* Naming conventions
* - Symbols are prefixed with MSVCRT_ if they conflict
* with libc symbols
* - Internal symbols are usually prefixed by msvcrt_.
* - Exported symbols that are not present in the public
* headers are usually kept the same as the original.
* Other conventions
* - To avoid conflicts with the standard C library,
* no msvcrt headers are included in the implementation.
* - Instead, symbols are duplicated here, prefixed with
* MSVCRT_, as explained above.
* - To avoid inconsistencies, a test for each symbol is
* added into tests/headers.c. Please always add a
* corresponding test when you add a new symbol!
*/
#ifndef __WINE_MSVCRT_H
#define __WINE_MSVCRT_H
#include <stdarg.h>
#include <signal.h>
#include "windef.h"
#include "winbase.h"
extern unsigned int __lc_codepage;
extern int __lc_collate_cp;
extern int __mb_cur_max;
extern const unsigned short _ctype [257];
void __cdecl _purecall(void);
__declspec(noreturn) void __cdecl _amsg_exit(int errnum);
extern char **_environ;
extern wchar_t **_wenviron;
extern char ** SnapshotOfEnvironmentA(char **);
extern wchar_t ** SnapshotOfEnvironmentW(wchar_t **);
/* Application type flags */
#define _UNKNOWN_APP 0
#define _CONSOLE_APP 1
#define _GUI_APP 2
/* I/O Streamming flags missing from stdio.h */
#define _IOYOURBUF 0x0100
#define _IOAPPEND 0x0200
#define _IOSETVBUF 0x0400
#define _IOFEOF 0x0800
#define _IOFLRTN 0x1000
#define _IOCTRLZ 0x2000
#define _IOCOMMIT 0x4000
#define _IOFREE 0x10000
//wchar_t *wstrdupa(const char *);
//
///* FIXME: This should be declared in new.h but it's not an extern "C" so
// * it would not be much use anyway. Even for Winelib applications.
// */
//int __cdecl _set_new_mode(int mode);
//
void* __cdecl MSVCRT_operator_new(size_t);
void __cdecl MSVCRT_operator_delete(void*);
typedef void* (__cdecl *malloc_func_t)(size_t);
typedef void (__cdecl *free_func_t)(void*);
/* Setup and teardown multi threaded locks */
extern void msvcrt_init_mt_locks(void);
extern void msvcrt_free_mt_locks(void);
extern BOOL msvcrt_init_locale(void);
extern void msvcrt_init_math(void);
extern void msvcrt_init_io(void);
extern void msvcrt_free_io(void);
extern void msvcrt_init_console(void);
extern void msvcrt_free_console(void);
extern void msvcrt_init_args(void);
extern void msvcrt_free_args(void);
extern void msvcrt_init_signals(void);
extern void msvcrt_free_signals(void);
extern void msvcrt_free_popen_data(void);
extern unsigned create_io_inherit_block(WORD*, BYTE**);
/* _set_abort_behavior codes */
#define MSVCRT__WRITE_ABORT_MSG 1
#define MSVCRT__CALL_REPORTFAULT 2
#define MSVCRT_LC_ALL LC_ALL
#define MSVCRT_LC_COLLATE LC_COLLATE
#define MSVCRT_LC_CTYPE LC_CTYPE
#define MSVCRT_LC_MONETARY LC_MONETARY
#define MSVCRT_LC_NUMERIC LC_NUMERIC
#define MSVCRT_LC_TIME LC_TIME
#define MSVCRT_LC_MIN LC_MIN
#define MSVCRT_LC_MAX LC_MAX
#define MSVCRT__OUT_TO_DEFAULT 0
#define MSVCRT__OUT_TO_STDERR 1
#define MSVCRT__OUT_TO_MSGBOX 2
#define MSVCRT__REPORT_ERRMODE 3
extern char* __cdecl __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int);
/* __unDName/__unDNameEx flags */
#define UNDNAME_COMPLETE (0x0000)
#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) /* Don't show __ in calling convention */
#define UNDNAME_NO_MS_KEYWORDS (0x0002) /* Don't show calling convention at all */
#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) /* Don't show function/method return value */
#define UNDNAME_NO_ALLOCATION_MODEL (0x0008)
#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010)
#define UNDNAME_NO_MS_THISTYPE (0x0020)
#define UNDNAME_NO_CV_THISTYPE (0x0040)
#define UNDNAME_NO_THISTYPE (0x0060)
#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) /* Don't show access specifier (public/protected/private) */
#define UNDNAME_NO_THROW_SIGNATURES (0x0100)
#define UNDNAME_NO_MEMBER_TYPE (0x0200) /* Don't show static/virtual specifier */
#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400)
#define UNDNAME_32_BIT_DECODE (0x0800)
#define UNDNAME_NAME_ONLY (0x1000) /* Only report the variable/method name */
#define UNDNAME_NO_ARGUMENTS (0x2000) /* Don't show method arguments */
#define UNDNAME_NO_SPECIAL_SYMS (0x4000)
#define UNDNAME_NO_COMPLEX_TYPE (0x8000)
typedef void (*float_handler)(int, int);
void _default_handler(int signal);
typedef struct _sig_element
{
int signal;
char *signame;
__p_sig_fn_t handler;
}sig_element;
#define MSVCRT_malloc malloc
#define MSVCRT_free free
char* _setlocale(int,const char*);
NTSYSAPI VOID NTAPI RtlAssert(PVOID FailedAssertion,PVOID FileName,ULONG LineNumber,PCHAR Message);
#endif /* __WINE_MSVCRT_H */

View file

@ -0,0 +1,50 @@
#define DEFINE_THISCALL_WRAPPER(func, args) \
void __declspec(naked) __thiscall_ ## func (void) \
{ \
__asm { pop eax } \
__asm { push ecx } \
__asm { push eax } \
__asm { jmp func } \
}
exception * __stdcall MSVCRT_exception_ctor(exception * _this, const char ** name);
exception * __stdcall MSVCRT_exception_ctor_noalloc(exception * _this, char ** name, int noalloc);
exception * __stdcall MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs);
exception * __stdcall MSVCRT_exception_default_ctor(exception * _this);
void __stdcall MSVCRT_exception_dtor(exception * _this);
exception * __stdcall MSVCRT_exception_opequals(exception * _this, const exception * rhs);
void * __stdcall MSVCRT_exception_vector_dtor(exception * _this, unsigned int flags);
void * __stdcall MSVCRT_exception_scalar_dtor(exception * _this, unsigned int flags);
const char * __stdcall MSVCRT_what_exception(exception * _this);
bad_typeid * __stdcall MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs);
bad_typeid * __stdcall MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name);
bad_typeid * __stdcall MSVCRT_bad_typeid_default_ctor(bad_typeid * _this);
void __stdcall MSVCRT_bad_typeid_dtor(bad_typeid * _this);
bad_typeid * __stdcall MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs);
void * __stdcall MSVCRT_bad_typeid_vector_dtor(bad_typeid * _this, unsigned int flags);
void * __stdcall MSVCRT_bad_typeid_scalar_dtor(bad_typeid * _this, unsigned int flags);
__non_rtti_object * __stdcall MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this, const __non_rtti_object * rhs);
__non_rtti_object * __stdcall MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this, const char * name);
void __stdcall MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this);
__non_rtti_object * __stdcall MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this, const __non_rtti_object *rhs);
void * __stdcall MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object * _this, unsigned int flags);
void * __stdcall MSVCRT___non_rtti_object_scalar_dtor(__non_rtti_object * _this, unsigned int flags);
bad_cast * __stdcall MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name);
bad_cast * __stdcall MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs);
bad_cast * __stdcall MSVCRT_bad_cast_ctor_charptr(bad_cast * _this, const char * name);
bad_cast * __stdcall MSVCRT_bad_cast_default_ctor(bad_cast * _this);
void __stdcall MSVCRT_bad_cast_dtor(bad_cast * _this);
bad_cast * __stdcall MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs);
void * __stdcall MSVCRT_bad_cast_vector_dtor(bad_cast * _this, unsigned int flags);
void * __stdcall MSVCRT_bad_cast_scalar_dtor(bad_cast * _this, unsigned int flags);
int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs);
int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs);
int __stdcall MSVCRT_type_info_before(type_info * _this, const type_info * rhs);
void __stdcall MSVCRT_type_info_dtor(type_info * _this);
const char * __stdcall MSVCRT_type_info_name(type_info * _this);
const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this);
void * __stdcall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int flags);
#define __ASM_VTABLE(name,funcs)
//void *MSVCRT_ ## name ##_vtable[] =

250
sdk/lib/crt/libcntpr.cmake Normal file
View file

@ -0,0 +1,250 @@
list(APPEND LIBCNTPR_SOURCE
float/isnan.c
math/abs.c
math/div.c
math/labs.c
math/rand_nt.c
mbstring/mbstrlen.c
mem/memccpy.c
mem/memcmp.c
mem/memicmp.c
misc/fltused.c
printf/_snprintf.c
printf/_snwprintf.c
printf/_vcprintf.c
printf/_vscwprintf.c
printf/_vsnprintf.c
printf/_vsnwprintf.c
printf/sprintf.c
printf/streamout.c
printf/swprintf.c
printf/vprintf.c
printf/vsprintf.c
printf/vswprintf.c
printf/wstreamout.c
search/bsearch.c
search/lfind.c
stdlib/qsort.c
string/_splitpath.c
string/_wsplitpath.c
string/ctype.c
string/iswctype.c
string/is_wctype.c
string/scanf.c
string/strcspn.c
string/stricmp.c
string/strnicmp.c
string/strlwr.c
string/strrev.c
string/strset.c
string/strstr.c
string/strupr.c
string/strpbrk.c
string/strspn.c
string/atoi64.c
string/atoi.c
string/atol.c
string/itoa.c
string/itow.c
string/mbstowcs_nt.c
string/strtoi64.c
string/strtol.c
string/strtoul.c
string/strtoull.c
string/wcs.c
string/wcstol.c
string/wcstombs_nt.c
string/wcstoul.c
string/wctype.c
string/wtoi64.c
string/wtoi.c
string/wtol.c
string/winesup.c
wstring/wcsicmp.c
wstring/wcslwr.c
wstring/wcsnicmp.c
wstring/wcsupr.c
wstring/wcscspn.c
wstring/wcsspn.c
wstring/wcsstr.c)
if(ARCH STREQUAL "i386")
list(APPEND LIBCNTPR_ASM_SOURCE
except/i386/chkstk_asm.s
setjmp/i386/setjmp.s
math/i386/alldiv_asm.s
math/i386/alldvrm_asm.s
math/i386/allmul_asm.s
math/i386/allrem_asm.s
math/i386/allshl_asm.s
math/i386/allshr_asm.s
math/i386/atan_asm.s
math/i386/atan2_asm.s
math/i386/aulldiv_asm.s
math/i386/aulldvrm_asm.s
math/i386/aullrem_asm.s
math/i386/aullshr_asm.s
math/i386/ceil_asm.s
math/i386/cos_asm.s
math/i386/fabs_asm.s
math/i386/floor_asm.s
math/i386/ftol_asm.s
math/i386/ftol2_asm.s
math/i386/log_asm.s
math/i386/log10_asm.s
math/i386/pow_asm.s
math/i386/sin_asm.s
math/i386/sqrt_asm.s
math/i386/tan_asm.s
misc/i386/readcr4.S)
list(APPEND LIBCNTPR_SOURCE
math/i386/ci.c
math/i386/cicos.c
math/i386/cilog.c
math/i386/cipow.c
math/i386/cisin.c
math/i386/cisqrt.c)
if(NOT MSVC)
list(APPEND LIBCNTPR_SOURCE except/i386/chkstk_ms.s)
endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND LIBCNTPR_ASM_SOURCE
except/amd64/chkstk_asm.s
except/amd64/seh.s
setjmp/amd64/setjmp.s
math/amd64/atan.S
math/amd64/atan2.S
math/amd64/ceil.S
math/amd64/exp.S
math/amd64/fabs.S
math/amd64/floor.S
math/amd64/floorf.S
math/amd64/fmod.S
math/amd64/ldexp.S
math/amd64/log.S
math/amd64/log10.S
math/amd64/pow.S
math/amd64/sqrt.S
math/amd64/tan.S)
list(APPEND LIBCNTPR_SOURCE
except/amd64/ehandler.c
math/cos.c
math/sin.c)
elseif(ARCH STREQUAL "arm")
list(APPEND LIBCNTPR_SOURCE
except/arm/chkstk_asm.s
except/arm/__jump_unwind.s
math/arm/__rt_sdiv.c
math/arm/__rt_sdiv64_worker.c
math/arm/__rt_udiv.c
math/arm/__rt_udiv64_worker.c
)
list(APPEND LIBCNTPR_ASM_SOURCE
except/arm/_abnormal_termination.s
except/arm/_except_handler2.s
except/arm/_except_handler3.s
except/arm/_global_unwind2.s
except/arm/_local_unwind2.s
except/arm/chkstk_asm.s
except/arm/ehandler.c
float/arm/_clearfp.s
float/arm/_controlfp.s
float/arm/_fpreset.s
float/arm/_statusfp.s
math/arm/atan.s
math/arm/atan2.s
math/arm/ceil.s
math/arm/exp.s
math/arm/fabs.s
math/arm/fmod.s
math/arm/floor.s
math/arm/ldexp.s
math/arm/log.s
math/arm/log10.s
math/arm/pow.s
math/arm/tan.s
math/arm/__dtoi64.s
math/arm/__dtou64.s
math/arm/__i64tod.s
math/arm/__i64tos.s
math/arm/__stoi64.s
math/arm/__stou64.s
math/arm/__u64tod.s
math/arm/__u64tos.s
math/arm/__rt_sdiv64.s
math/arm/__rt_srsh.s
math/arm/__rt_udiv64.s
setjmp/arm/setjmp.s
)
endif()
if(ARCH STREQUAL "i386")
list(APPEND LIBCNTPR_ASM_SOURCE
mem/i386/memchr_asm.s
mem/i386/memmove_asm.s
mem/i386/memset_asm.s
string/i386/strcat_asm.s
string/i386/strchr_asm.s
string/i386/strcmp_asm.s
string/i386/strcpy_asm.s
string/i386/strlen_asm.s
string/i386/strncat_asm.s
string/i386/strncmp_asm.s
string/i386/strncpy_asm.s
string/i386/strnlen_asm.s
string/i386/strrchr_asm.s
string/i386/wcscat_asm.s
string/i386/wcschr_asm.s
string/i386/wcscmp_asm.s
string/i386/wcscpy_asm.s
string/i386/wcslen_asm.s
string/i386/wcsncat_asm.s
string/i386/wcsncmp_asm.s
string/i386/wcsncpy_asm.s
string/i386/wcsnlen_asm.s
string/i386/wcsrchr_asm.s)
else()
list(APPEND LIBCNTPR_SOURCE
math/cos.c
math/sin.c
math/sqrt.c
mem/memchr.c
mem/memcpy.c
mem/memmove.c
mem/memset.c
string/strcat.c
string/strchr.c
string/strcmp.c
string/strcpy.c
string/strlen.c
string/strncat.c
string/strncmp.c
string/strncpy.c
string/strnlen.c
string/strrchr.c
string/wcscat.c
string/wcschr.c
string/wcscmp.c
string/wcscpy.c
string/wcslen.c
string/wcsncat.c
string/wcsncmp.c
string/wcsncpy.c
string/wcsnlen.c
string/wcsrchr.c)
endif()
set_source_files_properties(${LIBCNTPR_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "NO_RTL_INLINES;_NTSYSTEM_;_NTDLLBUILD_;_LIBCNT_;__CRT__NO_INLINE;CRTDLL")
add_asm_files(libcntpr_asm ${LIBCNTPR_ASM_SOURCE})
add_library(libcntpr ${LIBCNTPR_SOURCE} ${libcntpr_asm})
add_target_compile_definitions(libcntpr
NO_RTL_INLINES
_NTSYSTEM_
_NTDLLBUILD_
_LIBCNT_
__CRT__NO_INLINE
CRTDLL)
add_dependencies(libcntpr psdk asm)

1527
sdk/lib/crt/locale/locale.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
#include <math.h>
_Check_return_
float
_chgsignf(_In_ float x)
{
return (float)_chgsign((double)x);
}

View file

@ -0,0 +1,12 @@
#include <math.h>
_Check_return_
float
__cdecl
_copysignf(
_In_ float x,
_In_ float y)
{
return (float)_copysign((double)x, (double)y);
}

View file

@ -0,0 +1,12 @@
#include <math.h>
_Check_return_
float
__cdecl
_hypotf(
_In_ float x,
_In_ float y)
{
return (float)_hypot((double)x, (double)y);
}

16
sdk/lib/crt/math/abs.c Normal file
View file

@ -0,0 +1,16 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#ifdef _MSC_VER
#pragma warning(disable: 4164)
#pragma function(abs)
#endif
/*
* @implemented
*/
int
__cdecl
abs(int j)
{
return j<0 ? -j : j;
}

31
sdk/lib/crt/math/acos.c Normal file
View file

@ -0,0 +1,31 @@
/* 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>
#ifdef _MSC_VER
#pragma function(acos)
#endif
double acos(double __x)
{
return atan2(sqrt(1.0 - __x * __x), __x);
}

Some files were not shown because too many files have changed in this diff Show more