summaryrefslogtreecommitdiffstats
path: root/7.patch
blob: 3bc5393a471fcfc6d7fc9c9562ae4ec88822298c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
From 049d21d1865db4355a4b8598aa705ba2c3f3e7f1 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 30 Jan 2018 09:24:02 +0100
Subject: [PATCH 1/3] fix build warning [-Wunused-variable]

---
 zstd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/zstd.c b/zstd.c
index c382c83..2257280 100644
--- a/zstd.c
+++ b/zstd.c
@@ -294,7 +294,6 @@ ZEND_FUNCTION(zstd_uncompress_dict)
 
 ZEND_MINFO_FUNCTION(zstd)
 {
-    char buffer[128];
     php_info_print_table_start();
     php_info_print_table_row(2, "Zstd support", "enabled");
     php_info_print_table_row(2, "Extension Version", PHP_ZSTD_EXT_VERSION);

From 1bec6a0eb38159148e447b8126745d85a3a222e1 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 30 Jan 2018 09:26:19 +0100
Subject: [PATCH 2/3] add --with-libzstd option to use system library

---
 .gitignore |  2 ++
 config.m4  | 35 +++++++++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index b732353..c4bbefa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,5 @@ run-tests.php
 /build
 /include
 /modules
+ltmain.sh.backup
+tmp-php.ini
diff --git a/config.m4 b/config.m4
index 5a117e1..de86242 100644
--- a/config.m4
+++ b/config.m4
@@ -24,16 +24,39 @@ fi
 PHP_ARG_ENABLE(zstd, whether to enable zstd support,
 [  --enable-zstd           Enable zstd support])
 
+PHP_ARG_WITH(libzstd, whether to use system zstd library,
+[  --with-libzsd           Use system zstd library], no, no)
+
 if test "$PHP_ZSTD" != "no"; then
 
-  ZSTD_COMMON_SOURCES="zstd/lib/common/entropy_common.c zstd/lib/common/error_private.c zstd/lib/common/fse_decompress.c zstd/lib/common/pool.c zstd/lib/common/threading.c zstd/lib/common/xxhash.c zstd/lib/common/zstd_common.c"
-  ZSTD_COMPRESS_SOURCES="zstd/lib/compress/fse_compress.c zstd/lib/compress/huf_compress.c zstd/lib/compress/zstd_compress.c zstd/lib/compress/zstdmt_compress.c"
-  ZSTD_DECOMPRESS_SOURCES="zstd/lib/decompress/huf_decompress.c zstd/lib/decompress/zstd_decompress.c"
+  if test "$PHP_LIBZSTD" != "no"; then
+    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
 
-  PHP_ADD_INCLUDE(zstd/lib/common)
-  PHP_ADD_INCLUDE(zstd/lib)
+    AC_MSG_CHECKING(for libzstd)
+    if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzstd; then
+      if $PKG_CONFIG libzstd --atleast-version 1; then
+        LIBZSTD_CFLAGS=`$PKG_CONFIG libzstd --cflags`
+        LIBZSTD_LIBDIR=`$PKG_CONFIG libzstd --libs`
+        LIBZSTD_VERSON=`$PKG_CONFIG libzstd --modversion`
+        AC_MSG_RESULT(from pkgconfig: version $LIBZSTD_VERSON)
+      else
+        AC_MSG_ERROR(system libzstd is too old)
+      fi
+    else
+      AC_MSG_ERROR(pkg-config not found)
+    fi
+    PHP_EVAL_LIBLINE($LIBZSTD_LIBDIR, ZSTD_SHARED_LIBADD)
+    PHP_EVAL_INCLINE($LIBZSTD_CFLAGS)
+  else
+    ZSTD_COMMON_SOURCES="zstd/lib/common/entropy_common.c zstd/lib/common/error_private.c zstd/lib/common/fse_decompress.c zstd/lib/common/pool.c zstd/lib/common/threading.c zstd/lib/common/xxhash.c zstd/lib/common/zstd_common.c"
+    ZSTD_COMPRESS_SOURCES="zstd/lib/compress/fse_compress.c zstd/lib/compress/huf_compress.c zstd/lib/compress/zstd_compress.c zstd/lib/compress/zstdmt_compress.c"
+    ZSTD_DECOMPRESS_SOURCES="zstd/lib/decompress/huf_decompress.c zstd/lib/decompress/zstd_decompress.c"
 
+    PHP_ADD_INCLUDE(zstd/lib/common)
+    PHP_ADD_INCLUDE(zstd/lib)
+  fi
   PHP_NEW_EXTENSION(zstd, zstd.c $ZSTD_COMMON_SOURCES $ZSTD_COMPRESS_SOURCES $ZSTD_DECOMPRESS_SOURCES, $ext_shared)
+  PHP_SUBST(ZSTD_SHARED_LIBADD)
 
   ifdef([PHP_INSTALL_HEADERS],
   [
@@ -45,7 +68,7 @@ fi
 
 dnl coverage
 PHP_ARG_ENABLE(coverage, whether to enable coverage support,
-[  --enable-coverage     Enable coverage support], no, no)
+[  --enable-coverage       Enable coverage support], no, no)
 
 if test "$PHP_COVERAGE" != "no"; then
     EXTRA_CFLAGS="--coverage"

From 297f3761d19189c1abc4ad5975013fb459bf796d Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 30 Jan 2018 09:27:01 +0100
Subject: [PATCH 3/3] relax test (few char diff across libzstd versions)

---
 tests/008.phpt        | 44 ++++++++++++++++++++++----------------------
 tests/dictionary.phpt |  2 +-
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/tests/008.phpt b/tests/008.phpt
index 7b74976..0ab3666 100644
--- a/tests/008.phpt
+++ b/tests/008.phpt
@@ -30,28 +30,28 @@ check_compress($data, 0);
 *** Data size ***
 3547
 *** Compression Level ***
-1 -- 1874 -- true
-2 -- 1847 -- true
-3 -- 1840 -- true
-4 -- 1815 -- true
-5 -- 1805 -- true
-6 -- 1803 -- true
-7 -- 1803 -- true
-8 -- 1803 -- true
-9 -- 1803 -- true
-10 -- 1803 -- true
-11 -- 1800 -- true
-12 -- 1796 -- true
-13 -- 1796 -- true
-14 -- 1796 -- true
-15 -- 1796 -- true
-16 -- 1796 -- true
-17 -- 1796 -- true
-18 -- 1796 -- true
-19 -- 1796 -- true
-20 -- 1796 -- true
-21 -- 1796 -- true
-22 -- 1796 -- true
+1 -- 1%d -- true
+2 -- 1%d -- true
+3 -- 1%d -- true
+4 -- 1%d -- true
+5 -- 1%d -- true
+6 -- 1%d -- true
+7 -- 1%d -- true
+8 -- 1%d -- true
+9 -- 1%d -- true
+10 -- 1%d -- true
+11 -- 1%d -- true
+12 -- 1%d -- true
+13 -- 1%d -- true
+14 -- 1%d -- true
+15 -- 1%d -- true
+16 -- 1%d -- true
+17 -- 1%d -- true
+18 -- 1%d -- true
+19 -- 1%d -- true
+20 -- 1%d -- true
+21 -- 1%d -- true
+22 -- 1%d -- true
 *** Invalid Compression Level ***
 
 Warning: zstd_compress: compression level (100) must be within 1..22 in %s on line %d
diff --git a/tests/dictionary.phpt b/tests/dictionary.phpt
index c5c2ab6..b3455b6 100644
--- a/tests/dictionary.phpt
+++ b/tests/dictionary.phpt
@@ -24,5 +24,5 @@ check_compress_dict($data, $dictionary);
 *** Data size ***
 3547
 *** Dictionary Compression ***
-142 -- 1924 -- true
+142 -- 1%d -- true
 ===Done===