|
|
885bb5 |
From: Peter Lemenkov <lemenkov@gmail.com>
|
|
|
885bb5 |
Date: Sun, 2 Nov 2014 19:49:55 +0300
|
|
|
885bb5 |
Subject: [PATCH] Expose NIF version
|
|
|
885bb5 |
|
|
|
885bb5 |
This patch allows checking for NIF API version in a way similar to
|
|
|
885bb5 |
driver version. E.g. by calling erlang:system_info(nif_version).
|
|
|
885bb5 |
|
|
|
885bb5 |
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
|
|
885bb5 |
|
|
|
885bb5 |
diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml
|
|
|
885bb5 |
index 8416839..81f98cb 100644
|
|
|
885bb5 |
--- a/erts/doc/src/erlang.xml
|
|
|
885bb5 |
+++ b/erts/doc/src/erlang.xml
|
|
|
885bb5 |
@@ -6133,6 +6133,11 @@ ok
|
|
|
885bb5 |
<seealso marker="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</seealso>, and
|
|
|
885bb5 |
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>.
|
|
|
885bb5 |
</item>
|
|
|
885bb5 |
+ <tag><c>nif_version</c></tag>
|
|
|
885bb5 |
+ <item>
|
|
|
885bb5 |
+ Returns a string containing the erlang NIF version
|
|
|
885bb5 |
+ used by the runtime system. It will be on the form "<major ver>.<minor ver>".
|
|
|
885bb5 |
+ </item>
|
|
|
885bb5 |
<tag><marker id="system_info_otp_release"><c>otp_release</c></marker></tag>
|
|
|
885bb5 |
<item>
|
|
|
885bb5 |
Returns a string containing the OTP release number of the
|
|
|
885bb5 |
diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c
|
|
|
885bb5 |
index 6efe9d9..da38eea 100644
|
|
|
885bb5 |
--- a/erts/emulator/beam/erl_bif_info.c
|
|
|
885bb5 |
+++ b/erts/emulator/beam/erl_bif_info.c
|
|
|
885bb5 |
@@ -27,6 +27,7 @@
|
|
|
885bb5 |
#include "erl_process.h"
|
|
|
885bb5 |
#include "error.h"
|
|
|
885bb5 |
#include "erl_driver.h"
|
|
|
885bb5 |
+#include "erl_nif.h"
|
|
|
885bb5 |
#include "bif.h"
|
|
|
885bb5 |
#include "big.h"
|
|
|
885bb5 |
#include "erl_version.h"
|
|
|
885bb5 |
@@ -2459,6 +2460,13 @@ BIF_RETTYPE system_info_1(BIF_ALIST_1)
|
|
|
885bb5 |
ERL_DRV_EXTENDED_MINOR_VERSION);
|
|
|
885bb5 |
hp = HAlloc(BIF_P, 2*n);
|
|
|
885bb5 |
BIF_RET(buf_to_intlist(&hp, buf, n, NIL));
|
|
|
885bb5 |
+ } else if (ERTS_IS_ATOM_STR("nif_version", BIF_ARG_1)) {
|
|
|
885bb5 |
+ char buf[42];
|
|
|
885bb5 |
+ int n = erts_snprintf(buf, 42, "%d.%d",
|
|
|
885bb5 |
+ ERL_NIF_MAJOR_VERSION,
|
|
|
885bb5 |
+ ERL_NIF_MINOR_VERSION);
|
|
|
885bb5 |
+ hp = HAlloc(BIF_P, 2*n);
|
|
|
885bb5 |
+ BIF_RET(buf_to_intlist(&hp, buf, n, NIL));
|
|
|
885bb5 |
} else if (ERTS_IS_ATOM_STR("smp_support", BIF_ARG_1)) {
|
|
|
885bb5 |
#ifdef ERTS_SMP
|
|
|
885bb5 |
BIF_RET(am_true);
|
|
|
885bb5 |
diff --git a/erts/emulator/test/driver_SUITE.erl b/erts/emulator/test/driver_SUITE.erl
|
|
|
885bb5 |
index 336b618..081789f 100644
|
|
|
885bb5 |
--- a/erts/emulator/test/driver_SUITE.erl
|
|
|
885bb5 |
+++ b/erts/emulator/test/driver_SUITE.erl
|
|
|
885bb5 |
@@ -1199,8 +1199,8 @@ check_si_res(["sched_thrs", Value]) ->
|
|
|
885bb5 |
?line Value = integer_to_list(erlang:system_info(schedulers));
|
|
|
885bb5 |
|
|
|
885bb5 |
%% Data added in 3rd version of driver_system_info() (driver version 1.5)
|
|
|
885bb5 |
-check_si_res(["emu_nif_vsn", _Value]) ->
|
|
|
885bb5 |
- true;
|
|
|
885bb5 |
+check_si_res(["emu_nif_vsn", Value]) ->
|
|
|
885bb5 |
+ ?line Value = erlang:system_info(nif_version);
|
|
|
885bb5 |
|
|
|
885bb5 |
%% Data added in 4th version of driver_system_info() (driver version 3.1)
|
|
|
885bb5 |
check_si_res(["dirty_sched", _Value]) ->
|
|
|
885bb5 |
diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl
|
|
|
885bb5 |
index 98d7a94..de6a773 100644
|
|
|
885bb5 |
--- a/erts/preloaded/src/erlang.erl
|
|
|
885bb5 |
+++ b/erts/preloaded/src/erlang.erl
|
|
|
885bb5 |
@@ -2251,6 +2251,7 @@ tuple_to_list(_Tuple) ->
|
|
|
885bb5 |
(modified_timing_level) -> integer() | undefined;
|
|
|
885bb5 |
(multi_scheduling) -> disabled | blocked | enabled;
|
|
|
885bb5 |
(multi_scheduling_blockers) -> [PID :: pid()];
|
|
|
885bb5 |
+ (nif_version) -> string();
|
|
|
885bb5 |
(otp_release) -> string();
|
|
|
885bb5 |
(port_count) -> non_neg_integer();
|
|
|
885bb5 |
(port_limit) -> pos_integer();
|
|
|
885bb5 |
diff --git a/lib/runtime_tools/src/system_information.erl b/lib/runtime_tools/src/system_information.erl
|
|
|
885bb5 |
index f541d6e..04cc33e 100644
|
|
|
885bb5 |
--- a/lib/runtime_tools/src/system_information.erl
|
|
|
885bb5 |
+++ b/lib/runtime_tools/src/system_information.erl
|
|
|
885bb5 |
@@ -371,6 +371,7 @@ erlang_system_info() ->
|
|
|
885bb5 |
logical_processors_online,
|
|
|
885bb5 |
logical_processors_available,
|
|
|
885bb5 |
driver_version,
|
|
|
885bb5 |
+ nif_version,
|
|
|
885bb5 |
emu_args,
|
|
|
885bb5 |
ethread_info,
|
|
|
885bb5 |
beam_jump_table,
|
|
|
885bb5 |
diff --git a/lib/runtime_tools/test/system_information_SUITE_data/information_test_report.dat b/lib/runtime_tools/test/system_information_SUITE_data/information_test_report.dat
|
|
|
885bb5 |
index 1893837..bdc510e 100644
|
|
|
885bb5 |
--- a/lib/runtime_tools/test/system_information_SUITE_data/information_test_report.dat
|
|
|
885bb5 |
+++ b/lib/runtime_tools/test/system_information_SUITE_data/information_test_report.dat
|
|
|
885bb5 |
@@ -9720,6 +9720,7 @@
|
|
|
885bb5 |
{logical_processors_online,4},
|
|
|
885bb5 |
{logical_processors_available,4},
|
|
|
885bb5 |
{driver_version,"2.1"},
|
|
|
885bb5 |
+ {nif_version,"1.1"},
|
|
|
885bb5 |
{taints,[]}]},
|
|
|
885bb5 |
{erts_compile_info,
|
|
|
885bb5 |
[{ldflags,[]},
|