Rev 108 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 108 | Rev 154 | ||
---|---|---|---|
Line 13... | Line 13... | ||
13 | # define pthread_t HANDLE |
13 | # define pthread_t HANDLE |
14 | # define thread_t HANDLE |
14 | # define thread_t HANDLE |
15 | extern pthread_t NumaStartThread(void *func, void *args); |
15 | extern pthread_t NumaStartThread(void *func, void *args); |
16 | 16 | ||
17 | # include <windows.h> |
17 | # include <windows.h> |
18 | //# pragma intrinsic (_InterlockedExchange) // Pierre-Marie Baty -- it's already intrinsic, and there's no leading underscore |
- | |
19 | typedef volatile LONG lock_t[1]; |
18 | typedef volatile LONG lock_t[1]; |
20 | 19 | ||
21 | # define LockInit(v) ((v)[0] = 0) |
20 | # define LockInit(v) ((v)[0] = 0) |
22 | # define LockFree(v) ((v)[0] = 0) |
21 | # define LockFree(v) ((v)[0] = 0) |
23 | # define Unlock(v) ((v)[0] = 0) |
22 | # define Unlock(v) ((v)[0] = 0) |
24 | __forceinline void Lock(volatile LONG * hPtr) { |
23 | __forceinline void Lock(volatile LONG * hPtr) { |
25 | int iValue; |
24 | int iValue; |
26 | 25 | ||
27 | for (;;) { |
26 | for (;;) { |
28 | iValue = |
27 | iValue = _InterlockedExchange((LPLONG) hPtr, 1); |
29 | if (0 == iValue) |
28 | if (0 == iValue) |
30 | return; |
29 | return; |
31 | while (*hPtr); |
30 | while (*hPtr); |
32 | } |
31 | } |
33 | } |
32 | } |