From caf41aa046b58d5cf07b438b859c9465bf3258ea Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 12 Jun 2025 16:00:24 +0200 Subject: [PATCH 1/3] Fix #5321 --- core/thread/thread_unix.odin | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index ff79cfcbc..41b168407 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -3,6 +3,7 @@ package thread import "base:runtime" +import "core:c" import "core:sync" import "core:sys/posix" @@ -27,8 +28,6 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { // most of the time, don't ask me why. can_set_thread_cancel_state := posix.pthread_setcancelstate(.DISABLE when ODIN_OS == .Darwin else .ENABLE, nil) == nil - t.id = sync.current_thread_id() - if .Started not_in sync.atomic_load(&t.flags) { sync.wait(&t.start_ok) } @@ -125,6 +124,12 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { return nil } + + when size_of(posix.pthread_t) == size_of(i64) { + thread.id = int(transmute(i64)thread.unix_thread) + } else { + thread.id = int(transmute(i32)thread.unix_thread) + } return thread } From 994b5a2a6c340285f7a437cb9a4710e1a81e1525 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 12 Jun 2025 16:01:31 +0200 Subject: [PATCH 2/3] Remove c import --- core/thread/thread_unix.odin | 1 - 1 file changed, 1 deletion(-) diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index 41b168407..1df446b86 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -3,7 +3,6 @@ package thread import "base:runtime" -import "core:c" import "core:sync" import "core:sys/posix" From 59ba37f23266a5541002b4beb057837a207793f0 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 12 Jun 2025 16:05:34 +0200 Subject: [PATCH 3/3] Remove transmute --- core/thread/thread_unix.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index 1df446b86..da5929d1d 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -125,9 +125,9 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { when size_of(posix.pthread_t) == size_of(i64) { - thread.id = int(transmute(i64)thread.unix_thread) + thread.id = int((^i64)(&thread.unix_thread)^) } else { - thread.id = int(transmute(i32)thread.unix_thread) + thread.id = int((^i32)(&thread.unix_thread)^) } return thread }