mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix gbMutex for *nix
This commit is contained in:
@@ -752,7 +752,7 @@ bit_set_type :: proc() {
|
|||||||
assert(size_of(x) == size_of(u32));
|
assert(size_of(x) == size_of(u32));
|
||||||
y: bit_set[0..8; u16];
|
y: bit_set[0..8; u16];
|
||||||
fmt.println(typeid_of(type_of(x))); // bit_set[A..Z]
|
fmt.println(typeid_of(type_of(x))); // bit_set[A..Z]
|
||||||
fmt.println(typeid_of(type_of(y))); // bit_set[0..8]
|
fmt.println(typeid_of(type_of(y))); // bit_set[0..8l u16]
|
||||||
|
|
||||||
incl(&x, 'F');
|
incl(&x, 'F');
|
||||||
assert('F' in x);
|
assert('F' in x);
|
||||||
|
|||||||
+7
-9
@@ -937,6 +937,7 @@ typedef struct gbMutex {
|
|||||||
CRITICAL_SECTION win32_critical_section;
|
CRITICAL_SECTION win32_critical_section;
|
||||||
#else
|
#else
|
||||||
pthread_mutex_t pthread_mutex;
|
pthread_mutex_t pthread_mutex;
|
||||||
|
pthread_mutexattr_t pthread_mutexattr;
|
||||||
#endif
|
#endif
|
||||||
} gbMutex;
|
} gbMutex;
|
||||||
|
|
||||||
@@ -4609,8 +4610,9 @@ gb_inline void gb_mutex_init(gbMutex *m) {
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
InitializeCriticalSection(&m->win32_critical_section);
|
InitializeCriticalSection(&m->win32_critical_section);
|
||||||
#else
|
#else
|
||||||
// IMPORTANT TODO HACK(bill): Enable this
|
pthread_mutexattr_init(&m->pthread_mutexattr);
|
||||||
// pthread_mutex_init(&m->pthread_mutex, NULL);
|
pthread_mutexattr_settype(&m->pthread_mutexattr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
pthread_mutex_init(&m->pthread_mutex, &m->pthread_mutexattr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4618,8 +4620,7 @@ gb_inline void gb_mutex_destroy(gbMutex *m) {
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
DeleteCriticalSection(&m->win32_critical_section);
|
DeleteCriticalSection(&m->win32_critical_section);
|
||||||
#else
|
#else
|
||||||
// IMPORTANT TODO HACK(bill): Enable this
|
pthread_mutex_destroy(&m->pthread_mutex);
|
||||||
// pthread_mutex_destroy(&m->pthread_mutex);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4627,8 +4628,7 @@ gb_inline void gb_mutex_lock(gbMutex *m) {
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
EnterCriticalSection(&m->win32_critical_section);
|
EnterCriticalSection(&m->win32_critical_section);
|
||||||
#else
|
#else
|
||||||
// IMPORTANT TODO HACK(bill): Enable this
|
pthread_mutex_lock(&m->pthread_mutex);
|
||||||
// pthread_mutex_lock(&m->pthread_mutex);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4636,9 +4636,7 @@ gb_inline b32 gb_mutex_try_lock(gbMutex *m) {
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
return TryEnterCriticalSection(&m->win32_critical_section) != 0;
|
return TryEnterCriticalSection(&m->win32_critical_section) != 0;
|
||||||
#else
|
#else
|
||||||
// IMPORTANT TODO HACK(bill): Enable this
|
return pthread_mutex_trylock(&m->pthread_mutex) == 0;
|
||||||
// return pthread_mutex_trylock(&m->pthread_mutex) == 0;
|
|
||||||
return 1;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user