mirror of
https://github.com/reactos/wine.git
synced 2025-02-18 11:58:22 +00:00
![Alexandre Julliard](/assets/img/avatar_default.png)
Sun Mar 2 14:57:37 1997 Alexandre Julliard <julliard@lrc.epfl.ch> * [*/*] Completed transition to new Win32 types. * [tools/build.c] Changed CallTo16_regs to take a CONTEXT argument. * [memory/virtual.c] Rewrote Virtual* functions. Implemented CreateFileMapping and OpenFileMapping. Broke MapViewOfFile ;-) * [win32/k32obj.c] Implemented named objects. Sun Mar 2 00:33:21 1997 Mikolaj Zalewski <zmikolaj@free.polbox.pl> * [misc/ole2nls.c] [resources/sysres_Pl.c] Added Polish language support. Sat Mar 1 13:31:25 1997 David Faure <david.faure@ifhamy.insa-lyon.fr> * [windows/keyboard.c] Wrote VkKeyScan and tested with Winword. Works ok except for dead chars. Fri Feb 28 09:34:03 1997 John Harvey <john@division.co.uk> * [graphics/win16drv/font.c] [graphics/win16drv/init.c] [graphics/win16drv/obects.c] Added start of SelectObject call for printer driver. Write should now run with the printer driver enabled. Wed Feb 26 20:03:32 1997 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [debugger/*.c] Re-added a disassembly command (list serves another functionality now). * [loader/pe_resource.c] Added # support. * [misc/ole2nls.c] GetStringType* added. * [objects/color.c] VGA16 fixes. * [windows/class.c] Look for global widget classes too in GetClassInfo32. * [windows/sysmetrics.c] [include/windows.h] Added Win32 sysmetrics. Sat Feb 22 23:56:29 1997 Jukka Iivonen <iivonen@cc.helsinki.fi> * [documentation/languages] The fourth case updated. * [if1632/ntdll.spec] Added some is* and to* functions. Sat Feb 22 23:05:47 1997 Morten Welinder <terra@diku.dk> * [configure.in] Add tests for wait4 and waitpid. * [loader/signal.c] Clean up OS-dependent code. I hope I got it right, :-) * [tools/wineconf] Recognise vfat file systems. Ignore floppy drives specified in /etc/fstab. * [files/*] Fix function names in error messages. Sat Feb 22 06:15:13 1997 Pablo Saratxaga <srtxg@chanae.stben.be> * [windows/keyboard.c] [windows/message.c] Support for more latin alphabet dead keys for iso-8859-{1,2,3,4,9} characters sets. Fri Feb 21 20:37:50 1997 Huw D M Davies <h.davies1@physics.oxford.ac.uk> * [controls/edit.c] Fix incorrect arg order in LOCAL_Alloc() call. Fri Feb 21 18:19:17 1997 Andrew Taylor <andrew@riscan.com> * [multimedia/mmsystem.c] [multimedia/mcistring.c] Fixed bug related to device IDs returned by multimedia system. Implemented mciGetDeviceID. Sat Feb 15 00:58:19 1997 Jimen Ching <jching@aloha.com> * [debugger/dbg.y] Do not dereference invalid expressions.
263 lines
6.9 KiB
C
263 lines
6.9 KiB
C
/*
|
|
* Win32 kernel functions
|
|
*
|
|
* Copyright 1995 Martin von Loewis
|
|
* Copyright 1997 Onno Hovers
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <sys/ipc.h>
|
|
#include <sys/sem.h>
|
|
#include "windows.h"
|
|
#include "winbase.h"
|
|
#include "winerror.h"
|
|
#include "stddebug.h"
|
|
#include "debug.h"
|
|
#include "xmalloc.h"
|
|
|
|
|
|
/*
|
|
* FIXME:
|
|
* The c functions do not protect from non-interlocked accesses
|
|
* This is no problem as long as we do not have multiple Win32 threads
|
|
* or processes.
|
|
* The assembly macro's do protect from non-interlocked access,
|
|
* but they will only work for i386 systems with GCC.
|
|
*/
|
|
|
|
/************************************************************************
|
|
* InterlockedIncrement [KERNEL32] *
|
|
* *
|
|
* InterlockedIncrement adds 1 to a long variable and returns *
|
|
* - a negative number if the result < 0 *
|
|
* - zero if the result == 0 *
|
|
* - a positive number if the result > 0 *
|
|
* *
|
|
* The returned number need not be equal to the result!!!! *
|
|
************************************************************************/
|
|
|
|
LONG InterlockedIncrement(LPLONG lpAddend)
|
|
{
|
|
#if defined(__i386__)&&defined(__GNUC__)
|
|
long ret;
|
|
__asm__
|
|
(
|
|
"\tlock\n" /* for SMP systems */
|
|
"\tincl (%1)\n"
|
|
"\tje 2f\n"
|
|
"\tjl 1f\n"
|
|
"\tincl %0\n"
|
|
"\tjmp 2f\n"
|
|
"1:\tdec %0\n"
|
|
"2:\n"
|
|
:"=r" (ret):"r" (lpAddend), "0" (0): "memory"
|
|
);
|
|
return ret;
|
|
#else
|
|
LONG ret;
|
|
/* StopAllThreadsAndProcesses() */
|
|
|
|
(*lpAddend)++;
|
|
ret=*lpAddend;
|
|
|
|
/* ResumeAllThreadsAndProcesses() */
|
|
return ret;
|
|
#endif
|
|
}
|
|
|
|
/************************************************************************
|
|
* InterlockedDecrement [KERNEL32] *
|
|
* *
|
|
* InterlockedIncrement adds 1 to a long variable and returns *
|
|
* - a negative number if the result < 0 *
|
|
* - zero if the result == 0 *
|
|
* - a positive number if the result > 0 *
|
|
* *
|
|
* The returned number need not be equal to the result!!!! *
|
|
************************************************************************/
|
|
|
|
LONG InterlockedDecrement(LPLONG lpAddend)
|
|
{
|
|
#if defined(__i386__)&&defined(__GNUC__)
|
|
LONG ret;
|
|
__asm__
|
|
(
|
|
"\tlock\n" /* for SMP systems */
|
|
"\tdecl (%1)\n"
|
|
"\tje 2f\n"
|
|
"\tjl 1f\n"
|
|
"\tincl %0\n"
|
|
"\tjmp 2f\n"
|
|
"1:\tdec %0\n"
|
|
"2:\n"
|
|
:"=r" (ret):"r" (lpAddend), "0" (0): "memory"
|
|
);
|
|
return ret;
|
|
#else
|
|
LONG ret;
|
|
/* StopAllThreadsAndProcesses() */
|
|
|
|
(*lpAddend)--;
|
|
ret=*lpAddend;
|
|
|
|
/* ResumeAllThreadsAndProcesses() */
|
|
return ret;
|
|
#endif
|
|
}
|
|
|
|
/************************************************************************
|
|
* InterlockedExchange [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
LONG InterlockedExchange(LPLONG target, LONG value)
|
|
{
|
|
#if defined(__i386__)&&defined(__GNUC__)
|
|
LONG ret;
|
|
__asm__
|
|
(
|
|
|
|
"\tlock\n" /* for SMP systems */
|
|
"\txchgl %0,(%1)\n"
|
|
:"=r" (ret):"r" (target), "0" (value):"memory"
|
|
);
|
|
return ret;
|
|
#else
|
|
LONG ret;
|
|
/* StopAllThreadsAndProcesses() */
|
|
|
|
ret=*target;
|
|
*target=value;
|
|
|
|
/* ResumeAllThreadsAndProcesses() */
|
|
return ret;
|
|
#endif
|
|
}
|
|
|
|
/* AAARGHH some CriticalSection functions get called before we
|
|
* have a threadid
|
|
*/
|
|
|
|
#define GetCurrentThreadId() (-1)
|
|
|
|
/************************************************************************
|
|
* InitializeCriticalSection [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
void InitializeCriticalSection(CRITICAL_SECTION *pcritical)
|
|
{
|
|
pcritical->LockCount=-1;
|
|
pcritical->RecursionCount=0;
|
|
pcritical->LockSemaphore=(HANDLE32) semget(IPC_PRIVATE,1,IPC_CREAT);
|
|
pcritical->OwningThread=(HANDLE32) -1;
|
|
pcritical->Reserved=0;
|
|
}
|
|
|
|
/************************************************************************
|
|
* DeleteCriticalSection [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
void DeleteCriticalSection(CRITICAL_SECTION *pcritical)
|
|
{
|
|
semctl((int) pcritical->LockSemaphore,0,IPC_RMID,NULL);
|
|
pcritical->Reserved=-1;
|
|
}
|
|
|
|
/************************************************************************
|
|
* EnterCriticalSection [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
void EnterCriticalSection (CRITICAL_SECTION *pcritical)
|
|
{
|
|
if( InterlockedIncrement(&(pcritical->LockCount)))
|
|
{
|
|
if( pcritical->OwningThread!= (HANDLE32) GetCurrentThreadId() )
|
|
{
|
|
struct sembuf sop;
|
|
|
|
sop.sem_num=0;
|
|
sop.sem_op=0;
|
|
sop.sem_flg=0;
|
|
semop((int) pcritical->LockSemaphore,&sop,0);
|
|
|
|
pcritical->OwningThread = (HANDLE32) GetCurrentThreadId();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pcritical->OwningThread =(HANDLE32) GetCurrentThreadId();
|
|
}
|
|
pcritical->RecursionCount++;
|
|
}
|
|
|
|
/************************************************************************
|
|
* TryEnterCriticalSection [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
BOOL32 TryEnterCriticalSection (CRITICAL_SECTION *pcritical)
|
|
{
|
|
if( InterlockedIncrement(&(pcritical->LockCount)))
|
|
{
|
|
if( pcritical->OwningThread!= (HANDLE32) GetCurrentThreadId() )
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
pcritical->OwningThread =(HANDLE32) GetCurrentThreadId();
|
|
}
|
|
pcritical->RecursionCount++;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/************************************************************************
|
|
* LeaveCriticalSection [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
void LeaveCriticalSection (CRITICAL_SECTION *pcritical)
|
|
{
|
|
/* do we actually own this critical section ??? */
|
|
if( pcritical->OwningThread!= (HANDLE32) GetCurrentThreadId())
|
|
return;
|
|
|
|
pcritical->RecursionCount--;
|
|
if( pcritical->RecursionCount==0)
|
|
{
|
|
pcritical->OwningThread=(HANDLE32)-1;
|
|
if(InterlockedDecrement(&(pcritical->LockCount))>=0)
|
|
{
|
|
struct sembuf sop;
|
|
|
|
sop.sem_num=0;
|
|
sop.sem_op=1;
|
|
sop.sem_flg=0;
|
|
semop((int) pcritical->LockSemaphore,&sop,0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
InterlockedDecrement(&(pcritical->LockCount));
|
|
}
|
|
}
|
|
|
|
/************************************************************************
|
|
* ReinitializeCriticalSection [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
void ReinitializeCriticalSection(CRITICAL_SECTION *lpCrit)
|
|
{
|
|
/* hmm ?????? */
|
|
}
|
|
|
|
/************************************************************************
|
|
* MakeCriticalSectionGlobal [KERNEL32] *
|
|
************************************************************************/
|
|
|
|
void MakeCriticalSectionGlobal(CRITICAL_SECTION *lpCrit)
|
|
{
|
|
/* nothing (SysV Semaphores are already global) */
|
|
return;
|
|
}
|
|
|