Compare commits

...

14 Commits

Author SHA1 Message Date
Daniel Lemire 74870a8189 Fixing issue 1013. (#1016)
* Fixing issue 1013.

* Bumping to 0.4.6

Co-authored-by: Daniel Lemire <lemire@gmai.com>
2020-07-01 14:14:51 -04:00
Daniel Lemire 0ef4d90ad0 Fix for issue 1014. (#1015)
* Fix for issue 1014.

* Explanation.

Co-authored-by: Daniel Lemire <lemire@gmai.com>
2020-06-30 19:36:26 -04:00
Daniel Lemire 1a1e7edb02 Tweaking the recently introduced mingw tests. (#1011)
Co-authored-by: Daniel Lemire <lemire@gmai.com>
2020-06-30 12:47:44 -04:00
Daniel Lemire 51b835f71b Correcting typo (#1007)
Co-authored-by: Daniel Lemire <lemire@gmai.com>
2020-06-30 10:19:37 -04:00
Daniel Lemire e38fe3d361 Version update 2020-06-30 09:41:20 -04:00
myd7349 cc042c9936 CMAKE_VS_PLATFORM_TOOLSET might be empty (#1009)
According to https://gitlab.kitware.com/cmake/cmake/-/issues/17976,
CMAKE_VS_PLATFORM_TOOLSET is set only when using a Visual Studio generator.

When we use Ninja as the generator, CMAKE_VS_PLATFORM_TOOLSET will be empty.
As a result:
if(${CMAKE_VS_PLATFORM_TOOLSET} STREQUAL "v140")
will be treated as:
if( STREQUAL "v140")

We may also quote it like this:
if("${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "v140")
but that won't make the warnings disappeared in VS2015.
2020-06-30 09:40:19 -04:00
Daniel Lemire 599e3bc937 Update README.md 2020-06-29 21:52:08 -04:00
Daniel Lemire 1fa0d940bc Update README.md 2020-06-29 21:44:05 -04:00
Daniel Lemire 7dc4a9525b Update README.md 2020-06-29 21:43:07 -04:00
Daniel Lemire b6f1f4ef64 Update basics.md 2020-06-29 21:41:50 -04:00
Daniel Lemire 3faae67663 New release 2020-06-29 21:11:58 -04:00
Daniel Lemire ccc94c9b05 Mingw tests (32-bit and 64-bit) (#1004) 2020-06-29 21:10:54 -04:00
Daniel Lemire 1fd30db726 This example in our documentation would not compile (#1005)
Co-authored-by: Daniel Lemire <lemire@gmai.com>
2020-06-29 16:25:11 -04:00
Daniel Lemire 0ba76ac066 This enables building the library under Visual Studio 2015 (#1002)
Co-authored-by: Daniel Lemire <lemire@gmai.com>
2020-06-29 08:43:47 -04:00
33 changed files with 348 additions and 65 deletions
+4
View File
@@ -20,6 +20,10 @@ environment:
platform: Win32
CMAKE_ARGS: -A %Platform% -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_ENABLE_THREADS=ON # This should be the default. Testing anyway.
CTEST_ARGS: -E checkperf
- job_name: VS2015
image: Visual Studio 2015
CMAKE_ARGS: -A %Platform% -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_ENABLE_THREADS=OFF
CTEST_ARGS: -E checkperf
build_script:
- mkdir build
+58
View File
@@ -0,0 +1,58 @@
name: MinGW32-CI
on: push
# Important: scoop will either install 32-bit GCC or 64-bit GCC, not both.
# It is important to build static libraries because cmake is not smart enough under Windows/mingw to take care of the path. So
# with a dynamic library, you could get failures due to the fact that the EXE can't find its DLL.
jobs:
ci:
name: windows-gcc
runs-on: windows-2016
env:
CMAKE_GENERATOR: Ninja # This is critical, try ' cmake -GNinja-DSIMDJSON_BUILD_STATIC=ON .. ' if using the command line
CC: gcc
CXX: g++
steps: # To reproduce what is below, start a powershell with administrative rights, using scoop *is* a good idea
- uses: actions/checkout@v2
- uses: actions/cache@v2 # we cache the scoop setup with 32-bit GCC
id: cache
with:
path: |
C:\ProgramData\scoop
key: scoop32 # static key: should be good forever
- name: Setup Windows # This should almost never run if the cache works.
if: steps.cache.outputs.cache-hit != 'true'
shell: powershell
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
scoop install sudo --global
sudo scoop install git --global
sudo scoop install ninja --global
sudo scoop install cmake --global
sudo scoop install gcc --arch 32bit --global
$env:path
Write-Host 'Everything has been installed, you are good!'
- name: Build and Test 32-bit x86
shell: powershell
run: |
$ENV:PATH="C:\ProgramData\scoop\shims;C:\ProgramData\scoop\apps\gcc\current\bin;C:\ProgramData\scoop\apps\ninja\current;$ENV:PATH"
g++ --version
cmake --version
ninja --version
git --version
mkdir build32
cd build32
cmake -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_ENABLE_THREADS=OFF ..
cmake --build . --target basictests numberparsingcheck stringparsingcheck errortests integer_tests pointercheck --verbose
ctest . -R stringparsingcheck --output-on-failure
ctest . -R numberparsingcheck --output-on-failure
ctest . -R errortests --output-on-failure
ctest . -R integer_tests --output-on-failure
ctest . -R pointercheck --output-on-failure
+60
View File
@@ -0,0 +1,60 @@
name: MinGW64-CI
on: push
# Important: scoop will either install 32-bit GCC or 64-bit GCC, not both.
# It is important to build static libraries because cmake is not smart enough under Windows/mingw to take care of the path. So
# with a dynamic library, you could get failures due to the fact that the EXE can't find its DLL.
jobs:
ci:
name: windows-gcc
runs-on: windows-2016
env:
CMAKE_GENERATOR: Ninja # This is critical, try ' cmake -GNinja-DSIMDJSON_BUILD_STATIC=ON .. ' if using the command line
CC: gcc
CXX: g++
steps: # To reproduce what is below, start a powershell with administrative rights, using scoop *is* a good idea
- uses: actions/checkout@v2
- uses: actions/cache@v2 # we cache the scoop setup with 64-bit GCC
id: cache
with:
path: |
C:\ProgramData\scoop
key: scoop64 # static key: should be good forever
- name: Setup Windows # This should almost never run if the cache works.
if: steps.cache.outputs.cache-hit != 'true'
shell: powershell
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
scoop install sudo --global
sudo scoop install git --global
sudo scoop install ninja --global
sudo scoop install cmake --global
sudo scoop install gcc --arch 64bit --global
$env:path
Write-Host 'Everything has been installed, you are good!'
- name: Build and Test 64-bit x64
shell: powershell
run: |
$ENV:PATH="C:\ProgramData\scoop\shims;C:\ProgramData\scoop\apps\gcc\current\bin;C:\ProgramData\scoop\apps\ninja\current;$ENV:PATH"
g++ --version
cmake --version
ninja --version
git --version
mkdir build64
cd build64
cmake -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_ENABLE_THREADS=OFF ..
cmake --build . --target basictests numberparsingcheck stringparsingcheck errortests integer_tests pointercheck --verbose
ctest . -R stringparsingcheck --output-on-failure
ctest . -R numberparsingcheck --output-on-failure
ctest . -R errortests --output-on-failure
ctest . -R integer_tests --output-on-failure
ctest . -R pointercheck --output-on-failure
+5 -7
View File
@@ -7,15 +7,12 @@ project(simdjson
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 4)
set(PROJECT_VERSION_PATCH 2)
set(SIMDJSON_LIB_VERSION "0.4.2" CACHE STRING "simdjson library version")
set(PROJECT_VERSION_PATCH 6)
set(SIMDJSON_SEMANTIC_VERSION "0.4.6" CACHE STRING "simdjson semantic version")
set(SIMDJSON_LIB_VERSION "2.0.0" CACHE STRING "simdjson library version")
set(SIMDJSON_LIB_SOVERSION "2" CACHE STRING "simdjson library soversion")
set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson)
# The SIMDJSON_LIB_SOVERSION is 0 for versions before 0.3.0.
# The SIMDJSON_LIB_SOVERSION is 1 for version 0.3.
# The SIMDJSON_LIB_SOVERSION is 2 for version 0.4.
include(GNUInstallDirs)
include(cmake/simdjson-flags.cmake)
include(cmake/simdjson-user-cmakecache.cmake)
@@ -47,8 +44,9 @@ add_subdirectory(windows)
if(NOT(SIMDJSON_JUST_LIBRARY))
add_subdirectory(dependencies) ## This needs to be before tools because of cxxopts
add_subdirectory(tools) ## This needs to be before tests because of cxxopts
add_subdirectory(singleheader)
endif()
add_subdirectory(singleheader)
install(FILES singleheader/simdjson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#
# Compile tools / tests / benchmarks
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = simdjson
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "0.4.2"
PROJECT_NUMBER = "0.4.6"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+3 -1
View File
@@ -1,8 +1,10 @@
[![Build Status](https://cloud.drone.io/api/badges/simdjson/simdjson/status.svg)](https://cloud.drone.io/simdjson/simdjson)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/simdjson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&q=proj%3Asimdjson&can=2)
[![Build status](https://ci.appveyor.com/api/projects/status/ae77wp5v3lebmu6n/branch/master?svg=true)](https://ci.appveyor.com/project/lemire/simdjson-jmmti/branch/master)
[![simdjson](https://circleci.com/gh/simdjson/simdjson.svg?style=svg)](https://circleci.com/gh/simdjson/simdjson)
[![CirrusCI](https://api.cirrus-ci.com/github/simdjson/simdjson.svg)](https://cirrus-ci.com/github/simdjson/simdjson)
[![][license img]][license] [![Doxygen Documentation](https://img.shields.io/badge/docs-doxygen-green.svg)](https://simdjson.org/api/0.3.1/index.html)
![MinGW64-CI](https://github.com/simdjson/simdjson/workflows/MinGW64-CI/badge.svg)
[![][license img]][license] [![Doxygen Documentation](https://img.shields.io/badge/docs-doxygen-green.svg)](https://simdjson.org/api/0.4.0/index.html)
simdjson : Parsing gigabytes of JSON per second
===============================================
+17
View File
@@ -2,6 +2,23 @@
## Highlights
- Test coverage has been greatly improved and we have resolved many static-analysis warnings on different systems.
- We added a fast (8GB/s) minifier that works directly on JSON strings.
- We added fast (10GB/s) UTF-8 validator that works directly on strings (any strings, including non-JSON).
- The array and object elements have a constant-time size() method.
- Performance improvements to the API (type(), get<>()).
- The parse_many function (ndjson) has been entirely reworked. It now uses a single secondary thread instead of several new threads.
- We have introduced a faster UTF-8 validation algorithm (lookup3) for all kernels (ARM, x64 SSE, x64 AVX).
- C++11 support for older compilers and systems.
- FreeBSD support (and tests).
- We support the clang front-end compiler (clangcl) under Visual Studio.
- It is now possible to target ARM platforms under Visual Studio.
- The simdjson library will never abort or print to standard output/error.
# 0.3
## Highlights
- **Multi-Document Parsing:** Read a bundle of JSON documents (ndjson) 2-4x faster than doing it
individually. [API docs](https://github.com/simdjson/simdjson/blob/master/doc/basics.md#newline-delimited-json-ndjson-and-json-lines) / [Design Details](https://github.com/simdjson/simdjson/blob/master/doc/parse_many.md)
- **Simplified API:** The API has been completely revamped for ease of use, including a new JSON
+9
View File
@@ -53,6 +53,9 @@ endif()
option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON)
option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" ON)
if(SIMDJSON_COMPETITION)
message(STATUS "Using SIMDJSON_GOOGLE_BENCHMARKS")
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
@@ -74,7 +77,13 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
if(MSVC)
if("${MSVC_TOOLSET_VERSION}" STREQUAL "140")
# Visual Studio 2015 issues warnings and we tolerate it, cmake -G"Visual Studio 14" ..
target_compile_options(simdjson-internal-flags INTERFACE /W0 /sdl)
else()
# Recent version of Visual Studio expected (2017, 2019...). Prior versions are unsupported.
target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl)
endif()
else()
target_compile_options(simdjson-internal-flags INTERFACE -fPIC)
target_compile_options(simdjson-internal-flags INTERFACE -Werror -Wall -Wextra -Weffc++)
+1
View File
@@ -18,6 +18,7 @@ if ((Git_FOUND) AND (SIMDJSON_IS_UNDER_GIT))
endfunction(initialize_submodule)
if (SIMDJSON_GOOGLE_BENCHMARKS)
message (STATUS "'SIMDJSON_GOOGLE_BENCHMARKS' is requested, configuring..." )
option(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
option(BENCHMARK_ENABLE_INSTALL OFF)
+1 -1
View File
@@ -25,7 +25,7 @@ Requirements
------------------
- A recent compiler (LLVM clang6 or better, GNU GCC 7 or better) on a 64-bit (ARM or x64 Intel/AMD) POSIX systems such as macOS, freeBSD or Linux. We require that the compiler supports the C++11 standard or better.
- Visual Studio 2017 or better under 64-bit Windows. Users should target a 64-bit build (x64) instead of a 32-bit build (x86). We support the LLVM clang compiler under Visual Studio (clangcl) as well as as the regular Visual Studio compiler.
- Visual Studio 2017 or better under 64-bit Windows. Users should target a 64-bit build (x64) instead of a 32-bit build (x86). We support the LLVM clang compiler under Visual Studio (clangcl) as well as as the regular Visual Studio compiler. We also support MinGW 64-bit under Windows.
Including simdjson
------------------
+1 -1
View File
@@ -47,7 +47,7 @@ Inspecting the Detected Implementation
You can check what implementation is running with `active_implementation`:
```c++
cout << "simdjson v" << #SIMDJSON_VERSION << endl;
cout << "simdjson v" << STRINGIFY(SIMDJSON_VERSION) << endl;
cout << "Detected the best implementation for your machine: " << simdjson::active_implementation->name();
cout << "(" << simdjson::active_implementation->description() << ")" << endl;
```
+6 -3
View File
@@ -81,12 +81,15 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS __pragma(warning( push, 0 ))
#define SIMDJSON_DISABLE_VS_WARNING(WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER ))
// Get rid of Intellisense-only warnings (Code Analysis)
// Though __has_include is C++17, it looks like it is supported in Visual Studio 2017 or better.
// We are probably not supporting earlier version of Visual Studio in any case.
// Though __has_include is C++17, it is supported in Visual Studio 2017 or better (_MSC_VER>=1910).
#if defined(_MSC_VER) && (_MSC_VER>=1910)
#if __has_include(<CppCoreCheck\Warnings.h>)
#include <CppCoreCheck\Warnings.h>
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS)
#else
#endif
#endif
#ifndef SIMDJSON_DISABLE_UNDESIRED_WARNINGS
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
#endif
+5
View File
@@ -391,7 +391,12 @@ private:
/**
* The loaded buffer (reused each time load() is called)
*/
#if defined(_MSC_VER) && _MSC_VER < 1910
// older versions of Visual Studio lack proper support for unique_ptr.
std::unique_ptr<char[]> loaded_bytes;
#else
std::unique_ptr<char[], decltype(&aligned_free_char)> loaded_bytes;
#endif
/** Capacity of loaded_bytes buffer. */
size_t _loaded_bytes_capacity{0};
+5
View File
@@ -21,7 +21,12 @@ inline char *allocate_padded_buffer(size_t length) noexcept {
// return (char *) malloc(length + SIMDJSON_PADDING);
// However, we might as well align to cache lines...
size_t totalpaddedlength = length + SIMDJSON_PADDING;
#if defined(_MSC_VER) && _MSC_VER < 1910
// For legacy Visual Studio 2015 since it does not have proper C++11 support
char *padded_buffer = new[totalpaddedlength];
#else
char *padded_buffer = aligned_malloc_char(64, totalpaddedlength);
#endif
#ifndef NDEBUG
if (padded_buffer == nullptr) {
return nullptr;
+8
View File
@@ -15,10 +15,18 @@ namespace dom {
//
// parser inline implementation
//
#if defined(_MSC_VER) && _MSC_VER < 1910
// older versions of Visual Studio lack proper support for unique_ptr.
really_inline parser::parser(size_t max_capacity) noexcept
: _max_capacity{max_capacity},
loaded_bytes(nullptr) {
}
#else
really_inline parser::parser(size_t max_capacity) noexcept
: _max_capacity{max_capacity},
loaded_bytes(nullptr, &aligned_free_char) {
}
#endif
really_inline parser::parser(parser &&other) noexcept = default;
really_inline parser &parser::operator=(parser &&other) noexcept = default;
+1 -2
View File
@@ -5,7 +5,7 @@
#include <cstdint>
#include <cstdlib>
#include <cfloat>
#include <cassert>
#ifdef _MSC_VER
#define SIMDJSON_VISUAL_STUDIO 1
@@ -232,7 +232,6 @@ static inline void aligned_free_char(char *mem_block) {
#else // NDEBUG
#include <cassert>
#define SIMDJSON_UNREACHABLE() assert(0);
#define SIMDJSON_ASSUME(COND) assert(COND)
+2 -2
View File
@@ -4,7 +4,7 @@
#define SIMDJSON_SIMDJSON_VERSION_H
/** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION 0.4.2
#define SIMDJSON_VERSION 0.4.6
namespace simdjson {
enum {
@@ -19,7 +19,7 @@ enum {
/**
* The revision (major.minor.REVISION) of simdjson being used.
*/
SIMDJSON_VERSION_REVISION = 2
SIMDJSON_VERSION_REVISION = 6
};
} // namespace simdjson
+6 -3
View File
@@ -20,7 +20,10 @@ set_source_files_properties(${SINGLEHEADER_FILES} PROPERTIES GENERATED TRUE)
find_program(BASH bash)
if (BASH)
# Under Windows, exectuting a bash script works, except that you cannot generally
# do bash C:/path to my script. You need a "mounted" path: /mnt/c/path
if (BASH AND (NOT WIN32))
add_custom_command(
OUTPUT ${SINGLEHEADER_FILES}
COMMAND ${CMAKE_COMMAND} -E env
@@ -69,7 +72,7 @@ if (BASH)
# add_custom_target(amalgamate DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/simdjson.cpp ${CMAKE_CURRENT_SOURCE_DIR}/simdjson.h ${CMAKE_CURRENT_SOURCE_DIR}/amalgamate_demo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
##
else(BASH)
else()
# We do not have bash, so we use existing amalgamated files instead of generating them ...
# (Do not do this if the source and destination are the same!)
@@ -83,7 +86,7 @@ else(BASH)
)
endif()
endif(BASH)
endif()
#
# Do not depend on singleheader files directly: depend on this target instead.
+1 -1
View File
@@ -1,4 +1,4 @@
/* auto-generated on Sun 28 Jun 2020 12:39:28 EDT. Do not edit! */
/* auto-generated on Wed Jul 1 14:00:57 EDT 2020. Do not edit! */
#include <iostream>
#include "simdjson.h"
+1 -1
View File
@@ -1,4 +1,4 @@
/* auto-generated on Sun 28 Jun 2020 12:39:28 EDT. Do not edit! */
/* auto-generated on Wed Jul 1 14:00:57 EDT 2020. Do not edit! */
/* begin file src/simdjson.cpp */
#include "simdjson.h"
+28 -8
View File
@@ -1,4 +1,4 @@
/* auto-generated on Sun 28 Jun 2020 12:39:28 EDT. Do not edit! */
/* auto-generated on Wed Jul 1 14:00:57 EDT 2020. Do not edit! */
/* begin file include/simdjson.h */
#ifndef SIMDJSON_H
#define SIMDJSON_H
@@ -59,7 +59,7 @@
#include <cstdint>
#include <cstdlib>
#include <cfloat>
#include <cassert>
#ifdef _MSC_VER
#define SIMDJSON_VISUAL_STUDIO 1
@@ -286,7 +286,6 @@ static inline void aligned_free_char(char *mem_block) {
#else // NDEBUG
#include <cassert>
#define SIMDJSON_UNREACHABLE() assert(0);
#define SIMDJSON_ASSUME(COND) assert(COND)
@@ -373,12 +372,15 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS __pragma(warning( push, 0 ))
#define SIMDJSON_DISABLE_VS_WARNING(WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER ))
// Get rid of Intellisense-only warnings (Code Analysis)
// Though __has_include is C++17, it looks like it is supported in Visual Studio 2017 or better.
// We are probably not supporting earlier version of Visual Studio in any case.
// Though __has_include is C++17, it is supported in Visual Studio 2017 or better (_MSC_VER>=1910).
#if defined(_MSC_VER) && (_MSC_VER>=1910)
#if __has_include(<CppCoreCheck\Warnings.h>)
#include <CppCoreCheck\Warnings.h>
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS)
#else
#endif
#endif
#ifndef SIMDJSON_DISABLE_UNDESIRED_WARNINGS
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
#endif
@@ -2038,7 +2040,7 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS
#define SIMDJSON_SIMDJSON_VERSION_H
/** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION 0.4.2
#define SIMDJSON_VERSION 0.4.6
namespace simdjson {
enum {
@@ -2053,7 +2055,7 @@ enum {
/**
* The revision (major.minor.REVISION) of simdjson being used.
*/
SIMDJSON_VERSION_REVISION = 2
SIMDJSON_VERSION_REVISION = 6
};
} // namespace simdjson
@@ -3673,7 +3675,12 @@ private:
/**
* The loaded buffer (reused each time load() is called)
*/
#if defined(_MSC_VER) && _MSC_VER < 1910
// older versions of Visual Studio lack proper support for unique_ptr.
std::unique_ptr<char[]> loaded_bytes;
#else
std::unique_ptr<char[], decltype(&aligned_free_char)> loaded_bytes;
#endif
/** Capacity of loaded_bytes buffer. */
size_t _loaded_bytes_capacity{0};
@@ -6779,7 +6786,12 @@ inline char *allocate_padded_buffer(size_t length) noexcept {
// return (char *) malloc(length + SIMDJSON_PADDING);
// However, we might as well align to cache lines...
size_t totalpaddedlength = length + SIMDJSON_PADDING;
#if defined(_MSC_VER) && _MSC_VER < 1910
// For legacy Visual Studio 2015 since it does not have proper C++11 support
char *padded_buffer = new[totalpaddedlength];
#else
char *padded_buffer = aligned_malloc_char(64, totalpaddedlength);
#endif
#ifndef NDEBUG
if (padded_buffer == nullptr) {
return nullptr;
@@ -7401,10 +7413,18 @@ namespace dom {
//
// parser inline implementation
//
#if defined(_MSC_VER) && _MSC_VER < 1910
// older versions of Visual Studio lack proper support for unique_ptr.
really_inline parser::parser(size_t max_capacity) noexcept
: _max_capacity{max_capacity},
loaded_bytes(nullptr) {
}
#else
really_inline parser::parser(size_t max_capacity) noexcept
: _max_capacity{max_capacity},
loaded_bytes(nullptr, &aligned_free_char) {
}
#endif
really_inline parser::parser(parser &&other) noexcept = default;
really_inline parser &parser::operator=(parser &&other) noexcept = default;
+11 -1
View File
@@ -78,7 +78,17 @@ if(NOT MSVC)
## We output the library at the root of the current directory where cmake is invoked
## This is handy but Visual Studio will happily ignore us
set_target_properties(simdjson PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
MESSAGE( STATUS "Library output directory (does not apply to Visual Studio): " ${PROJECT_BINARY_DIR})
MESSAGE( STATUS "Library output directory: " ${PROJECT_BINARY_DIR})
############
# Please do not delete the following, our users want version numbers. See
# https://github.com/simdjson/simdjson/issues/1014
# https://github.com/simdjson/simdjson/issues/52
###########
set_target_properties(simdjson PROPERTIES VERSION ${SIMDJSON_LIB_VERSION} SOVERSION ${SIMDJSON_LIB_SOVERSION})
##########
# End of the do-not-delete message.
#########
endif()
#
+20 -1
View File
@@ -62,9 +62,12 @@ add_cpp_test(unicode_tests LABELS acceptance per_implementation)
find_program(BASH bash)
# Below we skip anything on Windows, not just visual studio, because running bash under Windows requires you to
# map app paths to their "mounted" equivalent (e.g., /mnt/c/...). So even if you have bash under Windows, extra work would be
# required to make things work robustly. Simply put: bash is not quite portable.
# Script tests
if (BASH AND (NOT MSVC) AND (TARGET json2json)) # The scripts are not robust enough to run under Windows even if bash is available
if (BASH AND (NOT WIN32) AND (TARGET json2json)) # The scripts are not robust enough to run under Windows even if bash is available
#
# json2json test
#
@@ -174,4 +177,20 @@ endif()
# target_link_libraries(singleheader simdjson simdjson-flags)
# add_test(singleheader singleheader)
if(NOT MSVC)
######
# This tests is to guard us against ever again removing the soversion
# number from the library. See Bug
# https://github.com/simdjson/simdjson/issues/1014
#####
get_target_property(REPORTED_SIMDJSON_SOVERSION simdjson SOVERSION)
if(NOT ${REPORTED_SIMDJSON_SOVERSION} STREQUAL ${SIMDJSON_LIB_SOVERSION})
message(FATAL_ERROR "The library target does not have the proper soversion information." )
endif()
get_target_property(REPORTED_SIMDJSON_VERSION simdjson VERSION)
if(NOT ${REPORTED_SIMDJSON_VERSION} STREQUAL ${SIMDJSON_LIB_VERSION})
message(FATAL_ERROR "The library target does not have the proper version information." )
endif()
endif()
add_subdirectory(compilation_failure_tests)
+20 -4
View File
@@ -18,6 +18,7 @@
#include "test_macros.h"
const size_t AMAZON_CELLPHONES_NDJSON_DOC_COUNT = 793;
#define SIMDJSON_SHOW_DEFINE(x) printf("%s=%s\n", #x, STRINGIFY(x))
namespace number_tests {
@@ -68,7 +69,9 @@ namespace number_tests {
uint64_t ulp = f64_ulp_dist(actual,expected);
if(ulp > maxulp) maxulp = ulp;
if(ulp > 0) {
std::cerr << "JSON '" << buf << " parsed to " << actual << " instead of " << expected << std::endl;
std::cerr << "JSON '" << buf << " parsed to ";
fprintf( stderr," %18.18g instead of %18.18g\n", actual, expected); // formatting numbers is easier with printf
SIMDJSON_SHOW_DEFINE(FLT_EVAL_METHOD);
return false;
}
}
@@ -152,18 +155,25 @@ namespace number_tests {
std::cout << __func__ << std::endl;
char buf[1024];
simdjson::dom::parser parser;
for (int i = -1000000; i <= 308; ++i) {// large negative values should be zero.
bool is_pow_correct{1e-308 == std::pow(10,-308)};
int start_point = is_pow_correct ? -10000 : -307;
if(!is_pow_correct) {
std::cout << "On your system, the pow function is busted. Sorry about that. " << std::endl;
}
for (int i = start_point; i <= 308; ++i) {// large negative values should be zero.
size_t n = snprintf(buf, sizeof(buf), "1e%d", i);
if (n >= sizeof(buf)) { abort(); }
fflush(NULL);
double actual;
auto error = parser.parse(buf, n).get(actual);
if (error) { std::cerr << error << std::endl; return false; }
double expected = ((i >= -307) ? testing_power_of_ten[i + 307]: std::pow(10, i));
int ulp = (int) f64_ulp_dist(actual, expected);
if(ulp > 0) {
std::cerr << "JSON '" << buf << " parsed to " << actual << " instead of " << expected << std::endl;
std::cerr << "JSON '" << buf << " parsed to ";
fprintf( stderr," %18.18g instead of %18.18g\n", actual, expected); // formatting numbers is easier with printf
SIMDJSON_SHOW_DEFINE(FLT_EVAL_METHOD);
return false;
}
}
@@ -1924,6 +1934,7 @@ namespace format_tests {
}
}
int main(int argc, char *argv[]) {
std::cout << std::unitbuf;
int c;
@@ -1949,6 +1960,11 @@ int main(int argc, char *argv[]) {
if (simdjson::active_implementation->name() == "unsupported") {
printf("unsupported CPU\n");
}
// We want to know what we are testing.
std::cout << "Running tests against this implementation: " << simdjson::active_implementation->name();
std::cout << "(" << simdjson::active_implementation->description() << ")" << std::endl;
std::cout << "------------------------------------------------------------" << std::endl;
std::cout << "Running basic tests." << std::endl;
if (validate_tests::run() &&
minify_tests::run() &&
+1 -1
View File
@@ -1,5 +1,5 @@
#include <cstring>
#ifndef _MSC_VER
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
#include <dirent.h>
#else
// Microsoft can't be bothered to provide standard utils.
+9 -1
View File
@@ -9,7 +9,7 @@
#define JSON_TEST_NUMBERS
#endif
#ifndef _MSC_VER
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
#include <dirent.h>
#else
#include <dirent_portable.h>
@@ -87,7 +87,11 @@ void found_integer(int64_t result, const uint8_t *buf) {
char *endptr;
long long expected = strtoll((const char *)buf, &endptr, 10);
if ((endptr == (const char *)buf) || (expected != result)) {
#if (!(__MINGW32__) && !(__MINGW64__))
fprintf(stderr, "Error: parsed %" PRId64 " out of %.32s, ", result, buf);
#else // mingw is busted since we include #include <inttypes.h>
fprintf(stderr, "Error: parsed %lld out of %.32s, ", (long long)result, buf);
#endif
fprintf(stderr, " while parsing %s \n", fullpath);
parse_error |= PARSE_ERROR;
}
@@ -98,7 +102,11 @@ void found_unsigned_integer(uint64_t result, const uint8_t *buf) {
char *endptr;
unsigned long long expected = strtoull((const char *)buf, &endptr, 10);
if ((endptr == (const char *)buf) || (expected != result)) {
#if (!(__MINGW32__) && !(__MINGW64__))
fprintf(stderr, "Error: parsed %" PRIu64 " out of %.32s, ", result, buf);
#else // mingw is busted since we include #include <inttypes.h>
fprintf(stderr, "Error: parsed %llu out of %.32s, ", (unsigned long long)result, buf);
#endif
fprintf(stderr, " while parsing %s \n", fullpath);
parse_error |= PARSE_ERROR;
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include <cstring>
#ifndef _MSC_VER
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
#include <dirent.h>
#else
// Microsoft can't be bothered to provide standard utils.
+1 -1
View File
@@ -12,7 +12,7 @@
#define JSON_TEST_STRINGS
#endif
#ifndef _MSC_VER
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
#include <dirent.h>
#else
#include <dirent_portable.h>
+1 -1
View File
@@ -1,5 +1,5 @@
#include <iostream>
#ifndef _MSC_VER
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
#include <dirent.h>
#endif
#include <unistd.h>
+50 -16
View File
@@ -7,7 +7,13 @@ import re
import subprocess
import io
import os
import fileinput
if sys.version_info < (3, 0):
sys.stdout.write("Sorry, requires Python 3.x or better\n")
sys.exit(1)
def colored(r, g, b, text):
return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)
def extractnumbers(s):
return tuple(map(int,re.findall("(\d+)\.(\d+)\.(\d+)",str(s))[0]))
@@ -22,17 +28,13 @@ pipe = subprocess.Popen(["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=sub
branchresult = pipe.communicate()[0].decode().strip()
if(branchresult != "master"):
print("release on master, you are on '"+branchresult+"'")
#sys.exit(-1)
print(colored(255, 0, 0, "We recommend that you release on master, you are on '"+branchresult+"'"))
ret = subprocess.call(["git", "remote", "update"])
if(ret != 0):
sys.exit(ret)
pipe = subprocess.Popen(["git", "log", "HEAD..", "--oneline"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
uptodateresult = pipe.communicate()[0].decode().strip()
@@ -42,7 +44,7 @@ if(len(uptodateresult) != 0):
pipe = subprocess.Popen(["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
maindir = pipe.communicate()[0].decode().strip()
scriptlocation = os.path.dirname(os.path.abspath(__file__))
print("repository: "+maindir)
@@ -79,7 +81,14 @@ else :
atleastminor= (currentv[0] != newversion[0]) or (currentv[1] != newversion[1])
if(atleastminor):
print("This is more than a revision.")
print(colored(0, 255, 0, "This is more than a revision."))
releasefile = maindir + os.sep + "RELEASES.md"
releasedata = open(releasefile).read()
pattern = re.compile("#\s+\d+\.\d+")
m = pattern.search(releasedata)
if(m == None):
print(colored(255, 0, 0, "You are preparing a new minor release and you have not yet updated RELEASES.md."))
sys.exit(-1)
versionfilerel = os.sep + "include" + os.sep + "simdjson" + os.sep + "simdjson_version.h"
versionfile = maindir + versionfilerel
@@ -114,10 +123,6 @@ with open(versionfile, 'w') as file:
print(versionfile + " modified")
import fileinput
import re
newmajorversionstring = str(newversion[0])
mewminorversionstring = str(newversion[1])
newrevversionstring = str(newversion[2])
@@ -140,24 +145,53 @@ if(atleastminor):
sonumber += 1
for line in fileinput.input(cmakefile, inplace=1, backup='.bak'):
line = re.sub('SIMDJSON_LIB_VERSION "\d+\.\d+\.\d+','SIMDJSON_LIB_VERSION "'+newversionstring, line.rstrip())
line = re.sub('SIMDJSON_LIB_SOVERSION "\d+','SIMDJSON_LIB_SOVERSION "'+newmajorversionstring, line)
line = re.sub('SIMDJSON_SEMANTIC_VERSION "\d+\.\d+\.\d+','SIMDJSON_SEMANTIC_VERSION "'+newversionstring, line.rstrip())
line = re.sub('SIMDJSON_LIB_VERSION "\d+','SIMDJSON_LIB_VERSION "'+str(sonumber), line)
line = re.sub('set\(PROJECT_VERSION_MAJOR \d+','set(PROJECT_VERSION_MAJOR '+newmajorversionstring, line)
line = re.sub('set\(PROJECT_VERSION_MINOR \d+','set(PROJECT_VERSION_MINOR '+mewminorversionstring, line)
line = re.sub('set\(PROJECT_VERSION_PATCH \d+','set(PROJECT_VERSION_PATCH '+newrevversionstring, line)
line = re.sub('set\(SIMDJSON_LIB_SOVERSION \"\d+\"','set(SIMDJSON_LIB_SOVERSION \"'+str(sonumber)+'\"', line)
print(line)
print("modified "+cmakefile+", a backup was made")
doxyfile = maindir + os.sep + "Doxyfile"
for line in fileinput.input(doxyfile, inplace=1, backup='.bak'):
line = re.sub('PROJECT_NUMBER = "\d+\.\d+\.\d+','PROJECT_NUMBER = "'+newversionstring, line.rstrip())
print(line)
print("modified "+doxyfile+", a backup was made")
scriptlocation = os.path.dirname(os.path.abspath(__file__))
print("Please run the tests before issuing a release, do make test && make amalgamate_test \n")
cp = subprocess.run(["bash", "amalgamate.sh"], stdout=subprocess.DEVNULL, cwd=maindir+ os.sep + "singleheader") # doesn't capture output
if(cp.returncode != 0):
print("Failed to run amalgamate")
cp = subprocess.run(["doxygen"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=maindir) # doesn't capture output
if(cp.returncode != 0):
print("Failed to run doxygen")
#ipe = subprocess.Popen(["doxygen"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=maindir)
#doxygenresult = pipe.communicate()[0].decode().strip()
pattern = re.compile("https://simdjson.org/api/(\d+\.\d+\.\d+)/index.html")
readmefile = maindir + os.sep + "README.md"
readmedata = open(readmefile).read()
m = pattern.search(readmedata)
if m == None:
print(colored(255, 0, 0, 'I cannot find a link to the API documentation in your README?????'))
else:
detectedreadme = m.group(1)
print("found a link to your API documentation in the README file: "+detectedreadme+" ("+toversionstring(*newversion)+")")
if(atleastminor):
if(detectedreadme != toversionstring(*newversion)):
print(colored(255, 0, 0, "Consider updating the readme link to "+toversionstring(*newversion)))
print("Please run the tests before issuing a release. \n")
print("to issue release, enter \n git commit -a && git push && git tag -a v"+toversionstring(*newversion)+" -m \"version "+toversionstring(*newversion)+"\" && git push --tags \n")
+1 -1
View File
@@ -1,5 +1,5 @@
add_library(simdjson-windows-headers INTERFACE)
if(MSVC)
if(MSVC OR MINGW)
target_include_directories(simdjson-windows-headers INTERFACE .)
# getopt.h triggers bogus CRT_SECURE warnings. If you include them, you need this.
target_compile_definitions(simdjson-windows-headers INTERFACE _CRT_SECURE_NO_WARNINGS)
+4 -4
View File
@@ -1,10 +1,10 @@
#ifndef SIMDBJSON_DIRENT_PORTABLE_INC_
#define SIMDBJSON_DIRENT_PORTABLE_INC_
#ifndef SIMDJSON_DIRENT_PORTABLE_INC_
#define SIMDJSON_DIRENT_PORTABLE_INC_
#if (!defined(_WIN32) && !defined(_WIN64))
#if (!defined(_WIN32) && !defined(_WIN64) && !(__MINGW32__) && !(__MINGW64__))
#include <dirent.h>
#else
#include "toni_ronnko_dirent.h"
#endif
#endif // SIMDBJSON_DIRENT_PORTABLE_INC_
#endif // SIMDJSON_DIRENT_PORTABLE_INC_
+6 -2
View File
@@ -1,4 +1,5 @@
#ifndef __GETOPT_H__
/** This file has been modified by D. Lemire for use in simdjson. **/
/* From https://github.com/skandhurkat/Getopt-for-Visual-Studio/blob/master/getopt.h */
/**
* DISCLAIMER
@@ -56,8 +57,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
#define __GETOPT_H__
@@ -110,7 +112,9 @@ char *optarg; /* argument associated with option */
extern char __declspec(dllimport) *__progname;
#endif
#if defined(__CYGWIN__) || defined(__clang__) // D. Lemire (April 2020): adding __clang__
// D. Lemire (April 2020): adding __clang__
// D. Lemire (June 2020): adding __MINGW32__ and __MINGW64__
#if defined(__CYGWIN__) || defined(__clang__) || defined(__MINGW32__) || defined(__MINGW64__)
static char EMSG[] = "";
#else
#define EMSG ""