summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-07 19:52:24 -0600
committerGitHub <noreply@github.com>2016-11-07 19:52:24 -0600
commit6c0d065c63fc99e32557bf28cc268c39a6003866 (patch)
tree17068991eb0a27d652796b84d05eab35d2bdac03 /src/codegen/mod.rs
parent8c737ecacd67bf37a949e524b3844cf0d3ea09cc (diff)
parent1091a4274eb5c91b6279905688759105ab95bfb4 (diff)
Auto merge of #221 - emilio:dont-override-float, r=fitzgen
Add an option to avoid converting to f32/f64 automatically float types. This implements another feature that we need for parity with upstream bindgen. r? @fitzgen
Diffstat (limited to 'src/codegen/mod.rs')
-rwxr-xr-xsrc/codegen/mod.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 85ac13b5..bf6af82b 100755
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1465,12 +1465,25 @@ impl ToRustTy for Type {
}
TypeKind::Float(fk) => {
use ir::ty::FloatKind;
- // TODO: we probably should just take the type layout into
- // account?
- match fk {
- FloatKind::Float => aster::ty::TyBuilder::new().f32(),
- FloatKind::Double | FloatKind::LongDouble => {
- aster::ty::TyBuilder::new().f64()
+ if ctx.options().convert_floats {
+ // TODO: we probably should just take the type layout into
+ // account?
+ //
+ // Also, maybe this one shouldn't be the default?
+ match fk {
+ FloatKind::Float => aster::ty::TyBuilder::new().f32(),
+ FloatKind::Double | FloatKind::LongDouble => {
+ aster::ty::TyBuilder::new().f64()
+ }
+ }
+ } else {
+ // FIXME: `c_longdouble` doesn't seem to be defined in some
+ // systems, so we use `c_double` directly.
+ match fk {
+ FloatKind::Float => raw!(c_float),
+ FloatKind::Double | FloatKind::LongDouble => {
+ raw!(c_double)
+ }
}
}
}