Browse files

Fix build against libmemcached versions before 0.39.

memcached_server_instance_st was defined in 0.39. Built and tested
against 0.31 and 0.49.
  • Loading branch information...
1 parent b0f5bff commit 468487d5af9a63505d20696aac7ca11332e59150 @tricky tricky committed May 4, 2011
Showing with 19 additions and 1 deletion.
  1. +1 −0 package.xml
  2. +16 −0 php_libmemcached_compat.h
  3. +1 −0 php_memcached.c
  4. +1 −1 php_memcached_session.c
View
1 package.xml
@@ -64,6 +64,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file role='src' name='php_memcached.h'/>
<file role='src' name='php_memcached_session.c'/>
<file role='src' name='php_memcached_session.h'/>
+ <file role='src' name='php_libmemcached_compat.h'/>
<file role='src' name='g_fmt.c'/>
<file role='src' name='g_fmt.h'/>
<file role='src' name='fastlz/fastlz.c'/>
View
16 php_libmemcached_compat.h
@@ -0,0 +1,16 @@
+/*
+ * Here we define backwards compatibility for older
+ * libmemcached API:s
+ *
+ * // Teddy Grenman <teddy.grenman@iki.fi>
+ */
+
+#ifndef PHP_LIBMEMCACHED_COMPAT
+#define PHP_LIBMEMCACHED_COMPAT
+
+#if !defined(LIBMEMCACHED_VERSION_HEX) || LIBMEMCACHED_VERSION_HEX < 0x00039000
+/* definition from libmemcached/types.h version 0.39+ */
+typedef const struct memcached_server_st *memcached_server_instance_st;
+#endif
+
+#endif
View
1 php_memcached.c
@@ -45,6 +45,7 @@
#include <ext/standard/basic_functions.h>
#include <libmemcached/memcached.h>
+#include "php_libmemcached_compat.h"
#include "php_memcached.h"
#include "g_fmt.h"
View
2 php_memcached_session.c
@@ -47,7 +47,7 @@ ps_module ps_mod_memcached = {
/*
* Stolen from libmemcached/common.h, because we need it and they don't expose it.
*/
-static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
+static inline int memcached_validate_key_length(size_t key_length, bool binary)
{
if (key_length == 0)
return MEMCACHED_BAD_KEY_PROVIDED;

0 comments on commit 468487d

Please sign in to comment.