Repository navigation
rust: Port libobs/util/threading-windows.c to obs-util - #389
Merged
Merged
Conversation
test sem_initial_value fails because Sem::try_new(2) returns None. test event_init_auto fails because os_event_init returns -1 and a null handle. Refs obs-rust#356
nathan-v
force-pushed
the
port/threading
branch
from
October 12, 2026 16:24
c8f78a4 to
221d623
Compare
Win32 CreateEvent and CreateSemaphore replace the condvar stand-in the task queue was using. os_set_thread_name raises 0x406D1388 from a small MSVC helper and then calls SetThreadDescription. Header-inline atomics stay C. ENABLE_RUST_LIBOBS drops util/threading-windows.c. The generator expression is closed, same as pipe-windows.c. The Win32 event and semaphore live in platform/windows. The POSIX condvar event lives in platform/unix. threading.rs re-exports both and has no host cfg. Event::wait returns () on both platforms. The Windows shim reads the wait code from wait_code, 0 or EINVAL. The oracle renames os_event_*, os_sem_* and os_set_thread_name on Windows the same way it already does on Unix, and does not compile the raw threading-windows.c. A NULL out-pointer after a successful create returns EINVAL and the kernel object is closed. SetEvent failure returns EINVAL, matching threading-windows.c. The boxed handle is not the raw HANDLE. Neither path uses bmalloc. Refs obs-rust#356 Local-Gate: v1 tree=d7477f2d6f1fc32b3ae219011b48efb2ad70cd5a secs=148 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791822753,"gate":"rust/all/fmt","host":"darwin-arm64","key":"5891f2a006c8903d78667a176430e1396d7296963a3d9f2abf48543131ec9d66","lane":"lint","parents":["2c576d5d9ae2fa88648bda9dbf43c5699b9d29b4"],"secs":39,"stamp":"e63960e291499e22c4b1180a9dc48dc8","tree":"d7477f2d6f1fc32b3ae219011b48efb2ad70cd5a","v":1,"via":"run"} Ci-Attestation: {"at":1791822753,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"darwin-arm64","key":"5891f2a006c8903d78667a176430e1396d7296963a3d9f2abf48543131ec9d66","lane":"lint","parents":["2c576d5d9ae2fa88648bda9dbf43c5699b9d29b4"],"secs":39,"stamp":"90e39ce1d4eedf7c1f520b346be98fec","tree":"d7477f2d6f1fc32b3ae219011b48efb2ad70cd5a","v":1,"via":"run"} Ci-Attestation: {"at":1791822753,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"darwin-arm64","key":"41dd345b754730afa358955fa9ca8a2b38b9143c5bbddbbd2028e10f25918621","lane":"rust-test","parents":["2c576d5d9ae2fa88648bda9dbf43c5699b9d29b4"],"secs":38,"stamp":"98ad9b6ea7dd31d80e4fdb346bc1e8d9","tree":"d7477f2d6f1fc32b3ae219011b48efb2ad70cd5a","v":1,"via":"run"} Ci-Attestation: {"at":1791822753,"gate":"cpp/linux-x64/tier2","host":"darwin-arm64","key":"c7d57bcdaf77c1ff704af41f8107ddd36c4cd2b2f85ab02a3daea19c5d62b11a","lane":"tier2-linux","parents":["2c576d5d9ae2fa88648bda9dbf43c5699b9d29b4"],"secs":70,"stamp":"fc718e16b0b28b423901a9a9ca4d18b0","tree":"d7477f2d6f1fc32b3ae219011b48efb2ad70cd5a","v":1,"via":"run"}
nathan-v
force-pushed
the
port/threading
branch
from
October 12, 2026 16:32
221d623 to
4b9482e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #356
What and why
threading-posix.calready builds as the Rust event and semaphore. This portsthreading-windows.c: a Win32 event, a Win32 semaphore, andos_set_thread_name. On Windows the task queue uses that semaphore and event.Both sides sit on the platform boundary. The POSIX condvar event is in
platform/unix. The Win32 event and semaphore are inplatform/windows.threading.rsre-exportsEvent,EventType, andSem.Event::waitreturns()on both platforms. The Windows shim reads the wait code fromwait_code, which is 0 orEINVAL. Header-inline atomics stay C.The oracle renames
os_event_*,os_sem_*, andos_set_thread_nameon Windows the same way it already does on Unix, and it does not compile the rawthreading-windows.c. That keeps the public symbols out of the oracle archive. TheENABLE_RUST_LIBOBSgenerator expression is closed, same as thepipe-windows.cline.A NULL out-pointer after a successful
CreateEventorCreateSemaphorereturnsEINVALand the kernel object is closed. C writes through the pointer.SetEventfailure returnsEINVAL, asthreading-windows.cdoes. The boxed handle is not the rawHANDLE. Neither path usesbmalloc.test/cmocka/test_threading.cwas already the characterization test. It is unchanged, so the branch on master is RED then GREEN.RED → GREEN
2c576d5d9. On Windows,sem_initial_valuefails becauseSem::try_new(2)returns None, andevent_init_autofails becauseos_event_initreturns -1 and a null handle. Those tests are#![cfg(windows)].4b9482eac, stamped. macOS Tier 2 on the POSIX tree: 77/77 withENABLE_RUST_LIBOBSOFF and ON, then 100 repeats oftest_threading|test_taskin each build. Exported symbols identical, 1876. Linux Tier 2 was re-run for this tree in the local-gatetier2-linuxlane (70s). Rust tests and lint passed in that stamp.thread_name_seh.cis clang-formatted; the lint lane does not scan.cfiles underrust/, and CI does. This machine has no Windows target, so Windows Tier 1, Tier 3, and Tier 2 are the Windows CI job.Checklist
master