From 0d5708a01de941ef6b2efaf439b1ccb74c4664fc Mon Sep 17 00:00:00 2001 From: FURUHASHI Sadayuki Date: Thu, 24 Feb 2011 00:21:54 +0900 Subject: [PATCH] cpp: fixes problem that InterlockedIncrement/Decrement are not found on _WIN32 platform --- cpp/msgpack_vc.postbuild.bat | 4 ++-- cpp/src/msgpack/type/string.hpp | 4 ++-- cpp/src/unpack.c | 4 ++++ msgpack/sysdep.h | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/msgpack_vc.postbuild.bat b/cpp/msgpack_vc.postbuild.bat index fd582cf2..c7791e6a 100644 --- a/cpp/msgpack_vc.postbuild.bat +++ b/cpp/msgpack_vc.postbuild.bat @@ -40,6 +40,6 @@ copy src\msgpack\type\string.hpp include\msgpack\type\ copy src\msgpack\type\vector.hpp include\msgpack\type\ copy src\msgpack\type\tuple.hpp include\msgpack\type\ copy src\msgpack\type\define.hpp include\msgpack\type\ -copy src\msgpack\type\tr1\unordered_map.hpp include\msgpack\type\ -copy src\msgpack\type\tr1\unordered_set.hpp include\msgpack\type\ +copy src\msgpack\type\tr1\unordered_map.hpp include\msgpack\type\tr1\ +copy src\msgpack\type\tr1\unordered_set.hpp include\msgpack\type\tr1\ diff --git a/cpp/src/msgpack/type/string.hpp b/cpp/src/msgpack/type/string.hpp index f11a5e68..37d4a172 100644 --- a/cpp/src/msgpack/type/string.hpp +++ b/cpp/src/msgpack/type/string.hpp @@ -44,7 +44,7 @@ inline void operator<< (object::with_zone& o, const std::string& v) o.type = type::RAW; char* ptr = (char*)o.zone->malloc(v.size()); o.via.raw.ptr = ptr; - o.via.raw.size = v.size(); + o.via.raw.size = (uint32_t)v.size(); memcpy(ptr, v.data(), v.size()); } @@ -52,7 +52,7 @@ inline void operator<< (object& o, const std::string& v) { o.type = type::RAW; o.via.raw.ptr = v.data(); - o.via.raw.size = v.size(); + o.via.raw.size = (uint32_t)v.size(); } diff --git a/cpp/src/unpack.c b/cpp/src/unpack.c index 0c21780b..52b834c9 100644 --- a/cpp/src/unpack.c +++ b/cpp/src/unpack.c @@ -19,6 +19,10 @@ #include "msgpack/unpack_define.h" #include +#ifdef _msgpack_atomic_counter_header +#include _msgpack_atomic_counter_header +#endif + typedef struct { msgpack_zone* z; diff --git a/msgpack/sysdep.h b/msgpack/sysdep.h index c2b5c38f..557c7cd6 100644 --- a/msgpack/sysdep.h +++ b/msgpack/sysdep.h @@ -38,6 +38,7 @@ typedef unsigned __int64 uint64_t; #ifdef _WIN32 +#define _msgpack_atomic_counter_header typedef long _msgpack_atomic_counter_t; #define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr) #define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)