clang now uses emulated TLS for the classic Mac OS (clang-retro/llvm
#57). runtime/libc/emutls.c gives __emutls_get_address over a pthread
key: each thread gets its own copy of a variable at its first access,
and the copies are released when the thread ends. tests/thread.c and
tests/cxxthread.cpp check _Thread_local and C++ thread_local.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTDFNgD4oK9xbDsEGn
* Add C++: exceptions, RTTI and libstdc++ for 68k and PowerPC
- runtime/build-libstdcxx.sh builds LLVM's libunwind and GCC 15.2's
libstdc++ with clang over the C library, for both CPUs. The patch in
runtime/libstdcxx/ has the changes for clang and the classic Mac OS.
runtime/unwind/xcoff-ppc.c has libunwind's two assembly functions for
PowerPC, which clang cannot assemble for XCOFF.
- codelink.py: COMDAT groups, weak symbols, removal of the sections
that nothing reaches, and .eh_frame (with the FDEs of the removed
functions taken out) between __eh_frame_start and __eh_frame_end.
- peflink.py: weak symbols, removal of the csects that nothing reaches,
TOC entries of class TE, and R_POS/R_NEG pairs.
- macapp.py compiles C++ sources with libstdc++'s headers and links
libstdc++ and libunwind. All sources are compiled with
-ffunction-sections and -fdata-sections.
- tests/cxx.cpp checks the runtime and the library; tests/run.sh runs it
in both simulators when GCC_SRC is set, and CI gets GCC's source.
- docs/cxx.md tells how it works; the README has a summary.
Needs clang-retro/llvm#56 (M68k CFI and libunwind for classic Mac OS).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTDFNgD4oK9xbDsEGn
* Give every function of the linkers and macapp.py a doc summary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTDFNgD4oK9xbDsEGn
* Note the C++ test's runs on System 7.6.1 and Mac OS 9.2.1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTDFNgD4oK9xbDsEGn
* Add file information, folders and POSIX threads to the C library
The Mac layer now gives stat, lstat, fstat, ftruncate, utime, mkdir,
rmdir, opendir, readdir, rewinddir, closedir and getcwd over the HFS
catalog calls, and clock_gettime.
It also gives POSIX threads (pthread.h) over the Thread Manager:
cooperative threads, mutexes, condition variables, keys,
pthread_once, sched_yield, nanosleep and usleep. The library examines
Gestalt('thds') first. ThreadsLib is now a weak import on PowerPC.
The simulators fake the HFS catalog calls, Gestalt, TickCount and the
Thread Manager. tests/libc.c checks the new file functions and
tests/thread.c checks the threads. docs/threads.md tells how the
threads operate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTDFNgD4oK9xbDsEGn
* Build the C++ library with the posix thread model
libstdc++ now uses the C library's cooperative threads, so
std::thread, std::mutex, std::condition_variable, std::call_once,
std::async and std::this_thread::sleep_for work.
- build-libstdcxx.sh: thread model posix, gthr-default.h for
configure, and clock_gettime, nanosleep and sched_yield turned on in
config.h (configure cannot make the link tests that find them).
- runtime/atomic.c: the __sync_ and __atomic_ functions that clang
calls when the CPU cannot do an operation (all of them on the
68000). Plain operations are atomic between cooperative threads.
- pthread_cancel, which gthr-posix.h names: it gives ENOTSUP.
- tests/cxxthread.cpp checks the C++ threads in both simulators.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTDFNgD4oK9xbDsEGn
---------
Co-authored-by: Claude <noreply@anthropic.com>