Merge branch 'master' of git://github.com/thepowersgang/acess2
[tpg/acess2.git] / Usermode / Libraries / libc++.so_src / guard.cc
1 /*
2  * Acess2 C++ Library
3  * - By John Hodge (thePowersGang)
4  *
5  * guard.cc
6  * - One-time construction API
7  */
8 #include <stdint.h>
9 #include <acess/sys.h>
10 #include <cstdlib>
11
12 #define FLAG_INIT_COMPLETE      (1<<0)
13 #define FLAG_INIT_LOCKED        (1<<1)
14
15 extern "C" int __cxa_guard_acquire ( int64_t *guard_object )
16 {
17         // TODO: Mutex!
18         if( *guard_object == FLAG_INIT_COMPLETE )
19                 return 0;
20         if( *guard_object == FLAG_INIT_LOCKED ) {
21                 _SysDebug("ERROR: __cxa_guard_acquire - nested");
22         }
23         *guard_object = FLAG_INIT_LOCKED;
24         return 1;
25 }
26
27 extern "C" void __cxa_guard_release ( int64_t *guard_object )
28 {
29         *guard_object = FLAG_INIT_COMPLETE;
30 }
31
32 extern "C" void __cxa_guard_abort ( int64_t *guard_object )
33 {
34         *guard_object = FLAG_INIT_COMPLETE;
35         _SysDebug("__cxa_guard_abort");
36         abort();
37 }
38

UCC git Repository :: git.ucc.asn.au