On CHERI, and thus Arm's Morello prototype, pointers are represented as
hardware capabilities. These capabilities are comprised of not just an
integer address, as is the representation for traditional pointers, but
also bounds, permissions and other metadata, plus a tag bit used as the
validity bit, which provides fine-grained spatial and referential safety
for C and C++ in hardware. This tag bit is not part of the data itself
and is instead kept on the side, flowing with the capability between
registers and the memory subsystem, and any attempt to amplify the
privilege of or corrupt a capability clears this tag (or, in some cases,
traps), rendering them impossible to forge; you can only create
capabilities that are (possibly trivial) subsets of existing ones.
When the capability is stored in memory, this tag bit needs to be
preserved, which is done through the use of tagged memory. Every
capability-sized word gains an additional non-addressable (from the
CPU's perspective; depending on the implementation the tag bits may be
stored in a small block of memory carved out of normal DRAM that the CPU
is blocked from accessing) bit. This means that capabilities can only be
stored to aligned locations; attempting to store them to unaligned
locations will trap with an alignment fault or, if you end up using a
memcpy call, will copy the raw bytes of the capability's representation
but lose the tag, so when it is eventually loaded back as a capability
and dereferenced it will fault.
Since, on 64-bit architectures, our capabilities, used to implement C
language pointers, are 128-bit quantities, this means they need 16-byte
alignment. Currently the various #pragma pack directives, used to work
around (extremely broken and bogus) code that includes jsoncpp in a
context where the maximum alignment has been overridden, hard-code 8 as
the maximum alignment to use, and so do not sufficiently align CHERI /
Morello capabilities on 64-bit architectures. On Windows x64, the
default is also not 8 but 16 (ARM64 is supposedly 8), so this is
slightly dodgy to do there too, but in practice likely not an issue so
long as you don't use any 128-bit types there.
Instead of hard-coding a width, use a directive that resets the packing
back to the default. Unfortunately, whilst GCC and Clang both accept
using #pragma pack(push, 0) as shorthand like for any non-zero value,
MSVC does not, so this needs to be two directives.
* ENH: Prevent cmake in source builds
Building directly inside the root of the source tree
can cause problems where the build intermediate files
overwrite or conflict with the intended source code
files.
This modification identifies this problem and
issues failure messages and suggestions to over
come the problem with more robust build suggestion.
Co-authored-by: Jordan Bayles <jophba@chromium.org>
This patch adds an explicit ctor with a std::nullptr_t argument, that is `delete`-d. This keeps Json::Value from exposing a coding error when automatically promoted to a const char* type.
* [clang-tidy] remove redundant string initialization
Found with readability-redundant-string-init
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] switch to raw strings
Easier to read.
Found with modernize-raw-string-literal
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] fix performance issues
Found with performance*
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* fix extra comma warnings
Found with clang's -Wextra-semi-stmt
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* remove JSONCPP_OP_EXPLICIT
This codebase in C++11. No need for compatibility with C++98.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* remove JSONCPP_NOEXCEPT
This codebase is C++11 now. No need for this macro.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
For Apple clang-800.0.42.1, which was released with Xcode 8 in
September 2016, the '=delete' on the 'is' and 'as' methods causes
the following errors for value.h:
inline declaration of 'as<bool>' follows non-inline definition
inline declaration of 'is<bool>' follows non-inline definition
etcetera for the other specializations of 'is' and 'as'. The same
problem also occurs for clang-3.8 but not clang-3.9 or later.
* Modernize meson.build
* Make tests optional
* Use `files()` for quick sanity checks
* Bump version to 1.9.3
* Bump SOVERSION, as some functions were removed
and structs were changed, as determined by
libabigail.
CPPTL support is no longer relevant to JsonCpp, and can be removed from
the library. This patch removes all mentions of CPPTL, by removing all
definitions and code sections conditionally compiled only when JsonCpp
is used with CPPTL. Include guards are also renamed to not refer to
CPPTL where appropriate.
* [clang-tidy] Add explicit to single argument constructor
Found with hicpp-explicit-conversions
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] Fix mismatching declaration
Found with readability-inconsistent-declaration-parameter-name
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] Replace {} with = default
Found with modernize-use-equals-default
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] Remove redundant .c_Str
Found with readability-redundant-string-cstr
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] Simplify boolean expressions
Found with readability-simplify-boolean-expr
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] Use std::move
Found with modernize-pass-by-value
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] Uppercase literal suffixes
Found with hicpp-uppercase-literal-suffix
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* Issue #958: Travis CI should enfore clang-format standards
This patch adds clang format support to the travis bots.
* Update path
* Roll back to version 8 since 9 is in test
* Cleanup clang
* Revert "Delete JSONCPP_DEPRECATED, use [[deprecated]] instead. (#978)" (#1029)
This reverts commit b27c83f691.
This patch fixes a build issue on CMake, presumably due to the new glibc
having a features.h include file. This patch renames our features.h file
to avoid a name collision.
The current check to define JSON_USE_INT64_DOUBLE_CONVERSION
works for GCC but not clang.
Clang does define __GNUC__ but with a value 4 which misses
the check for >= 6.
This avoids the -Wimplicit-int-float-conversion warning
when jsoncpp is built with a recent version of clang.
Signed-off-by: Manoj Gupta <manojgupta@google.com>
* Cleanup versioning strategy
Currently, versioning is a mess. CMake and Meson have seperate build
version number storage locations, with no way of knowing you need to
have both. Plus, due to recent revisions the amalgamate script is broken
unless you build first, and may still be broken afterwards.
This PR fixes some issues with versioning, and adds comments clarifying
what has to be done when doing a release.
* Run clang format
* Update SOVERSION....
* Cleanup versioning strategy
Currently, versioning is a mess. CMake and Meson have seperate build
version number storage locations, with no way of knowing you need to
have both. Plus, due to recent revisions the amalgamate script is broken
unless you build first, and may still be broken afterwards.
This PR fixes some issues with versioning, and adds comments clarifying
what has to be done when doing a release.
* Run clang format
* Update SOVERSION....
This patch adds a new flag, JSON_USE_NULLREF, which removes
the legacy singletons null, nullRef for consumers that require not
having static initialized globals, like Chromium.