mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 18:02:02 +00:00
Remove dead code in the compiler
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#if defined(GB_SYSTEM_LINUX)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4505)
|
||||
#endif
|
||||
|
||||
struct BlockingMutex;
|
||||
struct RecursiveMutex;
|
||||
@@ -269,48 +273,6 @@ struct MutexGuard {
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
struct Barrier {
|
||||
BlockingMutex mutex;
|
||||
Condition cond;
|
||||
isize index;
|
||||
isize generation_id;
|
||||
isize thread_count;
|
||||
};
|
||||
|
||||
gb_internal void barrier_init(Barrier *b, isize thread_count) {
|
||||
mutex_init(&b->mutex);
|
||||
condition_init(&b->cond);
|
||||
b->index = 0;
|
||||
b->generation_id = 0;
|
||||
b->thread_count = 0;
|
||||
}
|
||||
|
||||
gb_internal void barrier_destroy(Barrier *b) {
|
||||
condition_destroy(&b->cond);
|
||||
mutex_destroy(&b->mutex);
|
||||
}
|
||||
|
||||
// Returns true if it is the leader
|
||||
gb_internal bool barrier_wait(Barrier *b) {
|
||||
mutex_lock(&b->mutex);
|
||||
defer (mutex_unlock(&b->mutex));
|
||||
isize local_gen = b->generation_id;
|
||||
b->index += 1;
|
||||
if (b->index < b->thread_count) {
|
||||
while (local_gen == b->generation_id && b->index < b->thread_count) {
|
||||
condition_wait(&b->cond, &b->mutex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
b->index = 0;
|
||||
b->generation_id += 1;
|
||||
condition_broadcast(&b->cond);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gb_internal u32 thread_current_id(void) {
|
||||
@@ -494,3 +456,7 @@ gb_internal void thread_set_name(Thread *t, char const *name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
Reference in New Issue
Block a user