Skip to content

Commit ffbbef9

Browse files
committed
change: library version
1 parent 1919efe commit ffbbef9

3 files changed

Lines changed: 127 additions & 109 deletions

File tree

config.m4

Lines changed: 124 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -54,121 +54,140 @@ if test "$PHP_SNAPPY" != "no"; then
5454
-L$LIBSNAPPY_LIBDIR
5555
])
5656

57+
AC_LANG_PUSH([C++])
58+
AC_RUN_IFELSE([
59+
AC_LANG_PROGRAM(
60+
[#include <stdio.h>
61+
#include <snappy-stubs-public.h>],
62+
[printf("%d.%d.%d\n", SNAPPY_MAJOR, SNAPPY_MINOR, SNAPPY_PATCHLEVEL)])],
63+
[cw_cv_system_version=$(./conftest$EXEEXT)],
64+
[AC_MSG_ERROR(Failed to compile a version program!?)])
65+
AC_LANG_POP([C++])
66+
eval "LIBSNAPPY_VERSON=$cw_cv_system_version"
67+
68+
AC_DEFINE_UNQUOTED(SNAPPY_LIB_VERSION, "$LIBSNAPPY_VERSON", [ ])
69+
5770
PHP_SUBST(SNAPPY_SHARED_LIBADD)
5871
PHP_NEW_EXTENSION(snappy, snappy.c, $ext_shared,, $LIBSNAPPY_CFLAGS)
5972
else
6073
AC_MSG_RESULT(use bundled version)
6174

62-
dnl compiler C++:
63-
PHP_REQUIRE_CXX()
64-
65-
dnl snappy
66-
SNAPPY_MAJOR="1"
67-
SNAPPY_MINOR="1"
68-
SNAPPY_PATCHLEVEL="7"
69-
70-
AC_PROG_CXX
71-
AC_LANG_PUSH([C++])
72-
AC_C_BIGENDIAN([AC_DEFINE([SNAPPY_IS_BIG_ENDIAN], [1], [snappy is big endian])])
73-
AC_CHECK_HEADERS([stdint.h stddef.h sys/mman.h sys/resource.h windows.h byteswap.h sys/byteswap.h sys/endian.h sys/time.h])
74-
75-
AC_CHECK_FUNC([mmap])
76-
77-
AC_MSG_CHECKING([if the compiler supports __builtin_expect])
78-
AC_TRY_COMPILE(, [
79-
return __builtin_expect(1, 1) ? 1 : 0
80-
], [
81-
snappy_have_builtin_expect=yes
82-
AC_MSG_RESULT([yes])
83-
], [
84-
snappy_have_builtin_expect=no
85-
AC_MSG_RESULT([no])
86-
])
87-
if test x$snappy_have_builtin_expect = xyes ; then
88-
AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])
89-
fi
75+
dnl compiler C++:
76+
PHP_REQUIRE_CXX()
9077

91-
AC_MSG_CHECKING([if the compiler supports __builtin_ctzll])
92-
AC_TRY_COMPILE(, [
93-
return (__builtin_ctzll(0x100000000LL) == 32) ? 1 : 0
94-
], [
95-
snappy_have_builtin_ctz=yes
96-
AC_MSG_RESULT([yes])
97-
], [
98-
snappy_have_builtin_ctz=no
99-
AC_MSG_RESULT([no])
100-
])
101-
if test x$snappy_have_builtin_ctz = xyes ; then
102-
AC_DEFINE([HAVE_BUILTIN_CTZ], [1], [Define to 1 if the compiler supports __builtin_ctz and friends.])
103-
fi
104-
AC_LANG_POP([C++])
78+
dnl snappy
79+
AC_SUBST([SNAPPY_VERSION_MAJOR], [1])
80+
AC_SUBST([SNAPPY_VERSION_MINOR], [2])
81+
AC_SUBST([SNAPPY_VERSION_PATCH], [1])
10582

106-
if test "$ac_cv_header_stdint_h" = "yes"; then
107-
AC_SUBST([ac_cv_have_stdint_h], [1])
108-
AC_SUBST([HAVE_STDINT_H_01], [1])
109-
else
110-
AC_SUBST([ac_cv_have_stdint_h], [0])
111-
AC_SUBST([HAVE_STDINT_H_01], [0])
112-
fi
113-
if test "$ac_cv_header_stddef_h" = "yes"; then
114-
AC_SUBST([ac_cv_have_stddef_h], [1])
115-
AC_SUBST([HAVE_STDDEF_H_01], [1])
116-
else
117-
AC_SUBST([ac_cv_have_stddef_h], [0])
118-
AC_SUBST([HAVE_STDDEF_H_01], [0])
119-
fi
120-
if test "$ac_cv_header_sys_uio_h" = "yes"; then
121-
AC_SUBST([ac_cv_have_sys_uio_h], [1])
122-
AC_SUBST([HAVE_SYS_UIO_H_01], [1])
123-
else
124-
AC_SUBST([ac_cv_have_sys_uio_h], [0])
125-
AC_SUBST([HAVE_SYS_UIO_H_01], [0])
126-
fi
83+
AC_PROG_CXX
84+
AC_LANG_PUSH([C++])
85+
AC_C_BIGENDIAN([AC_DEFINE([SNAPPY_IS_BIG_ENDIAN], [1], [snappy is big endian])])
86+
AC_CHECK_HEADERS([stdint.h stddef.h sys/mman.h sys/resource.h windows.h byteswap.h sys/byteswap.h sys/endian.h sys/time.h sys/uio.h])
12787

128-
AC_SUBST([SNAPPY_MAJOR])
129-
AC_SUBST([SNAPPY_MINOR])
130-
AC_SUBST([SNAPPY_PATCHLEVEL])
131-
132-
dnl Check for stdc++
133-
LIBNAME=stdc++
134-
AC_MSG_CHECKING([for stdc++])
135-
AC_LANG_SAVE
136-
AC_LANG_CPLUSPLUS
137-
AC_TRY_COMPILE(
138-
[
139-
#include <string>
140-
using namespace std;
141-
],[
142-
string dummy;
143-
],[
144-
AC_MSG_RESULT(yes)
145-
PHP_ADD_LIBRARY($LIBNAME, , SNAPPY_SHARED_LIBADD)
146-
],[
147-
AC_MSG_ERROR([wrong stdc++ library not found])
148-
])
149-
AC_LANG_RESTORE
150-
151-
PHP_SUBST(SNAPPY_SHARED_LIBADD)
152-
153-
dnl Sources
154-
SNAPPY_SOURCES="snappy/snappy-c.cc snappy/snappy.cc snappy/snappy-stubs-internal.cc snappy/snappy-sinksource.cc"
155-
156-
PHP_NEW_EXTENSION(snappy, snappy.c $SNAPPY_SOURCES, $ext_shared)
157-
158-
if test -f "$ext_srcdir/snappy/snappy-stubs-public.h.in"; then
159-
if test "$SNAPPY_PATCHLEVEL" -ge 7; then
160-
mv $ext_srcdir/snappy/snappy-stubs-public.h.in \
161-
$ext_srcdir/snappy/snappy-stubs-public.h.in.orig
88+
AC_CHECK_FUNC([mmap])
16289

163-
sed 's/${\(HAVE_[[A-Z\_]]*_H_01\)}/@\1@/' \
164-
$ext_srcdir/snappy/snappy-stubs-public.h.in.orig > \
165-
$ext_srcdir/snappy/snappy-stubs-public.h.in
90+
AC_MSG_CHECKING([if the compiler supports __builtin_expect])
91+
AC_TRY_COMPILE(, [
92+
return __builtin_expect(1, 1) ? 1 : 0
93+
], [
94+
snappy_have_builtin_expect=yes
95+
AC_MSG_RESULT([yes])
96+
], [
97+
snappy_have_builtin_expect=no
98+
AC_MSG_RESULT([no])
99+
])
100+
if test x$snappy_have_builtin_expect = xyes ; then
101+
AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])
166102
fi
167-
fi
168-
AC_CONFIG_FILES([$ext_srcdir/snappy/snappy-stubs-public.h])
169-
AC_OUTPUT
170-
PHP_ADD_BUILD_DIR($ext_builddir/snappy, 1)
171-
PHP_ADD_INCLUDE([$ext_srcdir/snappy])
103+
104+
AC_MSG_CHECKING([if the compiler supports __builtin_ctzll])
105+
AC_TRY_COMPILE(, [
106+
return (__builtin_ctzll(0x100000000LL) == 32) ? 1 : 0
107+
], [
108+
snappy_have_builtin_ctz=yes
109+
AC_MSG_RESULT([yes])
110+
], [
111+
snappy_have_builtin_ctz=no
112+
AC_MSG_RESULT([no])
113+
])
114+
if test x$snappy_have_builtin_ctz = xyes ; then
115+
AC_DEFINE([HAVE_BUILTIN_CTZ], [1], [Define to 1 if the compiler supports __builtin_ctz and friends.])
116+
fi
117+
AC_LANG_POP([C++])
118+
119+
if test "$ac_cv_header_stdint_h" = "yes"; then
120+
AC_SUBST([ac_cv_have_stdint_h], [1])
121+
AC_SUBST([HAVE_STDINT_H_01], [1])
122+
else
123+
AC_SUBST([ac_cv_have_stdint_h], [0])
124+
AC_SUBST([HAVE_STDINT_H_01], [0])
125+
fi
126+
if test "$ac_cv_header_stddef_h" = "yes"; then
127+
AC_SUBST([ac_cv_have_stddef_h], [1])
128+
AC_SUBST([HAVE_STDDEF_H_01], [1])
129+
else
130+
AC_SUBST([ac_cv_have_stddef_h], [0])
131+
AC_SUBST([HAVE_STDDEF_H_01], [0])
132+
fi
133+
if test "$ac_cv_header_sys_uio_h" = "yes"; then
134+
AC_SUBST([ac_cv_have_sys_uio_h], [1])
135+
AC_SUBST([HAVE_SYS_UIO_H_01], [1])
136+
dnl HAVE_SYS_UIO_H_01=1
137+
else
138+
AC_SUBST([ac_cv_have_sys_uio_h], [0])
139+
AC_SUBST([HAVE_SYS_UIO_H_01], [0])
140+
dnl HAVE_SYS_UIO_H_01=0
141+
fi
142+
143+
dnl Check for stdc++
144+
LIBNAME=stdc++
145+
AC_MSG_CHECKING([for stdc++])
146+
AC_LANG_SAVE
147+
AC_LANG_CPLUSPLUS
148+
AC_TRY_COMPILE(
149+
[
150+
#include <string>
151+
using namespace std;
152+
],[
153+
string dummy;
154+
],[
155+
AC_MSG_RESULT(yes)
156+
PHP_ADD_LIBRARY($LIBNAME, , SNAPPY_SHARED_LIBADD)
157+
],[
158+
AC_MSG_ERROR([wrong stdc++ library not found])
159+
])
160+
AC_LANG_RESTORE
161+
162+
PHP_SUBST(SNAPPY_SHARED_LIBADD)
163+
164+
dnl Sources
165+
SNAPPY_SOURCES="snappy/snappy-c.cc snappy/snappy.cc snappy/snappy-stubs-internal.cc snappy/snappy-sinksource.cc"
166+
167+
PHP_NEW_EXTENSION(snappy, snappy.c $SNAPPY_SOURCES, $ext_shared)
168+
169+
if test -f "$ext_srcdir/snappy/snappy-stubs-public.h.in"; then
170+
mv $ext_srcdir/snappy/snappy-stubs-public.h.in \
171+
$ext_srcdir/snappy/snappy-stubs-public.h.in.orig
172+
173+
dnl sed -e "s/\${HAVE_SYS_UIO_H_01}/$HAVE_SYS_UIO_H_01/" \
174+
dnl -e "s/\${PROJECT_VERSION_MAJOR}/$SNAPPY_VERSION_MAJOR/" \
175+
dnl -e "s/\${PROJECT_VERSION_MINOR}/$SNAPPY_VERSION_MINOR/" \
176+
dnl -e "s/\${PROJECT_VERSION_PATCH}/$SNAPPY_VERSION_PATCH/" \
177+
dnl $ext_srcdir/snappy/snappy-stubs-public.h.in.orig > \
178+
dnl $ext_srcdir/snappy/snappy-stubs-public.h.in
179+
180+
sed -e 's/${\(HAVE_[[A-Z\_]]*_H_01\)}/@\1@/' \
181+
-e 's/${PROJECT_VERSION_\([[A-Z]]*\)}/@SNAPPY_VERSION_\1@/' \
182+
$ext_srcdir/snappy/snappy-stubs-public.h.in.orig > \
183+
$ext_srcdir/snappy/snappy-stubs-public.h.in
184+
fi
185+
AC_CONFIG_FILES([$ext_srcdir/snappy/snappy-stubs-public.h])
186+
AC_OUTPUT
187+
PHP_ADD_BUILD_DIR($ext_builddir/snappy, 1)
188+
PHP_ADD_INCLUDE([$ext_srcdir/snappy])
189+
190+
AC_DEFINE_UNQUOTED(SNAPPY_LIB_VERSION, "$SNAPPY_VERSION_MAJOR.$SNAPPY_VERSION_MINOR.$SNAPPY_VERSION_PATCH", [ ])
172191
fi
173192

174193
AC_MSG_CHECKING([for APCu includes])

php_snappy.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define PHP_SNAPPY_H
44

55
#define SNAPPY_EXT_VERSION "0.2.2"
6-
#define SNAPPY_LIB_VERSION "1.2.1"
76

87
extern zend_module_entry snappy_module_entry;
98
#define phpext_snappy_ptr &snappy_module_entry

snappy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ PHP_MINFO_FUNCTION(snappy)
5454
php_info_print_table_start();
5555
php_info_print_table_row(2, "Snappy support", "enabled");
5656
php_info_print_table_row(2, "Extension Version", SNAPPY_EXT_VERSION);
57-
#ifdef HAVE_LIBSNAPPY
58-
php_info_print_table_row(2, "Snappy Version", "system library");
59-
#else
57+
#ifdef SNAPPY_LIB_VERSION
6058
php_info_print_table_row(2, "Snappy Version", SNAPPY_LIB_VERSION);
59+
#else
60+
php_info_print_table_row(2, "Snappy Version", "system library");
6161
#endif
6262
#if PHP_MAJOR_VERSION >= 7 && defined(HAVE_APCU_SUPPORT)
6363
php_info_print_table_row(2, "Snappy APCu serializer ABI",

0 commit comments

Comments
 (0)