Skip to content

Commit

Permalink
Fix NIF >=2.15 API functions for Windows
Browse files Browse the repository at this point in the history
When adding the newer functions, I messed up the order and missed one
function, which breaks rustler-sys for all newer API versions on
Windows. Other OS are not affected by this, as they link the symbols
directly instead of getting passed a struct.
  • Loading branch information
filmor committed Aug 5, 2024
1 parent 5b319a0 commit 6a8def2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rustler/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl From<ErlNifTermType> for TermType {
}

pub fn get_type(term: Term) -> TermType {
if cfg!(feature = "nif_version_2_15") && !cfg!(target_family = "windows") {
if cfg!(feature = "nif_version_2_15") {
term.get_erl_type().into()
} else if term.is_atom() {
TermType::Atom
Expand Down
20 changes: 10 additions & 10 deletions rustler_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,18 +845,18 @@ fn build_api(b: &mut dyn ApiBuilder, opts: &GenerateOptions) {

// 2.15 was introduced in OTP 22
if opts.nif_version >= (2, 15) {
b.dummy("enif_select_x");
b.func(
"ErlNifTermType",
"enif_term_type",
"env: *mut ErlNifEnv, term: ERL_NIF_TERM",
"ERL_NIF_TERM",
"enif_make_monitor_term",
"env: *mut ErlNifEnv, mon: *const ErlNifMonitor",
);

b.func("c_int", "enif_is_pid_undefined", "pid: *const ErlNifPid");
b.func("", "enif_set_pid_undefined", "pid: *mut ErlNifPid");
b.func(
"ERL_NIF_TERM",
"enif_make_monitor_term",
"env: *mut ErlNifEnv, mon: *const ErlNifMonitor",
"ErlNifTermType",
"enif_term_type",
"env: *mut ErlNifEnv, term: ERL_NIF_TERM",
);
}

Expand All @@ -868,14 +868,14 @@ fn build_api(b: &mut dyn ApiBuilder, opts: &GenerateOptions) {

// 2.17 was introduced in OTP 26
if opts.nif_version >= (2, 17) {
b.func("c_int", "enif_get_string_length", "env: *mut ErlNifEnv, list: ERL_NIF_TERM, len: *mut c_uint, encoding: ErlNifCharEncoding");
b.func("c_int", "enif_make_new_atom", "env: *mut ErlNifEnv, name: *const c_char, atom: *mut ERL_NIF_TERM, encoding: ErlNifCharEncoding");
b.func("c_int", "enif_make_new_atom_len", "env: *mut ErlNifEnv, name: *const c_char, len: size_t, atom: *mut ERL_NIF_TERM, encoding: ErlNifCharEncoding");
b.func(
"c_int",
"enif_set_option",
"env: *mut ErlNifEnv, opt: ErlNifOption",
);
b.func("c_int", "enif_get_string_length", "env: *mut ErlNifEnv, list: ERL_NIF_TERM, len: *mut c_uint, encoding: ErlNifCharEncoding");
b.func("c_int", "enif_make_new_atom", "env: *mut ErlNifEnv, name: *const c_char, atom: *mut ERL_NIF_TERM, encoding: ErlNifCharEncoding");
b.func("c_int", "enif_make_new_atom_len", "env: *mut ErlNifEnv, name: *const c_char, len: size_t, atom: *mut ERL_NIF_TERM, encoding: ErlNifCharEncoding");
}
}

Expand Down

0 comments on commit 6a8def2

Please sign in to comment.