Skip to content

Commit a013d24

Browse files
Merge branch 'develop' of github.com:phpredis/phpredis into develop
2 parents 4601887 + 3ce9d6b commit a013d24

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,17 @@ typedef struct {
275275
int nb_active;
276276
} ConnectionPool;
277277

278+
#if (PHP_MAJOR_VERSION < 7)
279+
typedef struct {
280+
zend_object std;
281+
RedisSock *sock;
282+
} redis_object;
283+
#else
278284
typedef struct {
279285
RedisSock *sock;
280286
zend_object std;
281287
} redis_object;
288+
#endif
282289

283290
/** Argument info for any function expecting 0 args */
284291
ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)

library.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,41 @@
3838
#include <sys/socket.h> /* SO_KEEPALIVE */
3939
#else
4040
#include <winsock.h>
41+
42+
# if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 4
43+
/* This proto is available from 5.5 on only */
44+
PHP_REDIS_API int usleep(unsigned int useconds);
45+
# endif
46+
#endif
47+
48+
#if (PHP_MAJOR_VERSION < 7)
49+
int (*_add_next_index_string)(zval *, const char *, int) = &add_next_index_string;
50+
int (*_add_next_index_stringl)(zval *, const char *, uint, int) = &add_next_index_stringl;
51+
int (*_add_assoc_bool_ex)(zval *, const char *, uint, int) = &add_assoc_bool_ex;
52+
int (*_add_assoc_long_ex)(zval *, const char *, uint, long) = &add_assoc_long_ex;
53+
int (*_add_assoc_double_ex)(zval *, const char *, uint, double) = &add_assoc_double_ex;
54+
int (*_add_assoc_string_ex)(zval *, const char *, uint, char *, int) = &add_assoc_string_ex;
55+
int (*_add_assoc_stringl_ex)(zval *, const char *, uint, char *, uint, int) = &add_assoc_stringl_ex;
56+
int (*_add_assoc_zval_ex)(zval *, const char *, uint, zval *) = &add_assoc_zval_ex;
57+
void (*_php_var_serialize)(smart_str *, zval **, php_serialize_data_t * TSRMLS_DC) = &php_var_serialize;
58+
int (*_php_var_unserialize)(zval **, const unsigned char **, const unsigned char *, php_unserialize_data_t * TSRMLS_DC) = &php_var_unserialize;
59+
60+
#define strpprintf zend_strpprintf
61+
62+
static zend_string *
63+
zend_strpprintf(size_t max_len, const char *format, ...)
64+
{
65+
va_list ap;
66+
zend_string *zstr;
67+
68+
va_start(ap, format);
69+
zstr = ecalloc(1, sizeof(*zstr));
70+
ZSTR_LEN(zstr) = vspprintf(&ZSTR_VAL(zstr), max_len, format, ap);
71+
zstr->gc = 0x11;
72+
va_end(ap);
73+
return zstr;
74+
}
75+
4176
#endif
4277

4378
extern zend_class_entry *redis_ce;
@@ -1738,7 +1773,7 @@ PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
17381773
}
17391774

17401775
gettimeofday(&tv, NULL);
1741-
persistent_id = strpprintf(0, "phpredis_%ld%ld", (long)tv.tv_sec, (long)tv.tv_usec);
1776+
persistent_id = strpprintf(0, "phpredis_%d%d", tv.tv_sec, tv.tv_usec);
17421777
} else {
17431778
if (redis_sock->persistent_id) {
17441779
persistent_id = strpprintf(0, "phpredis:%s:%s", host, ZSTR_VAL(redis_sock->persistent_id));

0 commit comments

Comments
 (0)