-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #549 - emilio:call-conv-lost, r=fitzgen
Fix calling convention propagation for function pointers. This sucks, but works. The full solution is a refactoring that needs more thought than the time I'm able to dedicate to bindgen right now, see the comment for details. r? @fitzgen
- Loading branch information
Showing
7 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(non_snake_case)] | ||
|
||
|
||
#[repr(C)] | ||
#[derive(Copy)] | ||
pub struct JNINativeInterface_ { | ||
pub GetVersion: ::std::option::Option<unsafe extern "stdcall" fn(env: | ||
*mut ::std::os::raw::c_void) | ||
-> ::std::os::raw::c_int>, | ||
pub __hack: ::std::os::raw::c_ulonglong, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_JNINativeInterface_() { | ||
assert_eq!(::std::mem::size_of::<JNINativeInterface_>() , 16usize , concat | ||
! ( "Size of: " , stringify ! ( JNINativeInterface_ ) )); | ||
assert_eq! (::std::mem::align_of::<JNINativeInterface_>() , 8usize , | ||
concat ! ( | ||
"Alignment of " , stringify ! ( JNINativeInterface_ ) )); | ||
assert_eq! (unsafe { | ||
& ( * ( 0 as * const JNINativeInterface_ ) ) . GetVersion as * | ||
const _ as usize } , 0usize , concat ! ( | ||
"Alignment of field: " , stringify ! ( JNINativeInterface_ ) , | ||
"::" , stringify ! ( GetVersion ) )); | ||
assert_eq! (unsafe { | ||
& ( * ( 0 as * const JNINativeInterface_ ) ) . __hack as * | ||
const _ as usize } , 8usize , concat ! ( | ||
"Alignment of field: " , stringify ! ( JNINativeInterface_ ) , | ||
"::" , stringify ! ( __hack ) )); | ||
} | ||
impl Clone for JNINativeInterface_ { | ||
fn clone(&self) -> Self { *self } | ||
} | ||
impl Default for JNINativeInterface_ { | ||
fn default() -> Self { unsafe { ::std::mem::zeroed() } } | ||
} | ||
extern "stdcall" { | ||
#[link_name = "_bar@0"] | ||
pub fn bar(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(non_snake_case)] | ||
|
||
|
||
pub type my_fun_t = | ||
::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int, | ||
arg2: ::std::os::raw::c_int, | ||
arg3: ::std::os::raw::c_int, | ||
arg4: ::std::os::raw::c_int, | ||
arg5: ::std::os::raw::c_int, | ||
arg6: ::std::os::raw::c_int, | ||
arg7: ::std::os::raw::c_int, | ||
arg8: ::std::os::raw::c_int, | ||
arg9: ::std::os::raw::c_int, | ||
arg10: ::std::os::raw::c_int, | ||
arg11: ::std::os::raw::c_int, | ||
arg12: ::std::os::raw::c_int, | ||
arg13: ::std::os::raw::c_int, | ||
arg14: ::std::os::raw::c_int, | ||
arg15: ::std::os::raw::c_int, | ||
arg16: ::std::os::raw::c_int)>; | ||
#[repr(C)] | ||
#[derive(Copy)] | ||
pub struct Foo { | ||
pub callback: my_fun_t, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_Foo() { | ||
assert_eq!(::std::mem::size_of::<Foo>() , 8usize , concat ! ( | ||
"Size of: " , stringify ! ( Foo ) )); | ||
assert_eq! (::std::mem::align_of::<Foo>() , 8usize , concat ! ( | ||
"Alignment of " , stringify ! ( Foo ) )); | ||
assert_eq! (unsafe { | ||
& ( * ( 0 as * const Foo ) ) . callback as * const _ as usize | ||
} , 0usize , concat ! ( | ||
"Alignment of field: " , stringify ! ( Foo ) , "::" , | ||
stringify ! ( callback ) )); | ||
} | ||
impl Clone for Foo { | ||
fn clone(&self) -> Self { *self } | ||
} | ||
impl Default for Foo { | ||
fn default() -> Self { unsafe { ::std::mem::zeroed() } } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// bindgen-flags: -- -target i686-pc-win32 | ||
// bindgen-unstable | ||
|
||
struct JNINativeInterface_ { | ||
int (__stdcall *GetVersion)(void *env); | ||
unsigned long long __hack; // A hack so the field alignment is the same than | ||
// for 64-bit, where we run CI. | ||
}; | ||
|
||
__stdcall void bar(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
typedef void (*my_fun_t)(int, int, int, int, | ||
int, int, int, int, | ||
int, int, int, int, | ||
int, int, int, int); | ||
|
||
struct Foo { | ||
my_fun_t callback; | ||
}; |