Skip to content

Support for f32/f64.#69

Open
waywardmonkeys wants to merge 1 commit intognzlbg:masterfrom
waywardmonkeys:support-f32-and-f64
Open

Support for f32/f64.#69
waywardmonkeys wants to merge 1 commit intognzlbg:masterfrom
waywardmonkeys:support-f32-and-f64

Conversation

@waywardmonkeys
Copy link
Copy Markdown

bindgen outputs f32/f64 instead of c_float/c_double now, so let's
support that here.

bindgen outputs f32/f64 instead of c_float/c_double now, so let's
support that here.
@gnzlbg
Copy link
Copy Markdown
Owner

gnzlbg commented May 28, 2019

Why does bindgen do that? If the platform does not define __STDC_IEC_559__ then f32 and f64 do not necessarily map to C's float and double. musl is an example of such a platform.

@gnzlbg
Copy link
Copy Markdown
Owner

gnzlbg commented May 28, 2019

That is, whether f32 and f64 are FFI safe is target-dependent.

@gnzlbg
Copy link
Copy Markdown
Owner

gnzlbg commented May 28, 2019

@gnzlbg
Copy link
Copy Markdown
Owner

gnzlbg commented May 28, 2019

cc @emilio: rust-bindgen should be generating libc::c_float and libc::c_double here. OTOH, it should not be generating libc::uint32_t and similar types for integers, but u32 instead. It is guaranteed that u32 matches C's uint32_t (https://rust-lang.github.io/unsafe-code-guidelines/layout/scalars.html#fixed-width-integer-types), and therefore the aliases should probably be deprecated from libc.

@emilio
Copy link
Copy Markdown

emilio commented May 28, 2019

Yes, I think this is a bindgen bug. Should be trivial to patch, probably goes as far as bindgen goes, since even before my rewrite it was generating f32: rust-lang/rust-bindgen@cfdf15f#diff-9fd798837900e68cf440b740d0b7363bL2004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants