Skip to content

Commit

Permalink
remove libc dep, change ERL_NIF_TERM to newtype
Browse files Browse the repository at this point in the history
  • Loading branch information
goertzenator committed Jun 27, 2016
1 parent 0b11f0e commit 13c20e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "erlang_nif-sys"
version = "0.4.2"
version = "0.4.3"
authors = ["Daniel Goertzen <daniel.goertzen@gmail.com>"]
description = "Create Erlang NIF modules in Rust using the C NIF API."
documentation = "http://goertzenator.github.io/erlang_nif-sys/erlang_nif_sys/index.html"
Expand All @@ -9,9 +9,3 @@ license = "MIT/Apache-2.0"
keywords = ["FFI", "Erlang", "NIF"]

build = "build.rs"

[build-dependencies]
libc = "0.2"

[dependencies]
libc = "0.2"
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Execute Erlang script to generate API lists and extract config.
//

extern crate libc;
use std::os::raw::c_ulong;
use std::process::Command;
use std::env;
use std::path::Path;
Expand All @@ -13,7 +13,7 @@ fn main() {
let escript = env::var("ESCRIPT").unwrap_or("escript".to_string());

// get size of C long
let ulong_size = std::mem::size_of::<libc::c_ulong>();
let ulong_size = std::mem::size_of::<c_ulong>();

// setup output directory
let out_dir = env::var("OUT_DIR")
Expand Down
24 changes: 8 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,21 @@ extern "C" fn native_add(env: *mut ErlNifEnv,
*/

extern crate libc;

/// libc types
pub use libc::c_int;
pub use libc::c_void;
pub use libc::c_uint;
pub use libc::c_char;
pub use libc::c_uchar;
pub use libc::size_t;
pub use libc::c_ulong;
pub use libc::c_long;
pub use libc::c_double;
pub use std::os::raw::{c_int, c_void, c_uint, c_char, c_uchar, c_ulong, c_long, c_double};

#[allow(non_camel_case_types)]
pub type size_t = usize;

use std::option::Option;

#[allow(non_camel_case_types)]
pub type ERL_NIF_UINT = size_t;
//type ERL_NIF_UINT = usize; // complains about non-ffi type.


#[derive(Debug, Copy, Clone)]
#[repr(C)]
#[allow(non_camel_case_types)]
//pub type ERL_NIF_TERM = *const c_void;
pub type ERL_NIF_TERM = ERL_NIF_UINT;
pub struct ERL_NIF_TERM(ERL_NIF_UINT);


/// See [ErlNifEnv](http://www.erlang.org/doc/man/erl_nif.html#ErlNifEnv) in the Erlang docs.
#[derive(Debug)]
Expand Down

0 comments on commit 13c20e3

Please sign in to comment.