pack_define.h \
pack.h \
pack_template.h \
- predef.h \
sbuffer.h \
sysdep.h \
timestamp.h \
#define MSGPACK_FBUFFER_H
#include <stdio.h>
+#include <assert.h>
#ifdef __cplusplus
extern "C" {
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
{
+ assert(buf || len == 0);
+ if(!buf) return 0;
+
return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
}
#if BYTE_ORDER == LITTLE_ENDIAN
#define MSGPACK_ENDIAN_LITTLE_BYTE 1
+#define MSGPACK_ENDIAN_BIG_BYTE 0
#elif BYTE_ORDER == BIG_ENDIAN
+#define MSGPACK_ENDIAN_LITTLE_BYTE 0
#define MSGPACK_ENDIAN_BIG_BYTE 1
#endif
case MSGPACK_OBJECT_STR:
MSGPACK_CHECKED_CALL(ret, snprintf, aux_buffer, aux_buffer_size, "\"");
- MSGPACK_CHECKED_CALL(ret, snprintf, aux_buffer, aux_buffer_size, "%.*s", (int)o.via.str.size, o.via.str.ptr);
+ if (o.via.str.size > 0) {
+ MSGPACK_CHECKED_CALL(ret, snprintf, aux_buffer, aux_buffer_size, "%.*s", (int)o.via.str.size, o.via.str.ptr);
+ }
MSGPACK_CHECKED_CALL(ret, snprintf, aux_buffer, aux_buffer_size, "\"");
break;
* http://www.boost.org/LICENSE_1_0.txt)
*/
+#include "vendor/msgpack/lttng-config.h"
+
#if MSGPACK_ENDIAN_LITTLE_BYTE
#define TAKE8_8(d) ((uint8_t*)&d)[0]
#define TAKE8_16(d) ((uint8_t*)&d)[0]
+++ /dev/null
-/*
-Copyright Rene Rivera 2008-2015
-Distributed under the Boost Software License, Version 1.0.
-(See accompanying file LICENSE_1_0.txt or copy at
-http://www.boost.org/LICENSE_1_0.txt)
-*/
-
-#if !defined(MSGPACK_PREDEF_H) || defined(MSGPACK_PREDEF_INTERNAL_GENERATE_TESTS)
-#ifndef MSGPACK_PREDEF_H
-#define MSGPACK_PREDEF_H
-#endif
-
-#include <vendor/msgpack/predef/language.h>
-#include <vendor/msgpack/predef/architecture.h>
-#include <vendor/msgpack/predef/compiler.h>
-#include <vendor/msgpack/predef/library.h>
-#include <vendor/msgpack/predef/os.h>
-#include <vendor/msgpack/predef/other.h>
-#include <vendor/msgpack/predef/platform.h>
-#include <vendor/msgpack/predef/hardware.h>
-
-#include <vendor/msgpack/predef/version.h>
-
-#endif
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#ifdef __cplusplus
extern "C" {
{
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
+ assert(buf || len == 0);
+ if(!buf) return 0;
+
if(sbuf->alloc - sbuf->size < len) {
void* tmp;
size_t nsize = (sbuf->alloc) ?
memcpy(sbuf->data + sbuf->size, buf, len);
sbuf->size += len;
+
return 0;
}
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
+# if defined(_WIN64)
+ typedef signed __int64 intptr_t;
+ typedef unsigned __int64 uintptr_t;
+# else
+ typedef signed __int32 intptr_t;
+ typedef unsigned __int32 uintptr_t;
+# endif
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
# include <stdint.h>
#else
-#define MSGPACK_VERSION_MAJOR 3
-#define MSGPACK_VERSION_MINOR 3
+#define MSGPACK_VERSION_MAJOR 4
+#define MSGPACK_VERSION_MINOR 0
#define MSGPACK_VERSION_REVISION 0
size_t ref_size, size_t chunk_size)
{
size_t nfirst;
- struct iovec* array;
+ msgpack_iovec* array;
msgpack_vrefbuffer_chunk* chunk;
if (ref_size == 0) {
return false;
}
- nfirst = (sizeof(struct iovec) < 72/2) ?
- 72 / sizeof(struct iovec) : 8;
+ nfirst = (sizeof(msgpack_iovec) < 72/2) ?
+ 72 / sizeof(msgpack_iovec) : 8;
- array = (struct iovec*)malloc(
- sizeof(struct iovec) * nfirst);
+ array = (msgpack_iovec*)malloc(
+ sizeof(msgpack_iovec) * nfirst);
if(array == NULL) {
return false;
}
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
const size_t nnext = nused * 2;
- struct iovec* nvec = (struct iovec*)realloc(
- vbuf->array, sizeof(struct iovec)*nnext);
+ msgpack_iovec* nvec = (msgpack_iovec*)realloc(
+ vbuf->array, sizeof(msgpack_iovec)*nnext);
if(nvec == NULL) {
return -1;
}
{
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
if(to->tail + nused < vbuf->end) {
- struct iovec* nvec;
+ msgpack_iovec* nvec;
const size_t tosize = (size_t)(to->tail - to->array);
const size_t reqsize = nused + tosize;
size_t nnext = (size_t)(to->end - to->array) * 2;
nnext = tmp_nnext;
}
- nvec = (struct iovec*)realloc(
- to->array, sizeof(struct iovec)*nnext);
+ nvec = (msgpack_iovec*)realloc(
+ to->array, sizeof(msgpack_iovec)*nnext);
if(nvec == NULL) {
free(empty);
return -1;
to->tail = nvec + tosize;
}
- memcpy(to->tail, vbuf->array, sizeof(struct iovec)*nused);
+ memcpy(to->tail, vbuf->array, sizeof(msgpack_iovec)*nused);
to->tail += nused;
vbuf->tail = vbuf->array;
#include "zone.h"
#include <stdlib.h>
+#include <assert.h>
#if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
#include <sys/uio.h>
+typedef struct iovec msgpack_iovec;
#else
-struct iovec {
+struct msgpack_iovec {
void *iov_base;
size_t iov_len;
};
+typedef struct msgpack_iovec msgpack_iovec;
#endif
#ifdef __cplusplus
} msgpack_vrefbuffer_inner_buffer;
typedef struct msgpack_vrefbuffer {
- struct iovec* tail;
- struct iovec* end;
- struct iovec* array;
+ msgpack_iovec* tail;
+ msgpack_iovec* end;
+ msgpack_iovec* array;
size_t chunk_size;
size_t ref_size;
static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len);
-static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref);
+static inline const msgpack_iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref);
static inline size_t msgpack_vrefbuffer_veclen(const msgpack_vrefbuffer* vref);
MSGPACK_DLLEXPORT
static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len)
{
msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)data;
+ assert(buf || len == 0);
+
+ if(!buf) return 0;
if(len < vbuf->ref_size) {
return msgpack_vrefbuffer_append_copy(vbuf, buf, len);
}
}
-static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref)
+static inline const msgpack_iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref)
{
return vref->array;
}
#include "sysdep.h"
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include <zlib.h>
#ifdef __cplusplus
{
msgpack_zbuffer* zbuf = (msgpack_zbuffer*)data;
+ assert(buf || len == 0);
+ if(!buf) return 0;
+
zbuf->stream.next_in = (Bytef*)buf;
zbuf->stream.avail_in = (uInt)len;
{
char* aligned =
(char*)(
- (size_t)(
+ (uintptr_t)(
zone->chunk_list.ptr + (MSGPACK_ZONE_ALIGN - 1)
- ) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN
+ ) & ~(uintptr_t)(MSGPACK_ZONE_ALIGN - 1)
);
size_t adjusted_size = size + (size_t)(aligned - zone->chunk_list.ptr);
if(zone->chunk_list.free >= adjusted_size) {
{
void* ptr = msgpack_zone_malloc_expand(zone, size + (MSGPACK_ZONE_ALIGN - 1));
if (ptr) {
- return (char*)((size_t)(ptr) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN);
+ return (char*)((uintptr_t)(ptr) & ~(uintptr_t)(MSGPACK_ZONE_ALIGN - 1));
}
}
return NULL;