123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- #include <stdio.h>
- #include "../App.h"
- #include "Enclave_u.h"
- #include <thread>
-
- void demo_counter_without_mutex()
- {
- sgx_status_t ret = SGX_ERROR_UNEXPECTED;
- ret = ecall_mutex_demo_no_protection(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
- }
- void demo_counter_mutex()
- {
- sgx_status_t ret = SGX_ERROR_UNEXPECTED;
- ret = ecall_mutex_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
- }
- void demo_cond_var_run()
- {
- sgx_status_t ret = SGX_ERROR_UNEXPECTED;
- ret = ecall_condition_variable_run(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
- }
- void demo_cond_var_load()
- {
- sgx_status_t ret = SGX_ERROR_UNEXPECTED;
- ret = ecall_condition_variable_load(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
- }
- void ecall_libcxx_functions(void)
- {
- sgx_status_t ret = SGX_ERROR_UNEXPECTED;
-
-
- ret = ecall_lambdas_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_auto_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_decltype_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_strongly_typed_enum_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
-
- ret = ecall_range_based_for_loops_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_static_assert_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
-
- ret = ecall_virtual_function_control_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_delegating_constructors_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_std_function_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
-
- ret = ecall_cxx11_algorithms_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_variadic_templates_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_SFINAE_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_initializer_list_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_rvalue_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_nullptr_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_enum_class_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_new_container_classes_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_tuple_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_shared_ptr_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
- ret = ecall_atomic_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
- std::thread t1(demo_counter_without_mutex);
- std::thread t2(demo_counter_without_mutex);
- std::thread t3(demo_counter_without_mutex);
- t1.join();
- t2.join();
- t3.join();
- ret = ecall_print_final_value_no_protection(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
-
-
-
- std::thread tm1(demo_counter_mutex);
- std::thread tm2(demo_counter_mutex);
- std::thread tm3(demo_counter_mutex);
- tm1.join();
- tm2.join();
- tm3.join();
- ret = ecall_print_final_value_mutex_demo(global_eid);
- if (ret != SGX_SUCCESS)
- abort();
- std::thread th1(demo_cond_var_run);
- std::thread th2(demo_cond_var_load);
- th2.join();
- th1.join();
- }
|