Skip to content

Commit

Permalink
update erthink to upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
erthink committed Jan 27, 2020
1 parent fa3af40 commit 6a1ad7a
Show file tree
Hide file tree
Showing 33 changed files with 364 additions and 158 deletions.
2 changes: 1 addition & 1 deletion src/erthink/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compiler:

os:
- linux
# - osx
- osx

script: >
cmake --version &&
Expand Down
2 changes: 1 addition & 1 deletion src/erthink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (c) 2012-2019 Leonid Yuriev <[email protected]>.
## Copyright (c) 2012-2020 Leonid Yuriev <[email protected]>.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand Down
20 changes: 20 additions & 0 deletions src/erthink/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Erthink header-only C++ library.

Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
https://github.com/leo-yuriev/erthink

-- Erthink C++ library 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.
10 changes: 10 additions & 0 deletions src/erthink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Erthink C++ header-only library
===============================

https://abf.io/erthink/erthink

Licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
with [exceptions](https://abf.io/erthink/erthink/blob/master/NOTICE) for GPL2/LGPL2.

### The [repository now only mirrored on the Github](https://abf.io/erthink/erthink) due to illegal discriminatory restrictions for Russian Crimea and for sovereign crimeans.
<!-- Required extensions: pymdownx.betterem, pymdownx.tilde, pymdownx.emoji, pymdownx.tasklist, pymdownx.superfences -->
34 changes: 18 additions & 16 deletions src/erthink/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 0.0.0.{build}

environment:
GTEST_SHUFFLE: 1
GTEST_RUNTIME_LIMIT: 142
GTEST_RUNTIME_LIMIT: 99
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE_GENERATOR: Visual Studio 16 2019
TOOLSET: 142
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: Visual Studio 15 2017
TOOLSET: v141
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
# CMAKE_GENERATOR: Visual Studio 16 2019
# TOOLSET: v142
TOOLSET: 141

branches:
except:
Expand All @@ -20,38 +20,40 @@ configuration:
- Release

platform:
- x86
- Win32
- x64

artifacts:
- path: '_build/Testing/Temporary/*'
name: test_results

install:
before_build:
- git submodule sync
- git fetch --tags --prune
- git submodule update --init --recursive
- git submodule foreach --recursive git fetch --tags --prune
- cmake --version

before_build:
build_script:
- ps: |
Write-Output "*******************************************************************************"
Write-Output "Configuration: $env:CONFIGURATION"
Write-Output "Platform: $env:PLATFORM"
$generator = $env:CMAKE_GENERATOR
if ($env:PLATFORM -eq "x64") {
$generator = "$generator Win64"
}
Write-Output "Toolchain: $generator ($env:TOOLSET)"
Write-Output "Toolchain: $env:CMAKE_GENERATOR v$env:TOOLSET"
Write-Output "*******************************************************************************"
build_script:
- ps: |
md _build -Force | Out-Null
cd _build
& cmake -G "$generator" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ..
$generator = $env:CMAKE_GENERATOR
if ($env:TOOLSET -lt 142) {
if ($env:PLATFORM -eq "x64") {
$generator = "$generator Win64"
}
& cmake -G "$generator" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ..
} else {
& cmake -G "$generator" -A $env:PLATFORM -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ..
}
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage"
}
Expand Down
25 changes: 21 additions & 4 deletions src/erthink/cmake/compiler.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (c) 2012-2019 Leonid Yuriev <[email protected]>.
## Copyright (c) 2012-2020 Leonid Yuriev <[email protected]>.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,11 @@ cmake_minimum_required(VERSION 3.8.2)
cmake_policy(PUSH)
cmake_policy(VERSION 3.8.2)

if (CMAKE_VERSION MATCHES ".*MSVC.*")
message(FATAL_ERROR "CMake from MSVC kit is unfit! "
"Please use the original CMake from https://cmake.org/download/")
endif()

