From ce5b02a4d00b0752d9cc61f2d507003e1dff48eb Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Thu, 9 Dec 2004 06:10:06 +0000 Subject: [PATCH] Started cleaning up the mess from my old import of Wine code in to msvcrt. I will start looking at cleaning up the memory allocation problems soon. svn path=/trunk/; revision=11992 --- reactos/lib/msvcrt/Makefile | 4 +- reactos/lib/msvcrt/misc/stubs.c | 10 ++ reactos/lib/msvcrt/wine/ctype.h | 115 ------------- reactos/lib/msvcrt/wine/exit.c | 261 ----------------------------- reactos/lib/msvcrt/wine/heap.c | 170 ------------------- reactos/lib/msvcrt/wine/lock.c | 31 +--- reactos/lib/msvcrt/wine/main.c | 217 ------------------------ reactos/lib/msvcrt/wine/stdlib.h | 273 ------------------------------- reactos/lib/msvcrt/wine/string.h | 149 ----------------- reactos/lib/msvcrt/wine/thread.c | 55 +------ 10 files changed, 27 insertions(+), 1258 deletions(-) create mode 100644 reactos/lib/msvcrt/misc/stubs.c delete mode 100644 reactos/lib/msvcrt/wine/ctype.h delete mode 100644 reactos/lib/msvcrt/wine/exit.c delete mode 100644 reactos/lib/msvcrt/wine/main.c delete mode 100644 reactos/lib/msvcrt/wine/stdlib.h delete mode 100644 reactos/lib/msvcrt/wine/string.h diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index 1af9f4164ce..aee279c623b 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.49 2004/12/03 23:37:41 blight Exp $ +# $Id: Makefile,v 1.50 2004/12/09 06:10:05 sedwards Exp $ PATH_TO_TOP = ../.. @@ -273,6 +273,7 @@ MISC_OBJECTS = \ misc/getargs.o \ misc/initterm.o \ misc/purecall.o \ + misc/stubs.o \ misc/tls.o PROCESS_OBJECTS = \ @@ -459,7 +460,6 @@ WINE_OBJECTS = \ wine/cppexcept.o \ wine/heap.o \ wine/lock.o \ - wine/main.o \ wine/thread.o WSTRING_OBJECTS = \ diff --git a/reactos/lib/msvcrt/misc/stubs.c b/reactos/lib/msvcrt/misc/stubs.c new file mode 100644 index 00000000000..7ab8a3afbc1 --- /dev/null +++ b/reactos/lib/msvcrt/misc/stubs.c @@ -0,0 +1,10 @@ +#include "precomp.h" + +/********************************************************************* + * $I10_OUTPUT (MSVCRT.@) + * Function not really understood but needed to make the DLL work + */ +void MSVCRT_I10_OUTPUT(void) +{ + /* FIXME: This is probably data, not a function */ +} diff --git a/reactos/lib/msvcrt/wine/ctype.h b/reactos/lib/msvcrt/wine/ctype.h deleted file mode 100644 index 49ac0978009..00000000000 --- a/reactos/lib/msvcrt/wine/ctype.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Character type definitions - * - * Derived from the mingw header written by Colin Peters. - * Modified for Wine use by Jon Griffiths and Francois Gouget. - * This file is in the public domain. - */ -#ifndef __WINE_CTYPE_H -#define __WINE_CTYPE_H -#ifndef __WINE_USE_MSVCRT -#define __WINE_USE_MSVCRT -#endif - -#ifndef MSVCRT -# ifdef USE_MSVCRT_PREFIX -# define MSVCRT(x) MSVCRT_##x -# else -# define MSVCRT(x) x -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef MSVCRT_WCHAR_T_DEFINED -#define MSVCRT_WCHAR_T_DEFINED -#ifndef __cplusplus -typedef unsigned short MSVCRT(wchar_t); -#endif -#endif - -#ifndef USE_MSVCRT_PREFIX -# ifndef WEOF -# define WEOF (wint_t)(0xFFFF) -# endif -#else -# ifndef MSVCRT_WEOF -# define MSVCRT_WEOF (MSVCRT_wint_t)(0xFFFF) -# endif -#endif /* USE_MSVCRT_PREFIX */ - -#ifndef MSVCRT_WCTYPE_T_DEFINED -typedef MSVCRT(wchar_t) MSVCRT(wint_t); -typedef MSVCRT(wchar_t) MSVCRT(wctype_t); -#define MSVCRT_WCTYPE_T_DEFINED -#endif - -/* ASCII char classification table - binary compatible */ -#define _UPPER 0x0001 /* C1_UPPER */ -#define _LOWER 0x0002 /* C1_LOWER */ -#define _DIGIT 0x0004 /* C1_DIGIT */ -#define _SPACE 0x0008 /* C1_SPACE */ -#define _PUNCT 0x0010 /* C1_PUNCT */ -#define _CONTROL 0x0020 /* C1_CNTRL */ -#define _BLANK 0x0040 /* C1_BLANK */ -#define _HEX 0x0080 /* C1_XDIGIT */ -#define _LEADBYTE 0x8000 -#define _ALPHA (0x0100|_UPPER|_LOWER) /* (C1_ALPHA|_UPPER|_LOWER) */ - -int MSVCRT(__isascii)(int); -int MSVCRT(__iscsym)(int); -int MSVCRT(__iscsymf)(int); -int MSVCRT(__toascii)(int); -int MSVCRT(_isctype)(int,int); -int MSVCRT(_tolower)(int); -int MSVCRT(_toupper)(int); -int MSVCRT(isalnum)(int); -int MSVCRT(isalpha)(int); -int MSVCRT(iscntrl)(int); -int MSVCRT(isdigit)(int); -int MSVCRT(isgraph)(int); -int MSVCRT(islower)(int); -int MSVCRT(isprint)(int); -int MSVCRT(ispunct)(int); -int MSVCRT(isspace)(int); -int MSVCRT(isupper)(int); -int MSVCRT(isxdigit)(int); -int MSVCRT(tolower)(int); -int MSVCRT(toupper)(int); - -#ifndef MSVCRT_WCTYPE_DEFINED -#define MSVCRT_WCTYPE_DEFINED -int MSVCRT(is_wctype)(MSVCRT(wint_t),MSVCRT(wctype_t)); -int MSVCRT(isleadbyte)(int); -int MSVCRT(iswalnum)(MSVCRT(wint_t)); -int MSVCRT(iswalpha)(MSVCRT(wint_t)); -int MSVCRT(iswascii)(MSVCRT(wint_t)); -int MSVCRT(iswcntrl)(MSVCRT(wint_t)); -int MSVCRT(iswctype)(MSVCRT(wint_t),MSVCRT(wctype_t)); -int MSVCRT(iswdigit)(MSVCRT(wint_t)); -int MSVCRT(iswgraph)(MSVCRT(wint_t)); -int MSVCRT(iswlower)(MSVCRT(wint_t)); -int MSVCRT(iswprint)(MSVCRT(wint_t)); -int MSVCRT(iswpunct)(MSVCRT(wint_t)); -int MSVCRT(iswspace)(MSVCRT(wint_t)); -int MSVCRT(iswupper)(MSVCRT(wint_t)); -int MSVCRT(iswxdigit)(MSVCRT(wint_t)); -MSVCRT(wchar_t) MSVCRT(towlower)(MSVCRT(wchar_t)); -MSVCRT(wchar_t) MSVCRT(towupper)(MSVCRT(wchar_t)); -#endif /* MSVCRT_WCTYPE_DEFINED */ - -#ifdef __cplusplus -} -#endif - - -#ifndef USE_MSVCRT_PREFIX -static inline int isascii(int c) { return __isascii(c); } -static inline int iscsym(int c) { return __iscsym(c); } -static inline int iscsymf(int c) { return __iscsymf(c); } -static inline int toascii(int c) { return __toascii(c); } -#endif /* USE_MSVCRT_PREFIX */ - -#endif /* __WINE_CTYPE_H */ diff --git a/reactos/lib/msvcrt/wine/exit.c b/reactos/lib/msvcrt/wine/exit.c deleted file mode 100644 index a719d1c1147..00000000000 --- a/reactos/lib/msvcrt/wine/exit.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * msvcrt.dll exit functions - * - * Copyright 2000 Jon Griffiths - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include -#include "msvcrt.h" - -#include "msvcrt/conio.h" -#include "msvcrt/stdlib.h" -#include "mtdll.h" -#include "winuser.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -/* MT */ -#define LOCK_EXIT _mlock(_EXIT_LOCK1) -#define UNLOCK_EXIT _munlock(_EXIT_LOCK1) - -static _onexit_t *MSVCRT_atexit_table = NULL; -static int MSVCRT_atexit_table_size = 0; -static int MSVCRT_atexit_registered = 0; /* Points to free slot */ - -static LPCSTR szMsgBoxTitle = "Wine C++ Runtime Library"; - -extern int MSVCRT_app_type; -extern char *MSVCRT__pgmptr; - -/* INTERNAL: call atexit functions */ -void __MSVCRT__call_atexit(void) -{ - /* Note: should only be called with the exit lock held */ - TRACE("%d atext functions to call\n", MSVCRT_atexit_registered); - /* Last registered gets executed first */ - while (MSVCRT_atexit_registered > 0) - { - MSVCRT_atexit_registered--; - TRACE("next is %p\n",MSVCRT_atexit_table[MSVCRT_atexit_registered]); - if (MSVCRT_atexit_table[MSVCRT_atexit_registered]) - (*MSVCRT_atexit_table[MSVCRT_atexit_registered])(); - TRACE("returned\n"); - } -} - -/********************************************************************* - * __dllonexit (MSVCRT.@) - */ -_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end) -{ - _onexit_t *tmp; - int len; - - TRACE("(%p,%p,%p)\n", func, start, end); - - if (!start || !*start || !end || !*end) - { - FIXME("bad table\n"); - return NULL; - } - - len = (*end - *start); - - TRACE("table start %p-%p, %d entries\n", *start, *end, len); - - if (++len <= 0) - return NULL; - - tmp = (_onexit_t *)MSVCRT_realloc(*start, len * sizeof(tmp)); - if (!tmp) - return NULL; - *start = tmp; - *end = tmp + len; - tmp[len - 1] = func; - TRACE("new table start %p-%p, %d entries\n", *start, *end, len); - return func; -} - -/********************************************************************* - * _exit (MSVCRT.@) - */ -void MSVCRT__exit(int exitcode) -{ - TRACE("(%d)\n", exitcode); - ExitProcess(exitcode); -} - -/* Print out an error message with an option to debug */ -static void DoMessageBox(LPCSTR lead, LPCSTR message) -{ - MSGBOXPARAMSA msgbox; - char text[2048]; - INT ret; - - snprintf(text,sizeof(text),"%s\n\nProgram: %s\n%s\n\n" - "Press OK to exit the program, or Cancel to start the Wine debugger.\n ", - lead, MSVCRT__pgmptr, message); - - msgbox.cbSize = sizeof(msgbox); - msgbox.hwndOwner = GetActiveWindow(); - msgbox.hInstance = 0; - msgbox.lpszText = text; - msgbox.lpszCaption = szMsgBoxTitle; - msgbox.dwStyle = MB_OKCANCEL|MB_ICONERROR; - msgbox.lpszIcon = NULL; - msgbox.dwContextHelpId = 0; - msgbox.lpfnMsgBoxCallback = NULL; - msgbox.dwLanguageId = LANG_NEUTRAL; - - ret = MessageBoxIndirectA(&msgbox); - if (ret == IDCANCEL) - DebugBreak(); -} - -/********************************************************************* - * _amsg_exit (MSVCRT.@) - */ -void MSVCRT__amsg_exit(int errnum) -{ - TRACE("(%d)\n", errnum); - /* FIXME: text for the error number. */ - if (MSVCRT_app_type == 2) - { - char text[32]; - sprintf(text, "Error: R60%d",errnum); - DoMessageBox("Runtime error!", text); - } - else - _cprintf("\nruntime error R60%d\n",errnum); - MSVCRT__exit(255); -} - -/********************************************************************* - * abort (MSVCRT.@) - */ -void MSVCRT_abort(void) -{ - TRACE("()\n"); - if (MSVCRT_app_type == 2) - { - DoMessageBox("Runtime error!", "abnormal program termination"); - } - else - _cputs("\nabnormal program termination\n"); - MSVCRT__exit(3); -} - -/********************************************************************* - * _assert (MSVCRT.@) - */ -void MSVCRT__assert(const char* str, const char* file, unsigned int line) -{ - TRACE("(%s,%s,%d)\n",str,file,line); - if (MSVCRT_app_type == 2) - { - char text[2048]; - snprintf(text, sizeof(text), "File: %s\nLine: %d\n\nEpression: \"%s\"", file, line, str); - DoMessageBox("Assertion failed!", text); - } - else - _cprintf("Assertion failed: %s, file %s, line %d\n\n",str, file, line); - MSVCRT__exit(3); -} - -/********************************************************************* - * _c_exit (MSVCRT.@) - */ -void MSVCRT__c_exit(void) -{ - TRACE("(void)\n"); - /* All cleanup is done on DLL detach; Return to caller */ -} - -/********************************************************************* - * _cexit (MSVCRT.@) - */ -void MSVCRT__cexit(void) -{ - TRACE("(void)\n"); - /* All cleanup is done on DLL detach; Return to caller */ -} - -/********************************************************************* - * _onexit (MSVCRT.@) - */ -_onexit_t _onexit(_onexit_t func) -{ - TRACE("(%p)\n",func); - - if (!func) - return NULL; - - LOCK_EXIT; - if (MSVCRT_atexit_registered > MSVCRT_atexit_table_size - 1) - { - _onexit_t *newtable; - TRACE("expanding table\n"); - newtable = MSVCRT_calloc(sizeof(void *),MSVCRT_atexit_table_size + 32); - if (!newtable) - { - TRACE("failed!\n"); - UNLOCK_EXIT; - return NULL; - } - memcpy (newtable, MSVCRT_atexit_table, MSVCRT_atexit_table_size); - MSVCRT_atexit_table_size += 32; - if (MSVCRT_atexit_table) - MSVCRT_free (MSVCRT_atexit_table); - MSVCRT_atexit_table = newtable; - } - MSVCRT_atexit_table[MSVCRT_atexit_registered] = func; - MSVCRT_atexit_registered++; - UNLOCK_EXIT; - return func; -} - -/********************************************************************* - * exit (MSVCRT.@) - */ -void MSVCRT_exit(int exitcode) -{ - TRACE("(%d)\n",exitcode); - LOCK_EXIT; - __MSVCRT__call_atexit(); - UNLOCK_EXIT; - ExitProcess(exitcode); -} - -/********************************************************************* - * atexit (MSVCRT.@) - */ -int MSVCRT_atexit(void (*func)(void)) -{ - TRACE("(%p)\n", func); - return _onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1; -} - - -/********************************************************************* - * _purecall (MSVCRT.@) - */ -void _purecall(void) -{ - TRACE("(void)\n"); - MSVCRT__amsg_exit( 25 ); -} diff --git a/reactos/lib/msvcrt/wine/heap.c b/reactos/lib/msvcrt/wine/heap.c index 33f14e30e18..61f0e6e4bf2 100644 --- a/reactos/lib/msvcrt/wine/heap.c +++ b/reactos/lib/msvcrt/wine/heap.c @@ -119,173 +119,3 @@ int MSVCRT__set_new_mode(int mode) UNLOCK_HEAP; return old_mode; } - -#if 0 /* __REACTOS__ */ -/********************************************************************* - * _callnewh (MSVCRT.@) - */ -int _callnewh(unsigned long size) -{ - if(MSVCRT_new_handler) - (*MSVCRT_new_handler)(size); - return 0; -} - -/********************************************************************* - * _expand (MSVCRT.@) - */ -void* _expand(void* mem, MSVCRT_size_t size) -{ - return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, size); -} - -/********************************************************************* - * _heapchk (MSVCRT.@) - */ -int _heapchk(void) -{ - if (!HeapValidate( GetProcessHeap(), 0, NULL)) - { - MSVCRT__set_errno(GetLastError()); - return _HEAPBADNODE; - } - return _HEAPOK; -} - -/********************************************************************* - * _heapmin (MSVCRT.@) - */ -int _heapmin(void) -{ - if (!HeapCompact( GetProcessHeap(), 0 )) - { - if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) - MSVCRT__set_errno(GetLastError()); - return -1; - } - return 0; -} - -/********************************************************************* - * _heapwalk (MSVCRT.@) - */ -int _heapwalk(_HEAPINFO* next) -{ - PROCESS_HEAP_ENTRY phe; - - LOCK_HEAP; - phe.lpData = next->_pentry; - phe.cbData = next->_size; - phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0; - - if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && - !HeapValidate( GetProcessHeap(), 0, phe.lpData )) - { - UNLOCK_HEAP; - MSVCRT__set_errno(GetLastError()); - return _HEAPBADNODE; - } - - do - { - if (!HeapWalk( GetProcessHeap(), &phe )) - { - UNLOCK_HEAP; - if (GetLastError() == ERROR_NO_MORE_ITEMS) - return _HEAPEND; - MSVCRT__set_errno(GetLastError()); - if (!phe.lpData) - return _HEAPBADBEGIN; - return _HEAPBADNODE; - } - } while (phe.wFlags & (PROCESS_HEAP_REGION|PROCESS_HEAP_UNCOMMITTED_RANGE)); - - UNLOCK_HEAP; - next->_pentry = phe.lpData; - next->_size = phe.cbData; - next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? _USEDENTRY : _FREEENTRY; - return _HEAPOK; -} - -/********************************************************************* - * _heapset (MSVCRT.@) - */ -int _heapset(unsigned int value) -{ - int retval; - _HEAPINFO heap; - - memset( &heap, 0, sizeof(_HEAPINFO) ); - LOCK_HEAP; - while ((retval = _heapwalk(&heap)) == _HEAPOK) - { - if (heap._useflag == _FREEENTRY) - memset(heap._pentry, value, heap._size); - } - UNLOCK_HEAP; - return retval == _HEAPEND? _HEAPOK : retval; -} - -/********************************************************************* - * _heapadd (MSVCRT.@) - */ -int _heapadd(void* mem, MSVCRT_size_t size) -{ - TRACE("(%p,%d) unsupported in Win32\n", mem,size); - *MSVCRT__errno() = MSVCRT_ENOSYS; - return -1; -} - -/********************************************************************* - * _msize (MSVCRT.@) - */ -MSVCRT_size_t _msize(void* mem) -{ - long size = HeapSize(GetProcessHeap(),0,mem); - if (size == -1) - { - WARN(":Probably called with non wine-allocated memory, ret = -1\n"); - /* At least the Win32 crtdll/msvcrt also return -1 in this case */ - } - return size; -} - -/********************************************************************* - * calloc (MSVCRT.@) - */ -void* MSVCRT_calloc(MSVCRT_size_t size, MSVCRT_size_t count) -{ - return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size * count ); -} - -/********************************************************************* - * free (MSVCRT.@) - */ -void MSVCRT_free(void* ptr) -{ - HeapFree(GetProcessHeap(),0,ptr); -} - -/********************************************************************* - * malloc (MSVCRT.@) - */ -void* MSVCRT_malloc(MSVCRT_size_t size) -{ - void *ret = HeapAlloc(GetProcessHeap(),0,size); - if (!ret) - MSVCRT__set_errno(GetLastError()); - return ret; -} - -/********************************************************************* - * realloc (MSVCRT.@) - */ -void* MSVCRT_realloc(void* ptr, MSVCRT_size_t size) -{ - if (!ptr) return MSVCRT_malloc(size); - if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, size); - MSVCRT_free(ptr); - return NULL; -} - -#endif /* __REACTOS__ */ diff --git a/reactos/lib/msvcrt/wine/lock.c b/reactos/lib/msvcrt/wine/lock.c index b2502ab4593..eee9da29fd7 100644 --- a/reactos/lib/msvcrt/wine/lock.c +++ b/reactos/lib/msvcrt/wine/lock.c @@ -16,28 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "config.h" -#include "wine/port.h" +#include "precomp.h" -#include +#define NDEBUG +#include -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "wine/winternl.h" -#include "wine/exception.h" -#include "winnt.h" -#include "excpt.h" -#include "wine/debug.h" -#include "msvcrt/malloc.h" -#include "msvcrt/stdlib.h" - -#include "msvcrt.h" -#include "cppexcept.h" #include "mtdll.h" -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - typedef struct { BOOL bInit; @@ -74,7 +59,7 @@ void msvcrt_init_mt_locks(void) { int i; - TRACE( "initializing mtlocks\n" ); + DPRINT( "initializing mtlocks\n" ); /* Initialize the table */ for( i=0; i < _TOTAL_LOCKS; i++ ) @@ -97,7 +82,7 @@ void msvcrt_free_mt_locks(void) { int i; - TRACE( ": uninitializing all mtlocks\n" ); + DPRINT(": uninitializing all mtlocks\n" ); /* Uninitialize the table */ for( i=0; i < _TOTAL_LOCKS; i++ ) @@ -115,7 +100,7 @@ void msvcrt_free_mt_locks(void) */ void _lock( int locknum ) { - TRACE( "(%d)\n", locknum ); + DPRINT( "(%d)\n", locknum ); /* If the lock doesn't exist yet, create it */ if( lock_table[ locknum ].bInit == FALSE ) @@ -126,7 +111,7 @@ void _lock( int locknum ) /* Check again if we've got a bit of a race on lock creation */ if( lock_table[ locknum ].bInit == FALSE ) { - TRACE( ": creating lock #%d\n", locknum ); + DPRINT( ": creating lock #%d\n", locknum ); msvcrt_initialize_mlock( locknum ); } @@ -144,7 +129,7 @@ void _lock( int locknum ) */ void _unlock( int locknum ) { - TRACE( "(%d)\n", locknum ); + DPRINT( "(%d)\n", locknum ); LeaveCriticalSection( &(lock_table[ locknum ].crit) ); } diff --git a/reactos/lib/msvcrt/wine/main.c b/reactos/lib/msvcrt/wine/main.c deleted file mode 100644 index eb5791bba88..00000000000 --- a/reactos/lib/msvcrt/wine/main.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * msvcrt.dll initialisation functions - * - * Copyright 2000 Jon Griffiths - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * This file isnt really the main file in ReactOS msvcrt. - * -sedwards - */ - -#include "config.h" -#include "wine/port.h" - -#include - -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "wine/winternl.h" -#include "wine/exception.h" -#include "winnt.h" -#include "excpt.h" -#include "wine/debug.h" -#include "msvcrt/malloc.h" -#include "msvcrt/stdlib.h" -#include "msvcrt/locale.h" -#include "msvcrt/stdio.h" - -#include "msvcrt.h" -#include "cppexcept.h" -#include "mtdll.h" - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -/* Index to TLS */ -DWORD MSVCRT_tls_index; - -static inline BOOL msvcrt_init_tls(void); -static inline BOOL msvcrt_free_tls(void); -//const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED; - -typedef void* (*MSVCRT_malloc_func)(size_t); - -char* MSVCRT___unDName(char *,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,unsigned short int); -char* MSVCRT___unDNameEx(char *,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,void *,unsigned short int); - -#if 0 /* __REACTOS__ */ - -/********************************************************************* - * Init - */ -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - MSVCRT_thread_data *tls; - - TRACE("(%p, %s, %p) pid(%lx), tid(%lx), tls(%ld)\n", - hinstDLL, msvcrt_get_reason(fdwReason), lpvReserved, - GetCurrentProcessId(), GetCurrentThreadId(), - (long)MSVCRT_tls_index); - - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - if (!msvcrt_init_tls()) - return FALSE; - msvcrt_init_mt_locks(); - msvcrt_init_io(); - msvcrt_init_console(); - msvcrt_init_args(); - MSVCRT_setlocale(0, "C"); - TRACE("finished process init\n"); - break; - case DLL_THREAD_ATTACH: - break; - case DLL_PROCESS_DETACH: - msvcrt_free_mt_locks(); - msvcrt_free_io(); - msvcrt_free_console(); - msvcrt_free_args(); - if (!msvcrt_free_tls()) - return FALSE; - TRACE("finished process free\n"); - break; - case DLL_THREAD_DETACH: - /* Free TLS */ - tls = TlsGetValue(MSVCRT_tls_index); - if (tls) HeapFree(GetProcessHeap(), 0, tls); - TRACE("finished thread free\n"); - break; - } - return TRUE; -} - -#endif /* __REACTOS__ */ - -static inline BOOL msvcrt_init_tls(void) -{ - MSVCRT_tls_index = TlsAlloc(); - - if (MSVCRT_tls_index == TLS_OUT_OF_INDEXES) - { - ERR("TlsAlloc() failed!\n"); - return FALSE; - } - return TRUE; -} - -static inline BOOL msvcrt_free_tls(void) -{ - if (!TlsFree(MSVCRT_tls_index)) - { - ERR("TlsFree() failed!\n"); - return FALSE; - } - return TRUE; -} - -const char* msvcrt_get_reason(DWORD reason) -{ - switch (reason) - { - case DLL_PROCESS_ATTACH: return "DLL_PROCESS_ATTACH"; - case DLL_PROCESS_DETACH: return "DLL_PROCESS_DETACH"; - case DLL_THREAD_ATTACH: return "DLL_THREAD_ATTACH"; - case DLL_THREAD_DETACH: return "DLL_THREAD_DETACH"; - } - return "UNKNOWN"; -} - - -/********************************************************************* - * $I10_OUTPUT (MSVCRT.@) - * Function not really understood but needed to make the DLL work - */ -void MSVCRT_I10_OUTPUT(void) -{ - /* FIXME: This is probably data, not a function */ -} - -/********************************************************************* - * __unDNameEx (MSVCRT.@) - * - * Demangle a C++ identifier. - * - * PARAMS - * OutStr [O] If not NULL, the place to put the demangled string - * mangled [I] Mangled name of the function - * OutStrLen[I] Length of OutStr - * memget [I] Function to allocate memory with - * memfree [I] Function to free memory with - * unknown [?] Unknown, possibly a call back - * flags [I] Flags determining demangled format - * - * RETURNS - * Success: A string pointing to the unmangled name, allocated with memget. - * Failure: NULL. - */ -char* MSVCRT___unDNameEx(char * OutStr, const char* mangled, int OutStrLen, - MSVCRT_malloc_func memget, - MSVCRT_free_func memfree, - void * unknown, - unsigned short int flags) -{ - FIXME("(%p,%s,%d,%p,%p,%p,%x) stub!\n", - OutStr, mangled, OutStrLen, memget, memfree, unknown, flags); - - /* FIXME: The code in tools/winebuild/msmangle.c is pretty complete and - * could be used here. - */ - - /* Experimentation reveals the following flag meanings when set: - * 0x0001 - Don't show __ in calling convention - * 0x0002 - Don't show calling convention at all - * 0x0004 - Don't show function/method return value - * 0x0010 - Same as 0x1 - * 0x0080 - Don't show access specifier (public/protected/private) - * 0x0200 - Don't show static specifier - * 0x0800 - Unknown, passed by type_info::name() - * 0x1000 - Only report the variable/class name - * 0x2000 - Unknown, passed by type_info::name() - */ - /* Duplicate the mangled name; for comparisons it doesn't matter anyway */ - if( OutStr == NULL) { - OutStrLen = strlen(mangled) + 1; - OutStr = memget( OutStrLen); - } - strncpy( OutStr, mangled, OutStrLen); - return OutStr; -} - - -/********************************************************************* - * __unDName (MSVCRT.@) - */ -char* MSVCRT___unDName(char * OutStr, const char* mangled, int OutStrLen, - MSVCRT_malloc_func memget, - MSVCRT_free_func memfree, - unsigned short int flags) -{ - return MSVCRT___unDNameEx( OutStr, mangled, OutStrLen, memget, memfree, - NULL, flags); -} diff --git a/reactos/lib/msvcrt/wine/stdlib.h b/reactos/lib/msvcrt/wine/stdlib.h deleted file mode 100644 index ac11517efb2..00000000000 --- a/reactos/lib/msvcrt/wine/stdlib.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Standard library definitions - * - * Derived from the mingw header written by Colin Peters. - * Modified for Wine use by Jon Griffiths and Francois Gouget. - * This file is in the public domain. - */ -#ifndef __WINE_STDLIB_H -#define __WINE_STDLIB_H -#ifndef __WINE_USE_MSVCRT -#define __WINE_USE_MSVCRT -#endif - -#ifndef MSVCRT -# ifdef USE_MSVCRT_PREFIX -# define MSVCRT(x) MSVCRT_##x -# else -# define MSVCRT(x) x -# endif -#endif - -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void*)0) -#endif -#endif - -#ifndef MSVCRT_WCHAR_T_DEFINED -#define MSVCRT_WCHAR_T_DEFINED -#ifndef __cplusplus -typedef unsigned short MSVCRT(wchar_t); -#endif -#endif - -#ifndef _MSC_VER -# ifndef __int64 -# define __int64 long long -# endif -#endif - -#ifndef USE_MSVCRT_PREFIX -#define EXIT_SUCCESS 0 -#define EXIT_FAILURE -1 -#define RAND_MAX 0x7FFF -#else -#define MSVCRT_RAND_MAX 0x7FFF -#endif /* USE_MSVCRT_PREFIX */ - -#ifndef _MAX_PATH -#define _MAX_DRIVE 3 -#define _MAX_FNAME 256 -#define _MAX_DIR _MAX_FNAME -#define _MAX_EXT _MAX_FNAME -#define _MAX_PATH 260 -#endif - - -typedef struct MSVCRT(_div_t) { - int quot; - int rem; -} MSVCRT(div_t); - -typedef struct MSVCRT(_ldiv_t) { - long quot; - long rem; -} MSVCRT(ldiv_t); - -#ifndef MSVCRT_SIZE_T_DEFINED -typedef unsigned int MSVCRT(size_t); -#define MSVCRT_SIZE_T_DEFINED -#endif - -#define __max(a,b) (((a) > (b)) ? (a) : (b)) -#define __min(a,b) (((a) < (b)) ? (a) : (b)) -#ifndef __cplusplus -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#endif - -/* _set_error_mode() constants */ -#define _OUT_TO_DEFAULT 0 -#define _OUT_TO_STDERR 1 -#define _OUT_TO_MSGBOX 2 -#define _REPORT_ERRMODE 3 - - -#ifdef __cplusplus -extern "C" { -#endif - -extern unsigned int* __p__osver(); -extern unsigned int* __p__winver(); -extern unsigned int* __p__winmajor(); -extern unsigned int* __p__winminor(); -#define _osver (*__p__osver()) -#define _winver (*__p__winver()) -#define _winmajor (*__p__winmajor()) -#define _winminor (*__p__winminor()) - -extern int* __p___argc(void); -extern char*** __p___argv(void); -extern MSVCRT(wchar_t)*** __p___wargv(void); -extern char*** __p__environ(void); -extern MSVCRT(wchar_t)*** __p__wenviron(void); -extern int* __p___mb_cur_max(void); -//extern unsigned long* __doserrno(void); -extern unsigned int* __p__fmode(void); -/* FIXME: We need functions to access these: - * int _sys_nerr; - * char** _sys_errlist; - */ -#ifndef USE_MSVCRT_PREFIX -#define __argc (*__p___argc()) -#define __argv (*__p___argv()) -#define __wargv (*__p___wargv()) -#define _environ (*__p__environ()) -#define _wenviron (*__p__wenviron()) -#define __mb_cur_max (*__p___mb_cur_max()) -#define _doserrno (*__doserrno()) -#define _fmode (*_fmode) -#endif /* USE_MSVCRT_PREFIX */ - - -extern int* MSVCRT(_errno)(void); -#ifndef USE_MSVCRT_PREFIX -# define errno (*_errno()) -#else -# define MSVCRT_errno (*MSVCRT__errno()) -#endif - - -//typedef int (*_onexit_t)(void); - - -__int64 _atoi64(const char*); -long double _atold(const char*); -void _beep(unsigned int,unsigned int); -char* _ecvt(double,int,int*,int*); -char* _fcvt(double,int,int*,int*); -char* _fullpath(char*,const char*,MSVCRT(size_t)); -char* _gcvt(double,int,char*); -char* _i64toa(__int64,char*,int); -char* _itoa(int,char*,int); -char* _ltoa(long,char*,int); -unsigned long _lrotl(unsigned long,int); -unsigned long _lrotr(unsigned long,int); -void _makepath(char*,const char*,const char*,const char*,const char*); -MSVCRT(size_t) _mbstrlen(const char*); -//_onexit_t _onexit(_onexit_t); -int _putenv(const char*); -unsigned int _rotl(unsigned int,int); -unsigned int _rotr(unsigned int,int); -void _searchenv(const char*,const char*,char*); -int _set_error_mode(int); -void _seterrormode(int); -void _sleep(unsigned long); -void _splitpath(const char*,char*,char*,char*,char*); -long double _strtold(const char*,char**); -//void _swab(char*,char*,int); //REACTOS -_CRTIMP void __cdecl _swab (const char*, char*, size_t); -char* _ui64toa(unsigned __int64,char*,int); -char* _ultoa(unsigned long,char*,int); - -void MSVCRT(_exit)(int); -void MSVCRT(abort)(); -int MSVCRT(abs)(int); -int MSVCRT(atexit)(void (*)(void)); -double MSVCRT(atof)(const char*); -int MSVCRT(atoi)(const char*); -long MSVCRT(atol)(const char*); -void* MSVCRT(calloc)(MSVCRT(size_t),MSVCRT(size_t)); -#ifndef __i386__ -MSVCRT(div_t) MSVCRT(div)(int,int); -MSVCRT(ldiv_t) MSVCRT(ldiv)(long,long); -#endif -void MSVCRT(exit)(int); -void MSVCRT(free)(void*); -char* MSVCRT(getenv)(const char*); -long MSVCRT(labs)(long); -void* MSVCRT(malloc)(MSVCRT(size_t)); -int MSVCRT(mblen)(const char*,MSVCRT(size_t)); -void MSVCRT(perror)(const char*); -int MSVCRT(rand)(void); -void* MSVCRT(realloc)(void*,MSVCRT(size_t)); -void MSVCRT(srand)(unsigned int); -double MSVCRT(strtod)(const char*,char**); -long MSVCRT(strtol)(const char*,char**,int); -unsigned long MSVCRT(strtoul)(const char*,char**,int); -int MSVCRT(system)(const char*); -void* MSVCRT(bsearch)(const void*,const void*,MSVCRT(size_t),MSVCRT(size_t), - int (*)(const void*,const void*)); -void MSVCRT(qsort)(void*,MSVCRT(size_t),MSVCRT(size_t), - int (*)(const void*,const void*)); - -#ifndef MSVCRT_WSTDLIB_DEFINED -#define MSVCRT_WSTDLIB_DEFINED -MSVCRT(wchar_t)*_itow(int,MSVCRT(wchar_t)*,int); -MSVCRT(wchar_t)*_i64tow(__int64,MSVCRT(wchar_t)*,int); -MSVCRT(wchar_t)*_ltow(long,MSVCRT(wchar_t)*,int); -MSVCRT(wchar_t)*_ui64tow(unsigned __int64,MSVCRT(wchar_t)*,int); -MSVCRT(wchar_t)*_ultow(unsigned long,MSVCRT(wchar_t)*,int); -MSVCRT(wchar_t)*_wfullpath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -MSVCRT(wchar_t)*_wgetenv(const MSVCRT(wchar_t)*); -void _wmakepath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -void _wperror(const MSVCRT(wchar_t)*); -int _wputenv(const MSVCRT(wchar_t)*); -void _wsearchenv(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*); -void _wsplitpath(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*); -int _wsystem(const MSVCRT(wchar_t)*); -int _wtoi(const MSVCRT(wchar_t)*); -__int64 _wtoi64(const MSVCRT(wchar_t)*); -long _wtol(const MSVCRT(wchar_t)*); - -MSVCRT(size_t) MSVCRT(mbstowcs)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t)); -int MSVCRT(mbtowc)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t)); -double MSVCRT(wcstod)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**); -long MSVCRT(wcstol)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int); -MSVCRT(size_t) MSVCRT(wcstombs)(char*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -unsigned long MSVCRT(wcstoul)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int); -int MSVCRT(wctomb)(char*,MSVCRT(wchar_t)); -#endif /* MSVCRT_WSTDLIB_DEFINED */ - -#ifdef __cplusplus -} -#endif - - -#ifndef USE_MSVCRT_PREFIX -#define environ _environ -#define onexit_t _onexit_t - -static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { return _ecvt(value, ndigit, decpt, sign); } -static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); } -static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); } -static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); } -static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); } -static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); } -static inline int putenv(const char* str) { return _putenv(str); } -static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); } -static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); } - -#ifdef __i386__ -static inline div_t __wine_msvcrt_div(int num, int denom) -{ - extern unsigned __int64 div(int,int); - div_t ret; - unsigned __int64 res = div(num,denom); - ret.quot = (int)res; - ret.rem = (int)(res >> 32); - return ret; -} -static inline ldiv_t __wine_msvcrt_ldiv(long num, long denom) -{ - extern unsigned __int64 ldiv(long,long); - ldiv_t ret; - unsigned __int64 res = ldiv(num,denom); - ret.quot = (long)res; - ret.rem = (long)(res >> 32); - return ret; -} -#define div(num,denom) __wine_msvcrt_div(num,denom) -#define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom) -#endif - -#endif /* USE_MSVCRT_PREFIX */ - -#endif /* __WINE_STDLIB_H */ diff --git a/reactos/lib/msvcrt/wine/string.h b/reactos/lib/msvcrt/wine/string.h deleted file mode 100644 index f0ecd84229d..00000000000 --- a/reactos/lib/msvcrt/wine/string.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * String definitions - * - * Derived from the mingw header written by Colin Peters. - * Modified for Wine use by Jon Griffiths and Francois Gouget. - * This file is in the public domain. - */ -#ifndef __WINE_STRING_H -#define __WINE_STRING_H -#ifndef __WINE_USE_MSVCRT -#define __WINE_USE_MSVCRT -#endif - -#ifndef MSVCRT -# ifdef USE_MSVCRT_PREFIX -# define MSVCRT(x) MSVCRT_##x -# else -# define MSVCRT(x) x -# endif -#endif - -#ifndef MSVCRT_WCHAR_T_DEFINED -#define MSVCRT_WCHAR_T_DEFINED -#ifndef __cplusplus -typedef unsigned short MSVCRT(wchar_t); -#endif -#endif - -#ifndef MSVCRT_SIZE_T_DEFINED -typedef unsigned int MSVCRT(size_t); -#define MSVCRT_SIZE_T_DEFINED -#endif - -#ifndef MSVCRT_NLSCMP_DEFINED -#define _NLSCMPERROR ((unsigned int)0x7fffffff) -#define MSVCRT_NLSCMP_DEFINED -#endif - -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -void* _memccpy(void*,const void*,int,MSVCRT(size_t)); -int _memicmp(const void*,const void*,MSVCRT(size_t)); -int _strcmpi(const char*,const char*); -char* _strdup(const char*); -char* _strerror(const char*); -int _stricmp(const char*,const char*); -int _stricoll(const char*,const char*); -char* _strlwr(char*); -int _strnicmp(const char*,const char*,MSVCRT(size_t)); -char* _strnset(char*,int,MSVCRT(size_t)); -char* _strrev(char*); -char* _strset(char*,int); -char* _strupr(char*); - -void* MSVCRT(memchr)(const void*,int,MSVCRT(size_t)); -int MSVCRT(memcmp)(const void*,const void*,MSVCRT(size_t)); -void* MSVCRT(memcpy)(void*,const void*,MSVCRT(size_t)); -void* MSVCRT(memmove)(void*,const void*,MSVCRT(size_t)); -void* MSVCRT(memset)(void*,int,MSVCRT(size_t)); -char* MSVCRT(strcat)(char*,const char*); -char* MSVCRT(strchr)(const char*,int); -int MSVCRT(strcmp)(const char*,const char*); -int MSVCRT(strcoll)(const char*,const char*); -char* MSVCRT(strcpy)(char*,const char*); -MSVCRT(size_t) MSVCRT(strcspn)(const char*,const char*); -char* MSVCRT(strerror)(int); -MSVCRT(size_t) MSVCRT(strlen)(const char*); -char* MSVCRT(strncat)(char*,const char*,MSVCRT(size_t)); -int MSVCRT(strncmp)(const char*,const char*,MSVCRT(size_t)); -char* MSVCRT(strncpy)(char*,const char*,MSVCRT(size_t)); -char* MSVCRT(strpbrk)(const char*,const char*); -char* MSVCRT(strrchr)(const char*,int); -MSVCRT(size_t) MSVCRT(strspn)(const char*,const char*); -char* MSVCRT(strstr)(const char*,const char*); -char* MSVCRT(strtok)(char*,const char*); -MSVCRT(size_t) MSVCRT(strxfrm)(char*,const char*,MSVCRT(size_t)); - -#ifndef MSVCRT_WSTRING_DEFINED -#define MSVCRT_WSTRING_DEFINED -MSVCRT(wchar_t)*_wcsdup(const MSVCRT(wchar_t)*); -int _wcsicmp(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -int _wcsicoll(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*_wcslwr(MSVCRT(wchar_t)*); -int _wcsnicmp(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -MSVCRT(wchar_t)*_wcsnset(MSVCRT(wchar_t)*,MSVCRT(wchar_t),MSVCRT(size_t)); -MSVCRT(wchar_t)*_wcsrev(MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*_wcsset(MSVCRT(wchar_t)*,MSVCRT(wchar_t)); -MSVCRT(wchar_t)*_wcsupr(MSVCRT(wchar_t)*); - -MSVCRT(wchar_t)*MSVCRT(wcscat)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*MSVCRT(wcschr)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)); -int MSVCRT(wcscmp)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -int MSVCRT(wcscoll)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*MSVCRT(wcscpy)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(size_t) MSVCRT(wcscspn)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(size_t) MSVCRT(wcslen)(const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*MSVCRT(wcsncat)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -int MSVCRT(wcsncmp)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -MSVCRT(wchar_t)*MSVCRT(wcsncpy)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -MSVCRT(wchar_t)*MSVCRT(wcspbrk)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*MSVCRT(wcsrchr)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t) wcFor); -MSVCRT(size_t) MSVCRT(wcsspn)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*MSVCRT(wcsstr)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(wchar_t)*MSVCRT(wcstok)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*); -MSVCRT(size_t) MSVCRT(wcsxfrm)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(size_t)); -#endif /* MSVCRT_WSTRING_DEFINED */ - -#ifdef __cplusplus -} -#endif - - -#ifndef USE_MSVCRT_PREFIX -static inline void* memccpy(void *s1, const void *s2, int c, MSVCRT(size_t) n) { return _memccpy(s1, s2, c, n); } -static inline int memicmp(const void* s1, const void* s2, MSVCRT(size_t) len) { return _memicmp(s1, s2, len); } -static inline int strcasecmp(const char* s1, const char* s2) { return _stricmp(s1, s2); } -static inline int strcmpi(const char* s1, const char* s2) { return _strcmpi(s1, s2); } -static inline char* strdup(const char* buf) { return _strdup(buf); } -static inline int stricmp(const char* s1, const char* s2) { return _stricmp(s1, s2); } -static inline int stricoll(const char* s1, const char* s2) { return _stricoll(s1, s2); } -static inline char* strlwr(char* str) { return _strlwr(str); } -static inline int strncasecmp(const char *str1, const char *str2, size_t n) { return _strnicmp(str1, str2, n); } -static inline int strnicmp(const char* s1, const char* s2, MSVCRT(size_t) n) { return _strnicmp(s1, s2, n); } -static inline char* strnset(char* str, int value, unsigned int len) { return _strnset(str, value, len); } -static inline char* strrev(char* str) { return _strrev(str); } -static inline char* strset(char* str, int value) { return _strset(str, value); } -static inline char* strupr(char* str) { return _strupr(str); } - -static inline MSVCRT(wchar_t)* wcsdup(const MSVCRT(wchar_t)* str) { return _wcsdup(str); } -static inline int wcsicoll(const MSVCRT(wchar_t)* str1, const MSVCRT(wchar_t)* str2) { return _wcsicoll(str1, str2); } -static inline MSVCRT(wchar_t)* wcslwr(MSVCRT(wchar_t)* str) { return _wcslwr(str); } -static inline int wcsnicmp(const MSVCRT(wchar_t)* str1, const MSVCRT(wchar_t)* str2, MSVCRT(size_t) n) { return _wcsnicmp(str1, str2, n); } -static inline MSVCRT(wchar_t)* wcsnset(MSVCRT(wchar_t)* str, MSVCRT(wchar_t) c, MSVCRT(size_t) n) { return _wcsnset(str, c, n); } -static inline MSVCRT(wchar_t)* wcsrev(MSVCRT(wchar_t)* str) { return _wcsrev(str); } -static inline MSVCRT(wchar_t)* wcsset(MSVCRT(wchar_t)* str, MSVCRT(wchar_t) c) { return _wcsset(str, c); } -static inline MSVCRT(wchar_t)* wcsupr(MSVCRT(wchar_t)* str) { return _wcsupr(str); } -#endif /* USE_MSVCRT_PREFIX */ - -#endif /* __WINE_STRING_H */ diff --git a/reactos/lib/msvcrt/wine/thread.c b/reactos/lib/msvcrt/wine/thread.c index ff64b9cfc3b..c192d7fcd8b 100644 --- a/reactos/lib/msvcrt/wine/thread.c +++ b/reactos/lib/msvcrt/wine/thread.c @@ -29,6 +29,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); void _amsg_exit (int errnum); +/* Index to TLS */ +DWORD MSVCRT_tls_index; /********************************************************************/ @@ -50,10 +52,11 @@ MSVCRT_thread_data *msvcrt_get_thread_data(void) if (!(ptr = TlsGetValue( MSVCRT_tls_index ))) { if (!(ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptr) ))) - //MSVCRT__amsg_exit( _RT_THREAD ); ROS - _amsg_exit( _RT_THREAD ); //ROS -// if (!TlsSetValue( MSVCRT_tls_index, ptr )) MSVCRT__amsg_exit( _RT_THREAD ); - if (!TlsSetValue( MSVCRT_tls_index, ptr )) _amsg_exit( _RT_THREAD ); + _amsg_exit( _RT_THREAD ); + if (!TlsSetValue( MSVCRT_tls_index, ptr )) + _amsg_exit( _RT_THREAD ); + if (!TlsSetValue( MSVCRT_tls_index, ptr )) + _amsg_exit( _RT_THREAD ); } SetLastError( err ); return ptr; @@ -102,47 +105,3 @@ unsigned long _beginthread( return (unsigned long)CreateThread(NULL, stack_size, _beginthread_trampoline, trampoline, 0, NULL); } -#if 0 /* __REACTOS__ */ -/********************************************************************* - * _beginthreadex (MSVCRT.@) - */ -unsigned long _beginthreadex( - void *security, /* [in] Security descriptor for new thread; must be NULL for Windows 9x applications */ - unsigned int stack_size, /* [in] Stack size for new thread or 0 */ - _beginthreadex_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */ - void *arglist, /* [in] Argument list to be passed to new thread or NULL */ - unsigned int initflag, /* [in] Initial state of new thread (0 for running or CREATE_SUSPEND for suspended) */ - unsigned int *thrdaddr) /* [out] Points to a 32-bit variable that receives the thread identifier */ -{ - TRACE("(%p, %d, %p, %p, %d, %p)\n", security, stack_size, start_address, arglist, initflag, thrdaddr); - - /* FIXME */ - return (unsigned long)CreateThread(security, stack_size, - (LPTHREAD_START_ROUTINE) start_address, - arglist, initflag, (LPDWORD) thrdaddr); -} - -/********************************************************************* - * _endthread (MSVCRT.@) - */ -void _endthread(void) -{ - TRACE("(void)\n"); - - /* FIXME */ - ExitThread(0); -} - -/********************************************************************* - * _endthreadex (MSVCRT.@) - */ -void _endthreadex( - unsigned int retval) /* [in] Thread exit code */ -{ - TRACE("(%d)\n", retval); - - /* FIXME */ - ExitThread(retval); -} - -#endif /* __REACTOS__ */