Skip to content

Commit 60cb410

Browse files
committed
Merge #59: Remove libc dependency
9b3496a Remove libc dependency (Tobin C. Harding) Pull request description: As we do in `rust-secp256k1` we can create type aliases for C integer types instead of depending on `libc`. Create type aliases (copied from `rust-secp256k1`) and remove libc dependency. Please note, this crate is copyright'ed to Tamas using Apache, but for this new file we use CC license since I copied it from `rust-secp256k1` (although its only a few trivial lines). Probably being overly paranoid but wanted to flag it. Fixes: #57 ACKs for top commit: apoelstra: ACK 9b3496a Tree-SHA512: 18fdb35d905060cf257e7431ccc082b3444393ee03a239d1d85a4d2e99c3bc3d4709bb2f0f733f6b8ad2c15707e947b75bd590a26c0d2b40ed1b30c5b3743654
2 parents 01f594e + 9b3496a commit 60cb410

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ std = []
2323
external-secp = []
2424

2525
[dependencies]
26-
libc="0.2"
2726

2827
[build-dependencies]
2928
cc = "1.0.28"

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
//! sources using Cargo and provides Rust bindings to its API.
1818
//!
1919
20-
extern crate libc;
20+
mod types;
2121

2222
use core::fmt;
2323

24-
use libc::{c_int, c_uchar, c_uint};
24+
use crate::types::*;
2525

2626
/// Errors returned by `libbitcoinconsensus` (see github.com/bitcoin/bitcoin/doc/shared-libraries.md).
2727
#[allow(non_camel_case_types)]

src/types.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Written by the Rust Bitcoin developers.
2+
// SPDX-License-Identifier: CC0-1.0
3+
4+
#![allow(non_camel_case_types)]
5+
6+
/// The C signed 32 bit integer type.
7+
pub type c_int = i32;
8+
/// The C unsigned 8 bit integer type.
9+
pub type c_uchar = u8;
10+
/// The C unsigned 32 bit integer type.
11+
pub type c_uint = u32;
12+
13+
#[cfg(test)]
14+
mod tests {
15+
use std::any::TypeId;
16+
use std::os::raw;
17+
18+
use crate::types;
19+
20+
#[test]
21+
fn verify_types() {
22+
assert_eq!(TypeId::of::<types::c_int>(), TypeId::of::<raw::c_int>());
23+
assert_eq!(TypeId::of::<types::c_uchar>(), TypeId::of::<raw::c_uchar>());
24+
assert_eq!(TypeId::of::<types::c_uint>(), TypeId::of::<raw::c_uint>());
25+
}
26+
}

0 commit comments

Comments
 (0)