summaryrefslogtreecommitdiffstats
path: root/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src')
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs
new file mode 100644
index 000000000..cde38aacf
--- /dev/null
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs
@@ -0,0 +1,49 @@
+std::arch::global_asm!(
+ r#"
+ .text
+ .global rust_plus_one_global_asm
+ .type rust_plus_one_global_asm, @function
+rust_plus_one_global_asm:
+ movl (%rdi), %eax
+ inc %eax
+ retq
+"#,
+ options(att_syntax)
+);
+
+extern "C" {
+ fn cc_plus_one_c(arg: &u32) -> u32;
+ fn cc_plus_one_c_asm(arg: &u32) -> u32;
+ fn cc_plus_one_cxx(arg: &u32) -> u32;
+ fn cc_plus_one_cxx_asm(arg: &u32) -> u32;
+ fn cc_plus_one_asm(arg: &u32) -> u32;
+ fn cmake_plus_one_c(arg: &u32) -> u32;
+ fn cmake_plus_one_c_asm(arg: &u32) -> u32;
+ fn cmake_plus_one_cxx(arg: &u32) -> u32;
+ fn cmake_plus_one_cxx_asm(arg: &u32) -> u32;
+ fn cmake_plus_one_c_global_asm(arg: &u32) -> u32;
+ fn cmake_plus_one_cxx_global_asm(arg: &u32) -> u32;
+ fn cmake_plus_one_asm(arg: &u32) -> u32;
+ fn rust_plus_one_global_asm(arg: &u32) -> u32;
+}
+
+fn main() {
+ let value: u32 = 41;
+ let question = "Answer to the Ultimate Question of Life, the Universe, and Everything:";
+
+ unsafe {
+ println!("{}: {}!", question, rust_plus_one_global_asm(&value));
+ println!("{}: {}!", question, cc_plus_one_c(&value));
+ println!("{}: {}!", question, cc_plus_one_c_asm(&value));
+ println!("{}: {}!", question, cc_plus_one_cxx(&value));
+ println!("{}: {}!", question, cc_plus_one_cxx_asm(&value));
+ println!("{}: {}!", question, cc_plus_one_asm(&value));
+ println!("{}: {}!", question, cmake_plus_one_c(&value));
+ println!("{}: {}!", question, cmake_plus_one_c_asm(&value));
+ println!("{}: {}!", question, cmake_plus_one_cxx(&value));
+ println!("{}: {}!", question, cmake_plus_one_cxx_asm(&value));
+ println!("{}: {}!", question, cmake_plus_one_c_global_asm(&value));
+ println!("{}: {}!", question, cmake_plus_one_cxx_global_asm(&value));
+ println!("{}: {}!", question, cmake_plus_one_asm(&value));
+ }
+}