Created
May 16, 2014 04:11
-
-
Save tsloughter/2771828e80b48b52e92c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
extern "C" fn foo(env: *mut ErlNifEnv, argc: i32, argv: *ERL_NIF_TERM) -> ERL_NIF_TERM { | |
print!("Hello Foo from Rust\n"); | |
unsafe { | |
let a = enif_make_atom(env, ("foo".to_c_str()).unwrap()); | |
return a; | |
} | |
} | |
#[no_mangle] | |
pub fn _nif_init() -> *Struct_enif_entry_t { | |
print!("hello from rust2"); | |
unsafe { | |
static nif_funcs: &'static [ErlNifFunc] = &[ErlNifFunc { | |
name: ("foo".to_c_str()).unwrap(), | |
arity: 0, | |
fptr: option::Some(foo) | |
}]; | |
static entry: Struct_enif_entry_t = Struct_enif_entry_t {major: 2, | |
minor: 6, | |
name: ("erl_nif".to_c_str()).unwrap(), | |
num_of_funcs: 1, | |
funcs: nif_funcs, | |
load: None, | |
reload: None, | |
upgrade: None, | |
unload: None, | |
vm_variant: ("beam.vanilla".to_c_str()).unwrap() }; | |
return &entry as *Struct_enif_entry_t; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment