Skip to content

Commit eacb49b

Browse files
author
haruyama-makoto
committed
Use zstd v1.1.3
1 parent bb8dbb5 commit eacb49b

27 files changed

+2954
-200
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ See https://github.com/facebook/zstd
99
Fork from https://github.com/jarredholman/ruby-zstd.
1010

1111
## Zstd version
12-
v1.1.2 (https://github.com/facebook/zstd/releases/tag/v1.1.2)
12+
v1.1.3 (https://github.com/facebook/zstd/releases/tag/v1.1.3)
1313

1414
## Installation
1515

ext/zstdruby/libzstd/BUCK

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
cxx_library(
2+
name='zstd',
3+
header_namespace='',
4+
visibility=['PUBLIC'],
5+
deps=[
6+
':common',
7+
':compress',
8+
':decompress',
9+
':deprecated',
10+
],
11+
)
12+
13+
cxx_library(
14+
name='compress',
15+
header_namespace='',
16+
visibility=['PUBLIC'],
17+
exported_headers=subdir_glob([
18+
('compress', 'zstdmt_compress.h'),
19+
]),
20+
headers=subdir_glob([
21+
('compress', 'zstd_opt.h'),
22+
]),
23+
srcs=[
24+
'compress/zstd_compress.c',
25+
'compress/zstdmt_compress.c',
26+
],
27+
deps=[':common'],
28+
)
29+
30+
cxx_library(
31+
name='decompress',
32+
header_namespace='',
33+
visibility=['PUBLIC'],
34+
srcs=['decompress/zstd_decompress.c'],
35+
deps=[
36+
':common',
37+
':legacy',
38+
],
39+
)
40+
41+
cxx_library(
42+
name='deprecated',
43+
header_namespace='',
44+
visibility=['PUBLIC'],
45+
exported_headers=subdir_glob([
46+
('decprecated', '*.h'),
47+
]),
48+
srcs=glob(['deprecated/*.c']),
49+
deps=[':common'],
50+
)
51+
52+
cxx_library(
53+
name='legacy',
54+
header_namespace='',
55+
visibility=['PUBLIC'],
56+
exported_headers=subdir_glob([
57+
('legacy', '*.h'),
58+
]),
59+
srcs=glob(['legacy/*.c']),
60+
deps=[':common'],
61+
)
62+
63+
cxx_library(
64+
name='zdict',
65+
header_namespace='',
66+
visibility=['PUBLIC'],
67+
exported_headers=subdir_glob([
68+
('dictBuilder', 'zdict.h'),
69+
]),
70+
headers=subdir_glob([
71+
('dictBuilder', 'divsufsort.h'),
72+
]),
73+
srcs=glob(['dictBuilder/*.c']),
74+
deps=[':common'],
75+
)
76+
77+
cxx_library(
78+
name='bitstream',
79+
header_namespace='',
80+
visibility=['PUBLIC'],
81+
exported_headers=subdir_glob([
82+
('common', 'bitstream.h'),
83+
]),
84+
)
85+
86+
cxx_library(
87+
name='entropy',
88+
header_namespace='',
89+
visibility=['PUBLIC'],
90+
exported_headers=subdir_glob([
91+
('common', 'fse.h'),
92+
('common', 'huf.h'),
93+
]),
94+
srcs=[
95+
'common/entropy_common.c',
96+
'common/fse_decompress.c',
97+
'compress/fse_compress.c',
98+
'compress/huf_compress.c',
99+
'decompress/huf_decompress.c',
100+
],
101+
deps=[
102+
':bitstream',
103+
':errors',
104+
':mem',
105+
],
106+
)
107+
108+
cxx_library(
109+
name='errors',
110+
header_namespace='',
111+
visibility=['PUBLIC'],
112+
exported_headers=subdir_glob([
113+
('common', 'error_private.h'),
114+
('common', 'zstd_errors.h'),
115+
]),
116+
srcs=['common/error_private.c'],
117+
)
118+
119+
cxx_library(
120+
name='mem',
121+
header_namespace='',
122+
visibility=['PUBLIC'],
123+
exported_headers=subdir_glob([
124+
('common', 'mem.h'),
125+
]),
126+
)
127+
128+
cxx_library(
129+
name='pool',
130+
header_namespace='',
131+
visibility=['PUBLIC'],
132+
exported_headers=subdir_glob([
133+
('common', 'pool.h'),
134+
]),
135+
srcs=['common/pool.c'],
136+
deps=[':threading'],
137+
)
138+
139+
cxx_library(
140+
name='threading',
141+
header_namespace='',
142+
visibility=['PUBLIC'],
143+
exported_headers=subdir_glob([
144+
('common', 'threading.h'),
145+
]),
146+
srcs=['common/threading.c'],
147+
)
148+
149+
cxx_library(
150+
name='xxhash',
151+
header_namespace='',
152+
visibility=['PUBLIC'],
153+
exported_headers=subdir_glob([
154+
('common', 'xxhash.h'),
155+
]),
156+
srcs=['common/xxhash.c'],
157+
)
158+
159+
cxx_library(
160+
name='zstd_common',
161+
header_namespace='',
162+
visibility=['PUBLIC'],
163+
exported_headers=subdir_glob([
164+
('', 'zstd.h'),
165+
('common', 'zstd_internal.h'),
166+
]),
167+
srcs=['common/zstd_common.c'],
168+
deps=[
169+
':errors',
170+
':mem',
171+
],
172+
)
173+
174+
cxx_library(
175+
name='common',
176+
deps=[
177+
':bitstream',
178+
':entropy',
179+
':errors',
180+
':mem',
181+
':pool',
182+
':threading',
183+
':xxhash',
184+
':zstd_common',
185+
]
186+
)

ext/zstdruby/libzstd/Makefile

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# ################################################################
1+
# ##########################################################################
22
# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
33
# All rights reserved.
44
#
5+
# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets
6+
#
57
# This source code is licensed under the BSD-style license found in the
68
# LICENSE file in the root directory of this source tree. An additional grant
79
# of patent rights can be found in the PATENTS file in the same directory.
8-
# ################################################################
10+
# ##########################################################################
911

1012
# Version numbers
1113
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
@@ -18,17 +20,12 @@ LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
1820
LIBVER := $(shell echo $(LIBVER_SCRIPT))
1921
VERSION?= $(LIBVER)
2022

21-
DESTDIR?=
22-
PREFIX ?= /usr/local
23-
LIBDIR ?= $(PREFIX)/lib
24-
INCLUDEDIR=$(PREFIX)/include
25-
2623
CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_
2724
CFLAGS ?= -O3
28-
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
29-
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef \
30-
-Wpointer-arith
31-
CFLAGS += $(MOREFLAGS)
25+
DEBUGFLAGS = -g -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
26+
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
27+
-Wstrict-prototypes -Wundef -Wpointer-arith
28+
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
3229
FLAGS = $(CPPFLAGS) $(CFLAGS)
3330

3431

@@ -41,6 +38,8 @@ CPPFLAGS += -I./legacy -DZSTD_LEGACY_SUPPORT=1
4138
ZSTD_FILES+= $(wildcard legacy/*.c)
4239
endif
4340

41+
ZSTD_OBJ := $(patsubst %.c,%.o,$(ZSTD_FILES))
42+
4443
# OS X linker doesn't support -soname, and use different extension
4544
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
4645
ifeq ($(shell uname), Darwin)
@@ -60,15 +59,14 @@ LIBZSTD = libzstd.$(SHARED_EXT_VER)
6059

6160
.PHONY: default all clean install uninstall
6261

63-
default: lib
62+
default: lib-release
6463

6564
all: lib
6665

6766
libzstd.a: ARFLAGS = rcs
68-
libzstd.a: $(ZSTD_FILES)
67+
libzstd.a: $(ZSTD_OBJ)
6968
@echo compiling static library
70-
@$(CC) $(FLAGS) -c $^
71-
@$(AR) $(ARFLAGS) $@ *.o
69+
@$(AR) $(ARFLAGS) $@ $^
7270

7371
$(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
7472
$(LIBZSTD): $(ZSTD_FILES)
@@ -87,14 +85,41 @@ libzstd : $(LIBZSTD)
8785

8886
lib: libzstd.a libzstd
8987

88+
lib-release: DEBUGFLAGS :=
89+
lib-release: lib
90+
9091
clean:
91-
@$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc dll/libzstd.dll dll/libzstd.lib
92-
@$(RM) decompress/*.o
92+
@$(RM) -r *.dSYM # Mac OS-X specific
93+
@$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
94+
@$(RM) dll/libzstd.dll dll/libzstd.lib
95+
@$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
9396
@echo Cleaning library completed
9497

95-
#------------------------------------------------------------------------
96-
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
97-
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly NetBSD))
98+
#-----------------------------------------------------------------------------
99+
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
100+
#-----------------------------------------------------------------------------
101+
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
102+
103+
ifneq (,$(filter $(shell uname),SunOS))
104+
INSTALL ?= ginstall
105+
else
106+
INSTALL ?= install
107+
endif
108+
109+
PREFIX ?= /usr/local
110+
DESTDIR ?=
111+
LIBDIR ?= $(PREFIX)/lib
112+
INCLUDEDIR ?= $(PREFIX)/include
113+
114+
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly))
115+
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
116+
else
117+
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
118+
endif
119+
120+
INSTALL_LIB ?= $(INSTALL) -m 755
121+
INSTALL_DATA ?= $(INSTALL) -m 644
122+
98123

99124
libzstd.pc:
100125
libzstd.pc: libzstd.pc.in
@@ -106,24 +131,26 @@ libzstd.pc: libzstd.pc.in
106131
$< >$@
107132

108133
install: libzstd.a libzstd libzstd.pc
109-
@install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/
110-
@install -m 755 libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
111-
@cp -a libzstd.$(SHARED_EXT_MAJOR) $(DESTDIR)$(LIBDIR)
112-
@cp -a libzstd.$(SHARED_EXT) $(DESTDIR)$(LIBDIR)
113-
@cp -a libzstd.pc $(DESTDIR)$(LIBDIR)/pkgconfig/
114-
@install -m 644 libzstd.a $(DESTDIR)$(LIBDIR)
115-
@install -m 644 zstd.h $(DESTDIR)$(INCLUDEDIR)
116-
@install -m 644 common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
117-
@install -m 644 deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
118-
@install -m 644 dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
134+
@$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/ $(DESTDIR)$(INCLUDEDIR)/
135+
@$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
136+
@echo Installing libraries
137+
@$(INSTALL_LIB) libzstd.a $(DESTDIR)$(LIBDIR)
138+
@$(INSTALL_LIB) libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
139+
@ln -sf libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
140+
@ln -sf libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
141+
@echo Installing includes
142+
@$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
143+
@$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
144+
@$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
145+
@$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
119146
@echo zstd static and shared library installed
120147

121148
uninstall:
122149
@$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
123150
@$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
124151
@$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
125152
@$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_VER)
126-
@$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libzstd.pc
153+
@$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
127154
@$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
128155
@$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
129156
@$(RM) $(DESTDIR)$(INCLUDEDIR)/zbuff.h # Deprecated streaming functions

ext/zstdruby/libzstd/common/mem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939
#endif
4040

4141
/* code only tested on 32 and 64 bits systems */
42-
#define MEM_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; }
42+
#define MEM_STATIC_ASSERT(c) { enum { MEM_static_assert = 1/(int)(!!(c)) }; }
4343
MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); }
4444

4545

0 commit comments

Comments
 (0)