Fix pure C compilation

This commit is contained in:
tbeu 2014-06-23 13:55:25 +02:00
parent 6e5fc6d396
commit 3cb2e4f7c6
3 changed files with 6 additions and 4 deletions

View File

@ -656,18 +656,18 @@ if(sizeof(unsigned long long) == 2) {
msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d) msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
{ {
unsigned char buf[5];
union { float f; uint32_t i; } mem; union { float f; uint32_t i; } mem;
mem.f = d; mem.f = d;
unsigned char buf[5];
buf[0] = 0xca; _msgpack_store32(&buf[1], mem.i); buf[0] = 0xca; _msgpack_store32(&buf[1], mem.i);
msgpack_pack_append_buffer(x, buf, 5); msgpack_pack_append_buffer(x, buf, 5);
} }
msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d) msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
{ {
unsigned char buf[9];
union { double f; uint64_t i; } mem; union { double f; uint64_t i; } mem;
mem.f = d; mem.f = d;
unsigned char buf[9];
buf[0] = 0xcb; buf[0] = 0xcb;
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi #if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
// https://github.com/msgpack/msgpack-perl/pull/1 // https://github.com/msgpack/msgpack-perl/pull/1

View File

@ -69,12 +69,13 @@ static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data; msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
if(sbuf->alloc - sbuf->size < len) { if(sbuf->alloc - sbuf->size < len) {
void* tmp;
size_t nsize = (sbuf->alloc) ? size_t nsize = (sbuf->alloc) ?
sbuf->alloc * 2 : MSGPACK_SBUFFER_INIT_SIZE; sbuf->alloc * 2 : MSGPACK_SBUFFER_INIT_SIZE;
while(nsize < sbuf->size + len) { nsize *= 2; } while(nsize < sbuf->size + len) { nsize *= 2; }
void* tmp = realloc(sbuf->data, nsize); tmp = realloc(sbuf->data, nsize);
if(!tmp) { return -1; } if(!tmp) { return -1; }
sbuf->data = (char*)tmp; sbuf->data = (char*)tmp;

View File

@ -90,13 +90,14 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size);
void* msgpack_zone_malloc_no_align(msgpack_zone* zone, size_t size) void* msgpack_zone_malloc_no_align(msgpack_zone* zone, size_t size)
{ {
char* ptr;
msgpack_zone_chunk_list* cl = &zone->chunk_list; msgpack_zone_chunk_list* cl = &zone->chunk_list;
if(zone->chunk_list.free < size) { if(zone->chunk_list.free < size) {
return msgpack_zone_malloc_expand(zone, size); return msgpack_zone_malloc_expand(zone, size);
} }
char* ptr = cl->ptr; ptr = cl->ptr;
cl->free -= size; cl->free -= size;
cl->ptr += size; cl->ptr += size;