-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix calling convention propagation for function pointers. #549
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 @@ | ||
// bindgen-flags: -- -target i686-pc-win32 | ||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice :-| |
||
|
||
struct Foo { | ||
my_fun_t callback; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least extending these checks is obvious and straight forward.