summaryrefslogtreecommitdiffstats
path: root/ffi-macros
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-06-26 10:41:35 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-06-26 10:41:35 +0200
commit2a4cb58fc9e680bb2bf3fe268ca96147cbe903ef (patch)
treea55cb61beb8285de5e38429eb416d6a6c608d067 /ffi-macros
parent16553c8bd46f16811691bb0f657e0ee6593697ef (diff)
openpgp-ffi, ffi, ffi-macros: Avoid deprecated integer types.
Diffstat (limited to 'ffi-macros')
-rw-r--r--ffi-macros/src/lib.rs4
-rw-r--r--ffi-macros/src/rust2c.rs10
2 files changed, 12 insertions, 2 deletions
diff --git a/ffi-macros/src/lib.rs b/ffi-macros/src/lib.rs
index 26c1beb9..2e957890 100644
--- a/ffi-macros/src/lib.rs
+++ b/ffi-macros/src/lib.rs
@@ -870,7 +870,7 @@ fn derive_hash(span: proc_macro2::Span, prefix: &str, name: &str,
/// Hashes this object.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn #ident #generics (this: *const #wrapper #generics)
- -> ::libc::uint64_t {
+ -> u64 {
use ::std::hash::{Hash, Hasher};
use ::RefRaw;
@@ -929,7 +929,7 @@ fn derive_parse(span: proc_macro2::Span, prefix: &str, name: &str,
/// Parses an object from the given buffer.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn #from_bytes #generics(errp: Option<&mut *mut ::error::Error>,
- b: *const ::libc::uint8_t, len: ::libc::size_t)
+ b: *const u8, len: ::libc::size_t)
-> ::Maybe<#wrapper #generics> {
use ::sequoia_openpgp::parse::Parse;
use ::MoveResultIntoRaw;
diff --git a/ffi-macros/src/rust2c.rs b/ffi-macros/src/rust2c.rs
index 84117ce5..56ef9761 100644
--- a/ffi-macros/src/rust2c.rs
+++ b/ffi-macros/src/rust2c.rs
@@ -29,6 +29,16 @@ fn ident2c(ident: &syn::Ident) -> (String, bool) {
"int8_t" | "int16_t" | "int32_t" | "int64_t" |
"uint8_t" | "uint16_t" | "uint32_t" | "uint64_t"
=> return (ident_string.clone(), false),
+
+ // Primitive types.
+ "u8" => return ("uint8_t".into(), false),
+ "u16" => return ("uint16_t".into(), false),
+ "u32" => return ("uint32_t".into(), false),
+ "u64" => return ("uint64_t".into(), false),
+ "i8" => return ("int8_t".into(), false),
+ "i16" => return ("int16_t".into(), false),
+ "i32" => return ("int32_t".into(), false),
+ "i64" => return ("int64_t".into(), false),
_ => (),
}