Skip to content

Commit

Permalink
clean samplecode
Browse files Browse the repository at this point in the history
  • Loading branch information
volcano0dr committed Sep 7, 2020
1 parent 93dffa4 commit 99599f2
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 99 deletions.
8 changes: 3 additions & 5 deletions samplecode/backtrace/app/app.c 100644 → 100755
Expand Up @@ -156,8 +156,6 @@ int SGX_CDECL main(int argc, char *argv[])
{
sgx_status_t sgx_ret = SGX_SUCCESS;
sgx_status_t enclave_ret = SGX_SUCCESS;
uint32_t sealed_log_size = 1024;
uint8_t sealed_log[1024] = {0};

(void)(argc);
(void)(argv);
Expand All @@ -173,9 +171,9 @@ int SGX_CDECL main(int argc, char *argv[])
size_t len = strlen(str);

sgx_ret = say_something(global_eid,
&enclave_ret,
(const uint8_t *) str,
len);
&enclave_ret,
(const uint8_t *) str,
len);

if(sgx_ret != SGX_SUCCESS) {
print_error_message(sgx_ret);
Expand Down
1 change: 0 additions & 1 deletion samplecode/db-proxy/db-proxy/Makefile 100644 → 100755
Expand Up @@ -149,7 +149,6 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
enclave:
$(MAKE) -C ./enclave/


.PHONY: clean
clean:
@rm -f $(App_Name) $(RustEnclave_Name) $(Signed_RustEnclave_Name) enclave/*_t.* app/*_u.* lib/*.a
Expand Down
2 changes: 0 additions & 2 deletions samplecode/hello-regex/app/app.c 100644 → 100755
Expand Up @@ -156,8 +156,6 @@ int SGX_CDECL main(int argc, char *argv[])
{
sgx_status_t sgx_ret = SGX_SUCCESS;
sgx_status_t enclave_ret = SGX_SUCCESS;
uint32_t sealed_log_size = 1024;
uint8_t sealed_log[1024] = {0};

(void)(argc);
(void)(argv);
Expand Down
66 changes: 0 additions & 66 deletions samplecode/hello-rust/enclave/src/lib.rs 100644 → 100755
Expand Up @@ -22,20 +22,15 @@
#![cfg_attr(target_env = "sgx", feature(rustc_private))]

extern crate sgx_types;
extern crate sgx_trts;
#[cfg(not(target_env = "sgx"))]
#[macro_use]
extern crate sgx_tstd as std;

use sgx_types::*;
use sgx_types::metadata::*;
use sgx_trts::enclave;
//use sgx_trts::{is_x86_feature_detected, is_cpu_feature_supported};
use std::string::String;
use std::vec::Vec;
use std::io::{self, Write};
use std::slice;
use std::backtrace::{self, PrintFormat};

#[no_mangle]
pub extern "C" fn say_something(some_string: *const u8, some_len: usize) -> sgx_status_t {
Expand Down Expand Up @@ -65,66 +60,5 @@ pub extern "C" fn say_something(some_string: *const u8, some_len: usize) -> sgx_
// Ocall to normal world for output
println!("{}", &hello_string);

let _ = backtrace::enable_backtrace("enclave.signed.so", PrintFormat::Full);

let gd = enclave::SgxGlobalData::new();
println!("gd: {} {} {} {} ", gd.get_static_tcs_num(), gd.get_eremove_tcs_num(), gd.get_dyn_tcs_num(), gd.get_tcs_max_num());
let (static_num, eremove_num, dyn_num) = get_thread_num();
println!("static: {} eremove: {} dyn: {}", static_num, eremove_num, dyn_num);

unsafe {
println!("EDMM: {}, feature: {}", EDMM_supported, g_cpu_feature_indicator);
}
if is_x86_feature_detected!("sgx") {
println!("supported sgx");
}

sgx_status_t::SGX_SUCCESS
}

#[link(name = "sgx_trts")]
extern {
static g_cpu_feature_indicator: uint64_t;
static EDMM_supported: c_int;
}


fn get_thread_num() -> (u32, u32, u32) {
let gd = unsafe {
let p = enclave::rsgx_get_global_data();
&*p
};

let mut static_thread_num: u32 = 0;
let mut eremove_thread_num: u32 = 0;
let mut dyn_thread_num: u32 = 0;
let layout_table = &gd.layout_table[0..gd.layout_entry_num as usize];
unsafe { traversal_layout(&mut static_thread_num, &mut dyn_thread_num, &mut eremove_thread_num, layout_table); }

unsafe fn traversal_layout(static_num: &mut u32, dyn_num: &mut u32, eremove_num: &mut u32, layout_table: &[layout_t])
{
for (i, layout) in layout_table.iter().enumerate() {
if !is_group_id!(layout.group.id as u32) {
if (layout.entry.attributes & PAGE_ATTR_EADD) != 0 {
if (layout.entry.content_offset != 0) && (layout.entry.si_flags == SI_FLAGS_TCS) {
if (layout.entry.attributes & PAGE_ATTR_EREMOVE) == 0 {
*static_num += 1;
} else {
*eremove_num += 1;
}
}
}
if (layout.entry.attributes & PAGE_ATTR_POST_ADD) != 0 {
if layout.entry.id == LAYOUT_ID_TCS_DYN as u16 {
*dyn_num += 1;
}
}
} else {
for _ in 0..layout.group.load_times {
traversal_layout(static_num, dyn_num, eremove_num, &layout_table[i - layout.group.entry_count as usize..i])
}
}
}
}
(static_thread_num, eremove_thread_num, dyn_thread_num)
}
8 changes: 3 additions & 5 deletions samplecode/helloworld/app/app.c 100644 → 100755
Expand Up @@ -156,8 +156,6 @@ int SGX_CDECL main(int argc, char *argv[])
{
sgx_status_t sgx_ret = SGX_SUCCESS;
sgx_status_t enclave_ret = SGX_SUCCESS;
uint32_t sealed_log_size = 1024;
uint8_t sealed_log[1024] = {0};

(void)(argc);
(void)(argv);
Expand All @@ -173,9 +171,9 @@ int SGX_CDECL main(int argc, char *argv[])
size_t len = strlen(str);

sgx_ret = say_something(global_eid,
&enclave_ret,
(const uint8_t *) str,
len);
&enclave_ret,
(const uint8_t *) str,
len);

if(sgx_ret != SGX_SUCCESS) {
print_error_message(sgx_ret);
Expand Down
1 change: 0 additions & 1 deletion samplecode/http_req/Makefile 100644 → 100755
Expand Up @@ -135,7 +135,6 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
enclave:
$(MAKE) -C ./enclave/


.PHONY: clean
clean:
@rm -f $(App_Name) $(RustEnclave_Name) $(Signed_RustEnclave_Name) enclave/*_t.* app/*_u.* lib/*.a *.c *.h *.p *.a
Expand Down
8 changes: 3 additions & 5 deletions samplecode/hugemem/app/app.c 100644 → 100755
Expand Up @@ -156,8 +156,6 @@ int SGX_CDECL main(int argc, char *argv[])
{
sgx_status_t sgx_ret = SGX_SUCCESS;
sgx_status_t enclave_ret = SGX_SUCCESS;
uint32_t sealed_log_size = 1024;
uint8_t sealed_log[1024] = {0};

(void)(argc);
(void)(argv);
Expand All @@ -173,9 +171,9 @@ int SGX_CDECL main(int argc, char *argv[])
size_t len = strlen(str);

sgx_ret = say_something(global_eid,
&enclave_ret,
(const uint8_t *) str,
len);
&enclave_ret,
(const uint8_t *) str,
len);

if(sgx_ret != SGX_SUCCESS) {
print_error_message(sgx_ret);
Expand Down
1 change: 0 additions & 1 deletion samplecode/pcl/pcl-seal/Makefile 100644 → 100755
Expand Up @@ -169,7 +169,6 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
enclave:
$(MAKE) -C ./enclave/


.PHONY: clean
clean:
@rm -f $(App_Name) $(RustEnclave_Name) $(Signed_RustEnclave_Name) $(PayloadEnclave_Name) enclave/*_t.* app/*_u.* lib/*.a enclave/Payload.edl bin/prov_key.bin
Expand Down
8 changes: 3 additions & 5 deletions samplecode/secretsharing/app/app.c 100644 → 100755
Expand Up @@ -156,8 +156,6 @@ int SGX_CDECL main(int argc, char *argv[])
{
sgx_status_t sgx_ret = SGX_SUCCESS;
sgx_status_t enclave_ret = SGX_SUCCESS;
uint32_t sealed_log_size = 1024;
uint8_t sealed_log[1024] = {0};

(void)(argc);
(void)(argv);
Expand All @@ -173,9 +171,9 @@ int SGX_CDECL main(int argc, char *argv[])
size_t len = strlen(str);

sgx_ret = say_something(global_eid,
&enclave_ret,
(const uint8_t *) str,
len);
&enclave_ret,
(const uint8_t *) str,
len);

if(sgx_ret != SGX_SUCCESS) {
print_error_message(sgx_ret);
Expand Down
2 changes: 0 additions & 2 deletions samplecode/serialize/app/app.c 100644 → 100755
Expand Up @@ -155,8 +155,6 @@ int initialize_enclave(void)
int SGX_CDECL main(int argc, char *argv[])
{
sgx_status_t sgx_ret = SGX_SUCCESS;
uint32_t sealed_log_size = 1024;
uint8_t sealed_log[1024] = {0};

(void)(argc);
(void)(argv);
Expand Down
1 change: 0 additions & 1 deletion samplecode/thread/app/App.cpp 100644 → 100755
Expand Up @@ -157,7 +157,6 @@ int SGX_CDECL main(int argc, char *argv[])
(void)(argc);
(void)(argv);


/* Initialize the enclave */
if(initialize_enclave() < 0){
printf("Enter a character before exit ...\n");
Expand Down
2 changes: 1 addition & 1 deletion samplecode/tls/tlsclient/app/src/main.rs 100644 → 100755
Expand Up @@ -29,7 +29,7 @@ use std::os::unix::io::AsRawFd;
use std::ffi::CString;
use std::net::SocketAddr;
use std::str;
use std::io::{self, Read, Write};
use std::io::{self, Write};

const BUFFER_SIZE: usize = 1024;

Expand Down
1 change: 0 additions & 1 deletion samplecode/tr-mpc/tr-mpc-server/Makefile 100644 → 100755
Expand Up @@ -150,7 +150,6 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
enclave:
$(MAKE) -C ./enclave/


.PHONY: clean
clean:
@rm -f $(App_Name) $(RustEnclave_Name) $(Signed_RustEnclave_Name) enclave/*_t.* app/*_u.* lib/*.a
Expand Down
1 change: 0 additions & 1 deletion samplecode/ue-ra/ue-ra-server/Makefile 100644 → 100755
Expand Up @@ -150,7 +150,6 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
enclave:
$(MAKE) -C ./enclave/


.PHONY: clean
clean:
@rm -f $(App_Name) $(RustEnclave_Name) $(Signed_RustEnclave_Name) enclave/*_t.* app/*_u.* lib/*.a
Expand Down
2 changes: 1 addition & 1 deletion samplecode/unit-test/enclave/src/test_mpsc.rs 100644 → 100755
Expand Up @@ -450,7 +450,7 @@ pub fn test_mpsc_stress_recv_timeout_shared() {
pub fn test_mpsc_very_long_recv_timeout_wont_panic() {
let (tx, rx) = channel::<()>();
let join_handle = thread::spawn(move || {
rx.recv_timeout(Duration::from_secs(u64::max_value()))
rx.recv_timeout(Duration::from_secs(u64::MAX))
});
thread::sleep(Duration::from_secs(1));
assert!(tx.send(()).is_ok());
Expand Down
2 changes: 1 addition & 1 deletion samplecode/unit-test/enclave/src/test_rand.rs 100644 → 100755
Expand Up @@ -53,7 +53,7 @@ pub fn test_rand_distributions () {
$(
let v: &[($ty, $ty)] = &[(0, 10),
(10, 127),
($ty::min_value(), $ty::max_value())];
($ty::min_value(), $ty::MAX)];
for &(low, high) in v {
let mut sampler: Range<$ty> = Range::new(low, high);
for _ in 0..1000 {
Expand Down

0 comments on commit 99599f2

Please sign in to comment.