Skip to content

Commit 52719cf

Browse files
author
Brujo Benavides
authored
Adjust for OTP23 (#6)
* Adjust to OTP23, including changes from @Licenser and @egobrain * Update Makefile based on the newest rebar3 template for that * Update version in app.src * Don't inline functions in CFLAGS * Revert dirty schedulers change
1 parent c0627c0 commit 52719cf

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

c_src/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ BASEDIR := $(abspath $(CURDIR)/..)
55

66
PROJECT ?= zstd_nif
77

8-
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).")
9-
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).")
10-
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).")
8+
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts/erts-~ts/include/\", [code:root_dir(), erlang:system_info(version)])." -s init stop)
9+
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, include)])." -s init stop)
10+
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, lib)])." -s init stop)
1111

1212
C_SRC_DIR = $(CURDIR)
1313
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so
@@ -33,7 +33,7 @@ endif
3333
CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) -I ../priv/zstd/lib
3434
CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
3535

36-
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei
36+
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lei
3737
LDFLAGS += -shared $(CURDIR)/../priv/zstd/lib/libzstd.a
3838

3939
# Verbosity.

c_src/zstd_nif.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static ERL_NIF_TERM zstd_nif_compress(ErlNifEnv* env, int argc, const ERL_NIF_TE
1313

1414
ZSTD_CCtx* ctx = (ZSTD_CCtx*)enif_tsd_get(zstdCompressContextKey);
1515
if (!ctx) {
16-
ctx = ZSTD_createCCtx();
16+
ctx = ZSTD_createCCtx();
1717
enif_tsd_set(zstdCompressContextKey, ctx);
1818
}
1919

@@ -26,7 +26,7 @@ static ERL_NIF_TERM zstd_nif_compress(ErlNifEnv* env, int argc, const ERL_NIF_TE
2626

2727
if(!enif_alloc_binary(buff_size, &ret_bin))
2828
return enif_make_atom(env, "error");
29-
29+
3030
compressed_size = ZSTD_compressCCtx(ctx, ret_bin.data, buff_size, bin.data, bin.size, compression_level);
3131
if(ZSTD_isError(compressed_size))
3232
return enif_make_atom(env, "error");
@@ -45,7 +45,7 @@ static ERL_NIF_TERM zstd_nif_decompress(ErlNifEnv* env, int argc, const ERL_NIF_
4545

4646
ZSTD_DCtx* ctx = (ZSTD_DCtx*)enif_tsd_get(zstdDecompressContextKey);
4747
if (!ctx) {
48-
ctx = ZSTD_createDCtx();
48+
ctx = ZSTD_createDCtx();
4949
enif_tsd_set(zstdDecompressContextKey, ctx);
5050
}
5151

@@ -55,7 +55,7 @@ static ERL_NIF_TERM zstd_nif_decompress(ErlNifEnv* env, int argc, const ERL_NIF_
5555
uncompressed_size = ZSTD_getDecompressedSize(bin.data, bin.size);
5656

5757
outp = enif_make_new_binary(env, uncompressed_size, &out);
58-
58+
5959
if(ZSTD_decompressDCtx(ctx, outp, uncompressed_size, bin.data, bin.size) != uncompressed_size)
6060
return enif_make_atom(env, "error");
6161

rebar.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
{alias, [{test, [format, lint, hank, xref, dialyzer, eunit]}]}.
4747

4848
{project_plugins,
49-
[{rebar3_format, "~> 1.0.0"}, {rebar3_lint, "~> 0.4.0"}, {rebar3_hank, "~> 0.4.0"}]}.
49+
[{rebar3_format, "~> 1.0.0"}, {rebar3_lint, "~> 0.4.0"}, {rebar3_hank, "~> 1.1.1"}]}.

src/zstd.app.src

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{application,
22
zstd,
33
[{description, "Zstd binding for Erlang/Elixir"},
4-
{vsn, "0.2.0"},
4+
{vsn, "0.3.0"},
55
{registered, []},
66
{applications, [kernel, stdlib]},
77
{env, []},

src/zstd.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ compress(Binary) ->
1717
compress(_, _) ->
1818
erlang:nif_error(?LINE).
1919

20-
-spec decompress(Compressed :: binary()) -> Uncompressed :: binary().
20+
-spec decompress(Compressed :: binary()) -> Uncompressed :: binary() | error.
2121
decompress(_) ->
2222
erlang:nif_error(?LINE).
2323

0 commit comments

Comments
 (0)