summaryrefslogtreecommitdiff
path: root/Libraries/LibC/cxxabi.cpp
AgeCommit message (Collapse)Author
2020-08-12LibC: Move C++ABI functions to cxxabi.cpp, typecheck cxa_atexitBen Wiederhake
2020-05-20Revert "LibC: Implement Itanium C++ ABI for static variable guards"Andreas Kling
This reverts commit cdbbe14062ea49f9a9d9b0e5627aba9efd07659a.
2020-05-20LibC: Implement Itanium C++ ABI for static variable guardsAndrew Kaster
This is __cxa_guard_acquire, __cxa_guard_release, and __cxa_guard_abort. We put these symbols in a 'fake' libstdc++ to trick gcc into thinking it has libstdc++. These symbols are necessary for C++ programs and not C programs, so, seems file. There's no way to tell gcc that, for example, the standard lib it should use is libc++ or libc. So, this is what we have for now. When threaded code enters a block that is trying to call the constructor for a block-scope static, the compiler will emit calls to these methods to handle the "call_once" nature of block-scope statics. The compiler creates a 64-bit guard variable, which it checks the first byte of to determine if the variable should be intialized or not. If the compiler-generated code reads that byte as a 0, it will call __cxa_guard_acquire to try and be the thread to call the constructor for the static variable. If the first byte is 1, it will assume that the variable's constructor was called, and go on to access it. __cxa_guard_acquire uses one of the 7 implementation defined bytes of the guard variable as an atomic 8 bit variable. To control a state machine that lets each entering thread know if they gained 'initialization rights', someone is working on the varaible, someone is working on the varaible and there's at least one thread waiting for it to be intialized, or if the variable was initialized and it's time to access it. We only store a 1 to the byte the compiler looks at in __cxa_guard_release, and use a futex to handle waiting.
2020-02-02Meta: Claim copyright on files added by meAndrew Kaster
Demos/DynamicLink, LibC/cxxabi.cpp, and LibELF/ELFDynamic*.[cpp/h]
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-01LibC: Move __cxa_finalize and __cxa_atexit code to their own fileAndrew Kaster
These guys aren't really related to initializing the C runtime, so move them to a new fancy file named C++ abi. Or rather, cxxabi :)