From fa75c23a4312bb68eda0930e1871ac0044f6a84b Mon Sep 17 00:00:00 2001 From: Isaac Whitfield Date: Mon, 25 Apr 2016 15:39:35 +0100 Subject: [PATCH] Fix incompatibilities with OTP 18.3 --- c_src/driver_comm.c | 2 +- c_src/driver_comm.h | 2 +- src/js_benchmark.erl | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/c_src/driver_comm.c b/c_src/driver_comm.c index 3876b61..a35d12a 100644 --- a/c_src/driver_comm.c +++ b/c_src/driver_comm.c @@ -55,7 +55,7 @@ char *read_string(char **data) { void *ejs_alloc(ErlDrvSizeT size) { void *p = driver_alloc(size); if (p == NULL) { - erl_exit(1, "erlang_js: Can't allocate %lu bytes of memory\n", size); + erts_exit(1, "erlang_js: Can't allocate %lu bytes of memory\n", size); } return p; } diff --git a/c_src/driver_comm.h b/c_src/driver_comm.h index 9f04d16..f5456a5 100644 --- a/c_src/driver_comm.h +++ b/c_src/driver_comm.h @@ -30,7 +30,7 @@ char *read_string(char **data); /* Wrapper around driver_alloc() that checks */ /* for OOM. */ -void erl_exit(int n, char*, ...); +void erts_exit(int n, char*, ...); void *ejs_alloc(ErlDrvSizeT size); #endif diff --git a/src/js_benchmark.erl b/src/js_benchmark.erl index 2a51668..37378dc 100644 --- a/src/js_benchmark.erl +++ b/src/js_benchmark.erl @@ -38,9 +38,8 @@ run() -> %% @private time_calls(Ctx, Count) -> io:format("Starting: ~p~n", [Count]), - Start = erlang:now(), - do_calls(Ctx, Count), - timer:now_diff(erlang:now(), Start) / Count. + {Elapsed, _} = timer:tc(fun do_calls/2, [Ctx, Count]), + Elapsed / Count. %% @private do_calls(_Ctx, 0) ->