Merge branch 'master' into for-core-4.0.x
This commit is contained in:
commit
c72d5d31cc
23 changed files with 784 additions and 1074 deletions
124
.github/workflows/build-and-test.yml
vendored
Normal file
124
.github/workflows/build-and-test.yml
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
name: Github Autobuild
|
||||
on: [ push, pull_request ]
|
||||
env:
|
||||
CCACHE_COMPRESS: exists means true
|
||||
CCACHE_SLOPPINESS: include_file_ctime,include_file_mtime,time_macros
|
||||
jobs:
|
||||
test-release:
|
||||
name: Build and run tests in Release mode
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install -y \
|
||||
ccache \
|
||||
parallel \
|
||||
libboost-thread-dev \
|
||||
libboost-iostreams-dev \
|
||||
libboost-date-time-dev \
|
||||
libboost-system-dev \
|
||||
libboost-filesystem-dev \
|
||||
libboost-program-options-dev \
|
||||
libboost-chrono-dev \
|
||||
libboost-test-dev \
|
||||
libboost-context-dev \
|
||||
libboost-regex-dev \
|
||||
libboost-coroutine-dev
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Configure
|
||||
run: |
|
||||
mkdir -p _build
|
||||
pushd _build
|
||||
export -n BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR
|
||||
cmake -D CMAKE_BUILD_TYPE=Release \
|
||||
-D CMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON \
|
||||
-D CMAKE_C_COMPILER=gcc \
|
||||
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
-D CMAKE_CXX_COMPILER=g++ \
|
||||
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
..
|
||||
popd
|
||||
- name: Load Cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ccache
|
||||
key: ccache-release-${{ github.ref }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
ccache-release-${{ github.ref }}-
|
||||
ccache-release-
|
||||
ccache-
|
||||
- name: Build
|
||||
run: |
|
||||
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"
|
||||
mkdir -p "$CCACHE_DIR"
|
||||
make -j 2 -C _build
|
||||
- name: Test
|
||||
run: |
|
||||
parallel echo Running {}\; sh -c "_build/tests/{}" <<_EOT_
|
||||
all_tests
|
||||
bloom_test -- README.md
|
||||
ecc_test README.md
|
||||
hmac_test
|
||||
task_cancel_test
|
||||
_EOT_
|
||||
test-debug:
|
||||
name: Build and run tests in Debug mode
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install -y \
|
||||
ccache \
|
||||
parallel \
|
||||
libboost-thread-dev \
|
||||
libboost-iostreams-dev \
|
||||
libboost-date-time-dev \
|
||||
libboost-system-dev \
|
||||
libboost-filesystem-dev \
|
||||
libboost-program-options-dev \
|
||||
libboost-chrono-dev \
|
||||
libboost-test-dev \
|
||||
libboost-context-dev \
|
||||
libboost-regex-dev \
|
||||
libboost-coroutine-dev
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Configure
|
||||
run: |
|
||||
mkdir -p _build
|
||||
pushd _build
|
||||
export -n BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR
|
||||
cmake -D CMAKE_BUILD_TYPE=Debug \
|
||||
-D CMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON \
|
||||
-D CMAKE_C_COMPILER=gcc \
|
||||
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
-D CMAKE_CXX_COMPILER=g++ \
|
||||
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
..
|
||||
popd
|
||||
- name: Load Cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ccache
|
||||
key: ccache-debug-${{ github.ref }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
ccache-debug-${{ github.ref }}-
|
||||
ccache-debug-
|
||||
ccache-
|
||||
- name: Build
|
||||
run: |
|
||||
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"
|
||||
mkdir -p "$CCACHE_DIR"
|
||||
make -j 2 -C _build
|
||||
- name: Test
|
||||
run: |
|
||||
parallel echo Running {}\; sh -c "_build/tests/{}" <<_EOT_
|
||||
all_tests
|
||||
bloom_test -- README.md
|
||||
ecc_test README.md
|
||||
hmac_test
|
||||
task_cancel_test
|
||||
_EOT_
|
||||
|
|
@ -21,8 +21,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/GitVersionGen")
|
|||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
||||
|
||||
INCLUDE(GetPrerequisites)
|
||||
INCLUDE( VersionMacros )
|
||||
INCLUDE( SetupTargetMacros )
|
||||
INCLUDE(GetGitRevisionDescription)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
|
||||
|
|
@ -159,8 +157,6 @@ ENDIF( LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB )
|
|||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
option( UNITY_BUILD OFF )
|
||||
|
||||
set( fc_sources
|
||||
src/popcount.cpp
|
||||
src/variant.cpp
|
||||
|
|
@ -244,7 +240,7 @@ list(APPEND sources ${fc_headers})
|
|||
|
||||
add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL )
|
||||
|
||||
setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC )
|
||||
add_library( fc ${sources} )
|
||||
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include )
|
||||
|
||||
# begin editline stuff
|
||||
|
|
@ -355,7 +351,7 @@ elseif(WIN32 AND MINGW)
|
|||
endif()
|
||||
|
||||
|
||||
IF(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(a|lib)$")
|
||||
IF(Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(so|dll)$")
|
||||
IF(MSVC)
|
||||
add_definitions(/DBOOST_TEST_DYN_LINK)
|
||||
ELSE(MSVC)
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
# This module defines the ARGUMENT_PARSER macro for parsing macro arguments.
|
||||
|
||||
# ARGUMENT_PARSER Macro
|
||||
# This macro parses a mixed list of arguments and headers into lists and boolean
|
||||
# variables. The output lists and boolean variables are stored using
|
||||
# tolower( header ) variable names. All non-header arguments will be added to
|
||||
# the output list that corresponds to the header that they follow (or to the
|
||||
# default list if no header has been parsed yet). If a boolean header is passed,
|
||||
# then its corresponding output variable is set to YES.
|
||||
#
|
||||
# Usage:
|
||||
# ARGUMENT_PARSER( default_list lists bools ARGN )
|
||||
#
|
||||
# Parameters:
|
||||
# default_list The name of the variable that list values should be added
|
||||
# to before any list headers have been reached. You may
|
||||
# pass "" to disregard premature list values.
|
||||
# lists The list headers (semicolon-separated string).
|
||||
# bools The boolean headers (semicolon-separated string).
|
||||
# ARGN The arguments to parse.
|
||||
MACRO( ARGUMENT_PARSER default_list lists bools )
|
||||
|
||||
# Start using the default list.
|
||||
SET( dest "${default_list}" )
|
||||
IF( NOT dest )
|
||||
SET( dest tmp )
|
||||
ENDIF( NOT dest )
|
||||
|
||||
# Clear all of the lists.
|
||||
FOREACH( list_itr ${lists} )
|
||||
STRING( TOLOWER ${list_itr} lower )
|
||||
SET( ${lower} "" )
|
||||
ENDFOREACH( list_itr )
|
||||
|
||||
# Set all boolean variables to NO.
|
||||
FOREACH( bool_itr ${bools} )
|
||||
STRING( TOLOWER ${bool_itr} lower )
|
||||
SET( ${lower} NO )
|
||||
ENDFOREACH( bool_itr )
|
||||
|
||||
# For all arguments.
|
||||
FOREACH( arg_itr ${ARGN} )
|
||||
|
||||
SET( done NO )
|
||||
|
||||
# For each of the list headers, if the current argument matches a list
|
||||
# header, then set the destination to the header.
|
||||
FOREACH( list_itr ${lists} )
|
||||
IF( ${arg_itr} STREQUAL ${list_itr} )
|
||||
STRING( TOLOWER ${arg_itr} lower )
|
||||
SET( dest ${lower} )
|
||||
SET( done YES )
|
||||
ENDIF( ${arg_itr} STREQUAL ${list_itr} )
|
||||
ENDFOREACH( list_itr )
|
||||
|
||||
# For each of the boolean headers, if the current argument matches a
|
||||
# boolean header, then set the boolean variable to true.
|
||||
FOREACH( bool_itr ${bools} )
|
||||
IF( ${arg_itr} STREQUAL ${bool_itr} )
|
||||
STRING( TOLOWER ${arg_itr} lower )
|
||||
SET( ${lower} YES )
|
||||
SET( done YES )
|
||||
ENDIF( ${arg_itr} STREQUAL ${bool_itr} )
|
||||
ENDFOREACH( bool_itr )
|
||||
|
||||
# If the current argument is not a header, then add it to the current
|
||||
# destination list.
|
||||
IF( NOT done )
|
||||
SET( ${dest} ${${dest}} ${arg_itr} )
|
||||
ENDIF( NOT done )
|
||||
|
||||
ENDFOREACH( arg_itr )
|
||||
|
||||
ENDMACRO( ARGUMENT_PARSER )
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
# Module for locating Visual Leak Detector.
|
||||
#
|
||||
# Customizable variables:
|
||||
# VLD_ROOT_DIR
|
||||
# This variable points to the Visual Leak Detector root directory. By
|
||||
# default, the module looks for the installation directory by examining the
|
||||
# Program Files/Program Files (x86) folders and the VLDROOT environment
|
||||
# variable.
|
||||
#
|
||||
# Read-only variables:
|
||||
# VLD_FOUND
|
||||
# Indicates that the library has been found.
|
||||
#
|
||||
# VLD_INCLUDE_DIRS
|
||||
# Points to the Visual Leak Detector include directory.
|
||||
#
|
||||
# VLD_LIBRARY_DIRS
|
||||
# Points to the Visual Leak Detector directory that contains the libraries.
|
||||
# The content of this variable can be passed to link_directories.
|
||||
#
|
||||
# VLD_LIBRARIES
|
||||
# Points to the Visual Leak Detector libraries that can be passed to
|
||||
# target_link_libararies.
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2012 Sergiu Dotenco
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
INCLUDE (FindPackageHandleStandardArgs)
|
||||
|
||||
SET (_VLD_POSSIBLE_LIB_SUFFIXES lib)
|
||||
|
||||
# Version 2.0 uses vld_x86 and vld_x64 instead of simply vld as library names
|
||||
IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
LIST (APPEND _VLD_POSSIBLE_LIB_SUFFIXES lib/Win32)
|
||||
ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
LIST (APPEND _VLD_POSSIBLE_LIB_SUFFIXES lib/Win64)
|
||||
ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
|
||||
FIND_PATH (VLD_ROOT_DIR
|
||||
NAMES include/vld.h
|
||||
PATHS ENV VLDROOT
|
||||
"$ENV{PROGRAMFILES}/Visual Leak Detector"
|
||||
"$ENV{PROGRAMFILES(X86)}/Visual Leak Detector"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Visual Leak Detector;InstallLocation]"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Visual Leak Detector;InstallLocation]"
|
||||
DOC "VLD root directory")
|
||||
|
||||
FIND_PATH (VLD_INCLUDE_DIR
|
||||
NAMES vld.h
|
||||
HINTS ${VLD_ROOT_DIR}
|
||||
PATH_SUFFIXES include
|
||||
DOC "VLD include directory")
|
||||
|
||||
FIND_LIBRARY (VLD_LIBRARY_DEBUG
|
||||
NAMES vld
|
||||
HINTS ${VLD_ROOT_DIR}
|
||||
PATH_SUFFIXES ${_VLD_POSSIBLE_LIB_SUFFIXES}
|
||||
DOC "VLD debug library")
|
||||
|
||||
IF (VLD_ROOT_DIR)
|
||||
SET (_VLD_VERSION_FILE ${VLD_ROOT_DIR}/CHANGES.txt)
|
||||
|
||||
IF (EXISTS ${_VLD_VERSION_FILE})
|
||||
SET (_VLD_VERSION_REGEX
|
||||
"Visual Leak Detector \\(VLD\\) Version (([0-9]+)\\.([0-9]+)([a-z]|(.([0-9]+)))?)")
|
||||
FILE (STRINGS ${_VLD_VERSION_FILE} _VLD_VERSION_TMP REGEX
|
||||
${_VLD_VERSION_REGEX})
|
||||
|
||||
STRING (REGEX REPLACE ${_VLD_VERSION_REGEX} "\\1" _VLD_VERSION_TMP
|
||||
"${_VLD_VERSION_TMP}")
|
||||
|
||||
STRING (REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1" VLD_VERSION_MAJOR
|
||||
"${_VLD_VERSION_TMP}")
|
||||
STRING (REGEX REPLACE "([0-9]+).([0-9]+).*" "\\2" VLD_VERSION_MINOR
|
||||
"${_VLD_VERSION_TMP}")
|
||||
|
||||
SET (VLD_VERSION ${VLD_VERSION_MAJOR}.${VLD_VERSION_MINOR})
|
||||
|
||||
IF ("${_VLD_VERSION_TMP}" MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||
# major.minor.patch version numbering scheme
|
||||
STRING (REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3"
|
||||
VLD_VERSION_PATCH "${_VLD_VERSION_TMP}")
|
||||
SET (VLD_VERSION "${VLD_VERSION}.${VLD_VERSION_PATCH}")
|
||||
SET (VLD_VERSION_COUNT 3)
|
||||
ELSE ("${_VLD_VERSION_TMP}" MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||
# major.minor version numbering scheme. The trailing letter is ignored.
|
||||
SET (VLD_VERSION_COUNT 2)
|
||||
ENDIF ("${_VLD_VERSION_TMP}" MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||
ENDIF (EXISTS ${_VLD_VERSION_FILE})
|
||||
ENDIF (VLD_ROOT_DIR)
|
||||
|
||||
IF (VLD_LIBRARY_DEBUG)
|
||||
SET (VLD_LIBRARY debug ${VLD_LIBRARY_DEBUG} CACHE DOC "VLD library")
|
||||
GET_FILENAME_COMPONENT (_VLD_LIBRARY_DIR ${VLD_LIBRARY_DEBUG} PATH)
|
||||
SET (VLD_LIBRARY_DIR ${_VLD_LIBRARY_DIR} CACHE PATH "VLD library directory")
|
||||
ENDIF (VLD_LIBRARY_DEBUG)
|
||||
|
||||
SET (VLD_INCLUDE_DIRS ${VLD_INCLUDE_DIR})
|
||||
SET (VLD_LIBRARY_DIRS ${VLD_LIBRARY_DIR})
|
||||
SET (VLD_LIBRARIES ${VLD_LIBRARY})
|
||||
|
||||
MARK_AS_ADVANCED (VLD_INCLUDE_DIR VLD_LIBRARY_DIR VLD_LIBRARY_DEBUG VLD_LIBRARY)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS (VLD REQUIRED_VARS VLD_ROOT_DIR
|
||||
VLD_INCLUDE_DIR VLD_LIBRARY VERSION_VAR VLD_VERSION)
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
# -*- mode: cmake -*-
|
||||
|
||||
#
|
||||
# Shamelessly stolen from MSTK who shamelessly stole from Amanzi open source code https://software.lanl.gov/ascem/trac)
|
||||
#
|
||||
# PARSE_LIBRARY_LIST( <lib_list>
|
||||
# DEBUG <out_debug_list>
|
||||
# OPT <out_opt_list>
|
||||
# GENERAL <out_gen_list> )
|
||||
|
||||
# CMake module
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(PARSE_LIBRARY_LIST)
|
||||
|
||||
# Macro: _print_usage
|
||||
macro(_print_usage)
|
||||
message("PARSE_LIBRARY_LIST <lib_list>\n"
|
||||
" FOUND <out_flag>\n"
|
||||
" DEBUG <out_debug_list>\n"
|
||||
" OPT <out_opt_list>\n"
|
||||
" GENERAL <out_gen_list>\n"
|
||||
"lib_list string to parse\n"
|
||||
"FOUND flag to indicate if keywords were found\n"
|
||||
"DEBUG variable containing debug libraries\n"
|
||||
"OPT variable containing optimized libraries\n"
|
||||
"GENERAL variable containing debug libraries\n")
|
||||
|
||||
endmacro()
|
||||
|
||||
# Read in args
|
||||
cmake_parse_arguments(PARSE_ARGS "" "FOUND;DEBUG;OPT;GENERAL" "" ${ARGN})
|
||||
set(_parse_list "${PARSE_ARGS_UNPARSED_ARGUMENTS}")
|
||||
if ( (NOT PARSE_ARGS_FOUND) OR
|
||||
(NOT PARSE_ARGS_DEBUG) OR
|
||||
(NOT PARSE_ARGS_OPT) OR
|
||||
(NOT PARSE_ARGS_GENERAL) OR
|
||||
(NOT _parse_list )
|
||||
)
|
||||
_print_usage()
|
||||
message(FATAL_ERROR "Invalid arguments")
|
||||
endif()
|
||||
|
||||
# Now split the list
|
||||
set(_debug_libs "")
|
||||
set(_opt_libs "")
|
||||
set(_gen_libs "")
|
||||
foreach( item ${_parse_list} )
|
||||
if( ${item} MATCHES debug OR
|
||||
${item} MATCHES optimized OR
|
||||
${item} MATCHES general )
|
||||
|
||||
if( ${item} STREQUAL "debug" )
|
||||
set( mylist "_debug_libs" )
|
||||
elseif( ${item} STREQUAL "optimized" )
|
||||
set( mylist "_opt_libs" )
|
||||
elseif( ${item} STREQUAL "general" )
|
||||
set( mylist "_gen_libs" )
|
||||
endif()
|
||||
else()
|
||||
list( APPEND ${mylist} ${item} )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
# Now set output vairables
|
||||
set(${PARSE_ARGS_DEBUG} "${_debug_libs}" PARENT_SCOPE)
|
||||
set(${PARSE_ARGS_OPT} "${_opt_libs}" PARENT_SCOPE)
|
||||
set(${PARSE_ARGS_GENERAL} "${_gen_libs}" PARENT_SCOPE)
|
||||
|
||||
# If any of the lib lists are defined set flag to TRUE
|
||||
if ( (_debug_libs) OR (_opt_libs) OR (_gen_libs) )
|
||||
set(${PARSE_ARGS_FOUND} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set(${PARSE_ARGS_FOUND} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
endfunction(PARSE_LIBRARY_LIST)
|
||||
|
||||
|
|
@ -1,369 +0,0 @@
|
|||
# This module defines several macros that are useful for setting up library,
|
||||
# plugin, and executable targets.
|
||||
|
||||
|
||||
INCLUDE( ArgumentParser )
|
||||
|
||||
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
|
||||
set(files ${${SOURCE_VARIABLE_NAME}})
|
||||
# Generate a unique filename for the unity build translation unit
|
||||
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp)
|
||||
# Exclude all translation units from compilation
|
||||
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)
|
||||
# Open the ub file
|
||||
FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
|
||||
# Add include statement for each translation unit
|
||||
foreach(source_file ${files} )
|
||||
FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
|
||||
endforeach(source_file)
|
||||
# Complement list of translation units with the name of ub
|
||||
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
|
||||
endfunction(enable_unity_build)
|
||||
|
||||
# SETUP_LIBRARY Macro
|
||||
# Sets up to build a library target. The macro uses the following global
|
||||
# variables to define default values (you may change these variables to change
|
||||
# the defaults:
|
||||
# DEFAULT_HEADER_INSTALL_DIR
|
||||
# DEFAULT_LIBRARY_INSTALL_DIR
|
||||
#
|
||||
# Usage:
|
||||
# SETUP_LIBRARY( target
|
||||
# SOURCES source1 [source2...]
|
||||
# MOC_HEADERS header1 [header2...]
|
||||
# LIBRARIES library1 [library2...]
|
||||
# INSTALL_HEADERS header1 [header2...]
|
||||
# HEADER_INSTALL_DIR dir
|
||||
# LIBRARY_INSTALL_DIR dir
|
||||
# DEBUG_POSTFIX string
|
||||
# LIBRARY_TYPE string
|
||||
# AUTO_INSTALL_HEADERS
|
||||
# DONT_INSTALL_LIBRARY )
|
||||
#
|
||||
# Parameters:
|
||||
# target The target library.
|
||||
# SOURCES Follow with the sources to compile.
|
||||
# MOC_HEADERS Follow with the headers to moc (Requires Qt).
|
||||
# LIBRARIES Follow with the libraries to link.
|
||||
# INSTALL_HEADERS Follow with the headers to install.
|
||||
# HEADER_INSTALL_DIR Follow with the directory to install the headers
|
||||
# in (${DEFAULT_HEADER_INSTALL_DIR} by default).
|
||||
# LIBRARY_INSTALL_DIR Follow with the directory to install the library
|
||||
# in (${DEFAULT_LIBRARY_INSTALL_DIR} by default).
|
||||
# DEBUG_POSTFIX Follow with the postfix to use when building in
|
||||
# debug mode (${CMAKE_DEBUG_POSTFIX} by default).
|
||||
# LIBRARY_TYPE Follow with the type of library to build: SHARED,
|
||||
# STATIC, or MODULE (if not passed, then the
|
||||
# behavior is defined by BUILD_SHARED_LIBS).
|
||||
# AUTO_INSTALL_HEADERS If passed, all *.h files in the current directory
|
||||
# will be installed.
|
||||
# DONT_INSTALL_LIBRARY If passed, the library will not be installed.
|
||||
MACRO( SETUP_LIBRARY target )
|
||||
|
||||
# Setup the list headers.
|
||||
SET( list_headers
|
||||
SOURCES
|
||||
MOC_HEADERS
|
||||
LIBRARIES
|
||||
INSTALL_HEADERS
|
||||
HEADER_INSTALL_DIR
|
||||
LIBRARY_INSTALL_DIR
|
||||
DEBUG_POSTFIX
|
||||
LIBRARY_TYPE
|
||||
)
|
||||
|
||||
# Setup the boolean headers.
|
||||
SET( bool_headers
|
||||
AUTO_INSTALL_HEADERS
|
||||
DONT_INSTALL_LIBRARY
|
||||
)
|
||||
|
||||
# Parse the arguments into variables.
|
||||
ARGUMENT_PARSER( "" "${list_headers}" "${bool_headers}" ${ARGN} )
|
||||
|
||||
# Set the default values for the header_install_dir, library_install_dir,
|
||||
# and debug_postfix.
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)HEADER_INSTALL_DIR($|;)" )
|
||||
SET( header_install_dir ${DEFAULT_HEADER_INSTALL_DIR} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)HEADER_INSTALL_DIR($|;)" )
|
||||
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)LIBRARY_INSTALL_DIR($|;)" )
|
||||
SET( library_install_dir ${DEFAULT_LIBRARY_INSTALL_DIR} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)LIBRARY_INSTALL_DIR($|;)" )
|
||||
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
|
||||
SET( debug_postfix ${CMAKE_DEBUG_POSTFIX} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
|
||||
|
||||
# Configure the header_install_dir and library_install_dir so that ${target}
|
||||
# may be used in them. Setting target to itself is REQUIRED for the
|
||||
# configuration to work.
|
||||
SET( target "${target}" )
|
||||
STRING( CONFIGURE "${header_install_dir}" header_install_dir )
|
||||
STRING( CONFIGURE "${library_install_dir}" library_install_dir )
|
||||
|
||||
# Setup the library_type.
|
||||
IF( NOT library_type )
|
||||
SET( library_type STATIC )
|
||||
IF( BUILD_SHARED_LIBS )
|
||||
SET( library_type SHARED )
|
||||
ENDIF( BUILD_SHARED_LIBS )
|
||||
ENDIF( NOT library_type )
|
||||
|
||||
# Clear the moc_sources.
|
||||
SET( moc_sources "" )
|
||||
|
||||
# If Qt is being used...
|
||||
IF( QT_FOUND AND QT_LIBRARIES )
|
||||
# Setup QT to build a shared library.
|
||||
IF( library_type MATCHES SHARED )
|
||||
ADD_DEFINITIONS( -DQT_SHARED )
|
||||
ENDIF( library_type MATCHES SHARED )
|
||||
|
||||
# Setup the moc sources.
|
||||
IF( moc_headers )
|
||||
QT4_WRAP_CPP( moc_sources ${moc_headers} )
|
||||
ENDIF( moc_headers )
|
||||
ENDIF( QT_FOUND AND QT_LIBRARIES )
|
||||
|
||||
# Fatal error if moc_headers given but moc_sources not created.
|
||||
IF( moc_headers AND NOT moc_sources )
|
||||
MESSAGE( FATAL_ERROR "Calling SETUP_LIBRARY() with MOC_HEADERS failed. "
|
||||
"Make sure that you included \${QT_USE_FILE} prior to calling "
|
||||
"SETUP_LIBRARY()." )
|
||||
ENDIF( moc_headers AND NOT moc_sources )
|
||||
|
||||
|
||||
IF( UNITY_BUILD )
|
||||
enable_unity_build( ${target} sources )
|
||||
ENDIF( UNITY_BUILD )
|
||||
|
||||
# Add the library.
|
||||
ADD_LIBRARY( "${target}" ${library_type} ${sources} ${moc_sources} )
|
||||
|
||||
# Setup the debug_postfix.
|
||||
SET_TARGET_PROPERTIES ( "${target}" PROPERTIES
|
||||
DEBUG_POSTFIX "${debug_postfix}" )
|
||||
|
||||
# Link in the dependency libraries.
|
||||
TARGET_LINK_LIBRARIES( "${target}" ${libraries} )
|
||||
|
||||
# If auto_install_headers, then set the headers to all .h files in the
|
||||
# directory.
|
||||
IF( auto_install_headers )
|
||||
FILE( GLOB install_headers *.h )
|
||||
ENDIF( auto_install_headers )
|
||||
|
||||
# Install the headers.
|
||||
IF( install_headers )
|
||||
INSTALL( FILES ${install_headers} DESTINATION "${header_install_dir}" )
|
||||
ENDIF( install_headers )
|
||||
|
||||
# Install the library.
|
||||
IF( NOT dont_install_library )
|
||||
INSTALL( TARGETS "${target}"
|
||||
LIBRARY DESTINATION "${library_install_dir}"
|
||||
ARCHIVE DESTINATION "${library_install_dir}" )
|
||||
ENDIF( NOT dont_install_library )
|
||||
|
||||
ENDMACRO( SETUP_LIBRARY )
|
||||
|
||||
|
||||
# SETUP_MODULE Macro
|
||||
# Sets up to build a module (also setup as a Qt plugin if using Qt). A module is
|
||||
# built as a shared library; however, modules are typically loaded dynamically
|
||||
# rather than linked against. Therefore, this macro does not install header
|
||||
# files and uses its own default install directory. The macro uses the following
|
||||
# global variables to define default values (you may change these variables to
|
||||
# change the defaults:
|
||||
# DEFAULT_MODULE_INSTALL_DIR
|
||||
#
|
||||
# Usage:
|
||||
# SETUP_MODULE( target
|
||||
# SOURCES source1 [source2...]
|
||||
# MOC_HEADERS header1 [header2...]
|
||||
# LIBRARIES library1 [library2...]
|
||||
# MODULE_INSTALL_DIR dir
|
||||
# DEBUG_POSTFIX string
|
||||
# DONT_INSTALL_MODULE )
|
||||
#
|
||||
# Parameters:
|
||||
# target The target module (built as a shared library).
|
||||
# SOURCES Follow with the sources to compile.
|
||||
# MOC_HEADERS Follow with the headers to moc (Requires Qt).
|
||||
# LIBRARIES Follow with the libraries to link.
|
||||
# MODULE_INSTALL_DIR Follow with the directory to install the module in
|
||||
# (${DEFAULT_MODULE_INSTALL_DIR} by default).
|
||||
# DEBUG_POSTFIX Follow with the postfix to use when building in
|
||||
# debug mode (${CMAKE_DEBUG_POSTFIX} by default).
|
||||
# DONT_INSTALL_MODULE If passed, the module will not be installed.
|
||||
MACRO( SETUP_MODULE target )
|
||||
|
||||
# Setup the list headers.
|
||||
SET( list_headers
|
||||
SOURCES
|
||||
MOC_HEADERS
|
||||
LIBRARIES
|
||||
MODULE_INSTALL_DIR
|
||||
DEBUG_POSTFIX
|
||||
)
|
||||
|
||||
# Setup the boolean headers.
|
||||
SET( bool_headers
|
||||
DONT_INSTALL_MODULE
|
||||
)
|
||||
|
||||
# Parse the arguments into variables.
|
||||
ARGUMENT_PARSER( "" "${list_headers}" "${bool_headers}" ${ARGN} )
|
||||
|
||||
# Set the default values for the module_install_dir and debug postfix.
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)MODULE_INSTALL_DIR($|;)" )
|
||||
SET( module_install_dir ${DEFAULT_MODULE_INSTALL_DIR} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)MODULE_INSTALL_DIR($|;)" )
|
||||
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
|
||||
SET( debug_postfix ${CMAKE_DEBUG_POSTFIX} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
|
||||
|
||||
# Configure the module_install_dir so that ${target} may be used in it.
|
||||
# Setting target to itself is REQUIRED for the configuration to work.
|
||||
SET( target "${target}" )
|
||||
STRING( CONFIGURE "${module_install_dir}" module_install_dir )
|
||||
|
||||
# Clear the moc_sources.
|
||||
SET( moc_sources "" )
|
||||
|
||||
# If Qt is being used...
|
||||
IF( QT_FOUND AND QT_LIBRARIES )
|
||||
ADD_DEFINITIONS( -DQT_PLUGIN )
|
||||
|
||||
# Setup the moc sources.
|
||||
IF( moc_headers )
|
||||
QT4_WRAP_CPP( moc_sources ${moc_headers} )
|
||||
ENDIF( moc_headers )
|
||||
ENDIF( QT_FOUND AND QT_LIBRARIES )
|
||||
|
||||
# Fatal error if moc_headers given but moc_sources not created.
|
||||
IF( moc_headers AND NOT moc_sources )
|
||||
MESSAGE( FATAL_ERROR "Calling SETUP_MODULE() with MOC_HEADERS failed. "
|
||||
"Make sure that you included \${QT_USE_FILE} prior to calling "
|
||||
"SETUP_MODULE()." )
|
||||
ENDIF( moc_headers AND NOT moc_sources )
|
||||
|
||||
# Add the module (built as a shared library).
|
||||
ADD_LIBRARY( "${target}" SHARED ${sources} ${moc_sources} )
|
||||
|
||||
# Setup the debug postfix.
|
||||
SET_TARGET_PROPERTIES ( "${target}" PROPERTIES
|
||||
DEBUG_POSTFIX "${debug_postfix}" )
|
||||
|
||||
# Link in the dependency libraries.
|
||||
TARGET_LINK_LIBRARIES( "${target}" ${libraries} )
|
||||
|
||||
# Install the module.
|
||||
IF( NOT dont_install_module )
|
||||
INSTALL( TARGETS "${target}"
|
||||
LIBRARY DESTINATION "${module_install_dir}" )
|
||||
ENDIF( NOT dont_install_module )
|
||||
|
||||
ENDMACRO( SETUP_MODULE )
|
||||
|
||||
|
||||
# SETUP_EXECUTABLE Macro
|
||||
# Sets up to build an executable target. The macro uses the following global
|
||||
# variables to define default values (you may change these variables to change
|
||||
# the defaults:
|
||||
# DEFAULT_EXECUTABLE_INSTALL_DIR
|
||||
#
|
||||
# Usage:
|
||||
# SETUP_EXECUTABLE( target
|
||||
# SOURCES source1 [source2...]
|
||||
# MOC_HEADERS header1 [header2...]
|
||||
# LIBRARIES library1 [library2...]
|
||||
# EXECUTABLE_INSTALL_DIR dir
|
||||
# DEBUG_POSTFIX string
|
||||
# DONT_INSTALL_EXECUTABLE )
|
||||
#
|
||||
# Parameters:
|
||||
# target The target executable.
|
||||
# SOURCES Follow with the sources to compile.
|
||||
# MOC_HEADERS Follow with the headers to moc (Requires Qt).
|
||||
# LIBRARIES Follow with the libraries to link.
|
||||
# EXECUTABLE_INSTALL_DIR Follow with the directory to install the
|
||||
# executable in
|
||||
# (${DEFAULT_EXECUTABLE_INSTALL_DIR} by default).
|
||||
# DEBUG_POSTFIX Follow with the postfix to use when building in
|
||||
# debug mode (${CMAKE_DEBUG_POSTFIX} by
|
||||
# default).
|
||||
# DONT_INSTALL_EXECUTABLE If passed, the executable will not be
|
||||
# installed.
|
||||
MACRO( SETUP_EXECUTABLE target )
|
||||
|
||||
# Setup the list headers.
|
||||
SET( list_headers
|
||||
SOURCES
|
||||
MOC_HEADERS
|
||||
LIBRARIES
|
||||
EXECUTABLE_INSTALL_DIR
|
||||
DEBUG_POSTFIX
|
||||
)
|
||||
|
||||
# Setup the boolean headers.
|
||||
SET( bool_headers
|
||||
DONT_INSTALL_EXECUTABLE
|
||||
)
|
||||
|
||||
# Parse the arguments into variables.
|
||||
ARGUMENT_PARSER( "" "${list_headers}" "${bool_headers}" ${ARGN} )
|
||||
|
||||
# Set the default values for the executable_install_dir and debug postfix.
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)EXECUTABLE_INSTALL_DIR($|;)" )
|
||||
SET( executable_install_dir ${DEFAULT_EXECUTABLE_INSTALL_DIR} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)EXECUTABLE_INSTALL_DIR($|;)" )
|
||||
|
||||
IF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
|
||||
SET( debug_postfix ${CMAKE_DEBUG_POSTFIX} )
|
||||
ENDIF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
|
||||
|
||||
# Configure the executable_install_dir so that ${target} may be used in it.
|
||||
# Setting target to itself is REQUIRED for the configuration to work.
|
||||
SET( target "${target}" )
|
||||
STRING( CONFIGURE "${executable_install_dir}" executable_install_dir )
|
||||
|
||||
# Clear the moc_sources.
|
||||
SET( moc_sources "" )
|
||||
|
||||
# If Qt is being used...
|
||||
IF( QT_FOUND AND QT_LIBRARIES )
|
||||
ADD_DEFINITIONS( -DQT_SHARED )
|
||||
|
||||
# Setup the moc sources.
|
||||
IF( moc_headers )
|
||||
QT4_WRAP_CPP( moc_sources ${moc_headers} )
|
||||
ENDIF( moc_headers )
|
||||
ENDIF( QT_FOUND AND QT_LIBRARIES )
|
||||
|
||||
# Fatal error if moc_headers given but moc_sources not created.
|
||||
IF( moc_headers AND NOT moc_sources )
|
||||
MESSAGE( FATAL_ERROR "Calling SETUP_EXECUTABLE() with MOC_HEADERS failed. "
|
||||
"Make sure that you included \${QT_USE_FILE} prior to calling "
|
||||
"SETUP_EXECUTABLE()." )
|
||||
ENDIF( moc_headers AND NOT moc_sources )
|
||||
|
||||
# Add the executable.
|
||||
ADD_EXECUTABLE( "${target}" ${sources} ${moc_sources} )
|
||||
|
||||
# Setup the debug postfix.
|
||||
SET_TARGET_PROPERTIES ( "${target}" PROPERTIES
|
||||
DEBUG_POSTFIX "${debug_postfix}" )
|
||||
|
||||
# Link in the dependency libraries.
|
||||
TARGET_LINK_LIBRARIES( "${target}" ${libraries} )
|
||||
|
||||
# Install the executable.
|
||||
IF( NOT dont_install_executable )
|
||||
INSTALL( TARGETS "${target}" RUNTIME DESTINATION
|
||||
"${executable_install_dir}" )
|
||||
ENDIF( NOT dont_install_executable )
|
||||
|
||||
ENDMACRO( SETUP_EXECUTABLE )
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
# This module defines macros that are useful for using libraries in a build. The
|
||||
# macros in this module are typically used along with the FindDependencyMacros.
|
||||
|
||||
# ADD_LIBRARY_TO_LIST Macro
|
||||
# Adds a library to a list of libraries if it is found. Otherwise, reports an
|
||||
# error.
|
||||
#
|
||||
# Usage:
|
||||
# ADD_LIBRARY_TO_LIST( libraries found lib lib_name )
|
||||
#
|
||||
# Parameters:
|
||||
# libraries The list of libraries to add the library to.
|
||||
# found Whether or not the library to add was found.
|
||||
# lib The library to add to the list.
|
||||
# lib_name The name of the library to add to the list.
|
||||
MACRO( ADD_LIBRARY_TO_LIST libraries found lib lib_name )
|
||||
|
||||
# Setting found to itself is necessary for the conditional to work.
|
||||
SET( found ${found} )
|
||||
|
||||
# IF found, then add the library to the list, else report an error.
|
||||
IF( found )
|
||||
LIST( REMOVE_ITEM ${libraries} ${lib} )
|
||||
SET( ${libraries} ${${libraries}} ${lib} )
|
||||
ENDIF( found )
|
||||
IF( NOT found )
|
||||
MESSAGE( "Using ${lib_name} failed." )
|
||||
ENDIF( NOT found )
|
||||
|
||||
ENDMACRO( ADD_LIBRARY_TO_LIST )
|
||||
|
||||
|
||||
# USE_LIBRARY_GLOBALS Macro
|
||||
# If ${prefix}_USE_${LIB} is true, then ${prefix}_${LIB}_LIBRARY will be added
|
||||
# to ${prefix}_LIBRARIES (assuming the library was correctly found). All of the
|
||||
# dependencies will also be added to ${prefix}_LIBRARIES.
|
||||
#
|
||||
# Usage:
|
||||
# USE_LIBRARY_GLOBALS( prefix lib
|
||||
# DEPS dependency1 [dependency2...] )
|
||||
#
|
||||
# Parameters:
|
||||
# prefix The prefix for the global variables.
|
||||
# lib The library to try to use.
|
||||
# DEPS Follow with the list of dependencies that should be added with
|
||||
# the given library.
|
||||
MACRO( USE_LIBRARY_GLOBALS prefix lib )
|
||||
|
||||
STRING( TOUPPER ${lib} upper )
|
||||
|
||||
# If the library should be used...
|
||||
IF( ${prefix}_USE_${upper} )
|
||||
|
||||
# Parse the arguments into variables.
|
||||
ARGUMENT_PARSER( "" "DEPS" "" ${ARGN} )
|
||||
|
||||
# Add the library to the list.
|
||||
ADD_LIBRARY_TO_LIST( ${prefix}_LIBRARIES "${${prefix}_${upper}_FOUND}"
|
||||
"${${prefix}_${upper}_LIBRARY}" ${lib} )
|
||||
|
||||
# For each of the library's dependencies.
|
||||
FOREACH( dep_itr ${deps} )
|
||||
STRING( TOUPPER ${dep_itr} upper )
|
||||
|
||||
# Add the dependency to the list.
|
||||
ADD_LIBRARY_TO_LIST( ${prefix}_LIBRARIES
|
||||
"${${prefix}_${upper}_FOUND}"
|
||||
"${${prefix}_${upper}_LIBRARY}" ${dep_itr} )
|
||||
ENDFOREACH( dep_itr )
|
||||
ENDIF( ${prefix}_USE_${upper} )
|
||||
|
||||
ENDMACRO( USE_LIBRARY_GLOBALS )
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
# This module defines several macros that are useful for handling version
|
||||
# information. These macros work for version strings of format "#.#.#"
|
||||
# representing major, minor, and patch integer components.
|
||||
|
||||
|
||||
INCLUDE( ArgumentParser )
|
||||
|
||||
|
||||
# PARSE_VERSION_STR Macro
|
||||
# This macro parses the version string information from a string. The macro
|
||||
# parses the string for the given definitions followed by whitespace (or by ':'
|
||||
# or '"' characters) and then version information. For example, passing
|
||||
# "MyVersion" as a definition would properly retrieve the version from a string
|
||||
# "containing the line "def MyVersion: 1.2.3".
|
||||
#
|
||||
# Usage:
|
||||
# PARSE_VERSION_STR( version string definition [definition2...] )
|
||||
#
|
||||
# Parameters:
|
||||
# version The variable to store the version string in.
|
||||
# string The string to parse.
|
||||
# definition The definition(s) that may preceed the version string
|
||||
# information.
|
||||
MACRO( PARSE_VERSION_STR version string )
|
||||
|
||||
# Parse the arguments into variables.
|
||||
ARGUMENT_PARSER( definitions "" "" ${ARGN} )
|
||||
|
||||
# For each of the given definitions...
|
||||
FOREACH( def_itr ${definitions} )
|
||||
# If the version has not been found, then attempt to parse it.
|
||||
IF( NOT ${version} )
|
||||
# Parse the version string.
|
||||
STRING( REGEX MATCH "${def_itr}[ \t\":]+[0-9]+(.[0-9]+)?(.[0-9]+)?"
|
||||
${version} ${string} )
|
||||
|
||||
STRING( REGEX MATCH "[0-9]+(.[0-9]+)?(.[0-9]+)?" ${version}
|
||||
"${${version}}" )
|
||||
|
||||
CORRECT_VERSION_STR( ${version} "${${version}}" )
|
||||
ENDIF( NOT ${version} )
|
||||
ENDFOREACH( def_itr )
|
||||
|
||||
ENDMACRO( PARSE_VERSION_STR )
|
||||
|
||||
|
||||
# PARSE_VERSION_INT Macro
|
||||
# This macro parses the version integer component information from a string. The
|
||||
# macro parses the string for the given definitions followed by whitespace (or
|
||||
# by ':' or '"' characters) and then version information. For example, passing
|
||||
# "MyVersionMajor" as a definition would properly retrieve the version from a
|
||||
# string "containing the line "def MyVersionMajor: 1".
|
||||
#
|
||||
# Usage:
|
||||
# PARSE_VERSION_INT( version string definition [definition2...] )
|
||||
#
|
||||
# Parameters:
|
||||
# version The variable to store the version integer component in.
|
||||
# string The string to parse.
|
||||
# definition The definition(s) that may preceed the version integer
|
||||
# component information.
|
||||
MACRO( PARSE_VERSION_INT version string )
|
||||
|
||||
# Parse the arguments into variables.
|
||||
ARGUMENT_PARSER( definitions "" "" ${ARGN} )
|
||||
|
||||
# For each of the given definitions...
|
||||
FOREACH( def_itr ${definitions} )
|
||||
# If the version has not been found, then attempt to parse it.
|
||||
IF( NOT ${version} )
|
||||
# Parse the version string.
|
||||
STRING( REGEX MATCH "${def_itr}[ \t\":]+[0-9]+" ${version}
|
||||
${string} )
|
||||
|
||||
STRING( REGEX MATCH "[0-9]+" ${version} "${${version}}" )
|
||||
ENDIF( NOT ${version} )
|
||||
ENDFOREACH( def_itr )
|
||||
|
||||
ENDMACRO( PARSE_VERSION_INT )
|
||||
|
||||
|
||||
# VERSION_STR_TO_INTS Macro
|
||||
# This macro converts a version string into its three integer components.
|
||||
#
|
||||
# Usage:
|
||||
# VERSION_STR_TO_INTS( major minor patch version )
|
||||
#
|
||||
# Parameters:
|
||||
# major The variable to store the major integer component in.
|
||||
# minor The variable to store the minor integer component in.
|
||||
# patch The variable to store the patch integer component in.
|
||||
# version The version string to convert ("#.#.#" format).
|
||||
MACRO( VERSION_STR_TO_INTS major minor patch version )
|
||||
|
||||
STRING( REGEX REPLACE "([0-9]+).[0-9]+.[0-9]+" "\\1" ${major} ${version} )
|
||||
STRING( REGEX REPLACE "[0-9]+.([0-9]+).[0-9]+" "\\1" ${minor} ${version} )
|
||||
STRING( REGEX REPLACE "[0-9]+.[0-9]+.([0-9]+)" "\\1" ${patch} ${version} )
|
||||
|
||||
ENDMACRO( VERSION_STR_TO_INTS )
|
||||
|
||||
|
||||
# VERSION_INTS_TO_STR Macro
|
||||
# This macro converts three version integer components into a version string.
|
||||
#
|
||||
# Usage:
|
||||
# VERSION_INTS_TO_STR( version major minor patch )
|
||||
#
|
||||
# Parameters:
|
||||
# version The variable to store the version string in.
|
||||
# major The major version integer.
|
||||
# minor The minor version integer.
|
||||
# patch The patch version integer.
|
||||
MACRO( VERSION_INTS_TO_STR version major minor patch )
|
||||
|
||||
SET( ${version} "${major}.${minor}.${patch}" )
|
||||
CORRECT_VERSION_STR( ${version} ${${version}} )
|
||||
|
||||
ENDMACRO( VERSION_INTS_TO_STR version major minor patch )
|
||||
|
||||
|
||||
# COMPARE_VERSION_STR Macro
|
||||
# This macro compares two version strings to each other. The macro sets the
|
||||
# result variable to -1 if lhs < rhs, 0 if lhs == rhs, and 1 if lhs > rhs.
|
||||
#
|
||||
# Usage:
|
||||
# COMPARE_VERSION_STR( result lhs rhs )
|
||||
#
|
||||
# Parameters:
|
||||
# result The variable to store the result of the comparison in.
|
||||
# lhs The version of the left hand side ("#.#.#" format).
|
||||
# rhs The version of the right hand side ("#.#.#" format).
|
||||
MACRO( COMPARE_VERSION_STR result lhs rhs )
|
||||
|
||||
VERSION_STR_TO_INTS( lhs_major lhs_minor lhs_patch ${lhs} )
|
||||
VERSION_STR_TO_INTS( rhs_major rhs_minor rhs_patch ${rhs} )
|
||||
|
||||
COMPARE_VERSION_INTS( ${result}
|
||||
${lhs_major} ${lhs_minor} ${lhs_patch}
|
||||
${rhs_major} ${rhs_minor} ${rhs_patch} )
|
||||
|
||||
ENDMACRO( COMPARE_VERSION_STR result lhs rhs )
|
||||
|
||||
|
||||
# COMPARE_VERSION_INTS Macro
|
||||
# This macro compares two versions to each other using their integer components.
|
||||
# The macro sets the result variable to -1 if lhs < rhs, 0 if lhs == rhs, and 1
|
||||
# if lhs > rhs.
|
||||
#
|
||||
# Usage:
|
||||
# COMPARE_VERSION_INTS( result
|
||||
# lhs_major lhs_minor lhs_patch
|
||||
# rhs_major rhs_minor rhs_patch )
|
||||
#
|
||||
# Parameters:
|
||||
# result The variable to store the result of the comparison in.
|
||||
# lhs_major The major integer component for the left hand side.
|
||||
# lhs_minor The minor integer component for the left hand side.
|
||||
# lhs_patch The patch integer component for the left hand side.
|
||||
# rhs_major The major integer component for the right hand side.
|
||||
# rhs_minor The minor integer component for the right hand side.
|
||||
# rhs_patch The patch integer component for the right hand side.
|
||||
MACRO( COMPARE_VERSION_INTS result lhs_major lhs_minor lhs_patch
|
||||
rhs_major rhs_minor rhs_patch )
|
||||
|
||||
SET( ${result} 0 )
|
||||
IF( NOT ${result} AND ${lhs_major} LESS ${rhs_major} )
|
||||
SET( ${result} -1 )
|
||||
ENDIF( NOT ${result} AND ${lhs_major} LESS ${rhs_major} )
|
||||
IF( NOT ${result} AND ${lhs_major} GREATER ${rhs_major} )
|
||||
SET( ${result} 1 )
|
||||
ENDIF( NOT ${result} AND ${lhs_major} GREATER ${rhs_major} )
|
||||
|
||||
IF( NOT ${result} AND ${lhs_minor} LESS ${rhs_minor} )
|
||||
SET( ${result} -1 )
|
||||
ENDIF( NOT ${result} AND ${lhs_minor} LESS ${rhs_minor} )
|
||||
IF( NOT ${result} AND ${lhs_minor} GREATER ${rhs_minor} )
|
||||
SET( ${result} 1 )
|
||||
ENDIF( NOT ${result} AND ${lhs_minor} GREATER ${rhs_minor} )
|
||||
|
||||
IF( NOT ${result} AND ${lhs_patch} LESS ${rhs_patch} )
|
||||
SET( ${result} -1 )
|
||||
ENDIF( NOT ${result} AND ${lhs_patch} LESS ${rhs_patch} )
|
||||
IF( NOT ${result} AND ${lhs_patch} GREATER ${rhs_patch} )
|
||||
SET( ${result} 1 )
|
||||
ENDIF( NOT ${result} AND ${lhs_patch} GREATER ${rhs_patch} )
|
||||
|
||||
ENDMACRO( COMPARE_VERSION_INTS result lhs_major lhs_minor lhs_patch
|
||||
rhs_major rhs_minor rhs_patch )
|
||||
|
||||
|
||||
# CORRECT_VERSION_STR Macro
|
||||
# This macro corrects the version_str and stores the result in the version
|
||||
# variable. If the version_str contains a version string in "#" or "#.#" format,
|
||||
# then ".0" will be appended to the string to convert it to "#.#.#" format. If
|
||||
# the version_str is invalid, then version will be set to "".
|
||||
#
|
||||
# Usage:
|
||||
# CORRECT_VERSION_STR( version version_str )
|
||||
#
|
||||
# Parameters:
|
||||
# version The variable to store the corrected version string in.
|
||||
# version_str The version string to correct.
|
||||
MACRO( CORRECT_VERSION_STR version version_str )
|
||||
|
||||
SET( ${version} "${version_str}" )
|
||||
|
||||
# Add ".0" to the end of the version string in case a full "#.#.#" string
|
||||
# was not given.
|
||||
FOREACH( itr RANGE 2 )
|
||||
IF( NOT ${version} MATCHES "[0-9]+.[0-9]+.[0-9]+" )
|
||||
SET( ${version} "${${version}}.0" )
|
||||
ENDIF( NOT ${version} MATCHES "[0-9]+.[0-9]+.[0-9]+" )
|
||||
ENDFOREACH( itr )
|
||||
|
||||
# If the version string is not correct, then set it to "".
|
||||
IF( NOT ${version} MATCHES "^[0-9]+.[0-9]+.[0-9]+$" )
|
||||
SET( ${version} "" )
|
||||
ENDIF( NOT ${version} MATCHES "^[0-9]+.[0-9]+.[0-9]+$" )
|
||||
|
||||
ENDMACRO( CORRECT_VERSION_STR )
|
||||
|
||||
|
||||
|
||||
# CORRECT_VERSION_Int Macro
|
||||
# This macro corrects the version_int and stores the result in the version
|
||||
# variable. If the version_int is invalid, then version will be set to "".
|
||||
#
|
||||
# Usage:
|
||||
# CORRECT_VERSION_Int( version version_int )
|
||||
#
|
||||
# Parameters:
|
||||
# version The variable to store the corrected version integer
|
||||
# component in.
|
||||
# version_INT The version integer component to correct.
|
||||
MACRO( CORRECT_VERSION_INT version version_int )
|
||||
|
||||
SET( ${version} "${version_int}" )
|
||||
|
||||
# If the version is not an integer, then set it to "".
|
||||
IF( NOT ${version} MATCHES "^[0-9]+$" )
|
||||
SET( ${version} "" )
|
||||
ENDIF( NOT ${version} MATCHES "^[0-9]+$" )
|
||||
|
||||
ENDMACRO( CORRECT_VERSION_INT )
|
||||
52
LICENSE.md
Normal file
52
LICENSE.md
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
The following license only applies to code that was contributed to this repository in the context of BitShares worker proposals and/or BitShares-1 delegate workers. Other code may be licensed indirectly by our "sister" repositories https://github.com/EOSIO/fc and https://github.com/bytemaster/fc/tree/phoenix .
|
||||
|
||||
All subsequent contributions to this repository are licensed by their respective authors under this same license as well, unless explicitly stated otherwise.
|
||||
|
||||
Furthermore, this repository includes code from third party authors. See the list at the end of this file.
|
||||
|
||||
----
|
||||
|
||||
Copyright (c) 2018-2019 BitShares Blockchain Foundation and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
----
|
||||
|
||||
The following terms apply to third-party code included here. Most have to be published along with binaries of this software.
|
||||
Some of the files are only used for building binaries of this software, without becoming an actual part of those binaries. Their respective licenses also do not apply to the binaries.
|
||||
|
||||
include/bloom_filter.hpp is copyright Arash Partow and covered by the MIT license. See http://www.opensource.org/licenses/MIT .
|
||||
|
||||
src/utf8 is copyright Nemanja Trifunovic and covered by the MIT license (Thrift variant). See licenses/MIT_Thrift_LICENSE.md.
|
||||
|
||||
src/crypto/base58.cpp is copyright Satoshi Nakamoto and The Bitcoin Developers and is covered by the MIT/X11 license. See licenses/MIT_X11_LICENSE.md.
|
||||
|
||||
src/crypto/base64.cpp is copyright René Nyffenegger and covered by the zlib/libpng license. See licenses/ZLIB_LICENSE.md.
|
||||
|
||||
src/crypto/city.cpp and libraries/fc/include/fc/crypto/city.hpp are copyright Google, Inc. and covered by the MIT/X11 license. See licenses/MIT_X11_LICENSE.md.
|
||||
|
||||
CMakeModules/CheckLibcxxAtomic.cmake was taken from the LLVM repository and is licensed under the Apache-2.0 license. See licenses/Apache.txt .
|
||||
|
||||
GitVersionGen/GetGitRevisionDescription.cmake is copyright Iowa State University and covered by the Boost Software License. See licenses/Boost_License-1.0.txt.
|
||||
|
||||
vendor/editline is copyright Simmule Turner and Rich Salz and covered by a BSD-like license. See vendor/editline/LICENSE.
|
||||
|
||||
vendor/secp256k1-zkp is copyright Pieter Wuille and covered by the MIT/X11 license. See vendor/secp256k1-zkp/COPYING.
|
||||
|
||||
vendor/websocketpp is copyright Peter Thorson and covered by a 3-clause BSD-license. It also includes code from 4th-party authors with various copyrights, see vendor/websocketpp/COPYING.
|
||||
|
|
@ -2,6 +2,7 @@ fc
|
|||
==
|
||||
|
||||
[](https://travis-ci.org/bitshares/bitshares-fc)
|
||||
[](https://github.com/bitshares/bitshares-fc/actions?query=branch%3Amaster)
|
||||
|
||||
**NOTE:** This fork reverts upstream commit a421e280488385cab26a42153f7ce3c8d5b6281f to avoid changing the BitShares API.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* *
|
||||
|
|
@ -11,27 +9,29 @@
|
|||
* *
|
||||
* Copyright notice: *
|
||||
* Free use of the Open Bloom Filter Library is permitted under the *
|
||||
* guidelines and in accordance with the most current version of the *
|
||||
* Common Public License. *
|
||||
* http://www.opensource.org/licenses/cpl1.0.php *
|
||||
* guidelines and in accordance with the MIT License. *
|
||||
* http://www.opensource.org/licenses/MIT *
|
||||
* *
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INCLUDE_BLOOM_FILTER_HPP
|
||||
#define INCLUDE_BLOOM_FILTER_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <fc/reflect/reflect.hpp>
|
||||
|
||||
namespace fc {
|
||||
|
||||
|
||||
static constexpr std::size_t bits_per_char = 0x08; // 8 bits in 1 char(unsigned)
|
||||
|
||||
static const unsigned char bit_mask[bits_per_char] = {
|
||||
0x01, //00000001
|
||||
0x02, //00000010
|
||||
|
|
@ -87,22 +87,22 @@ public:
|
|||
(0xFFFFFFFFFFFFFFFFULL == random_seed);
|
||||
}
|
||||
|
||||
//Allowed min/max size of the bloom filter in bits
|
||||
// Allowable min/max size of the bloom filter in bits
|
||||
unsigned long long int minimum_size;
|
||||
unsigned long long int maximum_size;
|
||||
|
||||
//Allowed min/max number of hash functions
|
||||
// Allowable min/max number of hash functions
|
||||
unsigned int minimum_number_of_hashes;
|
||||
unsigned int maximum_number_of_hashes;
|
||||
|
||||
//The approximate number of elements to be inserted
|
||||
//into the bloom filter, should be within one order
|
||||
//of magnitude. The default is 10000.
|
||||
// The approximate number of elements to be inserted
|
||||
// into the bloom filter, should be within one order
|
||||
// of magnitude. The default is 10000.
|
||||
unsigned long long int projected_element_count;
|
||||
|
||||
//The approximate false positive probability expected
|
||||
//from the bloom filter. The default is the reciprocal
|
||||
//of the projected_element_count.
|
||||
// The approximate false positive probability expected
|
||||
// from the bloom filter. The default is assumed to be
|
||||
// the reciprocal of the projected_element_count.
|
||||
double false_positive_probability;
|
||||
|
||||
unsigned long long int random_seed;
|
||||
|
|
@ -133,28 +133,32 @@ public:
|
|||
if (!(*this))
|
||||
return false;
|
||||
|
||||
double min_m = std::numeric_limits<double>::infinity();
|
||||
double min_k = 0.0;
|
||||
double curr_m = 0.0;
|
||||
double k = 1.0;
|
||||
double min_m = std::numeric_limits<double>::infinity();
|
||||
double min_k = 0.0;
|
||||
double k = 1.0;
|
||||
|
||||
while (k < 1000.0)
|
||||
{
|
||||
double numerator = (- k * projected_element_count);
|
||||
double denominator = std::log(1.0 - std::pow(false_positive_probability, 1.0 / k));
|
||||
curr_m = numerator / denominator;
|
||||
const double numerator = (- k * projected_element_count);
|
||||
const double denominator = std::log(1.0 - std::pow(false_positive_probability, 1.0 / k));
|
||||
|
||||
const double curr_m = numerator / denominator;
|
||||
|
||||
if (curr_m < min_m)
|
||||
{
|
||||
min_m = curr_m;
|
||||
min_k = k;
|
||||
}
|
||||
|
||||
k += 1.0;
|
||||
}
|
||||
|
||||
optimal_parameters_t& optp = optimal_parameters;
|
||||
|
||||
optp.number_of_hashes = static_cast<unsigned int>(min_k);
|
||||
|
||||
optp.table_size = static_cast<unsigned long long int>(min_m);
|
||||
|
||||
optp.table_size += (((optp.table_size % bits_per_char) != 0) ? (bits_per_char - (optp.table_size % bits_per_char)) : 0);
|
||||
|
||||
if (optp.number_of_hashes < minimum_number_of_hashes)
|
||||
|
|
@ -178,15 +182,15 @@ protected:
|
|||
|
||||
typedef unsigned int bloom_type;
|
||||
typedef unsigned char cell_type;
|
||||
typedef std::vector<unsigned char> table_type;
|
||||
|
||||
public:
|
||||
|
||||
bloom_filter()
|
||||
: salt_count_(0),
|
||||
table_size_(0),
|
||||
raw_table_size_(0),
|
||||
projected_element_count_(0),
|
||||
inserted_element_count_(0),
|
||||
inserted_element_count_ (0),
|
||||
random_seed_(0),
|
||||
desired_false_positive_probability_(0.0)
|
||||
{}
|
||||
|
|
@ -199,12 +203,10 @@ public:
|
|||
{
|
||||
salt_count_ = p.optimal_parameters.number_of_hashes;
|
||||
table_size_ = p.optimal_parameters.table_size;
|
||||
generate_unique_salt();
|
||||
raw_table_size_ = table_size_ / bits_per_char;
|
||||
|
||||
bit_table_.resize( static_cast<std::size_t>(raw_table_size_) );
|
||||
//bit_table_ = new cell_type[static_cast<std::size_t>(raw_table_size_)];
|
||||
std::fill_n(bit_table_.data(),raw_table_size_,0x00);
|
||||
generate_unique_salt();
|
||||
|
||||
bit_table_.resize(table_size_ / bits_per_char, static_cast<unsigned char>(0x00));
|
||||
}
|
||||
|
||||
bloom_filter(const bloom_filter& filter)
|
||||
|
|
@ -217,15 +219,15 @@ public:
|
|||
if (this != &f)
|
||||
{
|
||||
return
|
||||
(salt_count_ == f.salt_count_) &&
|
||||
(table_size_ == f.table_size_) &&
|
||||
(raw_table_size_ == f.raw_table_size_) &&
|
||||
(projected_element_count_ == f.projected_element_count_) &&
|
||||
(inserted_element_count_ == f.inserted_element_count_) &&
|
||||
(random_seed_ == f.random_seed_) &&
|
||||
(salt_count_ == f.salt_count_ ) &&
|
||||
(table_size_ == f.table_size_ ) &&
|
||||
(bit_table_.size() == f.bit_table_.size() ) &&
|
||||
(projected_element_count_ == f.projected_element_count_ ) &&
|
||||
(inserted_element_count_ == f.inserted_element_count_ ) &&
|
||||
(random_seed_ == f.random_seed_ ) &&
|
||||
(desired_false_positive_probability_ == f.desired_false_positive_probability_) &&
|
||||
(salt_ == f.salt_) &&
|
||||
std::equal(f.bit_table_.data(),f.bit_table_.data() + raw_table_size_,bit_table_.data());
|
||||
(salt_ == f.salt_ ) &&
|
||||
(bit_table_ == f.bit_table_ ) ;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
|
@ -242,21 +244,22 @@ public:
|
|||
{
|
||||
salt_count_ = f.salt_count_;
|
||||
table_size_ = f.table_size_;
|
||||
raw_table_size_ = f.raw_table_size_;
|
||||
bit_table_ = f.bit_table_;
|
||||
salt_ = f.salt_;
|
||||
|
||||
projected_element_count_ = f.projected_element_count_;
|
||||
inserted_element_count_ = f.inserted_element_count_;
|
||||
inserted_element_count_ = f.inserted_element_count_;
|
||||
|
||||
random_seed_ = f.random_seed_;
|
||||
|
||||
desired_false_positive_probability_ = f.desired_false_positive_probability_;
|
||||
bit_table_.resize( raw_table_size_ );
|
||||
std::copy(f.bit_table_.data(),f.bit_table_.data() + raw_table_size_,bit_table_.data());
|
||||
salt_ = f.salt_;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~bloom_filter()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
inline bool operator!() const
|
||||
{
|
||||
|
|
@ -265,23 +268,26 @@ public:
|
|||
|
||||
inline void clear()
|
||||
{
|
||||
std::fill_n(bit_table_.data(),raw_table_size_,0x00);
|
||||
std::fill(bit_table_.begin(), bit_table_.end(), static_cast<unsigned char>(0x00));
|
||||
inserted_element_count_ = 0;
|
||||
}
|
||||
|
||||
inline void insert(const unsigned char* key_begin, const std::size_t& length)
|
||||
{
|
||||
std::size_t bit_index = 0;
|
||||
std::size_t bit = 0;
|
||||
std::size_t bit = 0;
|
||||
|
||||
for (std::size_t i = 0; i < salt_.size(); ++i)
|
||||
{
|
||||
compute_indices(hash_ap(key_begin,length,salt_[i]),bit_index,bit);
|
||||
compute_indices(hash_ap(key_begin, length, salt_[i]), bit_index, bit);
|
||||
|
||||
bit_table_[bit_index / bits_per_char] |= bit_mask[bit];
|
||||
}
|
||||
|
||||
++inserted_element_count_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline void insert(const T& t)
|
||||
{
|
||||
// Note: T must be a C++ POD type.
|
||||
|
|
@ -290,7 +296,7 @@ public:
|
|||
|
||||
inline void insert(const std::string& key)
|
||||
{
|
||||
insert(reinterpret_cast<const unsigned char*>(key.c_str()),key.size());
|
||||
insert(reinterpret_cast<const unsigned char*>(key.data()),key.size());
|
||||
}
|
||||
|
||||
inline void insert(const char* data, const std::size_t& length)
|
||||
|
|
@ -298,10 +304,11 @@ public:
|
|||
insert(reinterpret_cast<const unsigned char*>(data),length);
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
template <typename InputIterator>
|
||||
inline void insert(const InputIterator begin, const InputIterator end)
|
||||
{
|
||||
InputIterator itr = begin;
|
||||
|
||||
while (end != itr)
|
||||
{
|
||||
insert(*(itr++));
|
||||
|
|
@ -311,19 +318,22 @@ public:
|
|||
inline virtual bool contains(const unsigned char* key_begin, const std::size_t length) const
|
||||
{
|
||||
std::size_t bit_index = 0;
|
||||
std::size_t bit = 0;
|
||||
std::size_t bit = 0;
|
||||
|
||||
for (std::size_t i = 0; i < salt_.size(); ++i)
|
||||
{
|
||||
compute_indices(hash_ap(key_begin,length,salt_[i]),bit_index,bit);
|
||||
compute_indices(hash_ap(key_begin, length, salt_[i]), bit_index, bit);
|
||||
|
||||
if ((bit_table_[bit_index / bits_per_char] & bit_mask[bit]) != bit_mask[bit])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
inline bool contains(const T& t) const
|
||||
{
|
||||
return contains(reinterpret_cast<const unsigned char*>(&t),static_cast<std::size_t>(sizeof(T)));
|
||||
|
|
@ -339,33 +349,39 @@ public:
|
|||
return contains(reinterpret_cast<const unsigned char*>(data),length);
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
template <typename InputIterator>
|
||||
inline InputIterator contains_all(const InputIterator begin, const InputIterator end) const
|
||||
{
|
||||
InputIterator itr = begin;
|
||||
|
||||
while (end != itr)
|
||||
{
|
||||
if (!contains(*itr))
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
template <typename InputIterator>
|
||||
inline InputIterator contains_none(const InputIterator begin, const InputIterator end) const
|
||||
{
|
||||
InputIterator itr = begin;
|
||||
|
||||
while (end != itr)
|
||||
{
|
||||
if (contains(*itr))
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
|
|
@ -374,7 +390,7 @@ public:
|
|||
return table_size_;
|
||||
}
|
||||
|
||||
inline std::size_t element_count() const
|
||||
inline unsigned long long int element_count() const
|
||||
{
|
||||
return inserted_element_count_;
|
||||
}
|
||||
|
|
@ -395,16 +411,17 @@ public:
|
|||
{
|
||||
/* intersection */
|
||||
if (
|
||||
(salt_count_ == f.salt_count_) &&
|
||||
(table_size_ == f.table_size_) &&
|
||||
(random_seed_ == f.random_seed_)
|
||||
(salt_count_ == f.salt_count_ ) &&
|
||||
(table_size_ == f.table_size_ ) &&
|
||||
(random_seed_ == f.random_seed_)
|
||||
)
|
||||
{
|
||||
for (std::size_t i = 0; i < raw_table_size_; ++i)
|
||||
for (std::size_t i = 0; i < bit_table_.size(); ++i)
|
||||
{
|
||||
bit_table_[i] &= f.bit_table_[i];
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -412,16 +429,17 @@ public:
|
|||
{
|
||||
/* union */
|
||||
if (
|
||||
(salt_count_ == f.salt_count_) &&
|
||||
(table_size_ == f.table_size_) &&
|
||||
(random_seed_ == f.random_seed_)
|
||||
(salt_count_ == f.salt_count_ ) &&
|
||||
(table_size_ == f.table_size_ ) &&
|
||||
(random_seed_ == f.random_seed_)
|
||||
)
|
||||
{
|
||||
for (std::size_t i = 0; i < raw_table_size_; ++i)
|
||||
for (std::size_t i = 0; i < bit_table_.size(); ++i)
|
||||
{
|
||||
bit_table_[i] |= f.bit_table_[i];
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -429,16 +447,17 @@ public:
|
|||
{
|
||||
/* difference */
|
||||
if (
|
||||
(salt_count_ == f.salt_count_) &&
|
||||
(table_size_ == f.table_size_) &&
|
||||
(random_seed_ == f.random_seed_)
|
||||
(salt_count_ == f.salt_count_ ) &&
|
||||
(table_size_ == f.table_size_ ) &&
|
||||
(random_seed_ == f.random_seed_)
|
||||
)
|
||||
{
|
||||
for (std::size_t i = 0; i < raw_table_size_; ++i)
|
||||
for (std::size_t i = 0; i < bit_table_.size(); ++i)
|
||||
{
|
||||
bit_table_[i] ^= f.bit_table_[i];
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -457,7 +476,7 @@ protected:
|
|||
inline virtual void compute_indices(const bloom_type& hash, std::size_t& bit_index, std::size_t& bit) const
|
||||
{
|
||||
bit_index = hash % table_size_;
|
||||
bit = bit_index % bits_per_char;
|
||||
bit = bit_index % bits_per_char;
|
||||
}
|
||||
|
||||
void generate_unique_salt()
|
||||
|
|
@ -469,6 +488,7 @@ protected:
|
|||
hash function with different values seems to be adequate.
|
||||
*/
|
||||
const unsigned int predef_salt_count = 128;
|
||||
|
||||
static const bloom_type predef_salt[predef_salt_count] =
|
||||
{
|
||||
0xAAAAAAAA, 0x55555555, 0x33333333, 0xCCCCCCCC,
|
||||
|
|
@ -510,25 +530,31 @@ protected:
|
|||
std::copy(predef_salt,
|
||||
predef_salt + salt_count_,
|
||||
std::back_inserter(salt_));
|
||||
for (unsigned int i = 0; i < salt_.size(); ++i)
|
||||
{
|
||||
|
||||
for (std::size_t i = 0; i < salt_.size(); ++i)
|
||||
{
|
||||
/*
|
||||
Note:
|
||||
This is done to integrate the user defined random seed,
|
||||
so as to allow for the generation of unique bloom filter
|
||||
instances.
|
||||
Note:
|
||||
This is done to integrate the user defined random seed,
|
||||
so as to allow for the generation of unique bloom filter
|
||||
instances.
|
||||
*/
|
||||
salt_[i] = salt_[i] * salt_[(i + 3) % salt_.size()] + static_cast<bloom_type>(random_seed_);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy(predef_salt,predef_salt + predef_salt_count,std::back_inserter(salt_));
|
||||
std::copy(predef_salt, predef_salt + predef_salt_count, std::back_inserter(salt_));
|
||||
|
||||
srand(static_cast<unsigned int>(random_seed_));
|
||||
|
||||
while (salt_.size() < salt_count_)
|
||||
{
|
||||
bloom_type current_salt = static_cast<bloom_type>(rand()) * static_cast<bloom_type>(rand());
|
||||
if (0 == current_salt) continue;
|
||||
|
||||
if (0 == current_salt)
|
||||
continue;
|
||||
|
||||
if (salt_.end() == std::find(salt_.begin(), salt_.end(), current_salt))
|
||||
{
|
||||
salt_.push_back(current_salt);
|
||||
|
|
@ -540,57 +566,71 @@ protected:
|
|||
inline bloom_type hash_ap(const unsigned char* begin, std::size_t remaining_length, bloom_type hash) const
|
||||
{
|
||||
const unsigned char* itr = begin;
|
||||
unsigned int loop = 0;
|
||||
unsigned int loop = 0;
|
||||
|
||||
while (remaining_length >= 8)
|
||||
{
|
||||
const unsigned int& i1 = *(reinterpret_cast<const unsigned int*>(itr)); itr += sizeof(unsigned int);
|
||||
const unsigned int& i2 = *(reinterpret_cast<const unsigned int*>(itr)); itr += sizeof(unsigned int);
|
||||
|
||||
hash ^= (hash << 7) ^ i1 * (hash >> 3) ^
|
||||
(~((hash << 11) + (i2 ^ (hash >> 5))));
|
||||
|
||||
remaining_length -= 8;
|
||||
}
|
||||
|
||||
if (remaining_length)
|
||||
{
|
||||
if (remaining_length >= 4)
|
||||
{
|
||||
const unsigned int& i = *(reinterpret_cast<const unsigned int*>(itr));
|
||||
|
||||
if (loop & 0x01)
|
||||
hash ^= (hash << 7) ^ i * (hash >> 3);
|
||||
else
|
||||
hash ^= (~((hash << 11) + (i ^ (hash >> 5))));
|
||||
|
||||
++loop;
|
||||
|
||||
remaining_length -= 4;
|
||||
|
||||
itr += sizeof(unsigned int);
|
||||
}
|
||||
|
||||
if (remaining_length >= 2)
|
||||
{
|
||||
const unsigned short& i = *(reinterpret_cast<const unsigned short*>(itr));
|
||||
|
||||
if (loop & 0x01)
|
||||
hash ^= (hash << 7) ^ i * (hash >> 3);
|
||||
else
|
||||
hash ^= (~((hash << 11) + (i ^ (hash >> 5))));
|
||||
|
||||
++loop;
|
||||
|
||||
remaining_length -= 2;
|
||||
|
||||
itr += sizeof(unsigned short);
|
||||
}
|
||||
|
||||
if (remaining_length)
|
||||
{
|
||||
hash += ((*itr) ^ (hash * 0xA5A5A5A5)) + loop;
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<bloom_type> salt_;
|
||||
std::vector<unsigned char> bit_table_;
|
||||
unsigned int salt_count_;
|
||||
unsigned long long int table_size_;
|
||||
unsigned long long int raw_table_size_;
|
||||
unsigned long long int projected_element_count_;
|
||||
unsigned int inserted_element_count_;
|
||||
unsigned long long int random_seed_;
|
||||
double desired_false_positive_probability_;
|
||||
public:
|
||||
std::vector<bloom_type> salt_;
|
||||
std::vector<unsigned char> bit_table_;
|
||||
unsigned int salt_count_;
|
||||
unsigned long long int table_size_;
|
||||
unsigned long long int projected_element_count_;
|
||||
unsigned long long int inserted_element_count_;
|
||||
unsigned long long int random_seed_;
|
||||
double desired_false_positive_probability_;
|
||||
};
|
||||
|
||||
inline bloom_filter operator & (const bloom_filter& a, const bloom_filter& b)
|
||||
|
|
@ -617,12 +657,15 @@ inline bloom_filter operator ^ (const bloom_filter& a, const bloom_filter& b)
|
|||
|
||||
} // namespace fc
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Note 1:
|
||||
If it can be guaranteed that bits_per_char will be of the form 2^n then
|
||||
the following optimization can be used:
|
||||
|
||||
hash_table[bit_index >> n] |= bit_mask[bit_index & (bits_per_char - 1)];
|
||||
bit_table_[bit_index >> n] |= bit_mask[bit_index & (bits_per_char - 1)];
|
||||
|
||||
Note 2:
|
||||
For performance reasons where possible when allocating memory it should
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace fc {
|
|||
boost::endian::little_uint64_buf_at hilo[2];
|
||||
hilo[0] = uint128_hi64( v );
|
||||
hilo[1] = uint128_lo64( v );
|
||||
s.write( hilo[0].data(), sizeof(hilo) );
|
||||
s.write( (char*)hilo[0].data(), sizeof(hilo) );
|
||||
}
|
||||
template<typename Stream>
|
||||
inline void unpack( Stream& s, uint128_t& v, uint32_t _max_depth )
|
||||
|
|
@ -731,7 +731,7 @@ namespace fc {
|
|||
void pack( Stream& s, const boost::endian::endian_buffer<O,T,N,A>& v, uint32_t _max_depth )
|
||||
{
|
||||
FC_ASSERT( _max_depth > 0 );
|
||||
s.write( v.data(), sizeof(v) );
|
||||
s.write( (char*)v.data(), sizeof(v) );
|
||||
}
|
||||
template<typename Stream, boost::endian::order O, class T, std::size_t N, boost::endian::align A>
|
||||
void unpack( Stream& s, boost::endian::endian_buffer<O,T,N,A>& v, uint32_t _max_depth )
|
||||
|
|
|
|||
|
|
@ -1,8 +1,26 @@
|
|||
// stacktrace.h (c) 2008, Timo Bingmann from http://idlebox.net/
|
||||
// published under the WTFPL v2.0
|
||||
|
||||
// Downloaded from http://panthema.net/2008/0901-stacktrace-demangled/
|
||||
// and modified for C++ and FC by Steemit, Inc.
|
||||
/*
|
||||
* Copyright (c) 2018 BitShares Blockchain Foundation, and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
|||
311
licenses/Apache.txt
Normal file
311
licenses/Apache.txt
Normal file
|
|
@ -0,0 +1,311 @@
|
|||
==============================================================================
|
||||
The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
|
||||
==============================================================================
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
---- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
|
||||
==============================================================================
|
||||
Software from third parties included in the LLVM Project:
|
||||
==============================================================================
|
||||
The LLVM Project contains third party software which is under different license
|
||||
terms. All such code will be identified clearly using at least one of two
|
||||
mechanisms:
|
||||
1) It will be in a separate directory tree with its own `LICENSE.txt` or
|
||||
`LICENSE` file at the top containing the specific license and restrictions
|
||||
which apply to that software, or
|
||||
2) It will contain specific license and restriction terms at the top of every
|
||||
file.
|
||||
|
||||
==============================================================================
|
||||
Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
|
||||
==============================================================================
|
||||
|
||||
The libc++ library is dual licensed under both the University of Illinois
|
||||
"BSD-Like" license and the MIT license. As a user of this code you may choose
|
||||
to use it under either license. As a contributor, you agree to allow your code
|
||||
to be used under both.
|
||||
|
||||
Full text of the relevant licenses is included below.
|
||||
|
||||
==============================================================================
|
||||
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
23
licenses/Boost_License-1.0.txt
Normal file
23
licenses/Boost_License-1.0.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
22
licenses/COPYING-CMAKE-SCRIPTS
Normal file
22
licenses/COPYING-CMAKE-SCRIPTS
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
23
licenses/MIT_Thrift_LICENSE.md
Normal file
23
licenses/MIT_Thrift_LICENSE.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
17
licenses/MIT_X11_LICENSE.md
Normal file
17
licenses/MIT_X11_LICENSE.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
17
licenses/ZLIB_LICENSE.md
Normal file
17
licenses/ZLIB_LICENSE.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
|
@ -185,7 +185,7 @@ std::vector<header> parse_urlencoded_params( const std::string& f ) {
|
|||
std::vector<header> h(num_args);
|
||||
int arg = 0;
|
||||
for( size_t i = 0; i < f.size(); ++i ) {
|
||||
while( f[i] != '=' && i < f.size() ) {
|
||||
while( i < f.size() && f[i] != '=' ) {
|
||||
if( f[i] == '%' ) {
|
||||
h[arg].key += char((fc::from_hex(f[i+1]) << 4) | fc::from_hex(f[i+2]));
|
||||
i += 3;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,27 @@
|
|||
//
|
||||
// A stacktrace handler for bitshares
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2018-2019 BitShares Blockchain Foundation, and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <ostream>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(dh_test)
|
|||
alice.p.clear(); alice.p.push_back(100); alice.p.push_back(2);
|
||||
BOOST_CHECK( !alice.validate() );
|
||||
alice.p = bob.p;
|
||||
alice.g = 9;
|
||||
alice.g = 1;
|
||||
BOOST_CHECK( !alice.validate() );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,17 +64,20 @@ public:
|
|||
BOOST_AUTO_TEST_CASE(static_variant_depth_test)
|
||||
{
|
||||
int64_t i = 1;
|
||||
fc::static_variant<uint8_t,uint16_t,uint32_t,uint64_t,int8_t,int16_t,int32_t,int64_t> test(i);
|
||||
fc::static_variant<std::string,std::vector<uint8_t>,std::vector<uint16_t>,std::vector<uint32_t>,
|
||||
uint8_t,uint16_t,uint32_t,uint64_t,int8_t,int16_t,int32_t,int64_t> test(i);
|
||||
|
||||
std::string stacktrace = test.visit( _svdt_visitor() );
|
||||
//std::cerr << stacktrace << "\n";
|
||||
std::cerr << stacktrace << "\n";
|
||||
std::vector<std::string> lines;
|
||||
boost::split( lines, stacktrace, boost::is_any_of("\n") );
|
||||
int count = 0;
|
||||
for( const auto& line : lines )
|
||||
if( line.find("_svdt_visitor") != std::string::npos ) count++;
|
||||
BOOST_CHECK_LT( 2, count ); // test.visit(), static_variant::visit, function object, visitor
|
||||
BOOST_CHECK_GT( 10, count ); // some is implementation-dependent
|
||||
BOOST_CHECK_LT( 2, count ); // test.visit(), static_variant::visit, function object, visitor.
|
||||
// The actual count depends on compiler and optimization settings.
|
||||
BOOST_CHECK_GT( 10, count ); // It *should* be less than the number of static variant components.
|
||||
// some is implementation-dependent
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue