Merge pull request #162 from redboltz/msvc_test_supported

Supported dll export for msvc.
This commit is contained in:
Nobuyuki Kubota 2014-11-15 17:22:51 -08:00
commit 0827d08cd7
10 changed files with 109 additions and 22 deletions

View File

@ -211,9 +211,9 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" ST
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W4 /wd4127 /wd4310" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /wd4290 /wd4309" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4127 /wd4310")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4290 /wd4309")
ENDIF ()
ENDIF ()

View File

@ -97,9 +97,10 @@ typedef struct msgpack_object_kv {
msgpack_object val;
} msgpack_object_kv;
MSGPACK_DLLEXPORT
void msgpack_object_print(FILE* out, msgpack_object o);
MSGPACK_DLLEXPORT
bool msgpack_object_equal(const msgpack_object x, const msgpack_object y);
/** @} */

View File

@ -36,6 +36,12 @@ typedef unsigned __int64 uint64_t;
#include <stdbool.h>
#endif
#if defined(_MSC_VER)
#define MSGPACK_DLLEXPORT __declspec(dllexport)
#else /* _MSC_VER */
#define MSGPACK_DLLEXPORT
#endif /* _MSC_VER */
#ifdef _WIN32
#define _msgpack_atomic_counter_header <windows.h>
typedef long _msgpack_atomic_counter_t;

View File

@ -47,6 +47,7 @@ typedef enum {
} msgpack_unpack_return;
MSGPACK_DLLEXPORT
msgpack_unpack_return
msgpack_unpack_next(msgpack_unpacked* result,
const char* data, size_t len, size_t* off);
@ -80,11 +81,13 @@ typedef struct msgpack_unpacker {
* Initializes a streaming deserializer.
* The initialized deserializer must be destroyed by msgpack_unpacker_destroy(msgpack_unpacker*).
*/
MSGPACK_DLLEXPORT
bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size);
/**
* Destroys a streaming deserializer initialized by msgpack_unpacker_init(msgpack_unpacker*, size_t).
*/
MSGPACK_DLLEXPORT
void msgpack_unpacker_destroy(msgpack_unpacker* mpac);
@ -92,11 +95,13 @@ void msgpack_unpacker_destroy(msgpack_unpacker* mpac);
* Creates a streaming deserializer.
* The created deserializer must be destroyed by msgpack_unpacker_free(msgpack_unpacker*).
*/
MSGPACK_DLLEXPORT
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size);
/**
* Frees a streaming deserializer created by msgpack_unpacker_new(size_t).
*/
MSGPACK_DLLEXPORT
void msgpack_unpacker_free(msgpack_unpacker* mpac);
@ -146,6 +151,7 @@ static inline void msgpack_unpacker_buffer_consumed(msgpack_unpacker* mpac, si
* Returns true if it successes. Otherwise false is returned.
* @param pac pointer to an initialized msgpack_unpacked object.
*/
MSGPACK_DLLEXPORT
msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* pac);
/**
@ -168,14 +174,19 @@ static inline void msgpack_unpacked_destroy(msgpack_unpacked* result);
static inline msgpack_zone* msgpack_unpacked_release_zone(msgpack_unpacked* result);
MSGPACK_DLLEXPORT
int msgpack_unpacker_execute(msgpack_unpacker* mpac);
MSGPACK_DLLEXPORT
msgpack_object msgpack_unpacker_data(msgpack_unpacker* mpac);
MSGPACK_DLLEXPORT
msgpack_zone* msgpack_unpacker_release_zone(msgpack_unpacker* mpac);
MSGPACK_DLLEXPORT
void msgpack_unpacker_reset_zone(msgpack_unpacker* mpac);
MSGPACK_DLLEXPORT
void msgpack_unpacker_reset(msgpack_unpacker* mpac);
static inline size_t msgpack_unpacker_message_size(const msgpack_unpacker* mpac);
@ -185,6 +196,7 @@ static inline size_t msgpack_unpacker_message_size(const msgpack_unpacker* mpac)
// obsolete
MSGPACK_DLLEXPORT
msgpack_unpack_return
msgpack_unpack(const char* data, size_t len, size_t* off,
msgpack_zone* result_zone, msgpack_object* result);
@ -194,8 +206,10 @@ msgpack_unpack(const char* data, size_t len, size_t* off,
static inline size_t msgpack_unpacker_parsed_size(const msgpack_unpacker* mpac);
MSGPACK_DLLEXPORT
bool msgpack_unpacker_flush_zone(msgpack_unpacker* mpac);
MSGPACK_DLLEXPORT
bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size);
static inline bool msgpack_unpacker_reserve_buffer(msgpack_unpacker* mpac, size_t size)

View File

@ -22,9 +22,11 @@
extern "C" {
#endif
MSGPACK_DLLEXPORT
const char* msgpack_version(void);
MSGPACK_DLLEXPORT
int msgpack_version_major(void);
MSGPACK_DLLEXPORT
int msgpack_version_minor(void);
#include "version_master.h"

View File

@ -70,8 +70,10 @@ typedef struct msgpack_vrefbuffer {
#define MSGPACK_VREFBUFFER_CHUNK_SIZE 8192
#endif
MSGPACK_DLLEXPORT
bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
size_t ref_size, size_t chunk_size);
MSGPACK_DLLEXPORT
void msgpack_vrefbuffer_destroy(msgpack_vrefbuffer* vbuf);
static inline msgpack_vrefbuffer* msgpack_vrefbuffer_new(size_t ref_size, size_t chunk_size);
@ -82,14 +84,18 @@ static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t l
static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref);
static inline size_t msgpack_vrefbuffer_veclen(const msgpack_vrefbuffer* vref);
MSGPACK_DLLEXPORT
int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
const char* buf, size_t len);
MSGPACK_DLLEXPORT
int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
const char* buf, size_t len);
MSGPACK_DLLEXPORT
int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to);
MSGPACK_DLLEXPORT
void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vref);
/** @} */

View File

@ -61,10 +61,14 @@ typedef struct msgpack_zone {
#define MSGPACK_ZONE_CHUNK_SIZE 8192
#endif
MSGPACK_DLLEXPORT
bool msgpack_zone_init(msgpack_zone* zone, size_t chunk_size);
MSGPACK_DLLEXPORT
void msgpack_zone_destroy(msgpack_zone* zone);
MSGPACK_DLLEXPORT
msgpack_zone* msgpack_zone_new(size_t chunk_size);
MSGPACK_DLLEXPORT
void msgpack_zone_free(msgpack_zone* zone);
static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size);
@ -75,8 +79,10 @@ static inline bool msgpack_zone_push_finalizer(msgpack_zone* zone,
static inline void msgpack_zone_swap(msgpack_zone* a, msgpack_zone* b);
MSGPACK_DLLEXPORT
bool msgpack_zone_is_empty(msgpack_zone* zone);
MSGPACK_DLLEXPORT
void msgpack_zone_clear(msgpack_zone* zone);
/** @} */
@ -86,6 +92,7 @@ void msgpack_zone_clear(msgpack_zone* zone);
#define MSGPACK_ZONE_ALIGN sizeof(int)
#endif
MSGPACK_DLLEXPORT
void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size);
void* msgpack_zone_malloc_no_align(msgpack_zone* zone, size_t size)

View File

@ -55,9 +55,9 @@ FOREACH (source_file ${check_PROGRAMS})
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /wd4290 /wd4309" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4290 /wd4309")
ENDIF ()
ENDIF ()
ENDFOREACH ()

View File

@ -11,6 +11,12 @@
#include <gtest/gtest.h>
#if defined(_MSC_VER)
#define msgpack_rand() ((double)rand() / RAND_MAX)
#else // _MSC_VER
#define msgpack_rand() drand48()
#endif // _MSC_VER
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -147,11 +153,20 @@ TEST(MSGPACK, simple_buffer_float)
v.push_back(numeric_limits<float>::min());
v.push_back(numeric_limits<float>::max());
v.push_back(nanf("tag"));
v.push_back(1.0/0.0); // inf
v.push_back(-(1.0/0.0)); // -inf
if (numeric_limits<float>::has_infinity) {
v.push_back(numeric_limits<float>::infinity());
v.push_back(-numeric_limits<float>::infinity());
}
if (numeric_limits<float>::has_quiet_NaN) {
v.push_back(numeric_limits<float>::quiet_NaN());
}
if (numeric_limits<float>::has_signaling_NaN) {
v.push_back(numeric_limits<float>::signaling_NaN());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(drand48());
v.push_back(-drand48());
v.push_back(static_cast<float>(msgpack_rand()));
v.push_back(static_cast<float>(-msgpack_rand()));
}
for (unsigned int i = 0; i < v.size() ; i++) {
msgpack::sbuffer sbuf;
@ -227,11 +242,24 @@ TEST(MSGPACK, simple_buffer_double)
v.push_back(numeric_limits<double>::min());
v.push_back(numeric_limits<double>::max());
v.push_back(nanf("tag"));
v.push_back(1.0/0.0); // inf
v.push_back(-(1.0/0.0)); // -inf
if (numeric_limits<double>::has_infinity) {
v.push_back(numeric_limits<double>::infinity());
v.push_back(-numeric_limits<double>::infinity());
}
if (numeric_limits<double>::has_quiet_NaN) {
v.push_back(numeric_limits<double>::quiet_NaN());
}
if (numeric_limits<double>::has_signaling_NaN) {
v.push_back(numeric_limits<double>::signaling_NaN());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(drand48());
v.push_back(-drand48());
v.push_back(msgpack_rand());
v.push_back(-msgpack_rand());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(msgpack_rand());
v.push_back(-msgpack_rand());
}
for (unsigned int i = 0; i < v.size() ; i++) {
msgpack::sbuffer sbuf;

View File

@ -6,6 +6,12 @@
#include <gtest/gtest.h>
#if defined(_MSC_VER)
#define msgpack_rand() ((double)rand() / RAND_MAX)
#else // _MSC_VER
#define msgpack_rand() drand48()
#endif // _MSC_VER
using namespace std;
const unsigned int kLoop = 10000;
@ -188,11 +194,20 @@ TEST(MSGPACKC, simple_buffer_float)
v.push_back(numeric_limits<float>::min());
v.push_back(numeric_limits<float>::max());
v.push_back(nanf("tag"));
v.push_back(1.0/0.0); // inf
v.push_back(-(1.0/0.0)); // -inf
if (numeric_limits<float>::has_infinity) {
v.push_back(numeric_limits<float>::infinity());
v.push_back(-numeric_limits<float>::infinity());
}
if (numeric_limits<float>::has_quiet_NaN) {
v.push_back(numeric_limits<float>::quiet_NaN());
}
if (numeric_limits<float>::has_signaling_NaN) {
v.push_back(numeric_limits<float>::signaling_NaN());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(drand48());
v.push_back(-drand48());
v.push_back(static_cast<float>(msgpack_rand()));
v.push_back(static_cast<float>(-msgpack_rand()));
}
for (unsigned int i = 0; i < v.size() ; i++) {
@ -230,11 +245,19 @@ TEST(MSGPACKC, simple_buffer_double)
v.push_back(numeric_limits<double>::min());
v.push_back(numeric_limits<double>::max());
v.push_back(nan("tag"));
v.push_back(1.0/0.0); // inf
v.push_back(-(1.0/0.0)); // -inf
if (numeric_limits<double>::has_infinity) {
v.push_back(numeric_limits<double>::infinity());
v.push_back(-numeric_limits<double>::infinity());
}
if (numeric_limits<double>::has_quiet_NaN) {
v.push_back(numeric_limits<double>::quiet_NaN());
}
if (numeric_limits<double>::has_signaling_NaN) {
v.push_back(numeric_limits<double>::signaling_NaN());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(drand48());
v.push_back(-drand48());
v.push_back(msgpack_rand());
v.push_back(-msgpack_rand());
}
for (unsigned int i = 0; i < v.size() ; i++) {