Permalink
Browse files

Merge branch 'version' of https://github.com/gar1t/erlzmq2 into gar1t…

…-version
  • Loading branch information...
2 parents 3aa9455 + bd1aaa4 commit 7d69ee121c8b37732f749e6b95ff403cf1439790 @yrashk yrashk committed Jun 12, 2011
Showing with 27 additions and 3 deletions.
  1. +12 −1 c_src/erlzmq_nif.c
  2. +7 −1 src/erlzmq.erl
  3. +5 −1 src/erlzmq_nif.erl
  4. +3 −0 test/erlzmq_test.erl
View
@@ -105,6 +105,7 @@ NIF(erlzmq_nif_send);
NIF(erlzmq_nif_recv);
NIF(erlzmq_nif_close);
NIF(erlzmq_nif_term);
+NIF(erlzmq_nif_version);
static void * polling_thread(void * handle);
static ERL_NIF_TERM add_active_req(ErlNifEnv* env, erlzmq_socket_t * socket);
@@ -121,7 +122,8 @@ static ErlNifFunc nif_funcs[] =
{"send", 3, erlzmq_nif_send},
{"recv", 2, erlzmq_nif_recv},
{"close", 1, erlzmq_nif_close},
- {"term", 1, erlzmq_nif_term}
+ {"term", 1, erlzmq_nif_term},
+ {"version", 0, erlzmq_nif_version}
};
NIF(erlzmq_nif_context)
@@ -709,6 +711,15 @@ NIF(erlzmq_nif_term)
}
}
+NIF(erlzmq_nif_version)
+{
+ int major, minor, patch;
+ zmq_version(&major, &minor, &patch);
+ return enif_make_tuple3(env, enif_make_int(env, major),
+ enif_make_int(env, minor),
+ enif_make_int(env, patch));
+}
+
static void * polling_thread(void * handle)
{
erlzmq_context_t * context = (erlzmq_context_t *) handle;
View
@@ -38,7 +38,8 @@
close/1,
close/2,
term/1,
- term/2]).
+ term/2,
+ version/0]).
-export_type([erlzmq_socket/0, erlzmq_context/0]).
%% @equiv context(1)
@@ -291,6 +292,11 @@ term(Context, Timeout) ->
Result
end.
+%% @doc Returns the 0MQ library version.
+%% @end
+-spec version() -> {integer(), integer(), integer()}.
+
+version() -> erlzmq_nif:version().
%% Private
View
@@ -10,7 +10,8 @@
setsockopt/3,
getsockopt/2,
close/1,
- term/1]).
+ term/1,
+ version/0]).
-on_load(init/0).
@@ -62,3 +63,6 @@ close(_Socket) ->
term(_Context) ->
erlang:nif_error(not_loaded).
+
+version() ->
+ erlang:nif_error(not_loaded).
@@ -58,6 +58,9 @@ reqrep_tcp_test() ->
shutdown_stress_test() ->
?assertMatch(ok, shutdown_stress_loop(10)).
+version_test() ->
+ ?assertEqual({2, 1, 7}, erlzmq:version()).
+
shutdown_stress_loop(0) ->
ok;
shutdown_stress_loop(N) ->

0 comments on commit 7d69ee1

Please sign in to comment.