kernel32: Moved the pthread emulation support to ntdll.

This commit is contained in:
Alexandre Julliard 2008-10-30 15:39:50 +01:00
parent 8551c8d50e
commit 5002bd21d1
7 changed files with 13 additions and 15 deletions

View File

@ -51,7 +51,6 @@ C_SRCS = \
powermgnt.c \
process.c \
profile.c \
pthread.c \
relay16.c \
resource.c \
resource16.c \

View File

@ -30,8 +30,7 @@ struct kernel_thread_data
WORD htask16; /* Win16 task handle */
DWORD sys_count[4]; /* syslevel mutex entry counters */
struct tagSYSLEVEL *sys_mutex[4]; /* syslevel mutex pointers */
void *pthread_data; /* private data for pthread emulation */
void *pad[43]; /* change this if you add fields! */
void *pad[44]; /* change this if you add fields! */
};
static inline struct kernel_thread_data *kernel_get_thread_data(void)
@ -71,8 +70,6 @@ extern HANDLE dos_handles[DOS_TABLE_SIZE];
extern const WCHAR *DIR_Windows;
extern const WCHAR *DIR_System;
extern void PTHREAD_Init(void);
extern VOID SYSLEVEL_CheckNotLevel( INT level );
extern void FILE_SetDosError(void);

View File

@ -970,8 +970,6 @@ void __wine_kernel_init(void)
/* Initialize everything */
PTHREAD_Init();
setbuf(stdout,NULL);
setbuf(stderr,NULL);
kernel32_handle = GetModuleHandleW(kernel32W);

View File

@ -30,6 +30,7 @@ C_SRCS = \
om.c \
path.c \
process.c \
pthread.c \
reg.c \
relay.c \
resource.c \

View File

@ -59,6 +59,7 @@ extern size_t get_signal_stack_total_size(void);
extern void version_init( const WCHAR *appname );
extern void debug_init(void);
extern HANDLE thread_init(void);
extern void pthread_init(void);
extern void actctx_init(void);
extern void virtual_init(void);
extern void virtual_init_threading(void);
@ -180,8 +181,9 @@ struct ntdll_thread_data
int reply_fd; /* 1e4 fd for receiving server replies */
int wait_fd[2]; /* 1e8 fd for sleeping server requests */
void *vm86_ptr; /* 1f0 data for vm86 mode */
void *pthread_data; /* 1f4 private data for pthread emulation */
void *pad[2]; /* 1f4 change this if you add fields! */
void *pad[1]; /* 1f8 change this if you add fields! */
};
static inline struct ntdll_thread_data *ntdll_get_thread_data(void)

View File

@ -46,7 +46,7 @@
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "kernel_private.h"
#include "ntdll_misc.h"
#include "wine/pthread.h"
#define P_OUTPUT(stuff) write(2,stuff,strlen(stuff))
@ -183,7 +183,7 @@ static void mutex_real_init( pthread_mutex_t *mutex )
CRITICAL_SECTION *critsect = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(CRITICAL_SECTION));
RtlInitializeCriticalSection(critsect);
if (InterlockedCompareExchangePointer((void**)&(((wine_mutex)mutex)->critsect),critsect,NULL) != NULL) {
if (interlocked_cmpxchg_ptr((void**)&(((wine_mutex)mutex)->critsect),critsect,NULL) != NULL) {
/* too late, some other thread already did it */
RtlDeleteCriticalSection(critsect);
RtlFreeHeap(GetProcessHeap(), 0, critsect);
@ -242,7 +242,7 @@ static void rwlock_real_init(pthread_rwlock_t *rwlock)
RTL_RWLOCK *lock = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_RWLOCK));
RtlInitializeResource(lock);
if (InterlockedCompareExchangePointer((void**)&(((wine_rwlock)rwlock)->lock),lock,NULL) != NULL) {
if (interlocked_cmpxchg_ptr((void**)&(((wine_rwlock)rwlock)->lock),lock,NULL) != NULL) {
/* too late, some other thread already did it */
RtlDeleteResource(lock);
RtlFreeHeap(GetProcessHeap(), 0, lock);
@ -363,7 +363,7 @@ static void wine_cond_real_init(pthread_cond_t *cond)
NtCreateEvent( &detail->waiters_done, EVENT_ALL_ACCESS, NULL, FALSE, FALSE );
RtlInitializeCriticalSection (&detail->waiters_count_lock);
if (InterlockedCompareExchangePointer((void**)&(((wine_cond)cond)->cond), detail, NULL) != NULL)
if (interlocked_cmpxchg_ptr((void**)&(((wine_cond)cond)->cond), detail, NULL) != NULL)
{
/* too late, some other thread already did it */
P_OUTPUT("FIXME:pthread_cond_init:expect troubles...\n");
@ -549,12 +549,12 @@ static int wine_pthread_equal(pthread_t thread1, pthread_t thread2)
static void *wine_get_thread_data(void)
{
return kernel_get_thread_data()->pthread_data;
return ntdll_get_thread_data()->pthread_data;
}
static void wine_set_thread_data( void *data )
{
kernel_get_thread_data()->pthread_data = data;
ntdll_get_thread_data()->pthread_data = data;
}
static const struct wine_pthread_callbacks callbacks =
@ -590,7 +590,7 @@ static const struct wine_pthread_callbacks callbacks =
static struct wine_pthread_functions pthread_functions;
void PTHREAD_Init(void)
void pthread_init(void)
{
wine_pthread_get_functions( &pthread_functions, sizeof(pthread_functions) );
pthread_functions.init_process( &callbacks, sizeof(callbacks) );

View File

@ -342,6 +342,7 @@ HANDLE thread_init(void)
user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart;
user_shared_data->TickCountMultiplier = 1 << 24;
pthread_init();
return exe_file;
}