1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include <stdlib.h>
- #include <new>
- #include "sgx_trts.h"
- #include "sgx_spinlock.h"
- #include "internal/se_cdefs.h"
- namespace std{
- static sgx_spinlock_t handler_lock = SGX_SPINLOCK_INITIALIZER;
-
- static new_handler new_handl = NULL;
-
-
-
-
-
-
-
-
-
-
-
-
- new_handler set_new_handler(new_handler handle) throw()
- {
- sgx_spin_lock(&handler_lock);
- new_handler retHandle = new_handl;
- if ( handle == NULL ){
- new_handl = NULL;
- } else if ( sgx_is_within_enclave((void *)handle, 0) ){
-
- new_handl = handle;
- }
- sgx_spin_unlock(&handler_lock);
- return retHandle;
- }
- };
- using namespace std;
- int call_newh()
- {
- int ret = 0;
- sgx_spin_lock(&handler_lock);
- new_handler handler = new_handl;
-
- sgx_spin_unlock(&handler_lock);
-
- if ( handler != NULL ){
- handler();
- ret = 1;
- }
-
- return ret;
- }
|