if (NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED))
message(FATAL_ERROR "This module required C or C++ to be enabled")
endif()
Expand Down Expand Up @@ -155,12 +160,12 @@ elseif(CMAKE_COMPILER_IS_ELBRUSC OR CMAKE_SYSTEM_PROCESSOR MATCHES "e2k.*|E2K.*|
set(E2K TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
set(X86_64 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*")
set(X86_32 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|ARM64.*)")
set(AARCH64 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARM32 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
set(AARCH64 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le.*")
set(PPC64LE TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64.*")
Expand Down Expand Up @@ -347,6 +352,18 @@ if(CMAKE_COMPILER_IS_CLANG)
(CMAKE_CLANG_LD AND CMAKE_CLANG_AR AND CMAKE_CLANG_NM AND CMAKE_CLANG_RANLIB))
set(CLANG_LTO_AVAILABLE TRUE)
message(STATUS "Link-Time Optimization by CLANG/LLVM is available")
elseif(CMAKE_TOOLCHAIN_FILE AND NOT CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 7.0)
set(CLANG_LTO_AVAILABLE TRUE)
if (NOT CMAKE_CLANG_AR)
set(CMAKE_CLANG_AR ${CMAKE_AR})
endif()
if (NOT CMAKE_CLANG_NM)
set(CMAKE_CLANG_NM ${CMAKE_NM})
endif()
if (NOT CMAKE_CLANG_RANLIB)
set(CMAKE_CLANG_RANLIB ${CMAKE_RANLIB })
endif()
message(STATUS "Assume Link-Time Optimization by CLANG/LLVM is available via ${CMAKE_TOOLCHAIN_FILE}")
else()
set(CLANG_LTO_AVAILABLE FALSE)
message(STATUS "Link-Time Optimization by CLANG/LLVM is NOT available")
Expand Down
2 changes: 1 addition & 1 deletion src/erthink/cmake/profile.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (c) 2012-2019 Leonid Yuriev <[email protected]>.
## Copyright (c) 2012-2020 Leonid Yuriev <[email protected]>.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand Down
30 changes: 29 additions & 1 deletion src/erthink/cmake/testing.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (c) 2012-2019 Leonid Yuriev <[email protected]>.
## Copyright (c) 2012-2020 Leonid Yuriev <[email protected]>.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,15 @@ include(CTest)
if(BUILD_TESTING)
cmake_policy(PUSH)

cmake_policy(SET CMP0054 NEW)
if(NOT CMAKE_VERSION VERSION_LESS 3.9)
cmake_policy(SET CMP0068 NEW)
cmake_policy(SET CMP0069 NEW)
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.12)
cmake_policy(SET CMP0075 NEW)
endif()

# Expected GTest was already found and/or pointed via ${gtest_root},
# otherwise will search at ${gtest_paths} locations, if defined or default ones.
find_package(GTest)
Expand Down Expand Up @@ -95,6 +104,25 @@ if(BUILD_TESTING)
endif()
endif()

list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_17 local_HAS_CXX17)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 local_HAS_CXX14)

if(NOT DEFINED GTEST_CXX_STANDARD)
if(DEFINED CMAKE_CXX_STANDARD)
set(GTEST_CXX_STANDARD ${CMAKE_CXX_STANDARD})
elseif(NOT local_HAS_CXX17 LESS 0)
set(GTEST_CXX_STANDARD 17)
elseif(NOT local_HAS_CXX14 LESS 0)
set(GTEST_CXX_STANDARD 14)
else()
set(GTEST_CXX_STANDARD 11)
endif()
endif()
message(STATUS "Use C++${GTEST_CXX_STANDARD} for GoogleTest")

target_compile_features(gtest PRIVATE "cxx_std_${GTEST_CXX_STANDARD}")
target_compile_features(gtest_main PRIVATE "cxx_std_${GTEST_CXX_STANDARD}")

if(CC_HAS_WERROR)
if(MSVC)
set(local_warn_no_error "/WX-")
Expand Down
2 changes: 1 addition & 1 deletion src/erthink/cmake/utils.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (c) 2012-2019 Leonid Yuriev <[email protected]>.
## Copyright (c) 2012-2020 Leonid Yuriev <[email protected]>.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/erthink/erthink.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
* Copyright (c) 1994-2020 Leonid Yuriev <[email protected]>.
* https://github.com/leo-yuriev/erthink
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/erthink/erthink_arch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
* Copyright (c) 1994-2020 Leonid Yuriev <[email protected]>.
* https://github.com/leo-yuriev/erthink
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
16 changes: 15 additions & 1 deletion src/erthink/erthink_bswap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
* Copyright (c) 1994-2020 Leonid Yuriev <[email protected]>.
* https://github.com/leo-yuriev/erthink
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,6 +22,16 @@
#include "erthink_defs.h"
#include "erthink_intrin.h"

#pragma push_macro("bswap16")
#pragma push_macro("bswap32")
#pragma push_macro("bswap64")

#undef bswap16
#undef bswap32
#undef bswap64

//------------------------------------------------------------------------------

#ifdef __cplusplus
namespace erthink {
#endif
Expand Down Expand Up @@ -121,3 +131,7 @@ template <> inline constexpr_intrin int64_t bswap<int64_t>(int64_t v) {
}
}
#endif

#pragma pop_macro("bswap16")
#pragma pop_macro("bswap32")
#pragma pop_macro("bswap64")
2 changes: 1 addition & 1 deletion src/erthink/erthink_byteorder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
* Copyright (c) 1994-2020 Leonid Yuriev <[email protected]>.
* https://github.com/leo-yuriev/erthink
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/erthink/erthink_carryadd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
* Copyright (c) 1994-2020 Leonid Yuriev <[email protected]>.
* https://github.com/leo-yuriev/erthink
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
12 changes: 6 additions & 6 deletions src/erthink/erthink_clz.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-2019 Leonid Yuriev <[email protected]>.
* Copyright (c) 1994-2020 Leonid Yuriev <[email protected]>.
* https://github.com/leo-yuriev/erthink
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,7 +33,7 @@ namespace erthink {

template <typename T> inline constexpr int clz(T v);

static inline int fallback_clz8(uint8_t v) {
static __maybe_unused inline int fallback_clz8(uint8_t v) {
static const int8_t lut[256] = {
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Expand All @@ -44,7 +44,7 @@ static inline int fallback_clz8(uint8_t v) {
return lut[v];
}

static inline int fallback_clz32(uint32_t v) {
static __maybe_unused inline int fallback_clz32(uint32_t v) {
// LY: strive for branchless (SSA-optimizer must solve this)
int r = 24, s = (v > 0xFFFF) << 4;
v >>= s;
Expand All @@ -57,7 +57,7 @@ static inline int fallback_clz32(uint32_t v) {
return r + fallback_clz8(static_cast<uint8_t>(v));
}

static inline int fallback_clz64(uint64_t v) {
static __maybe_unused inline int fallback_clz64(uint64_t v) {
#ifdef ERTHINK_ARCH32
const uint32_t hi = static_cast<uint32_t>(v >> 32);
return (hi ? 0 : 32) + fallback_clz32(hi ? hi : static_cast<uint32_t>(v));
Expand Down Expand Up @@ -112,8 +112,8 @@ template <> inline int clz<uint64_t>(uint64_t v) { return fallback_clz64(v); }

#endif /* compiler */

static __always_inline int clz64(uint64_t v) { return clz(v); }
static __maybe_unused __always_inline int clz64(uint64_t v) { return clz(v); }

static __always_inline int clz32(uint32_t v) { return clz(v); }
static __maybe_unused __always_inline int clz32(uint32_t v) { return clz(v); }

} // namespace erthink
Loading

0 comments on commit 6a1ad7a

Please sign in to comment.