Make windows locks do not use dyncall
This commit is contained in:
parent
3b732259c0
commit
266ea783e8
1 changed files with 14 additions and 12 deletions
|
|
@ -14,39 +14,41 @@
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
type
|
type
|
||||||
Handle = int
|
Handle = int
|
||||||
SysLock {.final, pure.} = object # CRITICAL_SECTION in WinApi
|
|
||||||
|
SysLock {.importc: "CRITICAL_SECTION",
|
||||||
|
header: "<windows.h>", final, pure.} = object # CRITICAL_SECTION in WinApi
|
||||||
DebugInfo: pointer
|
DebugInfo: pointer
|
||||||
LockCount: int32
|
LockCount: int32
|
||||||
RecursionCount: int32
|
RecursionCount: int32
|
||||||
OwningThread: int
|
OwningThread: int
|
||||||
LockSemaphore: int
|
LockSemaphore: int
|
||||||
Reserved: int32
|
SpinCount: int
|
||||||
|
|
||||||
SysCond = Handle
|
SysCond = Handle
|
||||||
|
|
||||||
{.deprecated: [THandle: Handle, TSysLock: SysLock, TSysCond: SysCond].}
|
{.deprecated: [THandle: Handle, TSysLock: SysLock, TSysCond: SysCond].}
|
||||||
|
|
||||||
proc initSysLock(L: var SysLock) {.stdcall, noSideEffect,
|
proc initSysLock(L: var SysLock) {.importc: "InitializeCriticalSection",
|
||||||
dynlib: "kernel32", importc: "InitializeCriticalSection".}
|
header: "<windows.h>".}
|
||||||
## Initializes the lock `L`.
|
## Initializes the lock `L`.
|
||||||
|
|
||||||
proc tryAcquireSysAux(L: var SysLock): int32 {.stdcall, noSideEffect,
|
proc tryAcquireSysAux(L: var SysLock): int32 {.importc: "TryEnterCriticalSection",
|
||||||
dynlib: "kernel32", importc: "TryEnterCriticalSection".}
|
header: "<windows.h>".}
|
||||||
## Tries to acquire the lock `L`.
|
## Tries to acquire the lock `L`.
|
||||||
|
|
||||||
proc tryAcquireSys(L: var SysLock): bool {.inline.} =
|
proc tryAcquireSys(L: var SysLock): bool {.inline.} =
|
||||||
result = tryAcquireSysAux(L) != 0'i32
|
result = tryAcquireSysAux(L) != 0'i32
|
||||||
|
|
||||||
proc acquireSys(L: var SysLock) {.stdcall, noSideEffect,
|
proc acquireSys(L: var SysLock) {.importc: "EnterCriticalSection",
|
||||||
dynlib: "kernel32", importc: "EnterCriticalSection".}
|
header: "<windows.h>".}
|
||||||
## Acquires the lock `L`.
|
## Acquires the lock `L`.
|
||||||
|
|
||||||
proc releaseSys(L: var SysLock) {.stdcall, noSideEffect,
|
proc releaseSys(L: var SysLock) {.importc: "LeaveCriticalSection",
|
||||||
dynlib: "kernel32", importc: "LeaveCriticalSection".}
|
header: "<windows.h>".}
|
||||||
## Releases the lock `L`.
|
## Releases the lock `L`.
|
||||||
|
|
||||||
proc deinitSys(L: var SysLock) {.stdcall, noSideEffect,
|
proc deinitSys(L: var SysLock) {.importc: "DeleteCriticalSection",
|
||||||
dynlib: "kernel32", importc: "DeleteCriticalSection".}
|
header: "<windows.h>".}
|
||||||
|
|
||||||
proc createEvent(lpEventAttributes: pointer,
|
proc createEvent(lpEventAttributes: pointer,
|
||||||
bManualReset, bInitialState: int32,
|
bManualReset, bInitialState: int32,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue