-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
364 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ compiler: | |
|
||
os: | ||
- linux | ||
# - osx | ||
- osx | ||
|
||
script: > | ||
cmake --version && | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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() | ||
|
@@ -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.*") | ||
|
@@ -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") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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) | ||
|
@@ -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-") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
@@ -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 | ||
|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
@@ -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, | ||
|
@@ -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; | ||
|
@@ -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)); | ||
|
@@ -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 |
Oops, something went wrong.