Commits

Anonymous committed 548ca9a

rename to bashohash

Comments (0)

Files changed (10)

 ^c_src/.*.o
 ^.eunit/.*
 ^ebin/.*.beam
-^priv/efnv_nifs.so
+^priv/bashohash_nifs.so

c_src/bashohash_nifs.c

+#include "bashohash_nifs.h"
+#include "fnv.h"
+#include "murmur.h"
+
+ERL_NIF_TERM efnv_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]);
+ERL_NIF_TERM murmur_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]);
+
+static ErlNifFunc nif_funcs[] = {
+    {"efnv_hash", 2, efnv_hash},
+    {"murmur_hash", 2, murmur_hash}
+};
+
+ERL_NIF_INIT(bashohash, nif_funcs, NULL, NULL, NULL, NULL);
+
+ERL_NIF_TERM efnv_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { 
+    ErlNifBinary bin_term;
+    unsigned int seed;
+    unsigned int result = 0;
+    if (!enif_inspect_binary(env, argv[0], &bin_term)) 
+        return enif_make_badarg(env);
+    if (!enif_get_uint(env, argv[1], &seed))
+        return enif_make_badarg(env);
+    result = fnv_hash((const void *)bin_term.data, bin_term.size, seed);
+    return enif_make_uint(env, result);
+}
+
+ERL_NIF_TERM murmur_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { 
+    ErlNifBinary bin_term;
+    unsigned int seed;
+    unsigned int result = 0;
+    if (!enif_inspect_binary(env, argv[0], &bin_term)) 
+        return enif_make_badarg(env);
+    if (!enif_get_uint(env, argv[1], &seed))
+        return enif_make_badarg(env);
+    result = MurmurHash2((const void *)bin_term.data, bin_term.size, seed);
+    return enif_make_uint(env, result);
+}

c_src/bashohash_nifs.h

+#ifndef BASHOHASH_NIFS_H
+#define BASHOHASH_NIFS_H
+
+#include "erl_nif.h"
+
+
+#endif /* include guard */
+

c_src/efnv_nifs.c

-#include "efnv_nifs.h"
-#include "fnv.h"
-#include "murmur.h"
-
-ERL_NIF_TERM efnv_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]);
-ERL_NIF_TERM murmur_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]);
-
-static ErlNifFunc nif_funcs[] = {
-    {"efnv_hash", 2, efnv_hash},
-    {"murmur_hash", 2, murmur_hash}
-};
-
-ERL_NIF_INIT(efnv, nif_funcs, NULL, NULL, NULL, NULL);
-
-ERL_NIF_TERM efnv_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { 
-    ErlNifBinary bin_term;
-    unsigned int seed;
-    unsigned int result = 0;
-    if (!enif_inspect_binary(env, argv[0], &bin_term)) 
-        return enif_make_badarg(env);
-    if (!enif_get_uint(env, argv[1], &seed))
-        return enif_make_badarg(env);
-    result = fnv_hash((const void *)bin_term.data, bin_term.size, seed);
-    return enif_make_uint(env, result);
-}
-
-ERL_NIF_TERM murmur_hash(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { 
-    ErlNifBinary bin_term;
-    unsigned int seed;
-    unsigned int result = 0;
-    if (!enif_inspect_binary(env, argv[0], &bin_term)) 
-        return enif_make_badarg(env);
-    if (!enif_get_uint(env, argv[1], &seed))
-        return enif_make_badarg(env);
-    result = MurmurHash2((const void *)bin_term.data, bin_term.size, seed);
-    return enif_make_uint(env, result);
-}

c_src/efnv_nifs.h

-#ifndef EFNV_NIFS_H_
-#define EFNV_NIFS_H_
-
-#include "erl_nif.h"
-
-
-#endif /* include guard */
-

ebin/bashohash.app

+{application, bashohash,
+ [
+  {description, ""},
+  {vsn, "0.1"},
+  {modules, [
+             bashohash
+            ]},
+  {registered, []},
+  {applications, [
+                  kernel,
+                  stdlib
+                 ]},
+  {env, []}
+ ]}.

ebin/efnv.app

-{application, efnv,
- [
-  {description, ""},
-  {vsn, "0.1"},
-  {modules, [
-             efnv
-            ]},
-  {registered, []},
-  {applications, [
-                  kernel,
-                  stdlib
-                 ]},
-  {env, []}
- ]}.
 {port_sources, ["c_src/*.c"]}.
-{so_name, "efnv_nifs.so"}.
+{so_name, "bashohash_nifs.so"}.
 
 {port_envs, [
              %% Make sure to link -lstdc++ on linux or solaris

src/bashohash.erl

+
+-module(bashohash).
+-author('cliff@powerset.com').
+-author('andy@basho.com').
+-export([fnv/1, fnv/2, murmur/1, murmur/2]).
+-on_load(init/0).
+
+-define(SEED, 2166136261).
+
+init() ->
+    case code:priv_dir(bashohash) of
+        {error, bad_name} ->
+            SoName = filename:join("../priv", bashohash_nifs);
+        Dir ->
+            SoName = filename:join(Dir, bashohash_nifs)
+    end,
+    erlang:load_nif(SoName, 0).
+
+fnv(T) -> fnv(T, ?SEED).
+fnv(T, Seed) when is_binary(T) -> efnv_hash(T, Seed);
+fnv(T, Seed) -> efnv_hash(term_to_binary(T), Seed).
+efnv_hash(_T, _Seed) -> "NIF library not loaded".    
+murmur(T) -> murmur(T, ?SEED).
+murmur(T, Seed) when is_binary(T) -> murmur_hash(T, Seed);
+murmur(T, Seed) -> murmur_hash(term_to_binary(T), Seed).    
+murmur_hash(_T, _Seed) -> "NIF library not loaded".
+    

src/efnv.erl

-
--module(efnv).
--author('cliff@powerset.com').
--author('andy@basho.com').
--export([fnv/1, fnv/2, murmur/1, murmur/2]).
--on_load(init/0).
-
--define(SEED, 2166136261).
-
-init() ->
-    case code:priv_dir(efnv) of
-        {error, bad_name} ->
-            SoName = filename:join("../priv", efnv_nifs);
-        Dir ->
-            SoName = filename:join(Dir, efnv_nifs)
-    end,
-    erlang:load_nif(SoName, 0).
-
-fnv(T) -> fnv(T, ?SEED).
-fnv(T, Seed) when is_binary(T) -> efnv_hash(T, Seed);
-fnv(T, Seed) -> efnv_hash(term_to_binary(T), Seed).
-efnv_hash(_T, _Seed) -> "NIF library not loaded".    
-murmur(T) -> murmur(T, ?SEED).
-murmur(T, Seed) when is_binary(T) -> murmur_hash(T, Seed);
-murmur(T, Seed) -> murmur_hash(term_to_binary(T), Seed).    
-murmur_hash(_T, _Seed) -> "NIF library not loaded".
-