一些基础组件

This commit is contained in:
2026-08-30 02:51:25 +08:00
parent 95e931727a
commit f26534c938
29 changed files with 4265 additions and 0 deletions
+44
View File
@@ -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*/