diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /src/test/run-make/raw-dylib-c | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/test/run-make/raw-dylib-c/Makefile | 2 | ||||
-rw-r--r-- | src/test/run-make/raw-dylib-c/extern_1.c | 12 | ||||
-rw-r--r-- | src/test/run-make/raw-dylib-c/lib.rs | 13 | ||||
-rw-r--r-- | src/test/run-make/raw-dylib-c/output.txt | 3 |
4 files changed, 28 insertions, 2 deletions
diff --git a/src/test/run-make/raw-dylib-c/Makefile b/src/test/run-make/raw-dylib-c/Makefile index 713f66507..f47ab24f4 100644 --- a/src/test/run-make/raw-dylib-c/Makefile +++ b/src/test/run-make/raw-dylib-c/Makefile @@ -2,7 +2,7 @@ # only-windows --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs diff --git a/src/test/run-make/raw-dylib-c/extern_1.c b/src/test/run-make/raw-dylib-c/extern_1.c index 72737c086..5d695547d 100644 --- a/src/test/run-make/raw-dylib-c/extern_1.c +++ b/src/test/run-make/raw-dylib-c/extern_1.c @@ -1,5 +1,7 @@ #include <stdio.h> +__declspec(dllexport) int extern_variable = 0; + __declspec(dllexport) void extern_fn_1() { printf("extern_fn_1\n"); fflush(stdout); @@ -10,7 +12,17 @@ __declspec(dllexport) void extern_fn_2() { fflush(stdout); } +__declspec(dllexport) void print_extern_variable() { + printf("extern_variable value: %d\n", extern_variable); + fflush(stdout); +} + __declspec(dllexport) void extern_fn_with_long_name() { printf("extern_fn_with_long_name; got the rename\n"); fflush(stdout); } + +__declspec(dllexport) void extern_fn_4() { + printf("extern_fn_4\n"); + fflush(stdout); +} diff --git a/src/test/run-make/raw-dylib-c/lib.rs b/src/test/run-make/raw-dylib-c/lib.rs index 58f7ccb38..005ffcdda 100644 --- a/src/test/run-make/raw-dylib-c/lib.rs +++ b/src/test/run-make/raw-dylib-c/lib.rs @@ -12,12 +12,23 @@ extern { pub fn library_function() { #[link(name = "extern_1", kind = "raw-dylib")] - extern { fn extern_fn_2(); } + extern { + fn extern_fn_2(); + fn print_extern_variable(); + static mut extern_variable: i32; + #[link_name = "extern_fn_4"] + fn extern_fn_4_renamed(); + } unsafe { extern_fn_1(); extern_fn_2(); extern_fn_3(); + extern_fn_4_renamed(); + extern_variable = 42; + print_extern_variable(); + extern_variable = -42; + print_extern_variable(); } } diff --git a/src/test/run-make/raw-dylib-c/output.txt b/src/test/run-make/raw-dylib-c/output.txt index 7800cba18..cc970cef7 100644 --- a/src/test/run-make/raw-dylib-c/output.txt +++ b/src/test/run-make/raw-dylib-c/output.txt @@ -1,3 +1,6 @@ extern_fn_1 extern_fn_2; didn't get the rename extern_fn_3 +extern_fn_4 +extern_variable value: 42 +extern_variable value: -42 |