mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 20:55:35 +03:00
cdbbe14062
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. |
||
---|---|---|
.. | ||
LibAudio | ||
LibC | ||
LibCore | ||
LibCrypto | ||
LibCxx | ||
LibDebug | ||
LibDesktop | ||
LibELF | ||
LibGemini | ||
LibGfx | ||
LibGUI | ||
LibHTTP | ||
LibIPC | ||
LibJS | ||
LibLine | ||
LibM | ||
LibMarkdown | ||
LibPCIDB | ||
LibProtocol | ||
LibPthread | ||
LibTextCodec | ||
LibThread | ||
LibTLS | ||
LibUnwind | ||
LibVT | ||
LibWeb | ||
LibX86 | ||
CMakeLists.txt |