erlang各种有用的函数包括一些有用nif封装,还有一些性能测试case。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
465 B

пре 5 година
  1. #include "erl_nif.h"
  2. #include <stdio.h>
  3. static ERL_NIF_TERM getBinAddr(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
  4. ErlNifBinary bin;
  5. enif_inspect_binary(env, argv[0], &bin);
  6. char buf[256];
  7. sprintf(buf, "bin: size=%zu, ptr=%p", bin.size, bin.data);
  8. return enif_make_string(env, buf, ERL_NIF_LATIN1);
  9. }
  10. static ErlNifFunc nif_funcs[] = {
  11. {"getBinAddr", 1, getBinAddr}
  12. };
  13. ERL_NIF_INIT(binaryAddr, nif_funcs, NULL, NULL, NULL, NULL);