-
Notifications
You must be signed in to change notification settings - Fork 723
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
long double becomes u128 #1549
Comments
I find all the first ones are strictly worse than the current behavior. With the current behavior at least you don't have ABI issues, and you can pass it by value transparently to C / C++. Unfortunately erroring out is a no-go since it's used in a lot of standard headers to implement |
Maybe the best option would be to still use It might also make sense to provide a way of converting |
Well, it will behave normally, right? As in, a long double value that you got from C should be fine to be passed to C again. It's only constructing rust values what's impossible / hard. |
You're right, it should behave correctly, at least where |
I also hit this just now, using SDL2. Throwing an error is obviously bad and not acceptable. Could we, for the time, emit some sort of dummy struct value with a meaningful name that's the correct size and alignment, and then has the bits as an inner field. This would at least make it very obvious that you should be treating it as a black box if you get it from C, though perhaps an expert could throw a lib at it or something if they really needed If a type is added to std::os::raw be sure to also add it to libc as well so that no_std can use it. |
Probably not, since in MSVC struct vs. POD type matters ABI-wise, and I think it'd break. |
you'd want to use repr(transparent) #[repr(transparent)]
pub struct IAmF128PleaseDontTouch {
raw: u128
} EDIT: well that gives the right size, but I do not know about the right alignment |
Yeah, |
In gcc and clang on x86_64, |
What about something like this:
|
Not sure if rust would like |
You can't do align+transparent |
Related things about Rustc removing f128:
It seems that using f128 with FFI is prone to causing error, and also it's usually brought to our view by |
cc @emilio |
* Update to latest redis 6 redismodule.h, no need to use the hacked redismodule.h from RediSearch. * Remove all API calls that use long double, this is because of and issue in bindgen: rust-lang/rust-bindgen#1549 * Added support for server events API. * Remove "static" from global const event id structs so they can be accessed from outside the c code. * cleanup * Use bindgen's parse_callbacks to avoid ugly explicit casts (#88) Co-authored-by: Gavrie Philipson <gavrie@redislabs.com>
Would bindgen be amicable to a --no-u128 or similar flag? Maybe a more generic primitive type filtering function? The u128 not being a valid FFI type is a pretty concerning warning to spew in certain circumstances. |
These functions are obsolete. It's no use in Rust code. Bindgen with |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
I'm not entirely sure. Here are the idea's I can think of
f128
crate but the layout of thef128
is different to the layout of a clong double
c_longdouble
type tostd::os::raw
. The problem is that on many machines (including mine)long double
is a 16 byte float, which rust doesn't suportThe text was updated successfully, but these errors were encountered: