tinycc/tests/tests2/threads.h
grischka 380597704e tccpe: tls on windows (i386 / x86-64 / arm64)
Also:
- arm64-gen.c: cleanup load/store
  fixes a problem with bound-check test1b with
  ./configure --cc=tcc

  Also, do not use 'long' or 'ul' suffix in tcc because
  for example on win32-arm64
      (uint64_t) ~0xffful == 0x00000000fffff000
  but on linux-arm64
      (uint64_t) ~0xffful == 0xfffffffffffff000

Also:
- tccpe.c: cleanup "quoted dll nanes in def" parse
- tests2: enable some threaded tests on windows
2026-07-28 23:46:30 +02:00

23 lines
460 B
C

#ifdef _WIN32
#include <windows.h>
typedef HANDLE pthread_t;
int pthread_create(pthread_t *p, void *x, void *fn, void *args)
{
DWORD tid;
*p = CreateThread(NULL, 0, fn, args, 0, &tid);
return *p ? 0 : -1;
}
int pthread_join(pthread_t h, void **ret)
{
DWORD r;
WaitForSingleObject(h, INFINITE);
GetExitCodeThread(h, &r);
CloseHandle(h);
if (ret)
*ret = (void*)(size_t)r;
return 0;
}
#else
#include <pthread.h>
#endif