Fixed compilation issues with Clang.

(GitHub issue #116).
This commit is contained in:
Nicolas Favre-Felix
2012-01-30 21:12:53 +00:00
parent 5d8839f15e
commit a5e53f1bbc
4 changed files with 44 additions and 15 deletions
+2
View File
@@ -32,6 +32,7 @@ PHPAPI void redis_stream_close(RedisSock *redis_sock TSRMLS_DC);
PHPAPI int redis_check_eof(RedisSock *redis_sock TSRMLS_DC);
//PHPAPI int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC);
PHPAPI void redis_free_socket(RedisSock *redis_sock);
PHPAPI void redis_send_discard(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock);
PHPAPI int
redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_DC);
@@ -40,3 +41,4 @@ redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len TSRMLS_DC);
PHPAPI int
redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval **return_value TSRMLS_DC);
+26 -3
View File
@@ -2186,7 +2186,19 @@ PHPAPI int generic_multiple_args_cmd(INTERNAL_FUNCTION_PARAMETERS, char *keyword
cmd[cmd_len] = 0;
php_printf("cmd=[%s]\n", cmd);
*/
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
/* call REDIS_PROCESS_REQUEST and skip void returns */
IF_MULTI_OR_ATOMIC() {
if(redis_sock_write(redis_sock, cmd, cmd_len TSRMLS_CC) < 0) {
efree(cmd);
return FAILURE;
}
efree(cmd);
}
IF_PIPELINE() {
PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len);
efree(cmd);
}
return SUCCESS;
}
@@ -3164,7 +3176,7 @@ generic_mset(INTERNAL_FUNCTION_PARAMETERS, char *kw, void (*fun)(INTERNAL_FUNCTI
}
val_free = redis_serialize(redis_sock, *z_value_pp, &val, &val_len TSRMLS_CC);
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
key_free = redis_key_prefix(redis_sock, &key, (int*)&key_len TSRMLS_CC);
if(step == 0) { /* counting */
cmd_len += 1 + integer_length(key_len) + 2
@@ -4234,7 +4246,18 @@ generic_hash_command_1(INTERNAL_FUNCTION_PARAMETERS, char *keyword, int keyword_
cmd_len = redis_cmd_format_static(&cmd, keyword, "s", key, key_len);
if(key_free) efree(key);
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
/* call REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len) without breaking the return value */
IF_MULTI_OR_ATOMIC() {
if(redis_sock_write(redis_sock, cmd, cmd_len TSRMLS_CC) < 0) {
efree(cmd);
return NULL;
}
efree(cmd);
}
IF_PIPELINE() {
PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len);
efree(cmd);
}
return redis_sock;
}
+5 -4
View File
@@ -792,8 +792,9 @@ PHP_METHOD(RedisArray, mset)
HashPosition pointer;
zval **redis_instances, *redis_inst, **argv;
char *key, **keys;
int key_len, type, *key_lens;
long idx;
unsigned int key_len;
int type, *key_lens;
unsigned long idx;
/* Multi/exec support */
HANDLE_MULTI_EXEC("MSET");
@@ -833,11 +834,11 @@ PHP_METHOD(RedisArray, mset)
continue;
}
redis_instances[i] = ra_find_node(ra, key, key_len - 1, &pos[i] TSRMLS_CC); /* -1 because of PHP assoc keys which count \0... */
redis_instances[i] = ra_find_node(ra, key, (int)key_len - 1, &pos[i] TSRMLS_CC); /* -1 because of PHP assoc keys which count \0... */
argc_each[pos[i]]++; /* count number of keys per node */
argv[i] = *data;
keys[i] = key;
key_lens[i] = key_len - 1;
key_lens[i] = (int)key_len - 1;
}
+11 -8
View File
@@ -501,20 +501,20 @@ ra_index_keys(zval *z_pairs, zval *z_redis TSRMLS_DC) {
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(z_pairs), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(z_pairs), (void **)&z_entry_pp, &pos) == SUCCESS) {
char *key;
int key_len;
long num_key;
unsigned int key_len;
unsigned long num_key;
zval *z_new;
MAKE_STD_ZVAL(z_new);
switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(z_pairs), &key, &key_len, &num_key, 1, &pos)) {
case HASH_KEY_IS_STRING:
ZVAL_STRINGL(z_new, key, key_len - 1, 0);
ZVAL_STRINGL(z_new, key, (int)key_len - 1, 0);
zend_hash_next_index_insert(Z_ARRVAL_P(z_keys), &z_new, sizeof(zval *), NULL);
break;
case HASH_KEY_IS_LONG:
Z_TYPE_P(z_new) = IS_LONG;
Z_LVAL_P(z_new) = num_key;
Z_LVAL_P(z_new) = (long)num_key;
zend_hash_next_index_insert(Z_ARRVAL_P(z_keys), &z_new, sizeof(zval *), NULL);
break;
}
@@ -775,6 +775,8 @@ ra_del_key(const char *key, int key_len, zval *z_from TSRMLS_DC) {
/* close transaction */
ra_index_exec(z_from, NULL, 0 TSRMLS_CC);
return 1;
}
static zend_bool
@@ -806,8 +808,9 @@ ra_move_zset(const char *key, int key_len, zval *z_from, zval *z_to, long ttl TS
int count;
HashTable *h_zset_vals;
char *val;
int val_len, i;
long idx;
unsigned int val_len;
int i;
unsigned long idx;
int type;
/* run ZRANGE key 0 -1 WITHSCORES on source */
@@ -855,10 +858,10 @@ ra_move_zset(const char *key, int key_len, zval *z_from, zval *z_to, long ttl TS
MAKE_STD_ZVAL(z_zadd_args[i+1]);
switch (zend_hash_get_current_key_ex(h_zset_vals, &val, &val_len, &idx, 0, NULL)) {
case HASH_KEY_IS_STRING:
ZVAL_STRINGL(z_zadd_args[i+1], val, val_len-1, 0); /* we have to remove 1 because it is an array key. */
ZVAL_STRINGL(z_zadd_args[i+1], val, (int)val_len-1, 0); /* we have to remove 1 because it is an array key. */
break;
case HASH_KEY_IS_LONG:
ZVAL_LONG(z_zadd_args[i+1], idx);
ZVAL_LONG(z_zadd_args[i+1], (long)idx);
break;
default:
return -1; // Todo: log error