Skip to content

Portability: HAL for Win32 thread/atomic/sync primitives (POSIX backend) #13

@felixx-sp

Description

@felixx-sp

Confidence: high · Effort: large (>3 d)

Problem

The whole engine in bruteforce.cu uses Win32 primitives: CRITICAL_SECTION, InterlockedExchange/Add64, _beginthreadex/_stdcall, WaitForSingleObject/CreateEventA, SetThreadAffinityMask, GetTickCount64, QueryPerformanceCounter. None of this is fundamentally Windows-only — C11 <threads.h> + <stdatomic.h> + pthread_setaffinity_np cover all of it. The GUI can stay Windows-only.

Files: src/bruteforce.cu:24, 27, 1609, 1621, 1635-1639, 2564-2587, plus src/bruteforce.c if [resync issue] lands first.

Suggested fix

Step 1 (this issue): introduce

  • include/os_atomic.h (Interlocked* → atomic_* wrappers)
  • include/os_thread.h (thread spawn/join, mutex, event, affinity)
  • include/os_time.h (high-res clock)

with Win32 + POSIX backends behind #ifdef _WIN32. Port the engine code in bruteforce.cu and bruteforce.c to use them. Leave gui.c/main.c Windows-only behind -DBUILD_GUI.

Why it matters

Unlocks a headless Linux build, opens contributions to non-Windows developers, and enables CI to run native Linux tests on free GitHub runners. Pairs with the CMake migration and CLI mode issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions