From a74f6b28671955c2472b1d68ee0b87b25aa12156 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:54:19 +0000 Subject: [PATCH 01/11] Updated config for vs2010/winsdk71 as well as vs2013 Define JSON_C_HAVE_INTTYPES_H in json_config.h.win32 only --- config.h.in | 3 +++ config.h.win32 | 34 +++++++++++++++++++++------------- json_config.h.win32 | 2 ++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/config.h.in b/config.h.in index 0dcab1a..af2e5fc 100644 --- a/config.h.in +++ b/config.h.in @@ -134,6 +134,9 @@ */ #undef LT_OBJDIR +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + /* Name of package */ #undef PACKAGE diff --git a/config.h.win32 b/config.h.win32 index 6515945..de6bc3c 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -8,35 +8,43 @@ /* Define to 1 if you have the declaration of `INFINITY', and to 0 if you don't. */ +#if defined(_MSC_VER) && _MSC_VER >= 1800 #define HAVE_DECL_INFINITY 1 +#endif /* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. */ +#if defined(_MSC_VER) && _MSC_VER >= 1800 #define HAVE_DECL_ISINF 1 +#endif /* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. */ +#if defined(_MSC_VER) && _MSC_VER >= 1800 #define HAVE_DECL_ISNAN 1 +#endif /* Define to 1 if you have the declaration of `nan', and to 0 if you don't. */ +#if defined(_MSC_VER) && _MSC_VER >= 1800 #define HAVE_DECL_NAN 1 +#endif /* Define to 1 if you have the declaration of `_finite', and to 0 if you don't. */ -#define HAVE_DECL__FINITE 0 +#define HAVE_DECL__FINITE 1 /* Define to 1 if you have the declaration of `_isnan', and to 0 if you don't. */ -#define HAVE_DECL__ISNAN 0 +#define HAVE_DECL__ISNAN 1 /* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H +#define HAVE_DLFCN_H 1 /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -#undef HAVE_DOPRNT +#define HAVE_DOPRNT 1 /* Define to 1 if you have the header file. */ -#define HAVE_ENDIAN_H 1 +#undef HAVE_ENDIAN_H /* Define to 1 if you have the header file. */ #define HAVE_FCNTL_H 1 @@ -58,7 +66,7 @@ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `open' function. */ -#undef HAVE_OPEN +#define HAVE_OPEN 1 /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ @@ -95,13 +103,13 @@ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strncasecmp' function. */ -#define HAVE_STRNCASECMP 1 +#undef HAVE_STRNCASECMP /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ -#undef HAVE_SYS_CDEFS_H +#define HAVE_SYS_CDEFS_H 1 /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H @@ -119,21 +127,21 @@ #undef HAVE_VASPRINTF /* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF +#define HAVE_VPRINTF 1 /* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF +#define HAVE_VSNPRINTF 1 /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG -/* Public define for json_inttypes.h */ -#define JSON_C_HAVE_INTTYPES_H 1 - /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + /* Name of package */ #define PACKAGE "json-c" diff --git a/json_config.h.win32 b/json_config.h.win32 index 405fda2..9c542a4 100644 --- a/json_config.h.win32 +++ b/json_config.h.win32 @@ -1,3 +1,5 @@ /* Define to 1 if you have the header file. */ +#if defined(_MSC_VER) && _MSC_VER >= 1800 #define JSON_C_HAVE_INTTYPES_H 1 +#endif From 0137103f4b91e0d99e74fc39079aeeec4f658777 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:55:25 +0000 Subject: [PATCH 02/11] Include config.h in linkhash so that HAVE_ENDIAN_H is defined (if available) --- linkhash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linkhash.c b/linkhash.c index a5b2945..989980c 100644 --- a/linkhash.c +++ b/linkhash.c @@ -10,6 +10,8 @@ * */ +#include "config.h" + #include #include #include From 72310c87a519b3530e54b96cd1ceb84e0d385a9c Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:56:49 +0000 Subject: [PATCH 03/11] Define INFINITY and NAN when missing --- math_compat.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/math_compat.h b/math_compat.h index f40b8fa..baf3eb9 100644 --- a/math_compat.h +++ b/math_compat.h @@ -1,7 +1,7 @@ #ifndef __math_compat_h #define __math_compat_h -/* Define isnan and isinf on Windows/MSVC */ +/* Define isnan, isinf, infinity and nan on Windows/MSVC */ #ifndef HAVE_DECL_ISNAN # ifdef HAVE_DECL__ISNAN @@ -17,12 +17,15 @@ # endif #endif -#ifndef HAVE_DECL_NAN -#error This platform does not have nan() +#ifndef HAVE_DECL_INFINITY +#include +#define INFINITY (DBL_MAX + DBL_MAX) +#define HAVE_DECL_INFINITY #endif -#ifndef HAVE_DECL_INFINITY -#error This platform does not have INFINITY +#ifndef HAVE_DECL_NAN +#define NAN (INFINITY - INFINITY) +#define HAVE_DECL_NAN #endif #endif From 9be71700eb580c815688584a64621a38867c3fdd Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:57:14 +0000 Subject: [PATCH 04/11] json_tokener requires INF and NAN --- json_tokener.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/json_tokener.c b/json_tokener.c index d9e9e24..8b1e3e6 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -16,6 +16,7 @@ #include "config.h" #include +#include "math_compat.h" #include #include #include @@ -353,7 +354,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_inf: /* aka starts with 'i' */ { - int size_inf; + size_t size_inf; int is_negative = 0; printbuf_memappend_fast(tok->pb, &c, 1); From 720d566d03e23418b7bb3cff2f74ef7d95c6a459 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:58:12 +0000 Subject: [PATCH 05/11] Define macros from inttypes.h when not available --- json_inttypes.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/json_inttypes.h b/json_inttypes.h index 9de8d24..e86f4cc 100644 --- a/json_inttypes.h +++ b/json_inttypes.h @@ -4,24 +4,15 @@ #include "json_config.h" -#if defined(_MSC_VER) && _MSC_VER <= 1700 - -/* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */ -typedef __int32 int32_t; -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX ((int32_t)_I32_MAX) -typedef __int64 int64_t; -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX ((int64_t)_I64_MAX) -#define PRId64 "I64d" -#define SCNd64 "I64d" +#ifdef JSON_C_HAVE_INTTYPES_H +/* inttypes.h includes stdint.h */ +#include #else +#include -#ifdef JSON_C_HAVE_INTTYPES_H -#include -#endif -/* inttypes.h includes stdint.h */ +#define PRId64 "I64d" +#define SCNd64 "I64d" #endif From bf32650c83c1850b5132a147d4a6dd59cdff8d37 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:58:39 +0000 Subject: [PATCH 06/11] Add missing include file to random_seed --- random_seed.c | 1 + 1 file changed, 1 insertion(+) diff --git a/random_seed.c b/random_seed.c index 2e7cd5e..3b61b77 100644 --- a/random_seed.c +++ b/random_seed.c @@ -11,6 +11,7 @@ #include #include "config.h" +#include "random_seed.h" #define DEBUG_SEED(s) From 18b3c49296adf5937700c5a60fb13a159d599eae Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 15:59:19 +0000 Subject: [PATCH 07/11] Use more appropriate casts --- json_object.c | 6 +++--- linkhash.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/json_object.c b/json_object.c index 9b89bb7..d0aba48 100644 --- a/json_object.c +++ b/json_object.c @@ -409,7 +409,7 @@ void json_object_object_add(struct json_object* jso, const char *key, lh_table_insert(jso->o.c_object, strdup(key), val); return; } - existing_value = (void *)existing_entry->v; + existing_value = (json_object *)existing_entry->v; if (existing_value) json_object_put(existing_value); existing_entry->v = val; @@ -661,8 +661,8 @@ struct json_object* json_object_new_double_s(double d, const char *ds) int json_object_userdata_to_json_string(struct json_object *jso, struct printbuf *pb, int level, int flags) { - int userdata_len = strlen(jso->_userdata); - printbuf_memappend(pb, jso->_userdata, userdata_len); + int userdata_len = strlen((const char *)jso->_userdata); + printbuf_memappend(pb, (const char *)jso->_userdata, userdata_len); return userdata_len; } diff --git a/linkhash.c b/linkhash.c index 989980c..572f4dc 100644 --- a/linkhash.c +++ b/linkhash.c @@ -415,7 +415,7 @@ unsigned long lh_char_hash(const void *k) #if defined __GNUC__ __sync_val_compare_and_swap(&random_seed, -1, seed); #elif defined _MSC_VER - InterlockedCompareExchange(&random_seed, seed, -1); + InterlockedCompareExchange((LONG *)&random_seed, seed, -1); #else #warning "racy random seed initializtion if used by multiple threads" random_seed = seed; /* potentially racy */ From d5baa0381f333b856fcb21469d6db81cab69188c Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 16:02:58 +0000 Subject: [PATCH 08/11] Update VS project to include current source files --- json-c.vcxproj | 8 +++++--- json-c.vcxproj.filters | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/json-c.vcxproj b/json-c.vcxproj index 9c50712..2351e51 100644 --- a/json-c.vcxproj +++ b/json-c.vcxproj @@ -1,4 +1,4 @@ - + @@ -12,7 +12,7 @@ {04D8CDBE-FB3E-4362-87E6-07DC3C0083B2} - Win32Proj + jsonc @@ -94,14 +94,16 @@ copy json_config.h.win32 json_config.h - + + + diff --git a/json-c.vcxproj.filters b/json-c.vcxproj.filters index 1805d88..8f40caa 100644 --- a/json-c.vcxproj.filters +++ b/json-c.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -14,7 +14,7 @@ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - {d3849076-874e-490e-858c-0871d04d1ecb} + {8c5a59ed-4639-4361-9b7c-ecdcd09b953c} @@ -44,9 +44,6 @@ Header Files - - Header Files - Header Files @@ -68,14 +65,23 @@ Header Files + + Header Files + + + Header Files + + + Header Files + Documentation + - \ No newline at end of file From e1a3f33a26434a13774061bc4a4fa2bf36e41298 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 16:12:28 +0000 Subject: [PATCH 09/11] Set CompileAsCpp flag (Required for vs2010/winsdk71) Revert some project settings to defaults --- json-c.vcxproj | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/json-c.vcxproj b/json-c.vcxproj index 2351e51..fd300bc 100644 --- a/json-c.vcxproj +++ b/json-c.vcxproj @@ -15,12 +15,12 @@ jsonc - + StaticLibrary v120 MultiByte - + StaticLibrary v120 MultiByte @@ -28,60 +28,47 @@ - + - + - - <_ProjectFileVersion>12.0.30324.0 - - - Debug\ - Debug\ - - - Release\ - Release\ - Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug - Level3 EditAndContinue + CompileAsCpp - - $(OutDir)json-c.lib - copy config.h.win32 config.h copy json_config.h.win32 json_config.h + + copy config.h from Windows template instead of calling configure + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - Level3 ProgramDatabase + CompileAsCpp - - $(OutDir)json-c.lib - copy config.h.win32 config.h copy json_config.h.win32 json_config.h + + copy config.h from Windows template instead of calling configure + From 9d3d8d6fc0d0e0afc2244cd3fbd3aff3ae3d4b00 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 16:15:06 +0000 Subject: [PATCH 10/11] Add x64 build configurations --- .gitignore | 2 ++ json-c.vcxproj | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/.gitignore b/.gitignore index 15000ba..ee8171d 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ /tests/*.trs /Debug /Release +/*/Debug +/*/Release *.lo *.o /libjson-c.la diff --git a/json-c.vcxproj b/json-c.vcxproj index fd300bc..008d724 100644 --- a/json-c.vcxproj +++ b/json-c.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {04D8CDBE-FB3E-4362-87E6-07DC3C0083B2} @@ -20,20 +28,36 @@ v120 MultiByte + + StaticLibrary + v120 + MultiByte + StaticLibrary v120 MultiByte + + StaticLibrary + v120 + MultiByte + + + + + + + @@ -48,6 +72,25 @@ copy config.h.win32 config.h copy json_config.h.win32 json_config.h + + + + copy config.h from Windows template instead of calling configure + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + EnableFastChecks + Level3 + EditAndContinue + CompileAsCpp + + + copy config.h.win32 config.h +copy json_config.h.win32 json_config.h @@ -64,6 +107,22 @@ copy json_config.h.win32 json_config.h copy config.h.win32 config.h copy json_config.h.win32 json_config.h + + + + copy config.h from Windows template instead of calling configure + + + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + Level3 + ProgramDatabase + CompileAsCpp + + + copy config.h.win32 config.h +copy json_config.h.win32 json_config.h From 736f4b35814b3c065311b7d25fd7b9602af13eed Mon Sep 17 00:00:00 2001 From: James Myatt Date: Thu, 5 Feb 2015 16:38:47 +0000 Subject: [PATCH 11/11] Build random_seed.c as well --- json-c.vcxproj | 1 + json-c.vcxproj.filters | 3 +++ 2 files changed, 4 insertions(+) diff --git a/json-c.vcxproj b/json-c.vcxproj index 008d724..c39ef7e 100644 --- a/json-c.vcxproj +++ b/json-c.vcxproj @@ -137,6 +137,7 @@ copy json_config.h.win32 json_config.h + diff --git a/json-c.vcxproj.filters b/json-c.vcxproj.filters index 8f40caa..63b6fb1 100644 --- a/json-c.vcxproj.filters +++ b/json-c.vcxproj.filters @@ -39,6 +39,9 @@ Source Files + + Source Files +