Skip to content

Commit c9a6ce2

Browse files
committed
Build fix for win32 (phpredis 2.1.3)
1 parent 73d99c3 commit c9a6ce2

File tree

9 files changed

+248
-178
lines changed

9 files changed

+248
-178
lines changed

Diff for: common.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,23 @@
5252

5353

5454
#define MULTI_RESPONSE(callback) IF_MULTI_OR_PIPELINE() { \
55-
fold_item *f1 = malloc(sizeof(fold_item)); \
55+
fold_item *f1, *current; \
56+
f1 = malloc(sizeof(fold_item)); \
5657
f1->fun = (void *)callback; \
5758
f1->next = NULL; \
58-
fold_item *current = redis_sock->current;\
59+
current = redis_sock->current;\
5960
if(current) current->next = f1; \
6061
redis_sock->current = f1; \
6162
}
6263

6364
#define PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len) request_item *tmp; \
65+
struct request_item *current_request;\
6466
tmp = malloc(sizeof(request_item));\
6567
tmp->request_str = calloc(cmd_len, 1);\
6668
memcpy(tmp->request_str, cmd, cmd_len);\
6769
tmp->request_size = cmd_len;\
6870
tmp->next = NULL;\
69-
struct request_item *current_request = redis_sock->pipeline_current; \
71+
current_request = redis_sock->pipeline_current; \
7072
if(current_request) {\
7173
current_request->next = tmp;\
7274
} \
@@ -81,11 +83,12 @@
8183
}
8284

8385
#define REDIS_SAVE_CALLBACK(callback, closure_context) IF_MULTI_OR_PIPELINE() { \
84-
fold_item *f1 = malloc(sizeof(fold_item)); \
86+
fold_item *f1, *current; \
87+
f1 = malloc(sizeof(fold_item)); \
8588
f1->fun = (void *)callback; \
8689
f1->ctx = closure_context; \
8790
f1->next = NULL; \
88-
fold_item *current = redis_sock->current;\
91+
current = redis_sock->current;\
8992
if(current) current->next = f1; \
9093
redis_sock->current = f1; \
9194
if(NULL == redis_sock->head) { \

Diff for: config.w32

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// vim: ft=javascript:
2+
3+
ARG_ENABLE("redis", "whether to enable redis support", "yes");
4+
ARG_ENABLE("redis-session", "whether to enable sessions", "yes");
5+
6+
if (PHP_REDIS != "no") {
7+
var sources = "redis.c library.c igbinary\\igbinary.c igbinary\\hash_si.c igbinary\\hash_function.c";
8+
if (PHP_REDIS_SESSION != "no") {
9+
AC_DEFINE('PHP_SESSION', 1);
10+
sources += " redis_session.c";
11+
}
12+
13+
AC_DEFINE("PHP_EXPORTS", 1);
14+
EXTENSION("redis", sources);
15+
}

Diff for: igbinary/hash_function.c

+3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
lookup3.c, by Bob Jenkins, May 2006, Public Domain.
44
*/
55

6+
#ifndef _MSC_VER
67
#include <sys/param.h> /* attempt to define endianness */
8+
#endif
9+
710
#ifdef linux
811
# include <endian.h> /* attempt to define endianness */
912
#endif

Diff for: igbinary/hash_si.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
#include "hash.h"
1414
#include "hash_function.h"
1515

16+
#ifdef _MSC_VER
17+
#define INLINE __forceinline /* use __forceinline (VC++ specific) */
18+
#else
19+
#define INLINE inline /* use standard inline */
20+
#endif
21+
1622
/* {{{ nextpow2 */
1723
/** Next power of 2.
1824
* @param n Integer.
1925
* @return next to n power of 2 .
2026
*/
21-
inline static uint32_t nextpow2(uint32_t n) {
27+
INLINE static uint32_t nextpow2(uint32_t n) {
2228
uint32_t m = 1;
2329
while (m < n) {
2430
m = m << 1;
@@ -66,7 +72,7 @@ void hash_si_deinit(struct hash_si *h) {
6672
* @param key_len Key length.
6773
* @return index.
6874
*/
69-
inline static size_t _hash_si_find(struct hash_si *h, const char *key, size_t key_len) {
75+
INLINE static size_t _hash_si_find(struct hash_si *h, const char *key, size_t key_len) {
7076
uint32_t hv;
7177
size_t size;
7278

@@ -155,7 +161,7 @@ int hash_si_remove(struct hash_si *h, const char *key, size_t key_len, uint32_t
155161
/** Rehash/resize hash_si.
156162
* @param h Pointer to hash_si struct.
157163
*/
158-
inline static void hash_si_rehash(struct hash_si *h) {
164+
INLINE static void hash_si_rehash(struct hash_si *h) {
159165
uint32_t hv;
160166
int i;
161167
struct hash_si newh;

Diff for: igbinary/igbinary.c

+15-14
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ int igbinary_unserialize(const uint8_t *buf, size_t buf_len, zval **z TSRMLS_DC)
294294
/* }}} */
295295
/* {{{ proto string igbinary_unserialize(mixed value) */
296296
PHP_FUNCTION(igbinary_unserialize) {
297+
char *string;
298+
int string_len;
299+
297300
(void) return_value_ptr;
298301
(void) this_ptr;
299302
(void) return_value_used;
300303

301-
char *string;
302-
int string_len;
303-
304304
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
305305
RETURN_NULL();
306306
}
@@ -316,13 +316,13 @@ PHP_FUNCTION(igbinary_unserialize) {
316316
/* }}} */
317317
/* {{{ proto mixed igbinary_serialize(string value) */
318318
PHP_FUNCTION(igbinary_serialize) {
319+
zval *z;
320+
struct igbinary_serialize_data igsd;
321+
319322
(void) return_value_ptr;
320323
(void) this_ptr;
321324
(void) return_value_used;
322325

323-
zval *z;
324-
struct igbinary_serialize_data igsd;
325-
326326
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z) == FAILURE) {
327327
RETURN_NULL();
328328
}
@@ -608,13 +608,14 @@ inline static int igbinary_serialize_long(struct igbinary_serialize_data *igsd,
608608
/* }}} */
609609
/* {{{ igbinary_serialize_double */
610610
/** Serializes double. */
611-
inline static int igbinary_serialize_double(struct igbinary_serialize_data *igsd, double d TSRMLS_DC) {
612-
igbinary_serialize8(igsd, igbinary_type_double TSRMLS_CC);
613-
611+
inline static int igbinary_serialize_double(struct igbinary_serialize_data *igsd, double d TSRMLS_DC)
612+
{
614613
union {
615614
double d;
616615
uint64_t u;
617616
} u;
617+
618+
igbinary_serialize8(igsd, igbinary_type_double TSRMLS_CC);
618619

619620
u.d = d;
620621

@@ -1295,18 +1296,18 @@ inline static int igbinary_unserialize_long(struct igbinary_unserialize_data *ig
12951296
/* {{{ igbinary_unserialize_double */
12961297
/** Unserializes double. */
12971298
inline static int igbinary_unserialize_double(struct igbinary_unserialize_data *igsd, enum igbinary_type t, double *ret TSRMLS_DC) {
1299+
union {
1300+
double d;
1301+
uint64_t u;
1302+
} u;
1303+
12981304
(void) t;
12991305

13001306
if (igsd->buffer_offset + 8 > igsd->buffer_size) {
13011307
zend_error(E_WARNING, "igbinary_unserialize_double: end-of-data");
13021308
return 1;
13031309
}
13041310

1305-
union {
1306-
double d;
1307-
uint64_t u;
1308-
} u;
1309-
13101311
u.u = igbinary_unserialize64(igsd TSRMLS_CC);
13111312

13121313
*ret = u.d;

Diff for: igbinary/igbinary.h

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
#define IGBINARY_VERSION "1.0.2"
1515

16+
#ifdef _MSC_VER
17+
#define __func__ __FUNCTION__
18+
#endif
19+
1620
/** Serialize zval.
1721
* Return buffer is allocated by this function with emalloc.
1822
* @param[out] ret Return buffer

0 commit comments

Comments
 (0)