Skip to content

Threads and C++

32-bit programs have threads: <threads.h> (C11 thrd_create, mutexes, condition variables, tss) runs on DosCreateThread and OS/2's mutex and event semaphores, the C library locks itself, and __thread variables, errno among them, are per thread through clang's emulated TLS. The OS/2 Dos calls for threads and semaphores are in os2.h too.

C++ programs (clang++ --target=i386-pc-os2) link libc++ once build-libcxx.sh has run:

BIN=/path/to/clang-retro/bin LLVM_SRC=/path/to/llvm \
  sh build-libcxx.sh /path/to/clang-retro/i386-os2

Exceptions unwind through setjmp/longjmp-style function contexts (an LX program keeps no tables for a table-driven unwinder), one chain per thread. std::thread, std::mutex, std::condition_variable, thread_local and steady_clock work. The terminate message does not demangle names, which keeps programs smaller.