mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3faae67663 | |||
| ccc94c9b05 | |||
| 1fd30db726 | |||
| 0ba76ac066 | |||
| 8b661fe556 | |||
| 077907b7c3 | |||
| 172d669780 |
@@ -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
|
||||
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
justlib-gcc10:
|
||||
description: Build just the library, install it and do a basic test
|
||||
executor: gcc10
|
||||
environment: { CMAKE_FLAGS: -SIMDJSON_JUST_LIBRARY=ON }
|
||||
environment: { CMAKE_FLAGS: -DSIMDJSON_JUST_LIBRARY=ON }
|
||||
steps: [ cmake_build, cmake_install_test ]
|
||||
gcc10:
|
||||
description: Build and run tests on GCC 10 and AVX 2 with a cmake static build, this test performance regression
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
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="$ENV:PATH;C:\ProgramData\scoop\apps\gcc\current\bin;C:\ProgramData\scoop\shims;C:\Users\runneradmin\scoop\shims"
|
||||
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
|
||||
@@ -0,0 +1,56 @@
|
||||
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="$ENV:PATH;C:\ProgramData\scoop\apps\gcc\current\bin;C:\ProgramData\scoop\shims;C:\Users\runneradmin\scoop\shims"
|
||||
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
|
||||
|
||||
+7
-3
@@ -7,11 +7,15 @@ project(simdjson
|
||||
|
||||
set(PROJECT_VERSION_MAJOR 0)
|
||||
set(PROJECT_VERSION_MINOR 4)
|
||||
set(PROJECT_VERSION_PATCH 1)
|
||||
set(SIMDJSON_LIB_VERSION "0.4.1" CACHE STRING "simdjson library version")
|
||||
set(PROJECT_VERSION_PATCH 3)
|
||||
set(SIMDJSON_LIB_VERSION "0.4.3" 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)
|
||||
@@ -43,8 +47,8 @@ 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)
|
||||
|
||||
#
|
||||
# Compile tools / tests / benchmarks
|
||||
|
||||
@@ -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.1"
|
||||
PROJECT_NUMBER = "0.4.3"
|
||||
|
||||
# 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
|
||||
|
||||
@@ -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(${CMAKE_VS_PLATFORM_TOOLSET} STREQUAL "v140")
|
||||
# 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++)
|
||||
|
||||
Vendored
+1
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
```
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION 0.4.1
|
||||
#define SIMDJSON_VERSION 0.4.3
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -19,7 +19,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 1
|
||||
SIMDJSON_VERSION_REVISION = 3
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
/* auto-generated on Fri 26 Jun 2020 20:03:28 EDT. Do not edit! */
|
||||
/* auto-generated on Mon Jun 29 21:11:53 EDT 2020. Do not edit! */
|
||||
|
||||
#include <iostream>
|
||||
#include "simdjson.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on Fri 26 Jun 2020 20:03:28 EDT. Do not edit! */
|
||||
/* auto-generated on Mon Jun 29 21:11:53 EDT 2020. Do not edit! */
|
||||
/* begin file src/simdjson.cpp */
|
||||
#include "simdjson.h"
|
||||
|
||||
|
||||
+35
-9
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on Fri 26 Jun 2020 20:03:28 EDT. Do not edit! */
|
||||
/* auto-generated on Mon Jun 29 21:11:53 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
|
||||
@@ -190,7 +190,6 @@ use a 64-bit target such as x64 or 64-bit ARM.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// workaround for large stack sizes under -O0.
|
||||
// https://github.com/simdjson/simdjson/issues/691
|
||||
#ifdef __APPLE__
|
||||
@@ -204,6 +203,13 @@ use a 64-bit target such as x64 or 64-bit ARM.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if SIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT
|
||||
// No matter what happened, we undefine SIMDJSON_THREADS_ENABLED and so disable threads.
|
||||
#undef SIMDJSON_THREADS_ENABLED
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__clang__)
|
||||
#define NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
|
||||
#elif defined(__GNUC__)
|
||||
@@ -280,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)
|
||||
|
||||
@@ -367,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
|
||||
|
||||
@@ -2032,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.1
|
||||
#define SIMDJSON_VERSION 0.4.3
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -2047,7 +2055,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 1
|
||||
SIMDJSON_VERSION_REVISION = 3
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
@@ -3667,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};
|
||||
@@ -6773,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;
|
||||
@@ -7395,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;
|
||||
|
||||
|
||||
@@ -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
|
||||
#
|
||||
|
||||
+20
-4
@@ -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
@@ -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,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,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.
|
||||
|
||||
@@ -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
@@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#ifndef _MSC_VER
|
||||
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SIMDBJSON_DIRENT_PORTABLE_INC_
|
||||
#define SIMDBJSON_DIRENT_PORTABLE_INC_
|
||||
|
||||
#if (!defined(_WIN32) && !defined(_WIN64))
|
||||
#if (!defined(_WIN32) && !defined(_WIN64) && !(__MINGW32__) && !(__MINGW64__))
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include "toni_ronnko_dirent.h"
|
||||
|
||||
+6
-2
@@ -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 ""
|
||||
|
||||
Reference in New Issue
Block a user