mirror of
https://github.com/reactos/wine.git
synced 2024-12-04 01:41:18 +00:00
85ed45e377
Sat Aug 22 17:46:19 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de> * [include/dosexe.h] [include/module.h] [include/pe_image.h] [include/process.h] [include/windows.h] [loader/dos/module.c] [loader/module.c] [loader/ne/module.c] [loader/pe_image.c] [scheduler/process.c] [win32/process.c] Partially implemented CreateProcess32. * [win32/device.c] [relay32/kernel32.spec] [scheduler/k32obj.c] [misc/registry.c] [win32/file.c] Partially implemented VxDCall (VMM registry services). * [files/dos_fs.c] DOSFS_FindNext made thread-safe. * [include/sig_context.h] [include/syslevel.h] [loader/signal.c] [scheduler/syslevel.c] [tools/build.c] Replaced CALLTO16_Current_fs by SYSLEVEL_Win16CurrentTeb. * [win32/kernel32.c] Bugfix: QT_Thunk/FT_Thunk should return 'long' in DX:AX, not EAX. * [if1632/relay.c] [relay32/builtin32.c] [windows/msgbox.c] [msdos/int20.c] [msdos/int21.c] Use ExitProcess instead of TASK_KillCurrentTask. * [include/task.h] [include/thread.h] [loader/task.c] [scheduler/thread.c] [include/queue.h] [windows/message.c] [windows/queue.c] [windows/win.c] Prevent Win32 threads from entering the TASK_Reschedule loop. (Note: Win32 messaging still doesn't work correctly; this patch is just preventing the system from crashing when Win32 threads call messaging functions. Messages will probably still get lost.) * [scheduler/critsection.c] Deactivated the use of SEM_UNDO for the SYSTEM_LOCK semaphore; for some reason, this leads to problems after threads terminate... Sat Aug 22 15:00:00 1998 Jürgen Schmied <juergen.schmied@metronet.de> * [include/authors.h] New file, includes all names of the developer (former shell.c) * [Makefile.in][configure][configure.in][dlls/Makefile.in] [dlls/shell32/Makefile.in][shres.rc] Created dlls/shell32 and moved the shell32 stuff in it. Started to create internal resources. * [dlls/shell32/*] Split the shell32 implementation into smaller files. New classes: IContextMenu, IExtractIcon, IShellView. Implemented Shell_GetImageList(). shell32 links to comctl32 now dynamically so it can use internal/external implementations. * [documentation/internal-dll] [documentation/shell32] New, could anybody do a spellcheck? * [include/commctrl.h] Many new LV constants, structures, functions. * [controls/comctl32undoc.c] Rewrote the DSA* functions. * [windows/winpos.c] SetShellWindow32, GetShellWindow32. Sat Aug 22 14:02:15 1998 Alexander Lukyanov <lav@long.yar.ru> * [loader/resource.c] Mark last accelerator as such in LoadAccelerators32W. * [relay32/shell32.spec] [misc/shell.c] Add stubs for SHGetSpecialFolderPath[AW]. Sat Aug 22 02:07:42 1998 Adrian Harvey <adrian@select.com.au> * [include/file.h] [file/file.c] [msdos/int21.c] [msdos/vxd.c] [misc/lzexpand.c] [win32/kernel32.c] [documentation/filehandles] Fixed file handle handling. Created universal HFILE16 to HFILE32 translation macro from msdos/int21 code by Ove Kaaven. Used macro in all Win16 functions so that win32 handles are translated to avoid DOS/Win16 stdxx handles. Removed handle translation from int21.c where Win16 functions are called. Changed remaining calls to use new macro names. Documented filehandle handling and differences between win 16 & 32. Fri Aug 21 20:32:49 1998 Alexandre Julliard <julliard@lrc.epfl.ch> * [server/process.c] [server/thread.c] Implemented object wait queues and synchronization. Fri Aug 21 18:40:02 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk> * [graphics/psdrv/*] DEVMODE dmPaper{Width|Length} fields are in 0.1mm. Select a 100 pixel default font in CreateDC. Thu Aug 20 22:47:39 1998 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de> * [objects/bitmap.c] Handle bits=32 in SetBitmapBits32 and GetBitmapBits32. * [msdos/int21.c] Add handling of Int21 0A and 37. * [misc/commdlg.c] Use MapHModuleLS and MapHModuleSL when translating HINSTANCE16 to HINSTANCE32 and vice versa. * [win32/file.c] CreateFile32A: Abort if filename == NULL. Thu Aug 20 12:28:31 1998 Marcus Meissner <marcus@jet.franken.de> * [*/*] Lots of missing prototypes added, some parameter types adapted to match SDK. * [debugger/stabs.c] Don't loop forever if we don't find wine or one of the libxxx.so. * [loader/ne/module.c] Implemented MapHModuleLS,MapHModuleSL,MapHinstLS,MapHinstSL. * [misc/network.c] Implemented WNetGetUser32A. * [misc/shellord.c] Implemented ILRemoveLastID. * [multimedia/dsound.c] Fixed StarCraft memory leak. * [graphics/ddraw.c] Removed some unnecessary simple relaying functions, tried polishing up the Xlib implementation (still doesn't work), temp. removed Xshm code (to be remerged with working Xlib code). Tue Aug 18 22:29:17 1998 Ove Kaaven <ovek@arcticnet.no> * [multimedia/mmio.c] [multimedia/mmsystem.c] Fixed most mmio bugs, fully implementing mmioSetBuffer buffering, ability to read memory files, and the sndPlaySound() SND_MEMORY flag. Most mmio-using programs now work fine. * [include/dosexe.h] [include/miscemu.h] [include/module.h] [loader/module.c] [loader/task.c] [msdos/dosmem.c] Improved DOS VM flexibility and portability somewhat. (Did I get the #ifdefs right this time, BSD-ers?) * [msdos/int21.c] Made "Get Current PSP address" work as expected in a DOS VM. * [loader/dos/*] Began improving flexibility and portability somewhat. It should be easier to add DPMI RMCB callbacks now. The DOS VM no longer leaves big files lying around in /tmp after a crash. Tue Aug 18 12:38:31 1998 Turchanov Sergey <turchanov@usa.net> * [relay32/winmm.spec] This patch allows WinAmp to play WAV files (at least in PCM format). Sun Aug 16 05:34:13 1998 Pablo Saratxaga <srtxg@chanae.alphanet.ch> * [windows/keyboard.c] Corrected keyboard code to properly handle keys : ? ~ and " on non US keyboards. Sat Aug 15 18:47:14 1998 Brian Craft <bcboy@dorothy.wanglab.brandeis.edu> * [windows/win.c] Fixed severe bug in EnumChildWindwos(). Thu Aug 13 21:05:35 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * [controls/tooltips.c] Fixed some bugs. Added subclassing support. * [controls/toolbar.c] Improved tooltip integration. Fixed some bugs. * [controls/commctrl.c] Changed control registration and added some documentation. Fixed ShowHideMenuCtl. * [controls/rebar.c][include/rebar.h][include/commctrl.h] Improved rebar implementation (still no display). * [controls/pager.c][include/pager.h][include/commctrl.h] Improved pager implementation (still no display). * [misc/imagelist.c] Fixed a bug. * [documentation/common_controls] Updated. Sun Aug 9 19:50:20 1998 James Juran <jrj120@psu.edu> * [Makefile.in] [documentation/Makefile.in] [programs/Makefile.in] [programs/*/Makefile.in] Added uninstall rules, cleaned up install rules a little bit. Sun Aug 9 13:21:35 1998 Andreas Mohr <100.30936@germany.net> * [loader/ne/module.c] [if1632/kernel.spec] Added the undocumented HIWORD of GetModuleHandle (hFirstModule). * [loader/ne/segment.c] Wine forgot to set some NE_SEGFLAGS_*. Combined with another loader change, this fixed the "BLINKER -- error in loading module" or ghost MessageBox problem that about 1% of all Windows programs have. Some BLINKER programs still don't work, though. But I'm working on it, with great help from Blinkinc. * [loader/task.c] InitTask needs to decrement the SP register by two as Win95 does. Sun Aug 9 02:41:28 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de> * [if1632/kernel.spec] [relay32/kernel32.spec] [scheduler/syslevel.c] [loader/main.c] [win32/ordinals.c] [include/syslevel.h] [scheduler/Makefile.in] Implemented Win95 'syslevel' routines (including Win16Lock). * [if1632/relay.c] [if1632/thunk.c] [tools/build.c] [loader/task.c] [loader/ne/segment.c] [win32/kernel32.c] [memory/selector.c] [include/stackframe.h] [include/thread.h] 16-bit %fs handling revised. Use Win16Lock where appropriate. * [include/thread.h] [scheduler/synchro.c] [windows/message.c] [windows/queue.c] [win32/process.c] Implemented MsgWaitForMultipleObjects. * [files/change.c] [files/Makefile.in] [scheduler/k32obj.c] [win32/newfns.c] Implemented (dummy) file change notification objects. * [debugger/dbg.y] [scheduler/process.c] [scheduler/thread.c] [include/process.h] [include/thread.h] Suspend all threads except current when hitting debugger break point. * [objects/dib.c] Bugfix for CreateDIBSection.
317 lines
9.0 KiB
C
317 lines
9.0 KiB
C
/*
|
|
* Win32 critical sections
|
|
*
|
|
* Copyright 1998 Alexandre Julliard
|
|
*/
|
|
|
|
/* Note: critical sections are not implemented exactly the same way
|
|
* than under NT (LockSemaphore should be a real semaphore handle).
|
|
* But since they are even more different under Win95, it probably
|
|
* doesn't matter...
|
|
*/
|
|
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/sem.h>
|
|
#include "debug.h"
|
|
#include "windows.h"
|
|
#include "winerror.h"
|
|
#include "winbase.h"
|
|
#include "heap.h"
|
|
#include "k32obj.h"
|
|
#include "debug.h"
|
|
#include "thread.h"
|
|
|
|
typedef struct
|
|
{
|
|
K32OBJ header;
|
|
THREAD_QUEUE wait_queue;
|
|
BOOL32 signaled;
|
|
} CRIT_SECTION;
|
|
|
|
/* On some systems this is supposed to be defined in the program */
|
|
#ifndef HAVE_UNION_SEMUN
|
|
union semun {
|
|
int val;
|
|
struct semid_ds *buf;
|
|
ushort *array;
|
|
};
|
|
#endif
|
|
|
|
static BOOL32 CRIT_SECTION_Signaled( K32OBJ *obj, DWORD thread_id );
|
|
static BOOL32 CRIT_SECTION_Satisfied( K32OBJ *obj, DWORD thread_id );
|
|
static void CRIT_SECTION_AddWait( K32OBJ *obj, DWORD thread_id );
|
|
static void CRIT_SECTION_RemoveWait( K32OBJ *obj, DWORD thread_id );
|
|
static void CRIT_SECTION_Destroy( K32OBJ *obj );
|
|
|
|
const K32OBJ_OPS CRITICAL_SECTION_Ops =
|
|
{
|
|
CRIT_SECTION_Signaled, /* signaled */
|
|
CRIT_SECTION_Satisfied, /* satisfied */
|
|
CRIT_SECTION_AddWait, /* add_wait */
|
|
CRIT_SECTION_RemoveWait, /* remove_wait */
|
|
NULL, /* read */
|
|
NULL, /* write */
|
|
CRIT_SECTION_Destroy /* destroy */
|
|
};
|
|
|
|
/***********************************************************************
|
|
* InitializeCriticalSection (KERNEL32.472) (NTDLL.406)
|
|
*/
|
|
void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
{
|
|
CRIT_SECTION *obj;
|
|
|
|
crit->LockCount = -1;
|
|
crit->RecursionCount = 0;
|
|
crit->OwningThread = 0;
|
|
crit->LockSemaphore = 0;
|
|
if (SystemHeap)
|
|
{
|
|
if (!(obj = (CRIT_SECTION *)HeapAlloc( SystemHeap, 0, sizeof(*obj) )))
|
|
return; /* No way to return an error... */
|
|
obj->header.type = K32OBJ_CRITICAL_SECTION;
|
|
obj->header.refcount = 1;
|
|
obj->wait_queue = NULL;
|
|
obj->signaled = FALSE;
|
|
crit->LockSemaphore = (HANDLE32)obj;
|
|
crit->Reserved = (DWORD)-1;
|
|
}
|
|
else
|
|
{
|
|
union semun val;
|
|
crit->Reserved = (DWORD)semget( IPC_PRIVATE, 1, IPC_CREAT | 0777 );
|
|
if (crit->Reserved == (DWORD)-1)
|
|
{
|
|
perror( "semget" );
|
|
return;
|
|
}
|
|
val.val = 0;
|
|
semctl( (int)crit->Reserved, 0, SETVAL, val );
|
|
}
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DeleteCriticalSection (KERNEL32.185) (NTDLL.327)
|
|
*/
|
|
void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
|
|
{
|
|
CRIT_SECTION *obj = (CRIT_SECTION *)crit->LockSemaphore;
|
|
|
|
if (obj)
|
|
{
|
|
if (crit->RecursionCount) /* Should not happen */
|
|
MSG("Deleting owned critical section (%p)\n", crit );
|
|
crit->LockCount = -1;
|
|
crit->RecursionCount = 0;
|
|
crit->OwningThread = 0;
|
|
crit->LockSemaphore = 0;
|
|
K32OBJ_DecCount( &obj->header );
|
|
}
|
|
else if (crit->Reserved != (DWORD)-1)
|
|
{
|
|
semctl( (int)crit->Reserved, 0, IPC_RMID, (union semun)0 );
|
|
}
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* EnterCriticalSection (KERNEL32.195) (NTDLL.344)
|
|
*/
|
|
void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
|
|
{
|
|
if ( (crit->Reserved==-1) && !(crit->LockSemaphore) &&
|
|
(crit!=HEAP_SystemLock)
|
|
) {
|
|
FIXME(win32,"entering uninitialized section(%p)?\n",crit);
|
|
InitializeCriticalSection(crit);
|
|
}
|
|
if (InterlockedIncrement( &crit->LockCount ))
|
|
{
|
|
if (crit->OwningThread == GetCurrentThreadId())
|
|
{
|
|
crit->RecursionCount++;
|
|
return;
|
|
}
|
|
/* Now wait for it */
|
|
if (crit->LockSemaphore)
|
|
{
|
|
WAIT_STRUCT *wait = &THREAD_Current()->wait_struct;
|
|
SYSTEM_LOCK();
|
|
wait->count = 1;
|
|
wait->signaled = WAIT_FAILED;
|
|
wait->wait_all = FALSE;
|
|
wait->objs[0] = (K32OBJ *)crit->LockSemaphore;
|
|
K32OBJ_IncCount( wait->objs[0] );
|
|
SYNC_WaitForCondition( wait, INFINITE32 );
|
|
K32OBJ_DecCount( wait->objs[0] );
|
|
SYSTEM_UNLOCK();
|
|
}
|
|
else if (crit->Reserved != (DWORD)-1)
|
|
{
|
|
int ret;
|
|
struct sembuf sop;
|
|
sop.sem_num = 0;
|
|
sop.sem_op = -1;
|
|
sop.sem_flg = 0/*SEM_UNDO*/;
|
|
do
|
|
{
|
|
ret = semop( (int)crit->Reserved, &sop, 1 );
|
|
} while ((ret == -1) && (errno == EINTR));
|
|
}
|
|
else
|
|
{
|
|
MSG( "Uninitialized critical section (%p)\n", crit );
|
|
return;
|
|
}
|
|
}
|
|
crit->OwningThread = GetCurrentThreadId();
|
|
crit->RecursionCount = 1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* TryEnterCriticalSection (KERNEL32.898) (NTDLL.969)
|
|
*/
|
|
BOOL32 WINAPI TryEnterCriticalSection( CRITICAL_SECTION *crit )
|
|
{
|
|
if (InterlockedIncrement( &crit->LockCount ))
|
|
{
|
|
if (crit->OwningThread == GetCurrentThreadId())
|
|
{
|
|
crit->RecursionCount++;
|
|
return TRUE;
|
|
}
|
|
/* FIXME: this doesn't work */
|
|
InterlockedDecrement( &crit->LockCount );
|
|
return FALSE;
|
|
}
|
|
crit->OwningThread = GetCurrentThreadId();
|
|
crit->RecursionCount = 1;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* LeaveCriticalSection (KERNEL32.494) (NTDLL.426)
|
|
*/
|
|
void WINAPI LeaveCriticalSection( CRITICAL_SECTION *crit )
|
|
{
|
|
if (crit->OwningThread != GetCurrentThreadId()) return;
|
|
|
|
if (--crit->RecursionCount)
|
|
{
|
|
InterlockedDecrement( &crit->LockCount );
|
|
return;
|
|
}
|
|
crit->OwningThread = 0;
|
|
if (InterlockedDecrement( &crit->LockCount ) >= 0)
|
|
{
|
|
/* Someone is waiting */
|
|
if (crit->LockSemaphore)
|
|
{
|
|
CRIT_SECTION *obj = (CRIT_SECTION *)crit->LockSemaphore;
|
|
SYSTEM_LOCK();
|
|
obj->signaled = TRUE;
|
|
SYNC_WakeUp( &obj->wait_queue, 1 );
|
|
SYSTEM_UNLOCK();
|
|
}
|
|
else if (crit->Reserved != (DWORD)-1)
|
|
{
|
|
struct sembuf sop;
|
|
sop.sem_num = 0;
|
|
sop.sem_op = 1;
|
|
sop.sem_flg = 0/*SEM_UNDO*/;
|
|
semop( (int)crit->Reserved, &sop, 1 );
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* MakeCriticalSectionGlobal (KERNEL32.515)
|
|
*/
|
|
void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
|
|
{
|
|
/* Nothing to do: a critical section is always global */
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* ReinitializeCriticalSection (KERNEL32.581)
|
|
*/
|
|
void WINAPI ReinitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
{
|
|
DeleteCriticalSection( crit );
|
|
InitializeCriticalSection( crit );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CRIT_SECTION_Signaled
|
|
*/
|
|
static BOOL32 CRIT_SECTION_Signaled( K32OBJ *obj, DWORD thread_id )
|
|
{
|
|
CRIT_SECTION *crit = (CRIT_SECTION *)obj;
|
|
assert( obj->type == K32OBJ_CRITICAL_SECTION );
|
|
return crit->signaled;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CRIT_SECTION_Satisfied
|
|
*
|
|
* Wait on this object has been satisfied.
|
|
*/
|
|
static BOOL32 CRIT_SECTION_Satisfied( K32OBJ *obj, DWORD thread_id )
|
|
{
|
|
CRIT_SECTION *crit = (CRIT_SECTION *)obj;
|
|
assert( obj->type == K32OBJ_CRITICAL_SECTION );
|
|
/* Only one thread is allowed to wake up */
|
|
crit->signaled = FALSE;
|
|
return FALSE; /* Not abandoned */
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CRIT_SECTION_AddWait
|
|
*
|
|
* Add thread to object wait queue.
|
|
*/
|
|
static void CRIT_SECTION_AddWait( K32OBJ *obj, DWORD thread_id )
|
|
{
|
|
CRIT_SECTION *crit = (CRIT_SECTION *)obj;
|
|
assert( obj->type == K32OBJ_CRITICAL_SECTION );
|
|
THREAD_AddQueue( &crit->wait_queue, THREAD_ID_TO_THDB(thread_id) );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CRIT_SECTION_RemoveWait
|
|
*
|
|
* Remove current thread from object wait queue.
|
|
*/
|
|
static void CRIT_SECTION_RemoveWait( K32OBJ *obj, DWORD thread_id )
|
|
{
|
|
CRIT_SECTION *crit = (CRIT_SECTION *)obj;
|
|
assert( obj->type == K32OBJ_CRITICAL_SECTION );
|
|
THREAD_RemoveQueue( &crit->wait_queue, THREAD_ID_TO_THDB(thread_id) );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CRIT_SECTION_Destroy
|
|
*/
|
|
static void CRIT_SECTION_Destroy( K32OBJ *obj )
|
|
{
|
|
CRIT_SECTION *crit = (CRIT_SECTION *)obj;
|
|
assert( obj->type == K32OBJ_CRITICAL_SECTION );
|
|
/* There cannot be any thread on the list since the ref count is 0 */
|
|
assert( crit->wait_queue == NULL );
|
|
obj->type = K32OBJ_UNKNOWN;
|
|
HeapFree( SystemHeap, 0, crit );
|
|
}
|