Commit Graph

100 Commits

Author SHA1 Message Date
Alan Coopersmith
6cf4847796 Use getrandom() if available in json_c_get_random_seed
Lower overhead than opening & reading from /dev/urandom, and works
in chroots and other situtations where /dev/urandom is not available.
Falls back to existing methods when kernel doesn't support the syscall.
2020-07-31 08:28:07 -07:00
Eric Haszlakiewicz
de02d09c32 Update the master branch to version 0.15.99 2020-07-26 15:26:53 +00:00
Eric Haszlakiewicz
730e3d044f Issue #594 - provide an OVERRIDE_GET_RANDOM_SEED cmake variable to override json_c_get_random_seed() for embedded platforms where time(NULL) doesn't work.
Example:
mkdir build && cd build
cmake -DOVERRIDE_GET_RANDOM_SEED='do { extern uint32_t getMsTicks(void); int ms = getMsTicks() * 433494437; return ms; } while(0)' ..
2020-07-22 02:25:03 +00:00
Simon McVittie
c2c94024f5 build: Add symbol versions to all exported symbols
With this version script, newly-linked binaries that depend on the
json-c shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-glib or libjansson if those libraries appear in
dependency search order before json-c, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.

Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when json_object_set_serializer() calls
json_object_set_userdata(). It does not affect calls from external
code into json-c, unless json-c was statically linked into the
external caller.

This change will also not prevent code that depends on json-glib or
libjansson from finding json-c's symbols and crashing; to prevent
that, a corresponding change in json-glib or libjansson would be needed.

Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version on a symbol would be an
incompatible change that requires a SONAME bump.

Resolves: https://github.com/json-c/json-c/issues/621
(when combined with an equivalent change to libjansson).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-01 18:24:26 +01:00
Eric Hawicz
99bb2121c6 Merge pull request #632 from json-c/json_object-split
Json object split
2020-06-20 13:04:32 -04:00
Micah Snyder
60494684a1 Issue #508: -fPIC to link libjson-c.a with libs
json-c has symbol collisions with other popular C JSON libraries.
To prevent random crashes in downstream applications that may use a
library which depends on json-c, the solution is to statically link
libjson-c.a into those libraries.

`-fPIC`/`-fPIE` is required when building a `.a` so it can be linked
into a `.so`.
2020-06-14 12:35:49 -04:00
Eric Haszlakiewicz
0a16b23adf Fix typo in previous commit to check for SSIZE_T on MSVC. 2020-06-07 15:19:29 +00:00
Eric Haszlakiewicz
eab1375123 Change CMakeLists.txt to look for SSIZE_T on MSVC too. 2020-06-07 03:36:59 +00:00
Eric Haszlakiewicz
0fc9d91277 Kick json_type_string out of struct json_object.
The default is now that string data is stored inline at the end of json_object, though to allow for json_object_set_string() to set a _longer_ string, we still need to allow for the possibility of a separate char * pointer.
All json types have been split out now, next step it cleanup.
2020-06-07 02:56:59 +00:00
Eric Haszlakiewicz
fe308b8862 Issue #626: Restore compatibility with cmake 2.8 by adjusting quoting and explicitly defining the PROJECT_VERSION* variables. 2020-05-30 19:37:46 +00:00
Björn Esser
1e94da779a CMake: Fix grammar: written -> wrote. 2020-05-18 20:36:16 +02:00
Björn Esser
61e2bae511 doc: Move Doxyfile into doc subdir 2020-05-18 20:36:16 +02:00
Björn Esser
8f3592b3d5 CMake: Fix out-of-tree build for Doxygen documentation. 2020-05-18 18:20:33 +02:00
Björn Esser
76dd99abb2 CMake: Re-format config-option block and re-order it alphabetically. 2020-05-18 12:34:08 +02:00
Björn Esser
78642dcb9b CMake: Add an option to disable the use of thread-local storage.
Using thread-local storage may not be desired in all environments
and/or use-cases, thus there should be an option to disable its use
on purpose.

Fixes #451.
2020-05-18 12:27:19 +02:00
Eric Haszlakiewicz
06742d6277 Issue #600: don't rename the static library on Windows, it _needs_ to have a different name because the dll build also creates a "json-c.lib" file. 2020-05-10 03:58:51 +00:00
Eric Haszlakiewicz
4f43a077a4 Issue #598: avoid building static libraries twice. 2020-05-10 03:48:45 +00:00
hofnarr
558ef8609c cmake: change variable name 2020-05-08 02:19:38 +03:00
hofnarr
929d74512a cmake: add list for build targets 2020-05-08 02:16:52 +03:00
dota17
e97fc20bfd update 2020-05-07 14:50:43 +08:00
dota17
952db0f397 support to build both static and shared libraries 2020-05-06 14:46:47 +08:00
Eric Haszlakiewicz
00272292a7 The json_parse command line app doesn't build on Windows, disable it. 2020-04-21 21:35:41 +00:00
Eric Haszlakiewicz
55d053118e Add an apps directory, and a json_parse program to parse an input file and report on memory usage.
This is intended to provide a way, during development, to test out the memory
and performance impacts of a change.
2020-04-21 03:57:56 +00:00
Eric Haszlakiewicz
fa6bc1e2d7 Issue #471: always create directories with mode 0755, regardless of umask. 2020-04-21 03:19:17 +00:00
Eric Haszlakiewicz
8b511c402b Issue #585: don't install config.h 2020-04-21 01:13:21 +00:00
Eric Haszlakiewicz
2babb5b780 Update the master branch to version 0.0.14.99 2020-04-19 03:57:08 +00:00
Jehan
8c33d1c3c9 CMakeLists: do not enforce strict prototypes on Windows.
On Windows, or at least when cross-built with Mingw-w64, build fails
because strict prototype fails on an included file (thus nothing we can
do about in json-c code):

> from /home/jehan/dev/src/json-c/json_util.c:44:
> /home/jehan/.local/share/crossroad/roads/w64/json-c/include/minwindef.h:196:3: error: function declaration isn't a prototype [-Werror=strict-prototypes]
>   196 |   typedef INT_PTR (WINAPI *FARPROC) ();
>       |   ^~~~~~~
> /home/jehan/.local/share/crossroad/roads/w64/json-c/include/minwindef.h:197:3: error: function declaration isn't a prototype [-Werror=strict-prototypes]
>   197 |   typedef INT_PTR (WINAPI *NEARPROC) ();
>       |   ^~~~~~~
> /home/jehan/.local/share/crossroad/roads/w64/json-c/include/minwindef.h:198:3: error: function declaration isn't a prototype [-Werror=strict-prototypes]
>   198 |   typedef INT_PTR (WINAPI *PROC) ();
>       |   ^~~~~~~

Let's just disable the errors for Windows build.
2020-04-15 13:03:11 +02:00
Björn Esser
053eaa61d7 Fix CMake tests for enforced strict prototypes. 2020-04-14 20:42:32 +02:00
Björn Esser
d0dc3489dc Enforce strict prototypes. 2020-04-13 11:29:52 +02:00
Björn Esser
165e6f58fc CMake: Install pkgconfig file in proper location by default
The default location for pkconfig files on most systems is:
  ${CMAKE_INSTALL_LIBDIR}/pkgconfig

Thus the file should get installed in there by default.
2020-04-12 19:21:54 +02:00
Björn Esser
78cd37fb18 Clean trailing white-space. 2020-04-11 09:41:04 +02:00
Björn Esser
e756777c92 CMake: Check whether BSYMBOLIC is supported by the linker.
Linking with '-Bsymbolic-functions' is supported for ELF-binaries, only.
2020-04-10 17:29:35 +02:00
Björn Esser
58670ec64e CMake: Build Doxygen documentation out-of-tree. 2020-04-10 14:20:57 +02:00
Björn Esser
a989651bd4 CMake: Fix appending of linker flags.
There was a typo in `CMAKE_SHARED_LINKER_FLAGS`.
2020-04-10 14:16:02 +02:00
Eric Haszlakiewicz
545464322b Issue #568: fix the strtoll and strtoull handing so config.h ends up creating defines for those only when needed, which should exclude mingw environments. 2020-04-09 20:58:28 +00:00
Eric Haszlakiewicz
19bbf2c069 Add includes and split off json_types.h to help ensure that headers can be included in any order. 2020-04-06 13:55:27 +00:00
dota17
1204a1fded modify the doc target message 2020-03-19 10:27:27 +08:00
Eric Haszlakiewicz
e94eb90f9f Merge pull request #546 from dota17/make_unistall
Add uninstall target in cmake
2020-03-10 22:12:13 -05:00
dota17
c14c6caa32 delete -r in uninstall 2020-03-11 10:47:04 +08:00
Eric Haszlakiewicz
a8c9284f06 Merge pull request #547 from dota17/assert_test
modify json-c default build type, and fix up the assert() errors in t…
2020-03-03 07:54:21 -06:00
dota17
0030e905b4 modify RELEASE 2020-03-03 14:16:13 +08:00
dota17
e56ab0146f update testcase and delete debug -O0 build 2020-03-02 20:19:35 +08:00
Eric Haszlakiewicz
737aee40c4 Merge pull request #542 from dota17/adduint64_final
add uint64 data to json-c
2020-03-01 08:51:26 -05:00
dota17
2d44f865c3 modify json-c default build type, and fix up the assert() errors in testcase 2020-02-29 15:32:42 +08:00
dota17
1160c8625c Add uninstall target in cmake 2020-02-27 21:02:31 +08:00
dota17
e3b6521baa add doc target on cmake 2020-02-26 18:18:07 +08:00
dota17
77d7a99c75 Increase distcheck target in cmake 2020-02-25 19:15:40 +08:00
dota17
3c3b5920f7 add uint64 data to json-c 2020-02-25 14:51:35 +08:00
Eric Haszlakiewicz
6c55f65d07 Set cmake policy CMP0075, to have check_include_file use the value of CMAKE_REQUIRED_LIBRARIES (currently, adds -lm). See issue #510. 2019-12-06 00:15:14 -05:00
Eric Haszlakiewicz
11a638048d Add a few missing features to the cmake setup that are present in configure.ac:
Include all compiler warnings, and provide DISABLE_WERROR to make them not be errors.
 Define _REENTRANT, if setting it works.
 Set -Bsymbolic-functions, and provide DISABLE_BSYMBOLIC to turn that off.
 Implement the check for HAS_GNU_WARNING_LONG
2019-11-26 23:02:15 -05:00