rusterlium / erlang_nif-sys

Low level bindings to Erlang NIF API for Rust
Apache License 2.0
90 stars 19 forks source link

Support nif 2.9 in OTP 18.2 #6

Closed tatsuya6502 closed 8 years ago

tatsuya6502 commented 8 years ago

Add enif_getenv() function to support nif 2.9. enif_getenv() was introduced to Erlang/OTP 18.2 by this commit: https://github.com/erlang/otp/commit/ef45d2c9f874354b17c2aca96de7b3306a9eb943

Manually tested with a modified version of ruster_unsafe_demo: https://github.com/tatsuya6502/ruster_unsafe_demo/commit/839db584e147459f714e5658d62e8a580c382bf2

% git remote -v
origin  git@github.com:tatsuya6502/ruster_unsafe_demo.git (fetch)
origin  git@github.com:tatsuya6502/ruster_unsafe_demo.git (push)
% git branch
  master
* nif-2.9
% cargo build
    Updating git repository `https://github.com/tatsuya6502/ruster_unsafe/`
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling ruster_unsafe v0.2.0 (https://github.com/tatsuya6502/ruster_unsafe/?rev=nif-2.9#2f68285f)
   Compiling libc v0.2.4
   Compiling ruster_unsafe_demo v0.0.1 (file:///usr/home/tatsuya/workhub/dev/ruster_unsafe_demo)
% erlc ruster_unsafe_demo.erl
%
% erl
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.2.1  (abort with ^G)
1> ruster_unsafe_demo:getenv("HOME").
"/home/tatsuya"
2> ruster_unsafe_demo:getenv("UNDEFINED").
** exception error: bad argument
     in function  ruster_unsafe_demo:getenv/1
        called as ruster_unsafe_demo:getenv("UNDEFINED")
3> os:getenv("HOME").
"/home/tatsuya"
4> os:getenv("UNDEFINED").
false
goertzenator commented 8 years ago

Thanks!

hansihe commented 8 years ago

Is there any particular reason why this wasn't merged? Anything I can do to help?

goertzenator commented 8 years ago

I could have sworn I merged this. Apologies. Thanks for poking me.

goertzenator commented 8 years ago

Ah, it makes you hit merge twice as confirmation. I must have only hit it once the first time.

hansihe commented 8 years ago

Ah, right, thank you :)

hansihe commented 8 years ago

Would you mind bumping the version number and uploading the newest version to crates? I can make a pull request if it's easier for you.

goertzenator commented 8 years ago

Crate 0.3.0 has been published.