Skip to content

Commit

Permalink
Add test cases for x86 Windows calling conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed May 14, 2019
1 parent d466754 commit 01c0d17
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/expectations/tests/libclang-3.8/mangling-win32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


extern "C" {
pub fn foo();
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
extern "C" {
#[link_name = "\u{1}?sBar@Foo@@2_NA"]
pub static mut Foo_sBar: bool;
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
::std::mem::size_of::<Foo>(),
1usize,
concat!("Size of: ", stringify!(Foo))
);
assert_eq!(
::std::mem::align_of::<Foo>(),
1usize,
concat!("Alignment of ", stringify!(Foo))
);
}
extern "C" {
#[link_name = "\u{1}@fast_call_func_no_args@0"]
pub fn fast_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "\u{1}@fast_call_func_many_args@12"]
pub fn fast_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "\u{1}@std_call_func_no_args@0"]
pub fn std_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "\u{1}@std_call_func_many_args@12"]
pub fn std_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,23 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
extern "fastcall" {
pub fn fast_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "fastcall" {
pub fn fast_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "stdcall" {
pub fn std_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "stdcall" {
pub fn std_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
51 changes: 51 additions & 0 deletions tests/expectations/tests/libclang-4/mangling-win32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


extern "C" {
pub fn foo();
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
extern "C" {
#[link_name = "\u{1}?sBar@Foo@@2_NA"]
pub static mut Foo_sBar: bool;
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
::std::mem::size_of::<Foo>(),
1usize,
concat!("Size of: ", stringify!(Foo))
);
assert_eq!(
::std::mem::align_of::<Foo>(),
1usize,
concat!("Alignment of ", stringify!(Foo))
);
}
extern "fastcall" {
pub fn fast_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "fastcall" {
pub fn fast_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "stdcall" {
pub fn std_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "stdcall" {
pub fn std_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
51 changes: 51 additions & 0 deletions tests/expectations/tests/libclang-5/mangling-win32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


extern "C" {
pub fn foo();
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
extern "C" {
#[link_name = "\u{1}?sBar@Foo@@2_NA"]
pub static mut Foo_sBar: bool;
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
::std::mem::size_of::<Foo>(),
1usize,
concat!("Size of: ", stringify!(Foo))
);
assert_eq!(
::std::mem::align_of::<Foo>(),
1usize,
concat!("Alignment of ", stringify!(Foo))
);
}
extern "fastcall" {
pub fn fast_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "fastcall" {
pub fn fast_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "stdcall" {
pub fn std_call_func_no_args() -> ::std::os::raw::c_int;
}
extern "stdcall" {
pub fn std_call_func_many_args(
arg1: ::std::os::raw::c_int,
arg2: ::std::os::raw::c_int,
arg3: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
11 changes: 11 additions & 0 deletions tests/headers/mangling-win32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ extern "C" void foo();
struct Foo {
static bool sBar;
};

// Also test some x86 Windows specific calling conventions that have their own
// special mangling
extern "C" {
int _fastcall fast_call_func_no_args();
// This will result in a suffix with more than one character (i.e. `@12`)
int _fastcall fast_call_func_many_args(int,int,int);
int _stdcall std_call_func_no_args();
// This will result in a suffix with more than one character (i.e. `@12`)
int _stdcall std_call_func_many_args(int,int,int);
}

0 comments on commit 01c0d17

Please sign in to comment.