Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mururu/zstd-erlang
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: alertlogic/zstd-erlang
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 7 commits
  • 2 files changed
  • 5 contributors

Commits on Jul 14, 2020

  1. Copy the full SHA
    de1d23b View commit details

Commits on Aug 11, 2020

  1. Merge pull request #1 from codyf221/handle_unknown_uncompressed_size

    Handle unknown content size
    codyf221 authored Aug 11, 2020
    Copy the full SHA
    07094c3 View commit details

Commits on Sep 8, 2020

  1. Use dirty schedules

    Yakov Kozlov committed Sep 8, 2020
    Copy the full SHA
    4f9e840 View commit details

Commits on Jul 25, 2022

  1. Merge pull request #1 from egobrain/master

    Use dirty schedules
    motobob authored Jul 25, 2022
    Copy the full SHA
    ef3e4e3 View commit details
  2. Merge pull request #2 from codyf221/master

    Handle unknown content size
    motobob authored Jul 25, 2022
    Copy the full SHA
    e3a7c8c View commit details

Commits on Aug 1, 2022

  1. fix homebrew path for latest MacOS

    Evgeny Bob committed Aug 1, 2022
    Copy the full SHA
    9c4b1d3 View commit details
  2. Merge pull request #3 from alertlogic/arm64

    fix homebrew path for latest MacOS
    motobob authored Aug 1, 2022
    Copy the full SHA
    8f6cbfa View commit details
Showing with 20 additions and 9 deletions.
  1. +10 −4 c_src/Makefile
  2. +10 −5 c_src/zstd_nif.c
14 changes: 10 additions & 4 deletions c_src/Makefile
Original file line number Diff line number Diff line change
@@ -16,10 +16,16 @@ C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so

UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -arch x86_64 -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
HOMEBREW_PREFIX ?= $(shell brew --prefix)

CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CFLAGS += -I $(HOMEBREW_PREFIX)/include -I $(HOMEBREW_PREFIX)/opt/openssl/include
LDFLAGS := $(LDFLAGS) -L $(HOMEBREW_PREFIX)/lib -L $(HOMEBREW_PREFIX)/opt/openssl/lib \
-mmacosx-version-min=$(shell sw_vers -productVersion) \
-Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
-flat_namespace -undefined suppress
LDLIBS += -L $(HOMEBREW_PREFIX)/opt/openssl/lib
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -Wall -Wmissing-prototypes
15 changes: 10 additions & 5 deletions c_src/zstd_nif.c
Original file line number Diff line number Diff line change
@@ -37,19 +37,24 @@ static ERL_NIF_TERM zstd_nif_decompress(ErlNifEnv* env, int argc, const ERL_NIF_
if(!enif_inspect_binary(env, argv[0], &bin))
return enif_make_badarg(env);

uncompressed_size = ZSTD_getDecompressedSize(bin.data, bin.size);
uncompressed_size = ZSTD_getFrameContentSize(bin.data, bin.size);

if (uncompressed_size==ZSTD_CONTENTSIZE_ERROR) {
return enif_make_badarg(env);
} else if (uncompressed_size==ZSTD_CONTENTSIZE_UNKNOWN) {
uncompressed_size = 10000000;
}

outp = enif_make_new_binary(env, uncompressed_size, &out);

if(ZSTD_decompress(outp, uncompressed_size, bin.data, bin.size) != uncompressed_size)
return enif_make_atom(env, "error");
ZSTD_decompress(outp, uncompressed_size, bin.data, bin.size);

return out;
}

static ErlNifFunc nif_funcs[] = {
{"compress", 2, zstd_nif_compress},
{"decompress", 1, zstd_nif_decompress}
{"compress", 2, zstd_nif_compress, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"decompress", 1, zstd_nif_decompress, ERL_NIF_DIRTY_JOB_CPU_BOUND}
};

ERL_NIF_INIT(zstd, nif_funcs, NULL, NULL, NULL, NULL);