summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-09-21 22:24:29 +0200
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-09-21 23:37:14 +0200
commit506531522c5910717d89fc3bfdf07d0cdf65485a (patch)
tree4cdfdabef1152770c58676104d04771653a89620
parent821252d070d6bc8fca462890d52426ffbe2d6d91 (diff)
Add Int128 types.
-rw-r--r--src/codegen/mod.rs5
-rw-r--r--src/ir/context.rs2
-rw-r--r--src/ir/int.rs6
-rw-r--r--tests/expectations/int128_t.rs7
-rw-r--r--tests/headers/int128_t.h7
5 files changed, 25 insertions, 2 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 8d5f453f..7de416a8 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1306,6 +1306,11 @@ impl ToRustTy for Type {
IntKind::ULongLong => raw!(c_ulonglong),
IntKind::U16 => aster::ty::TyBuilder::new().u16(),
IntKind::U32 => aster::ty::TyBuilder::new().u32(),
+ // FIXME: This doesn't generate the proper alignment, but we
+ // can't do better right now. We should be able to use
+ // i128/u128 when they're available.
+ IntKind::U128 |
+ IntKind::I128 => ArrayTyBuilder::new().with_len(2).build(aster::ty::TyBuilder::new().u64()),
}
}
TypeKind::Float(fk) => {
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 4d5d88e4..f3c24db2 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -583,6 +583,8 @@ impl<'ctx> BindgenContext<'ctx> {
CXType_ULong => TypeKind::Int(IntKind::ULong),
CXType_LongLong => TypeKind::Int(IntKind::LongLong),
CXType_ULongLong => TypeKind::Int(IntKind::ULongLong),
+ CXType_Int128 => TypeKind::Int(IntKind::I128),
+ CXType_UInt128 => TypeKind::Int(IntKind::U128),
CXType_Float => TypeKind::Float(FloatKind::Float),
CXType_Double => TypeKind::Float(FloatKind::Double),
CXType_LongDouble => TypeKind::Float(FloatKind::LongDouble),
diff --git a/src/ir/int.rs b/src/ir/int.rs
index d2769b77..75e576d4 100644
--- a/src/ir/int.rs
+++ b/src/ir/int.rs
@@ -13,6 +13,8 @@ pub enum IntKind {
ULongLong,
U16, // For Char16 and Wchar
U32, // For Char32
+ I128,
+ U128,
// Though now we're at it we could add equivalents for the rust types...
}
@@ -21,10 +23,10 @@ impl IntKind {
use self::IntKind::*;
match *self {
Bool | UChar | UShort |
- UInt | ULong | ULongLong | U16 | U32 => false,
+ UInt | ULong | ULongLong | U16 | U32 | U128 => false,
Char | Short | Int |
- Long | LongLong => true,
+ Long | LongLong | I128 => true,
}
}
}
diff --git a/tests/expectations/int128_t.rs b/tests/expectations/int128_t.rs
new file mode 100644
index 00000000..b4b7b2bc
--- /dev/null
+++ b/tests/expectations/int128_t.rs
@@ -0,0 +1,7 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+
diff --git a/tests/headers/int128_t.h b/tests/headers/int128_t.h
new file mode 100644
index 00000000..eece252c
--- /dev/null
+++ b/tests/headers/int128_t.h
@@ -0,0 +1,7 @@
+/**
+ * FIXME: Uncomment this once we can generate the proper alignment for the type,
+ * i.e., when we use u128/i128.
+struct Foo {
+ __int128 foo;
+};
+ */