all repos — mgba @ b2d406a411b31acce5bbf0246af32a80c22ca834

mGBA Game Boy Advance Emulator

src/third-party/lzma/Threads.h (view raw)

 1/* Threads.h -- multithreading library
 22017-06-18 : Igor Pavlov : Public domain */
 3
 4#ifndef __7Z_THREADS_H
 5#define __7Z_THREADS_H
 6
 7#ifdef _WIN32
 8#include <windows.h>
 9#endif
10
11#include "7zTypes.h"
12
13EXTERN_C_BEGIN
14
15WRes HandlePtr_Close(HANDLE *h);
16WRes Handle_WaitObject(HANDLE h);
17
18typedef HANDLE CThread;
19#define Thread_Construct(p) *(p) = NULL
20#define Thread_WasCreated(p) (*(p) != NULL)
21#define Thread_Close(p) HandlePtr_Close(p)
22#define Thread_Wait(p) Handle_WaitObject(*(p))
23
24typedef
25#ifdef UNDER_CE
26  DWORD
27#else
28  unsigned
29#endif
30  THREAD_FUNC_RET_TYPE;
31
32#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
33#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
34typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);
35WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param);
36
37typedef HANDLE CEvent;
38typedef CEvent CAutoResetEvent;
39typedef CEvent CManualResetEvent;
40#define Event_Construct(p) *(p) = NULL
41#define Event_IsCreated(p) (*(p) != NULL)
42#define Event_Close(p) HandlePtr_Close(p)
43#define Event_Wait(p) Handle_WaitObject(*(p))
44WRes Event_Set(CEvent *p);
45WRes Event_Reset(CEvent *p);
46WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled);
47WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p);
48WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled);
49WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p);
50
51typedef HANDLE CSemaphore;
52#define Semaphore_Construct(p) *(p) = NULL
53#define Semaphore_IsCreated(p) (*(p) != NULL)
54#define Semaphore_Close(p) HandlePtr_Close(p)
55#define Semaphore_Wait(p) Handle_WaitObject(*(p))
56WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount);
57WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
58WRes Semaphore_Release1(CSemaphore *p);
59
60typedef CRITICAL_SECTION CCriticalSection;
61WRes CriticalSection_Init(CCriticalSection *p);
62#define CriticalSection_Delete(p) DeleteCriticalSection(p)
63#define CriticalSection_Enter(p) EnterCriticalSection(p)
64#define CriticalSection_Leave(p) LeaveCriticalSection(p)
65
66EXTERN_C_END
67
68#endif