summaryrefslogtreecommitdiffstats
path: root/tests/run-make/raw-dylib-stdcall-ordinal
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/raw-dylib-stdcall-ordinal')
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/Makefile23
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/driver.rs5
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/expected_output.txt2
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def4
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def4
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/exporter.c11
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/lib.rs20
7 files changed, 69 insertions, 0 deletions
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/Makefile b/tests/run-make/raw-dylib-stdcall-ordinal/Makefile
new file mode 100644
index 000000000..b9deb7729
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/Makefile
@@ -0,0 +1,23 @@
+# Test the behavior of #[link(.., kind = "raw-dylib")], #[link_ordinal], and alternative calling conventions on i686 windows.
+
+# only-x86
+# only-windows
+
+include ../../run-make-fulldeps/tools.mk
+
+all:
+ $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs
+ $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)"
+ $(call COMPILE_OBJ,"$(TMPDIR)"/exporter.obj,exporter.c)
+ifdef IS_MSVC
+ $(CC) "$(TMPDIR)"/exporter.obj exporter-msvc.def -link -dll -out:"$(TMPDIR)"/exporter.dll -noimplib
+else
+ $(CC) "$(TMPDIR)"/exporter.obj exporter-gnu.def -shared -o "$(TMPDIR)"/exporter.dll
+endif
+ "$(TMPDIR)"/driver > "$(TMPDIR)"/actual_output.txt
+
+ifdef RUSTC_BLESS_TEST
+ cp "$(TMPDIR)"/actual_output.txt expected_output.txt
+else
+ $(DIFF) expected_output.txt "$(TMPDIR)"/actual_output.txt
+endif
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/driver.rs b/tests/run-make/raw-dylib-stdcall-ordinal/driver.rs
new file mode 100644
index 000000000..4059ede11
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/driver.rs
@@ -0,0 +1,5 @@
+extern crate raw_dylib_test;
+
+fn main() {
+ raw_dylib_test::library_function();
+}
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/expected_output.txt b/tests/run-make/raw-dylib-stdcall-ordinal/expected_output.txt
new file mode 100644
index 000000000..201577637
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/expected_output.txt
@@ -0,0 +1,2 @@
+exported_function_stdcall(6)
+exported_function_fastcall(125)
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def b/tests/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def
new file mode 100644
index 000000000..8d28d714b
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def
@@ -0,0 +1,4 @@
+LIBRARY exporter
+EXPORTS
+ exported_function_stdcall@4 @15 NONAME
+ @exported_function_fastcall@4 @18 NONAME \ No newline at end of file
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def b/tests/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def
new file mode 100644
index 000000000..5a4c79a58
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def
@@ -0,0 +1,4 @@
+LIBRARY exporter
+EXPORTS
+ _exported_function_stdcall@4 @15 NONAME
+ @exported_function_fastcall@4 @18 NONAME \ No newline at end of file
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/exporter.c b/tests/run-make/raw-dylib-stdcall-ordinal/exporter.c
new file mode 100644
index 000000000..1fb45bf01
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/exporter.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+void __stdcall exported_function_stdcall(int i) {
+ printf("exported_function_stdcall(%d)\n", i);
+ fflush(stdout);
+}
+
+void __fastcall exported_function_fastcall(int i) {
+ printf("exported_function_fastcall(%d)\n", i);
+ fflush(stdout);
+}
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs b/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs
new file mode 100644
index 000000000..b7921396a
--- /dev/null
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs
@@ -0,0 +1,20 @@
+#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
+
+#[link(name = "exporter", kind = "raw-dylib")]
+extern "stdcall" {
+ #[link_ordinal(15)]
+ fn imported_function_stdcall(i: i32);
+}
+
+#[link(name = "exporter", kind = "raw-dylib")]
+extern "fastcall" {
+ #[link_ordinal(18)]
+ fn imported_function_fastcall(i: i32);
+}
+
+pub fn library_function() {
+ unsafe {
+ imported_function_stdcall(6);
+ imported_function_fastcall(125);
+ }
+}