From 3f2bc58da542a400f32b4beb41a1cc00aece470f Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 6 Jun 2008 12:20:28 +0000 Subject: [PATCH] - Move scanf.c into strings, it belongs there. - Move thread.c to process, and remove outdated/duplicated copy. - Sync threadx with Wine. - Update README.WINE accordingly. svn path=/trunk/; revision=33865 --- reactos/lib/sdk/crt/crt.rbuild | 3 +- reactos/lib/sdk/crt/libcntpr.rbuild | 5 +- reactos/lib/sdk/crt/process/thread.c | 128 ++++++++++++++++--- reactos/lib/sdk/crt/process/threadx.c | 4 +- reactos/lib/sdk/crt/{wine => string}/scanf.c | 0 reactos/lib/sdk/crt/{wine => string}/scanf.h | 0 reactos/lib/sdk/crt/wine/thread.c | 106 --------------- reactos/media/doc/README.WINE | 4 +- 8 files changed, 118 insertions(+), 132 deletions(-) rename reactos/lib/sdk/crt/{wine => string}/scanf.c (100%) rename reactos/lib/sdk/crt/{wine => string}/scanf.h (100%) delete mode 100644 reactos/lib/sdk/crt/wine/thread.c diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index 7ea8acf176c..6cb16dd0c3a 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -421,6 +421,7 @@ atof.c ctype.c lasttok.c + scanf.c strcoll.c strdup.c strerror.c @@ -484,8 +485,6 @@ heap.c - scanf.c - thread.c undname.c diff --git a/reactos/lib/sdk/crt/libcntpr.rbuild b/reactos/lib/sdk/crt/libcntpr.rbuild index 40b94c3be1a..0a5519cc1d4 100644 --- a/reactos/lib/sdk/crt/libcntpr.rbuild +++ b/reactos/lib/sdk/crt/libcntpr.rbuild @@ -131,6 +131,7 @@ wcsrchr.c ctype.c + scanf.c strcspn.c stricmp.c strnicmp.c @@ -159,10 +160,6 @@ wtol.c - - scanf.c - - wcsicmp.c wcslwr.c diff --git a/reactos/lib/sdk/crt/process/thread.c b/reactos/lib/sdk/crt/process/thread.c index d058d7252e2..0e74ad52747 100644 --- a/reactos/lib/sdk/crt/process/thread.c +++ b/reactos/lib/sdk/crt/process/thread.c @@ -1,23 +1,117 @@ -#include - -#if 0 /* - * @unimplemented + * msvcrt.dll thread 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include +#include + +#include + +void _amsg_exit (int errnum); +/* Index to TLS */ +DWORD MSVCRT_tls_index; + +typedef void (*_beginthread_start_routine_t)(void *); +typedef unsigned int (__stdcall *_beginthreadex_start_routine_t)(void *); + +/********************************************************************/ + +typedef struct { + _beginthread_start_routine_t start_address; + void *arglist; +} _beginthread_trampoline_t; + +/********************************************************************* + * msvcrt_get_thread_data + * + * Return the thread local storage structure. + */ +MSVCRT_thread_data *msvcrt_get_thread_data(void) +{ + MSVCRT_thread_data *ptr; + DWORD err = GetLastError(); /* need to preserve last error */ + + if (!(ptr = TlsGetValue( MSVCRT_tls_index ))) + { + if (!(ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptr) ))) + _amsg_exit( _RT_THREAD ); + if (!TlsSetValue( MSVCRT_tls_index, ptr )) _amsg_exit( _RT_THREAD ); + ptr->random_seed = 1; + } + SetLastError( err ); + return ptr; +} + + +/********************************************************************* + * _beginthread_trampoline + */ +static DWORD CALLBACK _beginthread_trampoline(LPVOID arg) +{ + _beginthread_trampoline_t local_trampoline; + + /* Maybe it's just being paranoid, but freeing arg right + * away seems safer. + */ + memcpy(&local_trampoline,arg,sizeof(local_trampoline)); + free(arg); + + local_trampoline.start_address(local_trampoline.arglist); + return 0; +} + +/********************************************************************* + * _beginthread (MSVCRT.@) */ unsigned long _beginthread( - void (__cdecl *start_address)(void*), - unsigned stack_size, - void* arglist) -{ - __set_errno ( ENOSYS ); - return (unsigned long)-1; -} -#endif -/* - * @unimplemented - */ -void _endthread(void) + _beginthread_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */ + unsigned int stack_size, /* [in] Stack size for new thread or 0 */ + void *arglist) /* [in] Argument list to be passed to new thread or NULL */ { + _beginthread_trampoline_t* trampoline; + + DPRINT("(%p, %d, %p)\n", start_address, stack_size, arglist); + + /* Allocate the trampoline here so that it is still valid when the thread + * starts... typically after this function has returned. + * _beginthread_trampoline is responsible for freeing the trampoline + */ + trampoline=malloc(sizeof(*trampoline)); + trampoline->start_address = start_address; + trampoline->arglist = arglist; + + /* FIXME */ + return (unsigned long)CreateThread(NULL, stack_size, _beginthread_trampoline, + trampoline, 0, NULL); +} + +/********************************************************************* + * _endthread (MSVCRT.@) + */ +void CDECL _endthread(void) +{ + DPRINT("(void)\n"); + + /* FIXME */ + ExitThread(0); } -/* EOF */ diff --git a/reactos/lib/sdk/crt/process/threadx.c b/reactos/lib/sdk/crt/process/threadx.c index cf94a02c4b8..cd82b9b3ac2 100644 --- a/reactos/lib/sdk/crt/process/threadx.c +++ b/reactos/lib/sdk/crt/process/threadx.c @@ -3,7 +3,7 @@ /* * @unimplemented */ -unsigned long _beginthreadex( +unsigned long CDECL _beginthreadex( void* security, unsigned stack_size, unsigned (__stdcall *start_address)(void*), @@ -32,7 +32,7 @@ unsigned long _beginthreadex( /* * @implemented */ -void _endthreadex(unsigned retval) +void CDECL _endthreadex(unsigned retval) { /* * Just call the API function. Any CRT specific processing is done in diff --git a/reactos/lib/sdk/crt/wine/scanf.c b/reactos/lib/sdk/crt/string/scanf.c similarity index 100% rename from reactos/lib/sdk/crt/wine/scanf.c rename to reactos/lib/sdk/crt/string/scanf.c diff --git a/reactos/lib/sdk/crt/wine/scanf.h b/reactos/lib/sdk/crt/string/scanf.h similarity index 100% rename from reactos/lib/sdk/crt/wine/scanf.h rename to reactos/lib/sdk/crt/string/scanf.h diff --git a/reactos/lib/sdk/crt/wine/thread.c b/reactos/lib/sdk/crt/wine/thread.c deleted file mode 100644 index 385734a8571..00000000000 --- a/reactos/lib/sdk/crt/wine/thread.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * msvcrt.dll thread 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 - -#include -#include - -#include - -void _amsg_exit (int errnum); -/* Index to TLS */ -DWORD MSVCRT_tls_index; - -typedef void (*_beginthread_start_routine_t)(void *); -typedef unsigned int (__stdcall *_beginthreadex_start_routine_t)(void *); - -/********************************************************************/ - -typedef struct { - _beginthread_start_routine_t start_address; - void *arglist; -} _beginthread_trampoline_t; - -/********************************************************************* - * msvcrt_get_thread_data - * - * Return the thread local storage structure. - */ -MSVCRT_thread_data *msvcrt_get_thread_data(void) -{ - MSVCRT_thread_data *ptr; - DWORD err = GetLastError(); /* need to preserve last error */ - - if (!(ptr = TlsGetValue( MSVCRT_tls_index ))) - { - if (!(ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptr) ))) - _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; -} - -/********************************************************************* - * _beginthread_trampoline - */ -static DWORD CALLBACK _beginthread_trampoline(LPVOID arg) -{ - _beginthread_trampoline_t local_trampoline; - - /* Maybe it's just being paranoid, but freeing arg right - * away seems safer. - */ - memcpy(&local_trampoline,arg,sizeof(local_trampoline)); - free(arg); - - local_trampoline.start_address(local_trampoline.arglist); - return 0; -} - -/********************************************************************* - * _beginthread (MSVCRT.@) - */ -unsigned long _beginthread( - _beginthread_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */ - unsigned int stack_size, /* [in] Stack size for new thread or 0 */ - void *arglist) /* [in] Argument list to be passed to new thread or NULL */ -{ - _beginthread_trampoline_t* trampoline; - - DPRINT("(%p, %d, %p)\n", start_address, stack_size, arglist); - - /* Allocate the trampoline here so that it is still valid when the thread - * starts... typically after this function has returned. - * _beginthread_trampoline is responsible for freeing the trampoline - */ - trampoline=malloc(sizeof(*trampoline)); - trampoline->start_address = start_address; - trampoline->arglist = arglist; - - /* FIXME */ - return (unsigned long)CreateThread(NULL, stack_size, _beginthread_trampoline, - trampoline, 0, NULL); -} diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index fbe0597723e..18d127b1518 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -143,10 +143,12 @@ kernel32 - reactos/dll/win32/kernel32/misc/lcformat.c # Out of sync msvcrt - - reactos/dll/win32/msvcrt/wine/*.c # Out of sync reactos/lib/sdk/crt/cpp.c # Synced at 20071111 reactos/lib/sdk/crt/cppexcept.c # Synced at 20071111 + reactos/lib/sdk/crt/strings/scanf.c/h # Synced at 20080604 + reactos/lib/sdk/crt/wine/heap.c # Synced at 20080529 reactos/lib/sdk/crt/wine # Synced at XXXXXXXX + reactos/lib/sdk/crt/thread/thread.c # Synced at 20080604 User32 - reactos/dll/win32/user32/controls/button.c # Synced at 20071022