一些基础组件
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#ifndef INCLUDED_C_MUTEX_H
|
||||
#define INCLUDED_C_MUTEX_H
|
||||
|
||||
#ifndef INCLUDED_C_TYPES_H
|
||||
#include <c_Types.h>
|
||||
#endif /*INCLUDED_C_TYPES_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define PLATFORM_WINDOWS 1
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#define PLATFORM_POSIX 1
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct {
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
CRITICAL_SECTION handle;
|
||||
#elif defined(PLATFORM_POSIX)
|
||||
pthread_mutex_t handle;
|
||||
#endif
|
||||
c_bool_t is_initialized;
|
||||
} c_Mutex_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_Mutex_Init(c_Mutex_t* mutex);
|
||||
void c_Mutex_Destroy(c_Mutex_t* mutex);
|
||||
void c_Mutex_Lock(c_Mutex_t* mutex);
|
||||
c_bool_t c_Mutex_TryLock(c_Mutex_t* mutex);
|
||||
void c_Mutex_UnLock(c_Mutex_t* mutex);
|
||||
|
||||
#endif /*INCLUDED_C_MUTEX_H*/
|
||||
Reference in New Issue
Block a user