Skip to content
Snippets Groups Projects
Commit 3b951b61 authored by John Hodge (sonata)'s avatar John Hodge (sonata)
Browse files

Usermode/libc++ - cxa_guard behavior fix

parent 6fbf6b93
Branches
No related merge requests found
......@@ -6,24 +6,33 @@
* - One-time construction API
*/
#include <stdint.h>
#include <acess/sys.h>
#include <cstdlib>
#define FLAG_INIT_COMPLETE (1<<0)
#define FLAG_INIT_LOCKED (1<<1)
extern "C" int __cxa_guard_acquire ( int64_t *guard_object )
{
// TODO: Mutex!
if( *guard_object )
return 1;
*guard_object = 1;
return 0;
if( *guard_object == FLAG_INIT_COMPLETE )
return 0;
if( *guard_object == FLAG_INIT_LOCKED ) {
_SysDebug("ERROR: __cxa_guard_acquire - nested");
}
*guard_object = FLAG_INIT_LOCKED;
return 1;
}
extern "C" void __cxa_guard_release ( int64_t *guard_object )
{
*guard_object = 0;
*guard_object = FLAG_INIT_COMPLETE;
}
extern "C" void __cxa_guard_abort ( int64_t *guard_object )
{
*guard_object = 0;
// TODO: abort
*guard_object = FLAG_INIT_COMPLETE;
_SysDebug("__cxa_guard_abort");
abort();
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment