Hi! After running this patch, the binary protocol breaks on mget test. Cheers, -Brian On Jul 18, 2009, at 3:10 PM, Monty Taylor wrote: > Monty Taylor has proposed merging lp:~mordred/libmemcached/pandora- > build-write-strings into lp:libmemcached. > > Requested reviews: > Brian Aker (brianaker) > > Build fixes for solaris. Also Padraig's build fixes. > -- > https://code.launchpad.net/~mordred/libmemcached/pandora-build-write- > strings/+merge/9006 > You are requested to review the proposed merge of lp:~mordred/ > libmemcached/pandora-build-write-strings into lp:libmemcached. > === modified file 'libmemcached/memcached_analyze.c' > --- libmemcached/memcached_analyze.c 2009-06-14 21:24:48 +0000 > +++ libmemcached/memcached_analyze.c 2009-07-18 17:08:37 +0000 > @@ -24,10 +24,10 @@ > > static void calc_least_free_node(memcached_analysis_st *result, > const uint32_t server_num, > - const long max_allowed_bytes, > - const long used_bytes) > + const uint64_t max_allowed_bytes, > + const uint64_t used_bytes) > { > - uint64_t remaining_bytes= (uint64_t)max_allowed_bytes - used_bytes; > + uint64_t remaining_bytes= max_allowed_bytes - used_bytes; > > if (result->least_remaining_bytes == 0 || > remaining_bytes < result->least_remaining_bytes) > @@ -42,7 +42,7 @@ > const uint64_t total_bytes) > { > if (total_items > 0 && total_bytes > 0) > - result->average_item_size= total_bytes / total_items; > + result->average_item_size= (uint32_t) (total_bytes / > total_items); > } > > static void calc_hit_ratio(memcached_analysis_st *result, > @@ -55,7 +55,7 @@ > return; > } > > - double temp= (double)total_get_hits/total_get_cmds; > + double temp= (double) (total_get_hits/total_get_cmds); > result->pool_hit_ratio= temp * 100; > } > > @@ -84,7 +84,8 @@ > calc_largest_consumption(result, x, memc_stat[x].bytes); > calc_oldest_node(result, x, memc_stat[x].uptime); > calc_least_free_node(result, x, > - memc_stat[x].limit_maxbytes, > memc_stat[x].bytes); > + memc_stat[x].limit_maxbytes, > + memc_stat[x].bytes); > > total_get_hits+= memc_stat[x].get_hits; > total_get_cmds+= memc_stat[x].cmd_get; > > === modified file 'libmemcached/memcached_auto.c' > --- libmemcached/memcached_auto.c 2009-07-08 13:38:34 +0000 > +++ libmemcached/memcached_auto.c 2009-07-18 17:09:05 +0000 > @@ -85,13 +85,13 @@ > > request.message.header.request.magic= PROTOCOL_BINARY_REQ; > request.message.header.request.opcode= cmd; > - request.message.header.request.keylen= htons(key_length); > + request.message.header.request.keylen= htons((uint16_t) > key_length); > request.message.header.request.extlen= 20; > request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; > - request.message.header.request.bodylen= htonl(key_length + > request.message.header.request.extlen); > + request.message.header.request.bodylen= htonl((uint32_t) > (key_length + request.message.header.request.extlen)); > request.message.body.delta= htonll(offset); > request.message.body.initial= htonll(initial); > - request.message.body.expiration= htonl(expiration); > + request.message.body.expiration= htonl((uint32_t) expiration); > > if ((memcached_do(&ptr->hosts[server_key], request.bytes, > sizeof(request.bytes), 0)!=MEMCACHED_SUCCESS) || > > === modified file 'libmemcached/memcached_behavior.c' > --- libmemcached/memcached_behavior.c 2009-07-08 23:12:50 +0000 > +++ libmemcached/memcached_behavior.c 2009-07-18 17:09:22 +0000 > @@ -28,13 +28,13 @@ > ptr->number_of_replicas= (uint32_t)data; > break; > case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: > - ptr->io_msg_watermark= (int32_t)data; > + ptr->io_msg_watermark= (uint32_t) data; > break; > case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: > - ptr->io_bytes_watermark= (int32_t)data; > + ptr->io_bytes_watermark= (uint32_t)data; > break; > case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: > - ptr->io_key_prefetch = (int32_t)data; > + ptr->io_key_prefetch = (uint32_t)data; > break; > case MEMCACHED_BEHAVIOR_SND_TIMEOUT: > ptr->snd_timeout= (int32_t)data; > @@ -77,7 +77,7 @@ > ptr->distribution= (memcached_server_distribution)(data); > if (ptr->distribution == MEMCACHED_DISTRIBUTION_RANDOM) > { > - srandom(time(NULL)); > + srandom((uint32_t) time(NULL)); > } > run_distribution(ptr); > break; > @@ -214,7 +214,7 @@ > case MEMCACHED_BEHAVIOR_DISTRIBUTION: > return ptr->distribution; > case MEMCACHED_BEHAVIOR_KETAMA: > - return (ptr->distribution == > MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) ? 1 : 0; > + return (ptr->distribution == > MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) ? (uint64_t) 1 : 0; > case MEMCACHED_BEHAVIOR_HASH: > return ptr->hash; > case MEMCACHED_BEHAVIOR_KETAMA_HASH: > @@ -254,7 +254,7 @@ > SO_SNDBUF, &sock_size, &sock_length)) > return 0; /* Zero means error */ > > - return sock_size; > + return (uint64_t) sock_size; > } > case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: > { > @@ -270,7 +270,7 @@ > SO_RCVBUF, &sock_size, &sock_length)) > return 0; /* Zero means error */ > > - return sock_size; > + return (uint64_t) sock_size; > } > case MEMCACHED_BEHAVIOR_USER_DATA: > return MEMCACHED_FAILURE; > > === modified file 'libmemcached/memcached_connect.c' > --- libmemcached/memcached_connect.c 2009-05-19 20:32:02 +0000 > +++ libmemcached/memcached_connect.c 2009-07-18 17:09:41 +0000 > @@ -152,7 +152,7 @@ > servAddr.sun_family= AF_UNIX; > strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */ > > - addrlen= strlen(servAddr.sun_path) + sizeof(servAddr.sun_family); > + addrlen= (socklen_t) (strlen(servAddr.sun_path) + > sizeof(servAddr.sun_family)); > > test_connect: > if (connect(ptr->fd, > > === modified file 'libmemcached/memcached_delete.c' > --- libmemcached/memcached_delete.c 2009-07-01 19:36:25 +0000 > +++ libmemcached/memcached_delete.c 2009-07-18 17:09:59 +0000 > @@ -12,14 +12,14 @@ > unsigned int server_key, > const char *key, > size_t key_length, > - int flush); > + uint8_t flush); > > memcached_return memcached_delete_by_key(memcached_st *ptr, > const char *master_key, > size_t master_key_length, > const char *key, size_t > key_length, > time_t expiration) > { > - char to_write; > + uint8_t to_write; > size_t send_length; > memcached_return rc; > char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; > @@ -36,7 +36,7 @@ > return MEMCACHED_NO_SERVERS; > > server_key= memcached_generate_hash(ptr, master_key, > master_key_length); > - to_write= (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1; > + to_write= (uint8_t) (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1; > bool no_reply= (ptr->flags & MEM_NOREPLY); > > if (ptr->flags & MEM_BINARY_PROTOCOL) > @@ -44,16 +44,16 @@ > else > { > if (expiration) > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "delete %s%.*s %u%s\r\n", > - ptr->prefix_key, > - (int)key_length, key, > - (uint32_t)expiration, no_reply ? " > noreply" :"" ); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "delete %s%.*s %u%s\r\n", > + ptr->prefix_key, > + (int) key_length, key, > + (uint32_t)expiration, > no_reply ? " noreply" :"" ); > else > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "delete %s%.*s%s\r\n", > - ptr->prefix_key, > - (int)key_length, key, no_reply ? " > noreply" :""); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "delete %s%.*s%s\r\n", > + ptr->prefix_key, > + (int)key_length, key, > no_reply ? " noreply" :""); > > if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) > { > @@ -96,7 +96,7 @@ > unsigned int server_key, > const char *key, > size_t key_length, > - int flush) > + uint8_t flush) > { > protocol_binary_request_delete request= {.bytes= {0}}; > > @@ -107,7 +107,7 @@ > request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE; > request.message.header.request.keylen= htons((uint16_t)key_length); > request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; > - request.message.header.request.bodylen= htonl(key_length); > + request.message.header.request.bodylen= htonl((uint32_t) > key_length); > > if (ptr->flags & MEM_USE_UDP && !flush) > { > @@ -123,7 +123,7 @@ > if ((memcached_do(&ptr->hosts[server_key], request.bytes, > sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || > (memcached_io_write(&ptr->hosts[server_key], key, > - key_length, flush) == -1)) > + key_length, (char) flush) == -1)) > { > memcached_io_reset(&ptr->hosts[server_key]); > rc= MEMCACHED_WRITE_FAILURE; > @@ -142,7 +142,7 @@ > memcached_server_st* server= &ptr->hosts[server_key]; > if ((memcached_do(server, (const char*)request.bytes, > sizeof(request.bytes), 0) != > MEMCACHED_SUCCESS) || > - (memcached_io_write(server, key, key_length, flush) == -1)) > + (memcached_io_write(server, key, key_length, (char) > flush) == -1)) > memcached_io_reset(server); > else > memcached_server_response_decrement(server); > > === modified file 'libmemcached/memcached_do.c' > --- libmemcached/memcached_do.c 2009-03-09 21:59:06 +0000 > +++ libmemcached/memcached_do.c 2009-07-18 17:10:13 +0000 > @@ -23,7 +23,7 @@ > if (ptr->type == MEMCACHED_CONNECTION_UDP && with_flush && ptr- > >write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH) > memcached_io_write(ptr, NULL, 0, 1); > > - sent_length= memcached_io_write(ptr, command, command_length, > with_flush); > + sent_length= memcached_io_write(ptr, command, command_length, > (char) with_flush); > > if (sent_length == -1 || (size_t)sent_length != command_length) > rc= MEMCACHED_WRITE_FAILURE; > > === modified file 'libmemcached/memcached_dump.c' > --- libmemcached/memcached_dump.c 2009-07-07 21:57:24 +0000 > +++ libmemcached/memcached_dump.c 2009-07-18 17:10:35 +0000 > @@ -23,8 +23,8 @@ > /* 256 I BELIEVE is the upper limit of slabs */ > for (x= 0; x < 256; x++) > { > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "stats cachedump %u 0 0\r\n", x); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "stats cachedump %u 0 0\r\n", > x); > > rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, > 1); > > > === modified file 'libmemcached/memcached_flush.c' > --- libmemcached/memcached_flush.c 2009-03-09 21:59:06 +0000 > +++ libmemcached/memcached_flush.c 2009-07-18 17:10:56 +0000 > @@ -33,12 +33,12 @@ > { > bool no_reply= (ptr->flags & MEM_NOREPLY); > if (expiration) > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "flush_all %llu%s\r\n", > - (unsigned long long)expiration, > no_reply ? " noreply" : ""); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "flush_all %llu%s\r\n", > + (unsigned long > long)expiration, no_reply ? " noreply" : ""); > else > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "flush_all%s\r\n", no_reply ? " > noreply" : ""); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "flush_all%s\r\n", no_reply ? > " noreply" : ""); > > rc= memcached_do(&ptr->hosts[x], buffer, send_length, 1); > > @@ -63,7 +63,7 @@ > request.message.header.request.extlen= 4; > request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; > request.message.header.request.bodylen= > htonl(request.message.header.request.extlen); > - request.message.body.expiration= htonl(expiration); > + request.message.body.expiration= htonl((uint32_t) expiration); > > for (x= 0; x < ptr->number_of_hosts; x++) > { > > === modified file 'libmemcached/memcached_get.c' > --- libmemcached/memcached_get.c 2009-07-15 18:26:30 +0000 > +++ libmemcached/memcached_get.c 2009-07-18 17:11:19 +0000 > @@ -59,7 +59,7 @@ > { > if (rc == MEMCACHED_BUFFERED) > { > - uint8_t latch; /* We use latch to track the state of the > original socket */ > + uint64_t latch; /* We use latch to track the state of the > original socket */ > latch= memcached_behavior_get(ptr, > MEMCACHED_BEHAVIOR_BUFFER_REQUESTS); > if (latch == 0) > memcached_behavior_set(ptr, > MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1); > @@ -306,12 +306,12 @@ > > request.message.header.request.keylen= > htons((uint16_t)key_length[x]); > request.message.header.request.datatype= > PROTOCOL_BINARY_RAW_BYTES; > - request.message.header.request.bodylen= htonl(key_length[x]); > + request.message.header.request.bodylen= htonl((uint32_t) > key_length[x]); > > if ((memcached_io_write(&ptr->hosts[server_key], request.bytes, > sizeof(request.bytes), 0) == -1) || > (memcached_io_write(&ptr->hosts[server_key], keys[x], > - key_length[x], flush) == -1)) > + key_length[x], (char) flush) == -1)) > { > memcached_server_response_reset(&ptr->hosts[server_key]); > rc= MEMCACHED_SOME_ERRORS; > @@ -405,12 +405,12 @@ > > request.message.header.request.keylen= > htons((uint16_t)key_length[x]); > request.message.header.request.datatype= > PROTOCOL_BINARY_RAW_BYTES; > - request.message.header.request.bodylen= htonl(key_length[x]); > + request.message.header.request.bodylen= htonl((uint32_t) > key_length[x]); > > if ((memcached_io_write(&ptr->hosts[server], request.bytes, > sizeof(request.bytes), 0) == -1) || > (memcached_io_write(&ptr->hosts[server], keys[x], > - key_length[x], flush) == -1)) > + key_length[x], (char) flush) == -1)) > { > memcached_io_reset(&ptr->hosts[server]); > dead_servers[server]= true; > > === modified file 'libmemcached/memcached_hash.c' > --- libmemcached/memcached_hash.c 2009-07-01 16:18:18 +0000 > +++ libmemcached/memcached_hash.c 2009-07-18 17:11:32 +0000 > @@ -47,11 +47,11 @@ > break; > case MEMCACHED_HASH_FNV1A_64: > { > - hash= FNV_64_INIT; > + hash= (uint32_t) FNV_64_INIT; > for (x= 0; x < key_length; x++) > { > hash ^= key[x]; > - hash *= FNV_64_PRIME; > + hash *= (uint32_t) FNV_64_PRIME; > } > } > break; > @@ -146,7 +146,7 @@ > case MEMCACHED_DISTRIBUTION_MODULA: > return hash % ptr->number_of_hosts; > case MEMCACHED_DISTRIBUTION_RANDOM: > - return random() % ptr->number_of_hosts; > + return (uint32_t) random() % ptr->number_of_hosts; > default: > WATCHPOINT_ASSERT(0); /* We have added a distribution without > extending the logic */ > return hash % ptr->number_of_hosts; > @@ -201,11 +201,11 @@ > static uint32_t internal_generate_hash(const char *key, size_t > key_length) > { > const char *ptr= key; > - uint32_t value= 0; > + int32_t value= 0; > > while (key_length--) > { > - value += *ptr++; > + value += (int32_t) *ptr++; > value += (value << 10); > value ^= (value >> 6); > } > @@ -213,7 +213,7 @@ > value ^= (value >> 11); > value += (value << 15); > > - return value == 0 ? 1 : value; > + return value == 0 ? 1 : (uint32_t) value; > } > > static uint32_t internal_generate_md5(const char *key, size_t > key_length) > > === modified file 'libmemcached/memcached_hosts.c' > --- libmemcached/memcached_hosts.c 2009-06-14 21:24:48 +0000 > +++ libmemcached/memcached_hosts.c 2009-07-18 17:11:59 +0000 > @@ -29,7 +29,7 @@ > if (ptr->number_of_hosts) > { > qsort(ptr->hosts, ptr->number_of_hosts, > sizeof(memcached_server_st), compare_servers); > - ptr->hosts[0].count= ptr->number_of_hosts; > + ptr->hosts[0].count= (uint16_t) ptr->number_of_hosts; > } > } > > @@ -111,8 +111,8 @@ > uint32_t pointer_per_server= MEMCACHED_POINTS_PER_SERVER; > uint32_t pointer_per_hash= 1; > uint64_t total_weight= 0; > - uint32_t is_ketama_weighted= 0; > - uint32_t is_auto_ejecting= 0; > + uint64_t is_ketama_weighted= 0; > + uint64_t is_auto_ejecting= 0; > uint32_t points_per_server= 0; > uint32_t live_servers= 0; > struct timeval now; > @@ -146,7 +146,7 @@ > live_servers= ptr->number_of_hosts; > > is_ketama_weighted= memcached_behavior_get(ptr, > MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); > - points_per_server= is_ketama_weighted ? > MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER; > + points_per_server= (uint32_t) (is_ketama_weighted ? > MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER); > > if (live_servers == 0) > return MEMCACHED_SUCCESS; > @@ -186,7 +186,7 @@ > if (is_ketama_weighted) > { > float pct = (float)list[host_index].weight / > (float)total_weight; > - pointer_per_server= floorf(pct * > MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + > 0.0000000001) * 4; > + pointer_per_server= (uint32_t) ((floorf((float) (pct * > MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + > 0.0000000001))) * 4); > pointer_per_hash= 4; > #ifdef DEBUG > printf("ketama_weighted:%s|%d|%llu|%u\n", > @@ -205,18 +205,18 @@ > > if (list[host_index].port == MEMCACHED_DEFAULT_PORT) > { > - sort_host_length= snprintf(sort_host, > MEMCACHED_MAX_HOST_SORT_LENGTH, > - "%s-%d", > - list[host_index].hostname, > - pointer_index - 1); > + sort_host_length= (size_t) snprintf(sort_host, > MEMCACHED_MAX_HOST_SORT_LENGTH, > + "%s-%d", > + > list[host_index].hostname, > + pointer_index - 1); > > } > else > { > - sort_host_length= snprintf(sort_host, > MEMCACHED_MAX_HOST_SORT_LENGTH, > - "%s:%d-%d", > - list[host_index].hostname, > - list[host_index].port, > pointer_index - 1); > + sort_host_length= (size_t) snprintf(sort_host, > MEMCACHED_MAX_HOST_SORT_LENGTH, > + "%s:%d-%d", > + > list[host_index].hostname, > + list[host_index].port, > pointer_index - 1); > } > WATCHPOINT_ASSERT(sort_host_length); > > @@ -225,7 +225,7 @@ > unsigned int i; > for (i = 0; i < pointer_per_hash; i++) > { > - value= ketama_server_hash(sort_host, sort_host_length, i); > + value= ketama_server_hash(sort_host, (uint32_t) > sort_host_length, (int) i); > ptr->continuum[continuum_index].index= host_index; > ptr->continuum[continuum_index++].value= value; > } > @@ -289,7 +289,7 @@ > list[x].port, list[x].weight, > list[x].type); > ptr->number_of_hosts++; > } > - ptr->hosts[0].count= ptr->number_of_hosts; > + ptr->hosts[0].count= (uint16_t) ptr->number_of_hosts; > > return run_distribution(ptr); > } > @@ -374,7 +374,7 @@ > /* TODO: Check return type */ > (void)memcached_server_create_with(ptr, &ptr->hosts[ptr- > >number_of_hosts], hostname, port, weight, type); > ptr->number_of_hosts++; > - ptr->hosts[0].count= ptr->number_of_hosts; > + ptr->hosts[0].count= (uint16_t) ptr->number_of_hosts; > > return run_distribution(ptr); > } > @@ -445,7 +445,7 @@ > memcached_server_create_with(NULL, &new_host_list[count-1], > hostname, port, weight, MEMCACHED_CONNECTION_TCP); > > /* Backwards compatibility hack */ > - new_host_list[0].count= count; > + new_host_list[0].count= (uint16_t) count; > > *error= MEMCACHED_SUCCESS; > return new_host_list; > > === modified file 'libmemcached/memcached_io.c' > --- libmemcached/memcached_io.c 2009-06-14 21:24:48 +0000 > +++ libmemcached/memcached_io.c 2009-07-18 17:37:40 +0000 > @@ -146,8 +146,8 @@ > } > > ptr->io_bytes_sent = 0; > - ptr->read_data_length= data_read; > - ptr->read_buffer_length= data_read; > + ptr->read_data_length= (size_t) data_read; > + ptr->read_buffer_length= (size_t) data_read; > ptr->read_ptr= ptr->read_buffer; > } > > @@ -174,7 +174,7 @@ > } > > ptr->server_failure_counter= 0; > - *nread = (size_t)(buffer_ptr - (char*)buffer); > + *nread = (ssize_t)(buffer_ptr - (char*)buffer); > return MEMCACHED_SUCCESS; > } > > @@ -242,7 +242,7 @@ > return -1; > } > > - return original_length; > + return (ssize_t) original_length; > } > > memcached_return memcached_io_close(memcached_server_st *ptr) > @@ -408,11 +408,11 @@ > return -1; > } > > - ptr->io_bytes_sent += sent_length; > + ptr->io_bytes_sent += (uint32_t) sent_length; > > local_write_ptr+= sent_length; > - write_length-= sent_length; > - return_length+= sent_length; > + write_length-= (uint32_t) sent_length; > + return_length+= (uint32_t) sent_length; > } > > WATCHPOINT_ASSERT(write_length == 0); > @@ -426,7 +426,7 @@ > else > ptr->write_buffer_offset= 0; > > - return return_length; > + return (ssize_t) return_length; > } > > /* > @@ -456,7 +456,7 @@ > if (rc != MEMCACHED_SUCCESS) > return rc; > > - offset+= nread; > + offset+= (size_t) nread; > } > > return MEMCACHED_SUCCESS; > @@ -524,13 +524,13 @@ > { > struct udp_datagram_header_st *header= (struct > udp_datagram_header_st *)ptr->write_buffer; > uint16_t cur_req= get_udp_datagram_request_id(header); > - uint16_t msg_num= get_msg_num_from_request_id(cur_req); > - uint16_t thread_id= get_thread_id_from_request_id(cur_req); > + int msg_num= get_msg_num_from_request_id(cur_req); > + int thread_id= get_thread_id_from_request_id(cur_req); > > if (((++msg_num) & UDP_REQUEST_ID_THREAD_MASK) != 0) > msg_num= 0; > > - header->request_id= htons(thread_id | msg_num); > + header->request_id= htons((uint16_t) (thread_id | msg_num)); > } > > memcached_return memcached_io_init_udp_header(memcached_server_st > *ptr, uint16_t thread_id) > @@ -539,7 +539,7 @@ > return MEMCACHED_FAILURE; > > struct udp_datagram_header_st *header= (struct > udp_datagram_header_st *)ptr->write_buffer; > - header->request_id= > htons(generate_udp_request_thread_id(thread_id)); > + header->request_id= htons((uint16_t) > (generate_udp_request_thread_id(thread_id))); > header->num_datagrams= htons(1); > header->sequence_number= htons(0); > > > === modified file 'libmemcached/memcached_parse.c' > --- libmemcached/memcached_parse.c 2009-07-06 17:20:04 +0000 > +++ libmemcached/memcached_parse.c 2009-07-18 17:37:40 +0000 > @@ -10,7 +10,7 @@ > memcached_server_st *memcached_servers_parse(const char > *server_strings) > { > char *string; > - unsigned int port; > + uint32_t port; > uint32_t weight; > const char *begin_ptr; > const char *end_ptr; > @@ -32,7 +32,7 @@ > > if (string) > { > - memcpy(buffer, begin_ptr, string - begin_ptr); > + memcpy(buffer, begin_ptr, (size_t) (string - begin_ptr)); > buffer[(unsigned int)(string - begin_ptr)]= 0; > begin_ptr= string+1; > } > @@ -52,7 +52,7 @@ > > ptr++; > > - port= strtoul(ptr, (char **)NULL, 10); > + port= (uint32_t) strtoul(ptr, (char **)NULL, 10); > > ptr2= index(ptr, ' '); > if (! ptr2) > @@ -60,7 +60,7 @@ > if (ptr2) > { > ptr2++; > - weight = strtoul(ptr2, (char **)NULL, 10); > + weight = (uint32_t) strtoul(ptr2, (char **)NULL, 10); > } > } > > > === modified file 'libmemcached/memcached_purge.c' > --- libmemcached/memcached_purge.c 2009-05-13 07:43:30 +0000 > +++ libmemcached/memcached_purge.c 2009-07-18 17:37:40 +0000 > @@ -42,7 +42,7 @@ > * data to be sent from the server (the commands was in the > output buffer > * and just flushed > */ > - long timeo= ptr->root->poll_timeout; > + int32_t timeo= ptr->root->poll_timeout; > ptr->root->poll_timeout= 2000; > > result_ptr= memcached_result_create(ptr->root, &result); > @@ -68,7 +68,7 @@ > } > > memcached_result_free(result_ptr); > - ptr->root->poll_timeout=timeo; > + ptr->root->poll_timeout= timeo; > } > ptr->root->purging= 0; > > > === modified file 'libmemcached/memcached_quit.c' > --- libmemcached/memcached_quit.c 2009-05-02 06:54:30 +0000 > +++ libmemcached/memcached_quit.c 2009-07-18 17:37:40 +0000 > @@ -43,7 +43,7 @@ > memcached_io_close(ptr); > > ptr->fd= -1; > - ptr->write_buffer_offset= (ptr->type == > MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0 ; > + ptr->write_buffer_offset= (size_t) ((ptr->type == > MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0); > ptr->read_buffer_length= 0; > ptr->read_ptr= ptr->read_buffer; > memcached_server_response_reset(ptr); > > === modified file 'libmemcached/memcached_response.c' > --- libmemcached/memcached_response.c 2009-07-15 10:09:06 +0000 > +++ libmemcached/memcached_response.c 2009-07-18 17:37:40 +0000 > @@ -125,7 +125,7 @@ > if (end_ptr == string_ptr) > goto read_error; > for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++); > - result->flags= strtoul(next_ptr, &string_ptr, 10); > + result->flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10); > > if (end_ptr == string_ptr) > goto read_error; > @@ -250,7 +250,9 @@ > memory in the struct, which is important, for something > that > rarely should happen? > */ > - rel_ptr= (char *)ptr->root->call_realloc(ptr->root, ptr- > >cached_server_error, endptr - startptr + 1); > + rel_ptr= (char *)ptr->root->call_realloc(ptr->root, > + ptr- > >cached_server_error, > + (size_t) (endptr > - startptr + 1)); > > if (rel_ptr == NULL) > { > @@ -261,7 +263,7 @@ > } > ptr->cached_server_error= rel_ptr; > > - memcpy(ptr->cached_server_error, startptr, endptr - startptr); > + memcpy(ptr->cached_server_error, startptr, (size_t) (endptr - > startptr)); > ptr->cached_server_error[endptr - startptr]= 0; > return MEMCACHED_SERVER_ERROR; > } > @@ -461,7 +463,7 @@ > size_t nr= (bodylen > SMALL_STRING_LEN) ? SMALL_STRING_LEN : > bodylen; > if (memcached_safe_read(ptr, hole, nr) != MEMCACHED_SUCCESS) > return MEMCACHED_UNKNOWN_READ_FAILURE; > - bodylen -= nr; > + bodylen-= (uint32_t) nr; > } > > /* This might be an error from one of the quiet commands.. if > > === modified file 'libmemcached/memcached_stats.c' > --- libmemcached/memcached_stats.c 2009-07-16 12:11:04 +0000 > +++ libmemcached/memcached_stats.c 2009-07-18 17:37:40 +0000 > @@ -40,15 +40,15 @@ > } > else if (!strcmp("pid", key)) > { > - memc_stat->pid= strtol(value, (char **)NULL, 10); > + memc_stat->pid= (uint32_t) strtol(value, (char **)NULL, 10); > } > else if (!strcmp("uptime", key)) > { > - memc_stat->uptime= strtol(value, (char **)NULL, 10); > + memc_stat->uptime= (uint32_t) strtol(value, (char **)NULL, 10); > } > else if (!strcmp("time", key)) > { > - memc_stat->time= strtol(value, (char **)NULL, 10); > + memc_stat->time= (uint32_t) strtol(value, (char **)NULL, 10); > } > else if (!strcmp("version", key)) > { > @@ -57,7 +57,7 @@ > } > else if (!strcmp("pointer_size", key)) > { > - memc_stat->pointer_size= strtol(value, (char **)NULL, 10); > + memc_stat->pointer_size= (uint32_t) strtol(value, (char > **)NULL, 10); > } > else if (!strcmp("rusage_user", key)) > { > @@ -65,8 +65,8 @@ > for (walk_ptr= value; (!ispunct(*walk_ptr)); walk_ptr++); > *walk_ptr= 0; > walk_ptr++; > - memc_stat->rusage_user_seconds= strtol(value, (char **)NULL, 10); > - memc_stat->rusage_user_microseconds= strtol(walk_ptr, (char > **)NULL, 10); > + memc_stat->rusage_user_seconds= (uint32_t) strtol(value, (char > **)NULL, 10); > + memc_stat->rusage_user_microseconds= (uint32_t) > strtol(walk_ptr, (char **)NULL, 10); > } > else if (!strcmp("rusage_system", key)) > { > @@ -74,52 +74,52 @@ > for (walk_ptr= value; (!ispunct(*walk_ptr)); walk_ptr++); > *walk_ptr= 0; > walk_ptr++; > - memc_stat->rusage_system_seconds= strtol(value, (char **)NULL, > 10); > - memc_stat->rusage_system_microseconds= strtol(walk_ptr, (char > **)NULL, 10); > + memc_stat->rusage_system_seconds= (uint32_t) strtol(value, > (char **)NULL, 10); > + memc_stat->rusage_system_microseconds= (uint32_t) > strtol(walk_ptr, (char **)NULL, 10); > } > else if (!strcmp("curr_items", key)) > { > - memc_stat->curr_items= strtol(value, (char **)NULL, 10); > + memc_stat->curr_items= (uint32_t) strtol(value, (char **)NULL, > 10); > } > else if (!strcmp("total_items", key)) > { > - memc_stat->total_items= strtol(value, (char **)NULL, 10); > + memc_stat->total_items= (uint32_t) strtol(value, (char **)NULL, > 10); > } > else if (!strcmp("bytes_read", key)) > { > - memc_stat->bytes_read= strtoll(value, (char **)NULL, 10); > + memc_stat->bytes_read= (uint32_t) strtoll(value, (char **)NULL, > 10); > } > else if (!strcmp("bytes_written", key)) > { > - memc_stat->bytes_written= strtoll(value, (char **)NULL, 10); > + memc_stat->bytes_written= (uint32_t) strtoll(value, (char > **)NULL, 10); > } > else if (!strcmp("bytes", key)) > { > - memc_stat->bytes= strtoll(value, (char **)NULL, 10); > + memc_stat->bytes= (uint32_t) strtoll(value, (char **)NULL, 10); > } > else if (!strcmp("curr_connections", key)) > { > - memc_stat->curr_connections= strtoll(value, (char **)NULL, 10); > + memc_stat->curr_connections= (uint32_t) strtoll(value, (char > **)NULL, 10); > } > else if (!strcmp("total_connections", key)) > { > - memc_stat->total_connections= strtoll(value, (char **)NULL, 10); > + memc_stat->total_connections= (uint32_t) strtoll(value, (char > **)NULL, 10); > } > else if (!strcmp("connection_structures", key)) > { > - memc_stat->connection_structures= strtol(value, (char **)NULL, > 10); > + memc_stat->connection_structures= (uint32_t) strtol(value, > (char **)NULL, 10); > } > else if (!strcmp("cmd_get", key)) > { > - memc_stat->cmd_get= strtoll(value, (char **)NULL, 10); > + memc_stat->cmd_get= (uint64_t) strtoll(value, (char **)NULL, 10); > } > else if (!strcmp("cmd_set", key)) > { > - memc_stat->cmd_set= strtoll(value, (char **)NULL, 10); > + memc_stat->cmd_set= (uint64_t) strtoll(value, (char **)NULL, 10); > } > else if (!strcmp("get_hits", key)) > { > - memc_stat->get_hits= strtoll(value, (char **)NULL, 10); > + memc_stat->get_hits= (uint64_t) strtoll(value, (char **)NULL, > 10); > } > else if (!strcmp("get_misses", key)) > { > @@ -131,11 +131,11 @@ > } > else if (!strcmp("limit_maxbytes", key)) > { > - memc_stat->limit_maxbytes= strtoll(value, (char **)NULL, 10); > + memc_stat->limit_maxbytes= (uint64_t) strtoll(value, (char > **)NULL, 10); > } > else if (!strcmp("threads", key)) > { > - memc_stat->threads= strtol(value, (char **)NULL, 10); > + memc_stat->threads= (uint32_t) strtol(value, (char **)NULL, 10); > } > else if (!(strcmp("delete_misses", key) == 0 ||/* New stats in the > 1.3 beta */ > strcmp("delete_hits", key) == 0 ||/* Just swallow them > for now.. */ > @@ -162,7 +162,7 @@ > const char *key, memcached_return > *error) > { > char buffer[SMALL_STRING_LEN]; > - size_t length; > + int length; > char *ret; > > *error= MEMCACHED_SUCCESS; > @@ -217,8 +217,8 @@ > return NULL; > } > > - ret= ptr->call_malloc(ptr, length + 1); > - memcpy(ret, buffer, length); > + ret= ptr->call_malloc(ptr, (size_t) (length + 1)); > + memcpy(ret, buffer, (size_t) length); > ret[length]= '\0'; > > return ret; > @@ -239,14 +239,14 @@ > > if (args != NULL) > { > - int len= strlen(args); > + size_t len= strlen(args); > > rc= memcached_validate_key_length(len, true); > unlikely (rc != MEMCACHED_SUCCESS) > return rc; > > request.message.header.request.keylen= htons((uint16_t)len); > - request.message.header.request.bodylen= htonl(len); > + request.message.header.request.bodylen= htonl((uint32_t) len); > > if ((memcached_do(&ptr->hosts[server_key], request.bytes, > sizeof(request.bytes), 0) != > MEMCACHED_SUCCESS) || > @@ -305,11 +305,11 @@ > size_t send_length; > > if (args) > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "stats %s\r\n", args); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "stats %s\r\n", args); > else > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "stats\r\n"); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "stats\r\n"); > > if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) > return MEMCACHED_WRITE_FAILURE; > > === modified file 'libmemcached/memcached_storage.c' > --- libmemcached/memcached_storage.c 2009-07-08 13:38:34 +0000 > +++ libmemcached/memcached_storage.c 2009-07-18 17:37:40 +0000 > @@ -91,14 +91,14 @@ > server_key= memcached_generate_hash(ptr, master_key, > master_key_length); > > if (cas) > - write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "%s %s%.*s %u %llu %zu %llu%s\r\n", > - storage_op_string(verb), > - ptr->prefix_key, > - (int)key_length, key, flags, > - (unsigned long long)expiration, > value_length, > - (unsigned long long)cas, > - (ptr->flags & MEM_NOREPLY) ? " > noreply" : ""); > + write_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "%s %s%.*s %u %llu %zu %llu%s\r > \n", > + storage_op_string(verb), > + ptr->prefix_key, > + (int)key_length, key, flags, > + (unsigned long long)expiration, > value_length, > + (unsigned long long)cas, > + (ptr->flags & MEM_NOREPLY) ? " > noreply" : ""); > else > { > char *buffer_ptr= buffer; > @@ -118,11 +118,11 @@ > buffer_ptr++; > > write_length= (size_t)(buffer_ptr - buffer); > - write_length+= snprintf(buffer_ptr, > MEMCACHED_DEFAULT_COMMAND_SIZE, > - "%u %llu %zu%s\r\n", > - flags, > - (unsigned long long)expiration, > value_length, > - (ptr->flags & MEM_NOREPLY) ? " > noreply" : ""); > + write_length+= (size_t) snprintf(buffer_ptr, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "%u %llu %zu%s\r\n", > + flags, > + (unsigned long > long)expiration, value_length, > + (ptr->flags & MEM_NOREPLY) ? " > noreply" : ""); > } > > if (ptr->flags & MEM_USE_UDP && ptr->flags & MEM_BUFFER_REQUESTS) > @@ -429,7 +429,7 @@ > uint64_t cas, > > memcached_storage_action verb) > { > - char flush; > + uint8_t flush; > protocol_binary_request_set request= {.bytes= {0}}; > size_t send_length= sizeof(request.bytes); > uint32_t server_key= memcached_generate_hash(ptr, master_key, > @@ -450,13 +450,13 @@ > request.message.body.expiration= htonl((uint32_t)expiration); > } > > - request.message.header.request.bodylen= htonl(key_length + > value_length + > - request.message.header.request.extlen); > + request.message.header.request.bodylen= htonl((uint32_t) > (key_length + value_length + > + request.message.header.request.extlen)); > > if (cas) > request.message.header.request.cas= htonll(cas); > > - flush= ((server->root->flags & MEM_BUFFER_REQUESTS) && verb == > SET_OP) ? 0 : 1; > + flush= (uint8_t) (((server->root->flags & MEM_BUFFER_REQUESTS) && > verb == SET_OP) ? 0 : 1); > > if ((server->root->flags & MEM_USE_UDP) && !flush) > { > @@ -470,7 +470,7 @@ > /* write the header */ > if ((memcached_do(server, (const char*)request.bytes, send_length, > 0) != MEMCACHED_SUCCESS) || > (memcached_io_write(server, key, key_length, 0) == -1) || > - (memcached_io_write(server, value, value_length, flush) == -1)) > + (memcached_io_write(server, value, value_length, (char) > flush) == -1)) > { > memcached_io_reset(server); > return MEMCACHED_WRITE_FAILURE; > @@ -490,7 +490,7 @@ > if ((memcached_do(srv, (const char*)request.bytes, > send_length, 0) != MEMCACHED_SUCCESS) || > (memcached_io_write(srv, key, key_length, 0) == -1) || > - (memcached_io_write(srv, value, value_length, flush) == > -1)) > + (memcached_io_write(srv, value, value_length, (char) > flush) == -1)) > memcached_io_reset(srv); > else > memcached_server_response_decrement(srv); > > === modified file 'libmemcached/memcached_string.c' > --- libmemcached/memcached_string.c 2009-07-08 13:38:34 +0000 > +++ libmemcached/memcached_string.c 2009-07-18 17:37:40 +0000 > @@ -4,7 +4,7 @@ > { > if (need && need > (size_t)(string->current_size - (size_t)(string- > >end - string->string))) > { > - size_t current_offset= string->end - string->string; > + size_t current_offset= (size_t) (string->end - string->string); > char *new_value; > size_t adjust; > size_t new_size; > > === modified file 'libmemcached/memcached_verbosity.c' > --- libmemcached/memcached_verbosity.c 2009-05-13 21:40:19 +0000 > +++ libmemcached/memcached_verbosity.c 2009-07-18 17:37:40 +0000 > @@ -7,8 +7,8 @@ > memcached_return rc; > char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; > > - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, > - "verbosity %u\r\n", verbosity); > + send_length= (size_t) snprintf(buffer, > MEMCACHED_DEFAULT_COMMAND_SIZE, > + "verbosity %u\r\n", verbosity); > unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) > return MEMCACHED_WRITE_FAILURE; > > > === modified file 'libmemcached/murmur_hash.c' > --- libmemcached/murmur_hash.c 2009-06-14 21:24:48 +0000 > +++ libmemcached/murmur_hash.c 2009-07-18 17:37:40 +0000 > @@ -25,13 +25,13 @@ > */ > > const unsigned int m= 0x5bd1e995; > - const unsigned int seed= (0xdeadbeef * length); > + const size_t seed= (0xdeadbeef * length); > const int r= 24; > > > // Initialize the hash to a 'random' value > > - unsigned int h= seed ^ length; > + size_t h= seed ^ length; > > // Mix 4 bytes at a time into the hash > > @@ -72,5 +72,5 @@ > h *= m; > h ^= h >> 15; > > - return h; > + return (uint32_t) h; > } > > === modified file 'm4/lib-prefix.m4' > --- m4/lib-prefix.m4 2009-07-16 02:58:56 +0000 > +++ m4/lib-prefix.m4 2009-07-18 18:11:25 +0000 > @@ -183,18 +183,13 @@ > dnl "Portable Makefiles should refer to any library > directories using the 64 symbolic link." > dnl But we want to recognize the sparcv9 or amd64 subdirectory > also if the > dnl symlink is missing, so we set acl_libdirstem2 too. > - AC_MSG_CHECKING([if buildling 64-bit app]) > - AC_RUN_IFELSE([ > - AC_LANG_PROGRAM([ > - ], [ > - return sizeof(void*) == 8 ? 0 : 1; > - ]) > - ], [ > - gl_cv_solaris_64bit=yes > - ], [ > - gl_cv_solaris_64bit=no > - ]) > - AC_MSG_RESULT([$gl_cv_solaris_64bit]) > + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], > + [AC_RUN_IFELSE([ > + AC_LANG_PROGRAM([], [[ > + return sizeof(void*) == 8 ? 0 : 1; > + ]]) > + ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) > + ]) > if test $gl_cv_solaris_64bit = yes; then > acl_libdirstem=lib/64 > case "$host_cpu" in > > === modified file 'm4/pandora_64bit.m4' > --- m4/pandora_64bit.m4 2009-07-14 19:18:55 +0000 > +++ m4/pandora_64bit.m4 2009-07-18 18:11:25 +0000 > @@ -7,6 +7,8 @@ > dnl Macro: PANDORA_64BIT > dnl > --------------------------------------------------------------------------- > AC_DEFUN([PANDORA_64BIT],[ > + AC_BEFORE([$0], [AC_LIB_PREFIX]) > + > > AC_ARG_ENABLE([64bit],[ > AS_HELP_STRING([--disable-64bit], > > === modified file 'm4/pandora_canonical.m4' > --- m4/pandora_canonical.m4 2009-07-16 02:28:54 +0000 > +++ m4/pandora_canonical.m4 2009-07-18 18:11:25 +0000 > @@ -4,7 +4,7 @@ > dnl with or without modifications, as long as this notice is > preserved. > > dnl Which version of the canonical setup we're using > -AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.20]) > +AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.22]) > > AC_DEFUN([PANDORA_FORCE_DEPEND_TRACKING],[ > dnl Force dependency tracking on for Sun Studio builds > @@ -59,6 +59,7 @@ > > AC_REQUIRE([AC_PROG_CC]) > AC_REQUIRE([PANDORA_MAC_GCC42]) > + AC_REQUIRE([PANDORA_64BIT]) > > dnl Once we can use a modern autoconf, we can use this > dnl AC_PROG_CC_C99 > @@ -66,6 +67,7 @@ > AC_PROG_CPP > AM_PROG_CC_C_O > > + > gl_USE_SYSTEM_EXTENSIONS > m4_if(PCT_FORCE_GCC42, [yes], [ > AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION) > @@ -111,7 +113,6 @@ > PANDORA_CHECK_CXX_VERSION > > PANDORA_OPTIMIZE > - PANDORA_64BIT > > dnl We need to inject error into the cflags to test if visibility > works or not > save_CFLAGS="${CFLAGS}" > > === added file 'm4/pandora_have_libpq.m4' > --- m4/pandora_have_libpq.m4 1970-01-01 00:00:00 +0000 > +++ m4/pandora_have_libpq.m4 2009-07-18 18:11:25 +0000 > @@ -0,0 +1,31 @@ > +dnl Copyright (C) 2009 Sun Microsystems > +dnl This file is free software; Sun Microsystems > +dnl gives unlimited permission to copy and/or distribute it, > +dnl with or without modifications, as long as this notice is > preserved. > + > +AC_DEFUN([_PANDORA_SEARCH_LIBPQ],[ > + AC_REQUIRE([AC_LIB_PREFIX]) > + > + dnl > -------------------------------------------------------------------- > + dnl Check for libpq > + dnl > -------------------------------------------------------------------- > + > + AC_LIB_HAVE_LINKFLAGS(pq,,[ > + #include > + ], [ > + PGconn *conn; > + conn = PQconnectdb(NULL); > + ]) > + > + AM_CONDITIONAL(HAVE_LIBPQ, [test "x${ac_cv_libpq}" = "xyes"]) > +]) > + > +AC_DEFUN([PANDORA_HAVE_LIBPQ],[ > + AC_REQUIRE([_PANDORA_SEARCH_LIBPQ]) > +]) > + > +AC_DEFUN([PANDORA_REQUIRE_LIBPQ],[ > + AC_REQUIRE([PANDORA_HAVE_LIBPQ]) > + AS_IF([test x$ac_cv_libpq = xno], > + AC_MSG_ERROR([libpq is required for ${PACKAGE}])) > +]) >