Commit aa844899 by Abseil Team Committed by CJ Johnson

Creation of LTS branch "lts_2019_08_08"

  - 9ee91d3e Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 8efba58a Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - b49b8d16 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 67222ffc Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - c5c4db4f Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 14550beb Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 52e88ee5 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 36d37ab9 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - ad1485c8 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f3840bc5 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 278b2605 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - c6c3c1b4 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 44efe96d Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 3c98fcc0 Merge pull request #340 from jtsylve/macos_cxx17_fix by Matt Calabrese <38107210+mattcalabrese-google@users.noreply.github.com>
  - 74d91756 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - e6b05021 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - c964fcff Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 72e09a54 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - d65e19df Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5162fc83 Merge pull request #336 from shields/patch-2 by Shaindel Schwartz <31392632+shaindelschwartz@users.noreply.github.com>
  - 0389f7bf Merge pull request #335 from shields/patch-1 by Shaindel Schwartz <31392632+shaindelschwartz@users.noreply.github.com>
  - e9324d92 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 43ef2148 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a13d3df2 Merge pull request #323 from gosnik/master by Gennadiy Rozental <rogeeff@google.com>
  - 310a1186 Merge pull request #324 from RasPat1/patch-1 by Gennadiy Rozental <rogeeff@google.com>
  - 8f117240 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - b1dd4254 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 361cb8a9 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0238ab0a Merge pull request #321 from christoph-cullmann/c4245_fix... by Xiaoyi Zhang <zhangxy988@gmail.com>
  - 61c9bf3e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - bc9101f9 Merge pull request #320 from christoph-cullmann/master by Xiaoyi Zhang <zhangxy988@gmail.com>
  - 2f76a9bf Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 4adaf549 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 27c30ec6 Avoid undefined behavior when nullptr is passed to memcpy... by Roman Gershman <romange@gmail.com>
  - ce65f5ac Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a18fc746 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 8a394b19 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - daf381e8 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - fa00c321 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 436ba6c4 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0cbdc774 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 27c2f6e2 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - aa468ad7 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - cd86d0d2 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 33841c5c Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - ca3f8756 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - d902eb86 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a02f62f4 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0b545b46 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - dbae8764 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 044da8a2 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 6cc6ac44 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 666fc126 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 93dfcf74 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 2c8421e1 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5b65c4af Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - eab2078b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 253eb741 [CMake] Set correct flags for clang-cl (#278) by Loo Rong Jie <loorongjie@gmail.com>
  - e75672f6 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - bf294703 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 6fd82712 Merge pull request #280 from chiumichael/master by Derek Mauro <761129+derekmauro@users.noreply.github.com>
  - 7c7754fb Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 256be563 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 88a152ae Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - c1cecb25 Implement Span::first and Span::last from C++20 (#274) by Girts <girtsf@users.noreply.github.com>
  - 38b70438 Changed HTTP URLs to HTTPS where possible (#270) by nik7273 <nik8470@gmail.com>
  - febc5ee6 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 9fdf5e5b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 419f3184 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - b312c3cb Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 308ce315 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 93d155bc Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 426eaa4a Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 2901ec32 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - d78310fe Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - a4cb1c8b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 540e2537 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 89ea0c5f Merge pull request #255 from uilianries/hotfix/conan by ahedberg <ahedberg@google.com>
  - 5e0dcf72 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 0dffca4e Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 6b4201f9 Fix GCC8 warnings by Boris Staletic <boris.staletic@gmail.com>
  - 0b1e6d41 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - efccc502 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5e6a7813 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 5eea0f71 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 66f9becb Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 018b4db1 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 9449ae94 Merge pull request #243 from ThomsonTan/FixIntrinsic by Alex Strelnikov <strel@google.com>
  - b16aeb67 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 7ffbe09f Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 01b471d9 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 7bd8f36c Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 968a34ff Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 3e2e9b55 Merge pull request #231 from uilianries/feature/conan by Mark Barolak <mbxx@users.noreply.github.com>
  - 111ca706 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 389ec3f9 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 8fbcdb90 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 455dc17b Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - f197d7c7 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>
  - 284378a7 Export of internal Abseil changes. by Abseil Team <absl-team@google.com>

GitOrigin-RevId: 9ee91d3e
Change-Id: Ia06e548bc106cc9d136f6c65714be6645317aced
parent fcb10459

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

...@@ -10,3 +10,6 @@ build ...@@ -10,3 +10,6 @@ build
CMakeLists.txt.user CMakeLists.txt.user
# Ignore VS Code files # Ignore VS Code files
.vscode/* .vscode/*
# Ignore generated python artifacts
*.pyc
copts/__pycache__/
# Abseil-specific compiler flags. See absl/copts.bzl for description.
# DO NOT CHANGE THIS FILE WITHOUT THE CORRESPONDING CHANGE TO absl/copts.bzl
list(APPEND GCC_FLAGS
-Wall
-Wextra
-Wcast-qual
-Wconversion-null
-Wmissing-declarations
-Woverlength-strings
-Wpointer-arith
-Wunused-local-typedefs
-Wunused-result
-Wvarargs
-Wwrite-strings
-Wno-sign-compare
)
list(APPEND GCC_TEST_FLAGS
-Wno-conversion-null
-Wno-missing-declarations
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-parameter
-Wno-unused-private-field
)
list(APPEND LLVM_FLAGS
-Wall
-Wextra
-Weverything
-Wno-c++98-compat-pedantic
-Wno-conversion
-Wno-covered-switch-default
-Wno-deprecated
-Wno-disabled-macro-expansion
-Wno-double-promotion
-Wno-comma
-Wno-extra-semi
-Wno-packed
-Wno-padded
-Wno-sign-compare
-Wno-float-conversion
-Wno-float-equal
-Wno-format-nonliteral
-Wno-gcc-compat
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-nested-anon-types
-Wno-non-modular-include-in-module
-Wno-old-style-cast
-Wno-range-loop-analysis
-Wno-reserved-id-macro
-Wno-shorten-64-to-32
-Wno-switch-enum
-Wno-thread-safety-negative
-Wno-undef
-Wno-unknown-warning-option
-Wno-unreachable-code
-Wno-unused-macros
-Wno-weak-vtables
-Wbitfield-enum-conversion
-Wbool-conversion
-Wconstant-conversion
-Wenum-conversion
-Wint-conversion
-Wliteral-conversion
-Wnon-literal-null-conversion
-Wnull-conversion
-Wobjc-literal-conversion
-Wno-sign-conversion
-Wstring-conversion
)
list(APPEND LLVM_TEST_FLAGS
-Wno-c99-extensions
-Wno-missing-noreturn
-Wno-missing-prototypes
-Wno-missing-variable-declarations
-Wno-null-conversion
-Wno-shadow
-Wno-shift-sign-overflow
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-member-function
-Wno-unused-parameter
-Wno-unused-private-field
-Wno-unused-template
-Wno-used-but-marked-unused
-Wno-zero-as-null-pointer-constant
-Wno-gnu-zero-variadic-macro-arguments
)
list(APPEND MSVC_FLAGS
/W3
/wd4005
/wd4018
/wd4068
/wd4180
/wd4244
/wd4267
/wd4800
/DNOMINMAX
/DWIN32_LEAN_AND_MEAN
/D_CRT_SECURE_NO_WARNINGS
/D_SCL_SECURE_NO_WARNINGS
/D_ENABLE_EXTENDED_ALIGNED_STORAGE
)
list(APPEND MSVC_TEST_FLAGS
/wd4101
/wd4503
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(ABSL_DEFAULT_COPTS "${GCC_FLAGS}")
set(ABSL_TEST_COPTS "${GCC_FLAGS};${GCC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "-fexceptions")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# MATCHES so we get both Clang and AppleClang
set(ABSL_DEFAULT_COPTS "${LLVM_FLAGS}")
set(ABSL_TEST_COPTS "${LLVM_FLAGS};${LLVM_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "-fexceptions")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(ABSL_DEFAULT_COPTS "${MSVC_FLAGS}")
set(ABSL_TEST_COPTS "${MSVC_FLAGS};${MSVC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "/U_HAS_EXCEPTIONS;/D_HAS_EXCEPTIONS=1;/EHsc")
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags")
set(ABSL_DEFAULT_COPTS "")
set(ABSL_TEST_COPTS "")
set(ABSL_EXCEPTIONS_FLAG "")
endif()
# This flag is used internally for Bazel builds and is kept here for consistency
set(ABSL_EXCEPTIONS_FLAG_LINKOPTS "")
if("${CMAKE_CXX_STANDARD}" EQUAL 98)
message(FATAL_ERROR "Abseil requires at least C++11")
elseif(NOT "${CMAKE_CXX_STANDARD}")
message(STATUS "No CMAKE_CXX_STANDARD set, assuming 11")
set(ABSL_CXX_STANDARD 11)
else()
set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
endif()
include(GNUInstallDirs)
# absl_VERSION is only set if we are an LTS release being installed, in which
# case it may be into a system directory and so we need to make subdirectories
# for each installed version of Abseil. This mechanism is implemented in
# Abseil's internal Copybara (https://github.com/google/copybara) workflows and
# isn't visible in the CMake buildsystem itself.
if(absl_VERSION)
set(ABSL_SUBDIR "${PROJECT_NAME}_${PROJECT_VERSION}")
set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}/${ABSL_SUBDIR}")
set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${ABSL_SUBDIR}")
set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/{ABSL_SUBDIR}")
set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${ABSL_SUBDIR}")
else()
set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
endif()
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Abseil comes with a CMake build script ([CMakeLists.txt](../CMakeLists.txt)) Abseil comes with a CMake build script ([CMakeLists.txt](../CMakeLists.txt))
that can be used on a wide range of platforms ("C" stands for cross-platform.). that can be used on a wide range of platforms ("C" stands for cross-platform.).
If you don't have CMake installed already, you can download it for free from If you don't have CMake installed already, you can download it for free from
<http://www.cmake.org/>. <https://www.cmake.org/>.
CMake works by generating native makefiles or build projects that can CMake works by generating native makefiles or build projects that can
be used in the compiler environment of your choice. be used in the compiler environment of your choice.
...@@ -37,20 +37,12 @@ section of your executable or of your library.<br> ...@@ -37,20 +37,12 @@ section of your executable or of your library.<br>
Here is a short CMakeLists.txt example of a project file using Abseil. Here is a short CMakeLists.txt example of a project file using Abseil.
```cmake ```cmake
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5)
project(my_project) project(my_project)
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}") # Pick the C++ standard to compile with.
# Abseil currently supports C++11, C++14, and C++17.
if(MSVC) set(CMAKE_CXX_STANDARD 11)
# /wd4005 macro-redefinition
# /wd4068 unknown pragma
# /wd4244 conversion from 'type1' to 'type2'
# /wd4267 conversion from 'size_t' to 'type2'
# /wd4800 force value to bool 'true' or 'false' (performance warning)
add_compile_options(/wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS)
endif()
add_subdirectory(abseil-cpp) add_subdirectory(abseil-cpp)
...@@ -95,8 +87,8 @@ Here's a non-exhaustive list of Abseil CMake public targets: ...@@ -95,8 +87,8 @@ Here's a non-exhaustive list of Abseil CMake public targets:
```cmake ```cmake
absl::base absl::base
absl::algorithm absl::algorithm
absl::container
absl::debugging absl::debugging
absl::flat_hash_map
absl::memory absl::memory
absl::meta absl::meta
absl::numeric absl::numeric
......
# absl CMake configuration file.
include(FindThreads)
@PACKAGE_INIT@
include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
\ No newline at end of file
#
# Copyright 2019 The Abseil Authors.
#
# 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
#
# https://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.
# A simple CMakeLists.txt for testing cmake installation
cmake_minimum_required(VERSION 3.5)
project(absl_cmake_testing CXX)
set(CMAKE_CXX_STANDARD 11)
add_executable(simple simple.cc)
find_package(absl REQUIRED)
target_link_libraries(simple absl::strings)
//
// Copyright 2019 The Abseil Authors.
//
// 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
//
// https://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.
#include <iostream>
#include "absl/strings/substitute.h"
int main(int argc, char** argv) {
for (int i = 0; i < argc; ++i) {
std::cout << absl::Substitute("Arg $0: $1\n", i, argv[i]);
}
}
#!/bin/bash
#
# Copyright 2019 The Abseil Authors.
#
# 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
#
# https://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.
# "Unit" and integration tests for Absl CMake installation
# TODO(absl-team): This script isn't fully hermetic because
# -DABSL_USE_GOOGLETEST_HEAD=ON means that this script isn't pinned to a fixed
# version of GoogleTest. This means that an upstream change to GoogleTest could
# break this test. Fix this by allowing this script to pin to a known-good
# version of GoogleTest.
# Fail on any error. Treat unset variables an error. Print commands as executed.
set -euox pipefail
install_absl() {
pushd "${absl_build_dir}"
if [[ "${#}" -eq 1 ]]; then
cmake -DCMAKE_INSTALL_PREFIX="${1}" "${absl_dir}"
else
cmake "${absl_dir}"
fi
cmake --build . --target install -- -j
popd
}
uninstall_absl() {
xargs rm < "${absl_build_dir}"/install_manifest.txt
rm -rf "${absl_build_dir}"
mkdir -p "${absl_build_dir}"
}
lts_install=""
while getopts ":l" lts; do
case "${lts}" in
l )
lts_install="true"
;;
esac
done
absl_dir=/abseil-cpp
absl_build_dir=/buildfs/absl-build
project_dir="${absl_dir}"/CMake/install_test_project
project_build_dir=/buildfs/project-build
mkdir -p "${absl_build_dir}"
mkdir -p "${project_build_dir}"
if [[ "${lts_install}" ]]; then
install_dir="/usr/local"
else
install_dir="${project_build_dir}"/install
fi
mkdir -p "${install_dir}"
# Test build, install, and link against installed abseil
pushd "${project_build_dir}"
if [[ "${lts_install}" ]]; then
install_absl
cmake "${project_dir}"
else
install_absl "${install_dir}"
cmake "${project_dir}" -DCMAKE_PREFIX_PATH="${install_dir}"
fi
cmake --build . --target simple
output="$(${project_build_dir}/simple "printme" 2>&1)"
if [[ "${output}" != *"Arg 1: printme"* ]]; then
echo "Faulty output on simple project:"
echo "${output}"
exit 1
fi
popd
# Test that we haven't accidentally made absl::abslblah
pushd "${install_dir}"
# Starting in CMake 3.12 the default install dir is lib$bit_width
if [[ -d lib64 ]]; then
libdir="lib64"
elif [[ -d lib ]]; then
libdir="lib"
else
echo "ls *, */*, */*/*:"
ls *
ls */*
ls */*/*
echo "unknown lib dir"
fi
if [[ "${lts_install}" ]]; then
# LTS versions append the date of the release to the subdir.
# 9999/99/99 is the dummy date used in the local_lts workflow.
absl_subdir="absl_99999999"
else
absl_subdir="absl"
fi
if ! grep absl::strings "${libdir}/cmake/${absl_subdir}/abslTargets.cmake"; then
cat "${libdir}"/cmake/absl/abslTargets.cmake
echo "CMake targets named incorrectly"
exit 1
fi
uninstall_absl
popd
if [[ ! "${lts_install}" ]]; then
# Test that we warn if installed without a prefix or a system prefix
output="$(install_absl 2>&1)"
if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
echo "Install without prefix didn't warn as expected. Output:"
echo "${output}"
exit 1
fi
uninstall_absl
output="$(install_absl /usr 2>&1)"
if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
echo "Install with /usr didn't warn as expected. Output:"
echo "${output}"
exit 1
fi
uninstall_absl
fi
echo "Install test complete!"
exit 0
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
...@@ -14,44 +14,40 @@ ...@@ -14,44 +14,40 @@
# limitations under the License. # limitations under the License.
# #
# We require 3.0 for modern, target-based CMake. We require 3.1 for the use of # Most widely used distributions have cmake 3.5 or greater available as of March
# CXX_STANDARD in our targets. # 2019. A notable exception is RHEL-7 (CentOS7). You can install a current
cmake_minimum_required(VERSION 3.1) # version of CMake by first installing Extra Packages for Enterprise Linux
# (https://fedoraproject.org/wiki/EPEL#Extra_Packages_for_Enterprise_Linux_.28EPEL.29)
# and then issuing `yum install cmake3` on the command line.
cmake_minimum_required(VERSION 3.5)
# Compiler id for Apple Clang is now AppleClang. # Compiler id for Apple Clang is now AppleClang.
if (POLICY CMP0025) cmake_policy(SET CMP0025 NEW)
cmake_policy(SET CMP0025 NEW)
endif()
project(absl)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake) # if command can use IN_LIST
cmake_policy(SET CMP0057 NEW)
include(GNUInstallDirs) # Project version variables are the empty std::string if version is unspecified
include(AbseilHelpers) cmake_policy(SET CMP0048 NEW)
project(absl CXX)
# config options # when absl is included as subproject (i.e. using add_subdirectory(abseil-cpp))
if (MSVC) # in the source tree of a project that uses it, install rules are disabled.
# /wd4005 macro-redefinition if(NOT "^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
# /wd4068 unknown pragma set(ABSL_ENABLE_INSTALL FALSE)
# /wd4244 conversion from 'type1' to 'type2'
# /wd4267 conversion from 'size_t' to 'type2'
# /wd4800 force value to bool 'true' or 'false' (performance warning)
add_compile_options(/W3 /wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
# /D_ENABLE_EXTENDED_ALIGNED_STORAGE Introduced in VS 2017 15.8, before the
# member type would non-conformingly have an alignment of only alignof(max_align_t).
add_definitions(
/DNOMINMAX
/DWIN32_LEAN_AND_MEAN=1
/D_CRT_SECURE_NO_WARNINGS
/D_SCL_SECURE_NO_WARNINGS
/D_ENABLE_EXTENDED_ALIGNED_STORAGE
)
else() else()
set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)") set(ABSL_ENABLE_INSTALL TRUE)
endif() endif()
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/CMake
${CMAKE_CURRENT_LIST_DIR}/absl/copts
)
include(AbseilInstallDirs)
include(CMakePackageConfigHelpers)
include(AbseilHelpers)
## ##
...@@ -68,12 +64,6 @@ endif() ...@@ -68,12 +64,6 @@ endif()
# include current path # include current path
list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
# -std=X
set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
# -fexceptions
set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(ABSL_USING_CLANG ON) set(ABSL_USING_CLANG ON)
else() else()
...@@ -100,7 +90,9 @@ endif() ...@@ -100,7 +90,9 @@ endif()
if(BUILD_TESTING) if(BUILD_TESTING)
if(${ABSL_USE_GOOGLETEST_HEAD}) if(${ABSL_USE_GOOGLETEST_HEAD})
include(CMake/DownloadGTest.cmake) include(CMake/Googletest/DownloadGTest.cmake)
set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src)
set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build)
endif() endif()
check_target(gtest) check_target(gtest)
...@@ -116,3 +108,42 @@ if(BUILD_TESTING) ...@@ -116,3 +108,42 @@ if(BUILD_TESTING)
endif() endif()
add_subdirectory(absl) add_subdirectory(absl)
if(ABSL_ENABLE_INSTALL)
# install as a subdirectory only
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE absl::
DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
)
configure_package_config_file(
CMake/abslConfig.cmake.in
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
)
# Abseil only has a version in LTS releases. This mechanism is accomplished
# Abseil's internal Copybara (https://github.com/google/copybara) workflows and
# isn't visible in the CMake buildsystem itself.
if(absl_VERSION)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY ExactVersion
)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${ABSL_INSTALL_CONFIGDIR}
)
endif() # absl_VERSION
install(DIRECTORY absl
DESTINATION ${ABSL_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.inc"
PATTERN "*.h"
)
endif() # ABSL_ENABLE_INSTALL
Apache License Apache License
Version 2.0, January 2004 Version 2.0, January 2004
http://www.apache.org/licenses/ https://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
...@@ -193,12 +193,11 @@ ...@@ -193,12 +193,11 @@
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
\ No newline at end of file
...@@ -10,4 +10,5 @@ turn, use Abseil. (For more information about our releases, see the ...@@ -10,4 +10,5 @@ turn, use Abseil. (For more information about our releases, see the
The following lists LTS branches and the dates on which they have been released: The following lists LTS branches and the dates on which they have been released:
* [LTS Branch December 18, 2018](https://github.com/abseil/abseil-cpp/tree/lts_2018_12_18/)
* [LTS Branch June 20, 2018](https://github.com/abseil/abseil-cpp/tree/lts_2018_06_20/) * [LTS Branch June 20, 2018](https://github.com/abseil/abseil-cpp/tree/lts_2018_06_20/)
...@@ -42,8 +42,8 @@ the Abseil code, running tests, and getting a simple binary working. ...@@ -42,8 +42,8 @@ the Abseil code, running tests, and getting a simple binary working.
<a name="build"></a> <a name="build"></a>
## Building Abseil ## Building Abseil
[Bazel](http://bazel.build) is the official build system for Abseil, [Bazel](https://bazel.build) is the official build system for Abseil,
which is supported on most major platforms (Linux, Windows, MacOS, for example) which is supported on most major platforms (Linux, Windows, macOS, for example)
and compilers. See the [quickstart](https://abseil.io/docs/cpp/quickstart) for and compilers. See the [quickstart](https://abseil.io/docs/cpp/quickstart) for
more information on building Abseil using the Bazel build system. more information on building Abseil using the Bazel build system.
...@@ -106,9 +106,9 @@ license. See [LICENSE](LICENSE) for more information. ...@@ -106,9 +106,9 @@ license. See [LICENSE](LICENSE) for more information.
For more information about Abseil: For more information about Abseil:
* Consult our [Abseil Introduction](http://abseil.io/about/intro) * Consult our [Abseil Introduction](https://abseil.io/about/intro)
* Read [Why Adopt Abseil](http://abseil.io/about/philosophy) to understand our * Read [Why Adopt Abseil](https://abseil.io/about/philosophy) to understand our
design philosophy. design philosophy.
* Peruse our * Peruse our
[Abseil Compatibility Guarantees](http://abseil.io/about/compatibility) to [Abseil Compatibility Guarantees](https://abseil.io/about/compatibility) to
understand both what we promise to you, and what we expect of you in return. understand both what we promise to you, and what we expect of you in return.
# C++ Upgrade Tools
Abseil may occassionally release API-breaking changes. As noted in our
[Compatibility Guidelines][compatibility-guide], we will aim to provide a tool
to do the work of effecting such API-breaking changes, when absolutely
necessary.
These tools will be listed on the [C++ Upgrade Tools][upgrade-tools] guide on
https://abseil.io.
For more information, the [C++ Automated Upgrade Guide][api-upgrades-guide]
outlines this process.
[compatibility-guide]: https://abseil.io/about/compatibility
[api-upgrades-guide]: https://abseil.io/docs/cpp/tools/api-upgrades
[upgrade-tools]: https://abseil.io/docs/cpp/tools/upgrades/
...@@ -15,9 +15,9 @@ http_archive( ...@@ -15,9 +15,9 @@ http_archive(
# GoogleTest/GoogleMock framework. Used by most unit-tests. # GoogleTest/GoogleMock framework. Used by most unit-tests.
http_archive( http_archive(
name = "com_google_googletest", name = "com_google_googletest",
urls = ["https://github.com/google/googletest/archive/b4d4438df9479675a632b2f11125e57133822ece.zip"], # 2018-07-16 urls = ["https://github.com/google/googletest/archive/b6cd405286ed8635ece71c72f118e659f4ade3fb.zip"], # 2019-01-07
strip_prefix = "googletest-b4d4438df9479675a632b2f11125e57133822ece", strip_prefix = "googletest-b6cd405286ed8635ece71c72f118e659f4ade3fb",
sha256 = "5aaa5d566517cae711e2a3505ea9a6438be1b37fcaae0ebcb96ccba9aa56f23a", sha256 = "ff7a82736e158c077e76188232eac77913a15dac0b22508c390ab3f88e6d6d86",
) )
# Google benchmark. # Google benchmark.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
...@@ -25,13 +25,18 @@ create_llvm_config( ...@@ -25,13 +25,18 @@ create_llvm_config(
visibility = [":__subpackages__"], visibility = [":__subpackages__"],
) )
# following configs are based on mapping defined in: https://git.io/v5Ijz config_setting(
name = "osx",
constraint_values = [
"@bazel_tools//platforms:osx",
],
)
config_setting( config_setting(
name = "ios", name = "ios",
values = { constraint_values = [
"cpu": "darwin", "@bazel_tools//platforms:ios",
}, ],
visibility = [":__subpackages__"],
) )
config_setting( config_setting(
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
...@@ -20,10 +20,12 @@ add_subdirectory(base) ...@@ -20,10 +20,12 @@ add_subdirectory(base)
add_subdirectory(algorithm) add_subdirectory(algorithm)
add_subdirectory(container) add_subdirectory(container)
add_subdirectory(debugging) add_subdirectory(debugging)
add_subdirectory(flags)
add_subdirectory(hash) add_subdirectory(hash)
add_subdirectory(memory) add_subdirectory(memory)
add_subdirectory(meta) add_subdirectory(meta)
add_subdirectory(numeric) add_subdirectory(numeric)
add_subdirectory(random)
add_subdirectory(strings) add_subdirectory(strings)
add_subdirectory(synchronization) add_subdirectory(synchronization)
add_subdirectory(time) add_subdirectory(time)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
# #
load( load(
"//absl:copts.bzl", "//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_COPTS",
"ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS", "ABSL_TEST_COPTS",
) )
...@@ -28,6 +29,7 @@ cc_library( ...@@ -28,6 +29,7 @@ cc_library(
name = "algorithm", name = "algorithm",
hdrs = ["algorithm.h"], hdrs = ["algorithm.h"],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
) )
cc_test( cc_test(
...@@ -35,6 +37,7 @@ cc_test( ...@@ -35,6 +37,7 @@ cc_test(
size = "small", size = "small",
srcs = ["algorithm_test.cc"], srcs = ["algorithm_test.cc"],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [ deps = [
":algorithm", ":algorithm",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
...@@ -45,6 +48,7 @@ cc_test( ...@@ -45,6 +48,7 @@ cc_test(
name = "algorithm_benchmark", name = "algorithm_benchmark",
srcs = ["equal_benchmark.cc"], srcs = ["equal_benchmark.cc"],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"], tags = ["benchmark"],
deps = [ deps = [
":algorithm", ":algorithm",
...@@ -59,6 +63,7 @@ cc_library( ...@@ -59,6 +63,7 @@ cc_library(
"container.h", "container.h",
], ],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [ deps = [
":algorithm", ":algorithm",
"//absl/base:core_headers", "//absl/base:core_headers",
...@@ -70,6 +75,7 @@ cc_test( ...@@ -70,6 +75,7 @@ cc_test(
name = "container_test", name = "container_test",
srcs = ["container_test.cc"], srcs = ["container_test.cc"],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [ deps = [
":container", ":container",
"//absl/base", "//absl/base",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
...@@ -29,6 +29,8 @@ absl_cc_test( ...@@ -29,6 +29,8 @@ absl_cc_test(
algorithm_test algorithm_test
SRCS SRCS
"algorithm_test.cc" "algorithm_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::algorithm absl::algorithm
gmock_main gmock_main
...@@ -53,6 +55,8 @@ absl_cc_test( ...@@ -53,6 +55,8 @@ absl_cc_test(
container_test container_test
SRCS SRCS
"container_test.cc" "container_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::algorithm_container absl::algorithm_container
absl::base absl::base
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <type_traits> #include <type_traits>
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace algorithm_internal { namespace algorithm_internal {
...@@ -95,7 +95,7 @@ It RotateImpl(It first, It middle, It last, std::false_type) { ...@@ -95,7 +95,7 @@ It RotateImpl(It first, It middle, It last, std::false_type) {
// then the predicate is never invoked and the function returns false. // then the predicate is never invoked and the function returns false.
// //
// This is a C++11-compatible implementation of C++14 `std::equal`. See // This is a C++11-compatible implementation of C++14 `std::equal`. See
// http://en.cppreference.com/w/cpp/algorithm/equal for more information. // https://en.cppreference.com/w/cpp/algorithm/equal for more information.
template <typename InputIter1, typename InputIter2, typename Pred> template <typename InputIter1, typename InputIter2, typename Pred>
bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2, bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2,
InputIter2 last2, Pred&& pred) { InputIter2 last2, Pred&& pred) {
...@@ -146,7 +146,7 @@ ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ...@@ -146,7 +146,7 @@ ForwardIterator rotate(ForwardIterator first, ForwardIterator middle,
ForwardIterator>()); ForwardIterator>());
} }
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_ALGORITHM_ALGORITHM_H_ #endif // ABSL_ALGORITHM_ALGORITHM_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
// For template parameter and variable naming, `C` indicates the container type // For template parameter and variable naming, `C` indicates the container type
// to which the function is applied, `Pred` indicates the predicate object type // to which the function is applied, `Pred` indicates the predicate object type
// to be used by the function and `T` indicates the applicable element type. // to be used by the function and `T` indicates the applicable element type.
//
#ifndef ABSL_ALGORITHM_CONTAINER_H_ #ifndef ABSL_ALGORITHM_CONTAINER_H_
#define ABSL_ALGORITHM_CONTAINER_H_ #define ABSL_ALGORITHM_CONTAINER_H_
...@@ -56,7 +55,7 @@ ...@@ -56,7 +55,7 @@
#include "absl/meta/type_traits.h" #include "absl/meta/type_traits.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace container_algorithm_internal { namespace container_algorithm_internal {
// NOTE: it is important to defer to ADL lookup for building with C++ modules, // NOTE: it is important to defer to ADL lookup for building with C++ modules,
...@@ -512,6 +511,16 @@ OutputIterator c_move(C&& src, OutputIterator dest) { ...@@ -512,6 +511,16 @@ OutputIterator c_move(C&& src, OutputIterator dest) {
container_algorithm_internal::c_end(src), dest); container_algorithm_internal::c_end(src), dest);
} }
// c_move_backward()
//
// Container-based version of the <algorithm> `std::move_backward()` function to
// move a container's elements into an iterator in reverse order.
template <typename C, typename BidirectionalIterator>
BidirectionalIterator c_move_backward(C&& src, BidirectionalIterator dest) {
return std::move_backward(container_algorithm_internal::c_begin(src),
container_algorithm_internal::c_end(src), dest);
}
// c_swap_ranges() // c_swap_ranges()
// //
// Container-based version of the <algorithm> `std::swap_ranges()` function to // Container-based version of the <algorithm> `std::swap_ranges()` function to
...@@ -649,7 +658,6 @@ container_algorithm_internal::ContainerIter<C> c_generate_n(C& c, Size n, ...@@ -649,7 +658,6 @@ container_algorithm_internal::ContainerIter<C> c_generate_n(C& c, Size n,
// and `unique()` are omitted, because it's not clear whether or not such // and `unique()` are omitted, because it's not clear whether or not such
// functions should call erase on their supplied sequences afterwards. Either // functions should call erase on their supplied sequences afterwards. Either
// behavior would be surprising for a different set of users. // behavior would be surprising for a different set of users.
//
// c_remove_copy() // c_remove_copy()
// //
...@@ -1698,7 +1706,7 @@ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first, ...@@ -1698,7 +1706,7 @@ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first,
output_first, std::forward<BinaryOp>(op)); output_first, std::forward<BinaryOp>(op));
} }
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_ALGORITHM_CONTAINER_H_ #endif // ABSL_ALGORITHM_CONTAINER_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -636,6 +636,19 @@ TEST(MutatingTest, Move) { ...@@ -636,6 +636,19 @@ TEST(MutatingTest, Move) {
Pointee(5))); Pointee(5)));
} }
TEST(MutatingTest, MoveBackward) {
std::vector<std::unique_ptr<int>> actual;
actual.emplace_back(absl::make_unique<int>(1));
actual.emplace_back(absl::make_unique<int>(2));
actual.emplace_back(absl::make_unique<int>(3));
actual.emplace_back(absl::make_unique<int>(4));
actual.emplace_back(absl::make_unique<int>(5));
auto subrange = absl::MakeSpan(actual.data(), 3);
absl::c_move_backward(subrange, actual.end());
EXPECT_THAT(actual, ElementsAre(IsNull(), IsNull(), Pointee(1), Pointee(2),
Pointee(3)));
}
TEST(MutatingTest, MoveWithRvalue) { TEST(MutatingTest, MoveWithRvalue) {
auto MakeRValueSrc = [] { auto MakeRValueSrc = [] {
std::vector<std::unique_ptr<int>> src; std::vector<std::unique_ptr<int>> src;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
...@@ -16,6 +16,35 @@ ...@@ -16,6 +16,35 @@
absl_cc_library( absl_cc_library(
NAME NAME
atomic_hook
HDRS
"internal/atomic_hook.h"
COPTS
${ABSL_DEFAULT_COPTS}
)
absl_cc_library(
NAME
log_severity
HDRS
"log_severity.h"
SRCS
"log_severity.cc"
DEPS
absl::core_headers
COPTS
${ABSL_DEFAULT_COPTS}
)
absl_cc_library(
NAME
raw_logging_internal
COPTS
${ABSL_DEFAULT_COPTS}
)
absl_cc_library(
NAME
spinlock_wait spinlock_wait
HDRS HDRS
"internal/scheduling_mode.h" "internal/scheduling_mode.h"
...@@ -26,6 +55,8 @@ absl_cc_library( ...@@ -26,6 +55,8 @@ absl_cc_library(
"internal/spinlock_posix.inc" "internal/spinlock_posix.inc"
"internal/spinlock_wait.cc" "internal/spinlock_wait.cc"
"internal/spinlock_win32.inc" "internal/spinlock_win32.inc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::core_headers absl::core_headers
) )
...@@ -60,10 +91,12 @@ absl_cc_library( ...@@ -60,10 +91,12 @@ absl_cc_library(
core_headers core_headers
HDRS HDRS
"attributes.h" "attributes.h"
"const_init.h"
"macros.h" "macros.h"
"optimization.h" "optimization.h"
"port.h" "port.h"
"thread_annotations.h" "thread_annotations.h"
"internal/thread_annotations.h"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
...@@ -87,6 +120,7 @@ absl_cc_library( ...@@ -87,6 +120,7 @@ absl_cc_library(
absl::core_headers absl::core_headers
absl::dynamic_annotations absl::dynamic_annotations
absl::spinlock_wait absl::spinlock_wait
Threads::Threads
) )
absl_cc_library( absl_cc_library(
...@@ -99,6 +133,8 @@ absl_cc_library( ...@@ -99,6 +133,8 @@ absl_cc_library(
"internal/invoke.h" "internal/invoke.h"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS
absl::type_traits
) )
absl_cc_library( absl_cc_library(
...@@ -107,7 +143,6 @@ absl_cc_library( ...@@ -107,7 +143,6 @@ absl_cc_library(
HDRS HDRS
"call_once.h" "call_once.h"
"casts.h" "casts.h"
"internal/atomic_hook.h"
"internal/cycleclock.h" "internal/cycleclock.h"
"internal/low_level_scheduling.h" "internal/low_level_scheduling.h"
"internal/per_thread_tls.h" "internal/per_thread_tls.h"
...@@ -125,14 +160,19 @@ absl_cc_library( ...@@ -125,14 +160,19 @@ absl_cc_library(
"internal/sysinfo.cc" "internal/sysinfo.cc"
"internal/thread_identity.cc" "internal/thread_identity.cc"
"internal/unscaledcycleclock.cc" "internal/unscaledcycleclock.cc"
"log_severity.cc"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::atomic_hook
absl::base_internal absl::base_internal
absl::config absl::config
absl::core_headers absl::core_headers
absl::dynamic_annotations absl::dynamic_annotations
absl::log_severity
absl::spinlock_wait absl::spinlock_wait
absl::type_traits
Threads::Threads
PUBLIC PUBLIC
) )
...@@ -180,10 +220,11 @@ absl_cc_library( ...@@ -180,10 +220,11 @@ absl_cc_library(
SRCS SRCS
"internal/exception_safety_testing.cc" "internal/exception_safety_testing.cc"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_TEST_COPTS}
${ABSL_EXCEPTIONS_FLAG} ${ABSL_EXCEPTIONS_FLAG}
LINKOPTS
${ABSL_EXCEPTIONS_FLAG_LINKOPTS}
DEPS DEPS
absl::base
absl::config absl::config
absl::pretty_function absl::pretty_function
absl::memory absl::memory
...@@ -200,6 +241,7 @@ absl_cc_test( ...@@ -200,6 +241,7 @@ absl_cc_test(
SRCS SRCS
"exception_safety_testing_test.cc" "exception_safety_testing_test.cc"
COPTS COPTS
${ABSL_TEST_COPTS}
${ABSL_EXCEPTIONS_FLAG} ${ABSL_EXCEPTIONS_FLAG}
LINKOPTS LINKOPTS
${ABSL_EXCEPTIONS_FLAG_LINKOPTS} ${ABSL_EXCEPTIONS_FLAG_LINKOPTS}
...@@ -214,8 +256,10 @@ absl_cc_test( ...@@ -214,8 +256,10 @@ absl_cc_test(
atomic_hook_test atomic_hook_test
SRCS SRCS
"internal/atomic_hook_test.cc" "internal/atomic_hook_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::atomic_hook
absl::core_headers absl::core_headers
gtest_main gtest_main
) )
...@@ -225,6 +269,8 @@ absl_cc_test( ...@@ -225,6 +269,8 @@ absl_cc_test(
bit_cast_test bit_cast_test
SRCS SRCS
"bit_cast_test.cc" "bit_cast_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::core_headers absl::core_headers
...@@ -236,9 +282,11 @@ absl_cc_test( ...@@ -236,9 +282,11 @@ absl_cc_test(
throw_delegate_test throw_delegate_test
SRCS SRCS
"throw_delegate_test.cc" "throw_delegate_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl_internal_throw_delegate absl::throw_delegate
gtest_main gtest_main
) )
...@@ -250,6 +298,8 @@ absl_cc_test( ...@@ -250,6 +298,8 @@ absl_cc_test(
"inline_variable_test.cc" "inline_variable_test.cc"
"inline_variable_test_a.cc" "inline_variable_test_a.cc"
"inline_variable_test_b.cc" "inline_variable_test_b.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base_internal absl::base_internal
gtest_main gtest_main
...@@ -260,6 +310,8 @@ absl_cc_test( ...@@ -260,6 +310,8 @@ absl_cc_test(
invoke_test invoke_test
SRCS SRCS
"invoke_test.cc" "invoke_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base_internal absl::base_internal
absl::memory absl::memory
...@@ -290,6 +342,8 @@ absl_cc_test( ...@@ -290,6 +342,8 @@ absl_cc_test(
spinlock_test spinlock_test
SRCS SRCS
"spinlock_test_common.cc" "spinlock_test_common.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::core_headers absl::core_headers
...@@ -317,6 +371,8 @@ absl_cc_test( ...@@ -317,6 +371,8 @@ absl_cc_test(
endian_test endian_test
SRCS SRCS
"internal/endian_test.cc" "internal/endian_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::config absl::config
...@@ -329,6 +385,8 @@ absl_cc_test( ...@@ -329,6 +385,8 @@ absl_cc_test(
config_test config_test
SRCS SRCS
"config_test.cc" "config_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::config absl::config
absl::synchronization absl::synchronization
...@@ -340,6 +398,8 @@ absl_cc_test( ...@@ -340,6 +398,8 @@ absl_cc_test(
call_once_test call_once_test
SRCS SRCS
"call_once_test.cc" "call_once_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::core_headers absl::core_headers
...@@ -352,6 +412,8 @@ absl_cc_test( ...@@ -352,6 +412,8 @@ absl_cc_test(
raw_logging_test raw_logging_test
SRCS SRCS
"raw_logging_test.cc" "raw_logging_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::strings absl::strings
...@@ -363,6 +425,8 @@ absl_cc_test( ...@@ -363,6 +425,8 @@ absl_cc_test(
sysinfo_test sysinfo_test
SRCS SRCS
"internal/sysinfo_test.cc" "internal/sysinfo_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::synchronization absl::synchronization
...@@ -374,6 +438,8 @@ absl_cc_test( ...@@ -374,6 +438,8 @@ absl_cc_test(
low_level_alloc_test low_level_alloc_test
SRCS SRCS
"internal/low_level_alloc_test.cc" "internal/low_level_alloc_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::malloc_internal absl::malloc_internal
Threads::Threads Threads::Threads
...@@ -384,6 +450,8 @@ absl_cc_test( ...@@ -384,6 +450,8 @@ absl_cc_test(
thread_identity_test thread_identity_test
SRCS SRCS
"internal/thread_identity_test.cc" "internal/thread_identity_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::base absl::base
absl::core_headers absl::core_headers
...@@ -408,7 +476,57 @@ absl_cc_test( ...@@ -408,7 +476,57 @@ absl_cc_test(
bits_test bits_test
SRCS SRCS
"internal/bits_test.cc" "internal/bits_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS DEPS
absl::bits absl::bits
gtest_main gtest_main
) )
absl_cc_library(
NAME
scoped_set_env
SRCS
"internal/scoped_set_env.cc"
HDRS
"internal/scoped_set_env.h"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::base
)
absl_cc_test(
NAME
scoped_set_env_test
SRCS
"internal/scoped_set_env_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS
absl::scoped_set_env
gtest_main
)
absl_cc_test(
NAME
cmake_thread_test
SRCS
"internal/cmake_thread_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS
absl::base
)
absl_cc_test(
NAME
log_severity_test
SRCS
"log_severity_test.cc"
DEPS
absl::base
absl::log_severity
gmock
gtest_main
)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
// //
// A function-like feature checking macro that accepts C++11 style attributes. // A function-like feature checking macro that accepts C++11 style attributes.
// It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 // It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6
// (http://en.cppreference.com/w/cpp/experimental/feature_test). If we don't // (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't
// find `__has_cpp_attribute`, will evaluate to 0. // find `__has_cpp_attribute`, will evaluate to 0.
#if defined(__cplusplus) && defined(__has_cpp_attribute) #if defined(__cplusplus) && defined(__has_cpp_attribute)
// NOTE: requiring __cplusplus above should not be necessary, but // NOTE: requiring __cplusplus above should not be necessary, but
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
// //
// Tells the compiler to perform `printf` format string checking if the // Tells the compiler to perform `printf` format string checking if the
// compiler supports it; see the 'format' attribute in // compiler supports it; see the 'format' attribute in
// <http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html>. // <https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html>.
// //
// Note: As the GCC manual states, "[s]ince non-static C++ methods // Note: As the GCC manual states, "[s]ince non-static C++ methods
// have an implicit 'this' argument, the arguments of such methods // have an implicit 'this' argument, the arguments of such methods
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
// out of bounds or does other scary things with memory. // out of bounds or does other scary things with memory.
// NOTE: GCC supports AddressSanitizer(asan) since 4.8. // NOTE: GCC supports AddressSanitizer(asan) since 4.8.
// https://gcc.gnu.org/gcc-4.8/changes.html // https://gcc.gnu.org/gcc-4.8/changes.html
#if defined(__GNUC__) && defined(ADDRESS_SANITIZER) #if defined(__GNUC__)
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) #define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else #else
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS #define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
// This attribute is similar to the ADDRESS_SANITIZER attribute above, but deals // This attribute is similar to the ADDRESS_SANITIZER attribute above, but deals
// with initialized-ness rather than addressability issues. // with initialized-ness rather than addressability issues.
// NOTE: MemorySanitizer(msan) is supported by Clang but not GCC. // NOTE: MemorySanitizer(msan) is supported by Clang but not GCC.
#if defined(__GNUC__) && defined(MEMORY_SANITIZER) #if defined(__clang__)
#define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory)) #define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
#else #else
#define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY #define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
// Tells the ThreadSanitizer to not instrument a given function. // Tells the ThreadSanitizer to not instrument a given function.
// NOTE: GCC supports ThreadSanitizer(tsan) since 4.8. // NOTE: GCC supports ThreadSanitizer(tsan) since 4.8.
// https://gcc.gnu.org/gcc-4.8/changes.html // https://gcc.gnu.org/gcc-4.8/changes.html
#if defined(__GNUC__) && defined(THREAD_SANITIZER) #if defined(__GNUC__)
#define ABSL_ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) #define ABSL_ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))
#else #else
#define ABSL_ATTRIBUTE_NO_SANITIZE_THREAD #define ABSL_ATTRIBUTE_NO_SANITIZE_THREAD
...@@ -287,6 +287,17 @@ ...@@ -287,6 +287,17 @@
#define ABSL_ATTRIBUTE_NO_SANITIZE_CFI #define ABSL_ATTRIBUTE_NO_SANITIZE_CFI
#endif #endif
// ABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK
//
// Tells the SafeStack to not instrument a given function.
// See https://clang.llvm.org/docs/SafeStack.html for details.
#if defined(__GNUC__) && defined(SAFESTACK_SANITIZER)
#define ABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK \
__attribute__((no_sanitize("safe-stack")))
#else
#define ABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK
#endif
// ABSL_ATTRIBUTE_RETURNS_NONNULL // ABSL_ATTRIBUTE_RETURNS_NONNULL
// //
// Tells the compiler that a particular function never returns a null pointer. // Tells the compiler that a particular function never returns a null pointer.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "absl/base/macros.h" #include "absl/base/macros.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace { namespace {
template <int N> template <int N>
...@@ -105,5 +105,5 @@ TEST(BitCast, Double) { ...@@ -105,5 +105,5 @@ TEST(BitCast, Double) {
} }
} // namespace } // namespace
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <atomic> #include <atomic>
#include <cstdint> #include <cstdint>
#include <type_traits> #include <type_traits>
#include <utility>
#include "absl/base/internal/invoke.h" #include "absl/base/internal/invoke.h"
#include "absl/base/internal/low_level_scheduling.h" #include "absl/base/internal/low_level_scheduling.h"
...@@ -36,10 +37,11 @@ ...@@ -36,10 +37,11 @@
#include "absl/base/internal/scheduling_mode.h" #include "absl/base/internal/scheduling_mode.h"
#include "absl/base/internal/spinlock_wait.h" #include "absl/base/internal/spinlock_wait.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/base/optimization.h"
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
class once_flag; class once_flag;
...@@ -208,7 +210,7 @@ void call_once(absl::once_flag& flag, Callable&& fn, Args&&... args) { ...@@ -208,7 +210,7 @@ void call_once(absl::once_flag& flag, Callable&& fn, Args&&... args) {
} }
} }
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_CALL_ONCE_H_ #endif // ABSL_BASE_CALL_ONCE_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -18,15 +18,18 @@ ...@@ -18,15 +18,18 @@
#include <vector> #include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "absl/base/attributes.h"
#include "absl/base/const_init.h"
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace { namespace {
absl::once_flag once; absl::once_flag once;
Mutex counters_mu;
ABSL_CONST_INIT Mutex counters_mu(absl::kConstInit);
int running_thread_count GUARDED_BY(counters_mu) = 0; int running_thread_count GUARDED_BY(counters_mu) = 0;
int call_once_invoke_count GUARDED_BY(counters_mu) = 0; int call_once_invoke_count GUARDED_BY(counters_mu) = 0;
...@@ -100,5 +103,5 @@ TEST(CallOnceTest, ExecutionCount) { ...@@ -100,5 +103,5 @@ TEST(CallOnceTest, ExecutionCount) {
} }
} // namespace } // namespace
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -27,32 +27,25 @@ ...@@ -27,32 +27,25 @@
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include <utility>
#include "absl/base/internal/identity.h" #include "absl/base/internal/identity.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/meta/type_traits.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace internal_casts { namespace internal_casts {
// NOTE: Not a fully compliant implementation of `std::is_trivially_copyable`.
// TODO(calabrese) Branch on implementations that directly provide
// `std::is_trivially_copyable`, create a more rigorous workaround, and publicly
// expose in meta/type_traits.
template <class T>
struct is_trivially_copyable
: std::integral_constant<
bool, std::is_destructible<T>::value&& __has_trivial_destructor(T) &&
__has_trivial_copy(T) && __has_trivial_assign(T)> {};
template <class Dest, class Source> template <class Dest, class Source>
struct is_bitcastable struct is_bitcastable
: std::integral_constant<bool, : std::integral_constant<
sizeof(Dest) == sizeof(Source) && bool,
is_trivially_copyable<Source>::value && sizeof(Dest) == sizeof(Source) &&
is_trivially_copyable<Dest>::value && type_traits_internal::is_trivially_copyable<Source>::value &&
std::is_default_constructible<Dest>::value> {}; type_traits_internal::is_trivially_copyable<Dest>::value &&
std::is_default_constructible<Dest>::value> {};
} // namespace internal_casts } // namespace internal_casts
...@@ -185,7 +178,7 @@ inline Dest bit_cast(const Source& source) { ...@@ -185,7 +178,7 @@ inline Dest bit_cast(const Source& source) {
return dest; return dest;
} }
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_CASTS_H_ #endif // ABSL_BASE_CASTS_H_
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
// Checks whether `std::is_trivially_copy_assignable<T>` is supported. // Checks whether `std::is_trivially_copy_assignable<T>` is supported.
// Notes: Clang with libc++ supports these features, as does gcc >= 5.1 with // Notes: Clang with libc++ supports these features, as does gcc >= 5.1 with
// either libc++ or libstdc++, and Visual Studio. // either libc++ or libstdc++, and Visual Studio (but not NVCC).
#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) #if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
#error ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set #error ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set
#elif defined(ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) #elif defined(ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE)
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
(!defined(__clang__) && defined(__GNUC__) && \ (!defined(__clang__) && defined(__GNUC__) && \
(__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)) && \ (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)) && \
(defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \ (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \
defined(_MSC_VER) (defined(_MSC_VER) && !defined(__NVCC__))
#define ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 #define ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1
#define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 #define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
#endif #endif
...@@ -181,6 +181,13 @@ ...@@ -181,6 +181,13 @@
#endif #endif
#endif // defined(__ANDROID__) && defined(__clang__) #endif // defined(__ANDROID__) && defined(__clang__)
// Emscripten doesn't yet support `thread_local` or `__thread`.
// https://github.com/emscripten-core/emscripten/issues/3502
#if defined(__EMSCRIPTEN__)
#undef ABSL_HAVE_TLS
#undef ABSL_HAVE_THREAD_LOCAL
#endif // defined(__EMSCRIPTEN__)
// ABSL_HAVE_INTRINSIC_INT128 // ABSL_HAVE_INTRINSIC_INT128
// //
// Checks whether the __int128 compiler extension for a 128-bit integral type is // Checks whether the __int128 compiler extension for a 128-bit integral type is
...@@ -191,15 +198,13 @@ ...@@ -191,15 +198,13 @@
// * On Clang: // * On Clang:
// * Building using Clang for Windows, where the Clang runtime library has // * Building using Clang for Windows, where the Clang runtime library has
// 128-bit support only on LP64 architectures, but Windows is LLP64. // 128-bit support only on LP64 architectures, but Windows is LLP64.
// * Building for aarch64, where __int128 exists but has exhibits a sporadic
// compiler crashing bug.
// * On Nvidia's nvcc: // * On Nvidia's nvcc:
// * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions // * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions
// actually support __int128. // actually support __int128.
#ifdef ABSL_HAVE_INTRINSIC_INT128 #ifdef ABSL_HAVE_INTRINSIC_INT128
#error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set #error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set
#elif defined(__SIZEOF_INT128__) #elif defined(__SIZEOF_INT128__)
#if (defined(__clang__) && !defined(_WIN32) && !defined(__aarch64__)) || \ #if (defined(__clang__) && !defined(_WIN32)) || \
(defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \ (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
(defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__)) (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
#define ABSL_HAVE_INTRINSIC_INT128 1 #define ABSL_HAVE_INTRINSIC_INT128 1
...@@ -255,7 +260,7 @@ ...@@ -255,7 +260,7 @@
// Linux and Linux-derived __linux__ // Linux and Linux-derived __linux__
// Android __ANDROID__ (implies __linux__) // Android __ANDROID__ (implies __linux__)
// Linux (non-Android) __linux__ && !__ANDROID__ // Linux (non-Android) __linux__ && !__ANDROID__
// Darwin (Mac OS X and iOS) __APPLE__ // Darwin (macOS and iOS) __APPLE__
// Akaros (http://akaros.org) __ros__ // Akaros (http://akaros.org) __ros__
// Windows _WIN32 // Windows _WIN32
// NaCL __native_client__ // NaCL __native_client__
...@@ -365,16 +370,25 @@ ...@@ -365,16 +370,25 @@
#error "absl endian detection needs to be set up for your compiler" #error "absl endian detection needs to be set up for your compiler"
#endif #endif
// MacOS 10.13 doesn't let you use <any>, <optional>, or <variant> even though // macOS 10.13 and iOS 10.11 don't let you use <any>, <optional>, or <variant>
// the headers exist and are publicly noted to work. See // even though the headers exist and are publicly noted to work. See
// https://github.com/abseil/abseil-cpp/issues/207 and // https://github.com/abseil/abseil-cpp/issues/207 and
// https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes // https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes
// libc++ spells out the availability requirements in the file
// llvm-project/libcxx/include/__config via the #define
// _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS.
#if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \ #if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \
defined(__MAC_OS_X_VERSION_MIN_REQUIRED__) && \ ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \
#define ABSL_INTERNAL_MACOS_HAS_CXX_17_TYPES 1 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 120000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 50000))
#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
#else #else
#define ABSL_INTERNAL_MACOS_HAS_CXX_17_TYPES 0 #define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
#endif #endif
// ABSL_HAVE_STD_ANY // ABSL_HAVE_STD_ANY
...@@ -386,7 +400,7 @@ ...@@ -386,7 +400,7 @@
#ifdef __has_include #ifdef __has_include
#if __has_include(<any>) && __cplusplus >= 201703L && \ #if __has_include(<any>) && __cplusplus >= 201703L && \
ABSL_INTERNAL_MACOS_HAS_CXX_17_TYPES !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
#define ABSL_HAVE_STD_ANY 1 #define ABSL_HAVE_STD_ANY 1
#endif #endif
#endif #endif
...@@ -400,7 +414,7 @@ ...@@ -400,7 +414,7 @@
#ifdef __has_include #ifdef __has_include
#if __has_include(<optional>) && __cplusplus >= 201703L && \ #if __has_include(<optional>) && __cplusplus >= 201703L && \
ABSL_INTERNAL_MACOS_HAS_CXX_17_TYPES !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
#define ABSL_HAVE_STD_OPTIONAL 1 #define ABSL_HAVE_STD_OPTIONAL 1
#endif #endif
#endif #endif
...@@ -414,7 +428,7 @@ ...@@ -414,7 +428,7 @@
#ifdef __has_include #ifdef __has_include
#if __has_include(<variant>) && __cplusplus >= 201703L && \ #if __has_include(<variant>) && __cplusplus >= 201703L && \
ABSL_INTERNAL_MACOS_HAS_CXX_17_TYPES !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
#define ABSL_HAVE_STD_VARIANT 1 #define ABSL_HAVE_STD_VARIANT 1
#endif #endif
#endif #endif
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
// Copyright 2017 The Abseil Authors.
//
// 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
//
// https://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.
//
// -----------------------------------------------------------------------------
// kConstInit
// -----------------------------------------------------------------------------
//
// A constructor tag used to mark an object as safe for use as a global
// variable, avoiding the usual lifetime issues that can affect globals.
#ifndef ABSL_BASE_CONST_INIT_H_
#define ABSL_BASE_CONST_INIT_H_
// In general, objects with static storage duration (such as global variables)
// can trigger tricky object lifetime situations. Attempting to access them
// from the constructors or destructors of other global objects can result in
// undefined behavior, unless their constructors and destructors are designed
// with this issue in mind.
//
// The normal way to deal with this issue in C++11 is to use constant
// initialization and trivial destructors.
//
// Constant initialization is guaranteed to occur before any other code
// executes. Constructors that are declared 'constexpr' are eligible for
// constant initialization. You can annotate a variable declaration with the
// ABSL_CONST_INIT macro to express this intent. For compilers that support
// it, this annotation will cause a compilation error for declarations that
// aren't subject to constant initialization (perhaps because a runtime value
// was passed as a constructor argument).
//
// On program shutdown, lifetime issues can be avoided on global objects by
// ensuring that they contain trivial destructors. A class has a trivial
// destructor unless it has a user-defined destructor, a virtual method or base
// class, or a data member or base class with a non-trivial destructor of its
// own. Objects with static storage duration and a trivial destructor are not
// cleaned up on program shutdown, and are thus safe to access from other code
// running during shutdown.
//
// For a few core Abseil classes, we make a best effort to allow for safe global
// instances, even though these classes have non-trivial destructors. These
// objects can be created with the absl::kConstInit tag. For example:
// ABSL_CONST_INIT absl::Mutex global_mutex(absl::kConstInit);
//
// The line above declares a global variable of type absl::Mutex which can be
// accessed at any point during startup or shutdown. global_mutex's destructor
// will still run, but will not invalidate the object. Note that C++ specifies
// that accessing an object after its destructor has run results in undefined
// behavior, but this pattern works on the toolchains we support.
//
// The absl::kConstInit tag should only be used to define objects with static
// or thread_local storage duration.
namespace absl {
inline namespace lts_2019_08_08 {
enum ConstInitType {
kConstInit,
};
} // inline namespace lts_2019_08_08
} // namespace absl
#endif // ABSL_BASE_CONST_INIT_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
#define ANNOTATE_MEMORY_IS_INITIALIZED(address, size) /* empty */ #define ANNOTATE_MEMORY_IS_INITIALIZED(address, size) /* empty */
#define ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size) /* empty */ #define ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size) /* empty */
#endif /* DYNAMIC_ANNOTATIONS_ENABLED || MEMORY_SANITIZER */ #endif /* DYNAMIC_ANNOTATIONS_ENABLED || MEMORY_SANITIZER */
/* TODO(delesley) -- Replace __CLANG_SUPPORT_DYN_ANNOTATION__ with the /* TODO(delesley) -- Replace __CLANG_SUPPORT_DYN_ANNOTATION__ with the
appropriate feature ID. */ appropriate feature ID. */
#if defined(__clang__) && (!defined(SWIG)) \ #if defined(__clang__) && (!defined(SWIG)) \
...@@ -376,7 +377,7 @@ inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) { /* NOLINT */ ...@@ -376,7 +377,7 @@ inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) { /* NOLINT */
struct { char x[8] __attribute__ ((aligned (8))); } name struct { char x[8] __attribute__ ((aligned (8))); } name
#else #else
#define ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid) #define ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid)
#define ADDRESS_SANITIZER_REDZONE(name) #define ADDRESS_SANITIZER_REDZONE(name) static_assert(true, "")
#endif // ADDRESS_SANITIZER #endif // ADDRESS_SANITIZER
/* Undefine the macros intended only in this file. */ /* Undefine the macros intended only in this file. */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
namespace { namespace {
...@@ -60,5 +60,5 @@ TEST(InlineVariableTest, FunPtrType) { ...@@ -60,5 +60,5 @@ TEST(InlineVariableTest, FunPtrType) {
} // namespace } // namespace
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "absl/base/internal/inline_variable_testing.h" #include "absl/base/internal/inline_variable_testing.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
const Foo& get_foo_a() { return inline_variable_foo; } const Foo& get_foo_a() { return inline_variable_foo; }
...@@ -23,5 +23,5 @@ const Foo& get_foo_a() { return inline_variable_foo; } ...@@ -23,5 +23,5 @@ const Foo& get_foo_a() { return inline_variable_foo; }
const int& get_int_a() { return inline_variable_int; } const int& get_int_a() { return inline_variable_int; }
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "absl/base/internal/inline_variable_testing.h" #include "absl/base/internal/inline_variable_testing.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
const Foo& get_foo_b() { return inline_variable_foo; } const Foo& get_foo_b() { return inline_variable_foo; }
...@@ -23,5 +23,5 @@ const Foo& get_foo_b() { return inline_variable_foo; } ...@@ -23,5 +23,5 @@ const Foo& get_foo_b() { return inline_variable_foo; }
const int& get_int_b() { return inline_variable_int; } const int& get_int_b() { return inline_variable_int; }
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
template <typename T> template <typename T>
...@@ -161,7 +161,7 @@ class AtomicHook<ReturnType (*)(Args...)> { ...@@ -161,7 +161,7 @@ class AtomicHook<ReturnType (*)(Args...)> {
#undef ABSL_HAVE_WORKING_ATOMIC_POINTER #undef ABSL_HAVE_WORKING_ATOMIC_POINTER
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_ #endif // ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros64Slow(uint64_t n) { ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros64Slow(uint64_t n) {
...@@ -189,7 +189,7 @@ ABSL_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32(uint32_t n) { ...@@ -189,7 +189,7 @@ ABSL_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32(uint32_t n) {
#undef ABSL_BASE_INTERNAL_FORCEINLINE #undef ABSL_BASE_INTERNAL_FORCEINLINE
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_BITS_H_ #endif // ABSL_BASE_INTERNAL_BITS_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
// Copyright 2018 The Abseil Authors.
//
// 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
//
// https://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.
#include <iostream>
#include "absl/base/internal/thread_identity.h"
int main() {
auto* tid = absl::base_internal::CurrentThreadIdentityIfPresent();
// Make sure the above call can't be optimized out
std::cout << (void*)tid << std::endl;
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
#include "absl/base/internal/cycleclock.h" #include "absl/base/internal/cycleclock.h"
#include <atomic>
#include <chrono> // NOLINT(build/c++11) #include <chrono> // NOLINT(build/c++11)
#include "absl/base/internal/unscaledcycleclock.h" #include "absl/base/internal/unscaledcycleclock.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
#if ABSL_USE_UNSCALED_CYCLECLOCK #if ABSL_USE_UNSCALED_CYCLECLOCK
...@@ -53,17 +54,40 @@ static constexpr int32_t kShift = 2; ...@@ -53,17 +54,40 @@ static constexpr int32_t kShift = 2;
#endif #endif
static constexpr double kFrequencyScale = 1.0 / (1 << kShift); static constexpr double kFrequencyScale = 1.0 / (1 << kShift);
static std::atomic<CycleClockSourceFunc> cycle_clock_source;
CycleClockSourceFunc LoadCycleClockSource() {
// Optimize for the common case (no callback) by first doing a relaxed load;
// this is significantly faster on non-x86 platforms.
if (cycle_clock_source.load(std::memory_order_relaxed) == nullptr) {
return nullptr;
}
// This corresponds to the store(std::memory_order_release) in
// CycleClockSource::Register, and makes sure that any updates made prior to
// registering the callback are visible to this thread before the callback is
// invoked.
return cycle_clock_source.load(std::memory_order_acquire);
}
} // namespace } // namespace
int64_t CycleClock::Now() { int64_t CycleClock::Now() {
return base_internal::UnscaledCycleClock::Now() >> kShift; auto fn = LoadCycleClockSource();
if (fn == nullptr) {
return base_internal::UnscaledCycleClock::Now() >> kShift;
}
return fn() >> kShift;
} }
double CycleClock::Frequency() { double CycleClock::Frequency() {
return kFrequencyScale * base_internal::UnscaledCycleClock::Frequency(); return kFrequencyScale * base_internal::UnscaledCycleClock::Frequency();
} }
void CycleClockSource::Register(CycleClockSourceFunc source) {
// Corresponds to the load(std::memory_order_acquire) in LoadCycleClockSource.
cycle_clock_source.store(source, std::memory_order_release);
}
#else #else
int64_t CycleClock::Now() { int64_t CycleClock::Now() {
...@@ -79,5 +103,5 @@ double CycleClock::Frequency() { ...@@ -79,5 +103,5 @@ double CycleClock::Frequency() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
// not necessarily "CPU cycles" and code should not rely on that behavior, even // not necessarily "CPU cycles" and code should not rely on that behavior, even
// if experimentally observed. // if experimentally observed.
// //
//
// An arbitrary offset may have been added to the counter at power on. // An arbitrary offset may have been added to the counter at power on.
// //
// On some platforms, the rate and offset of the counter may differ // On some platforms, the rate and offset of the counter may differ
...@@ -46,7 +45,7 @@ ...@@ -46,7 +45,7 @@
#include <cstdint> #include <cstdint>
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -72,8 +71,22 @@ class CycleClock { ...@@ -72,8 +71,22 @@ class CycleClock {
CycleClock& operator=(const CycleClock&) = delete; CycleClock& operator=(const CycleClock&) = delete;
}; };
using CycleClockSourceFunc = int64_t (*)();
class CycleClockSource {
private:
// CycleClockSource::Register()
//
// Register a function that provides an alternate source for the unscaled CPU
// cycle count value. The source function must be async signal safe, must not
// call CycleClock::Now(), and must have a frequency that matches that of the
// unscaled clock used by CycleClock. A nullptr value resets CycleClock to use
// the default source.
static void Register(CycleClockSourceFunc source);
};
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_ #endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -62,7 +62,7 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t); ...@@ -62,7 +62,7 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t);
#endif // __BIONIC__ #endif // __BIONIC__
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// Platform specific logic extracted from // Platform specific logic extracted from
...@@ -129,7 +129,7 @@ inline int DirectMunmap(void* start, size_t length) { ...@@ -129,7 +129,7 @@ inline int DirectMunmap(void* start, size_t length) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#else // !__linux__ #else // !__linux__
...@@ -138,7 +138,7 @@ inline int DirectMunmap(void* start, size_t length) { ...@@ -138,7 +138,7 @@ inline int DirectMunmap(void* start, size_t length) {
// actual mmap()/munmap() methods. // actual mmap()/munmap() methods.
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd,
...@@ -151,7 +151,7 @@ inline int DirectMunmap(void* start, size_t length) { ...@@ -151,7 +151,7 @@ inline int DirectMunmap(void* start, size_t length) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // __linux__ #endif // __linux__
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <stdlib.h> // NOLINT(build/include) #include <stdlib.h> // NOLINT(build/include)
#elif defined(__APPLE__) #elif defined(__APPLE__)
// Mac OS X / Darwin features // macOS / Darwin features
#include <libkern/OSByteOrder.h> #include <libkern/OSByteOrder.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
#include <sys/endian.h> #include <sys/endian.h>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
// Use compiler byte-swapping intrinsics if they are available. 32-bit // Use compiler byte-swapping intrinsics if they are available. 32-bit
// and 64-bit versions are available in Clang and GCC as of GCC 4.3.0. // and 64-bit versions are available in Clang and GCC as of GCC 4.3.0.
...@@ -76,7 +76,7 @@ inline uint64_t gbswap_64(uint64_t host_int) { ...@@ -76,7 +76,7 @@ inline uint64_t gbswap_64(uint64_t host_int) {
if (__builtin_constant_p(host_int)) { if (__builtin_constant_p(host_int)) {
return __bswap_constant_64(host_int); return __bswap_constant_64(host_int);
} else { } else {
register uint64_t result; uint64_t result;
__asm__("bswap %0" : "=r"(result) : "0"(host_int)); __asm__("bswap %0" : "=r"(result) : "0"(host_int));
return result; return result;
} }
...@@ -268,7 +268,7 @@ inline void Store64(void *p, uint64_t v) { ...@@ -268,7 +268,7 @@ inline void Store64(void *p, uint64_t v) {
} // namespace big_endian } // namespace big_endian
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_ENDIAN_H_ #endif // ABSL_BASE_INTERNAL_ENDIAN_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "absl/base/config.h" #include "absl/base/config.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace { namespace {
const uint64_t kInitialNumber{0x0123456789abcdef}; const uint64_t kInitialNumber{0x0123456789abcdef};
...@@ -261,5 +261,5 @@ TEST(EndianessTest, big_endian) { ...@@ -261,5 +261,5 @@ TEST(EndianessTest, big_endian) {
} }
} // namespace } // namespace
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -169,8 +169,10 @@ class ConstructorTracker { ...@@ -169,8 +169,10 @@ class ConstructorTracker {
return current_tracker_instance_ != nullptr; return current_tracker_instance_ != nullptr;
} }
static std::string ErrorMessage(void* address, const std::string& address_description, static std::string ErrorMessage(void* address,
int countdown, const std::string& error_description) { const std::string& address_description,
int countdown,
const std::string& error_description) {
return absl::Substitute( return absl::Substitute(
"With coundtown at $0:\n" "With coundtown at $0:\n"
" $1\n" " $1\n"
...@@ -556,8 +558,8 @@ class ThrowingValue : private exceptions_internal::TrackedObject { ...@@ -556,8 +558,8 @@ class ThrowingValue : private exceptions_internal::TrackedObject {
// We provide both regular and templated operator delete because if only the // We provide both regular and templated operator delete because if only the
// templated version is provided as we did with operator new, the compiler has // templated version is provided as we did with operator new, the compiler has
// no way of knowing which overload of operator delete to call. See // no way of knowing which overload of operator delete to call. See
// http://en.cppreference.com/w/cpp/memory/new/operator_delete and // https://en.cppreference.com/w/cpp/memory/new/operator_delete and
// http://en.cppreference.com/w/cpp/language/delete for the gory details. // https://en.cppreference.com/w/cpp/language/delete for the gory details.
void operator delete(void* p) noexcept { ::operator delete(p); } void operator delete(void* p) noexcept { ::operator delete(p); }
template <typename... Args> template <typename... Args>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <cstdint> #include <cstdint>
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// Arbitrary value with high bits set. Xor'ing with it is unlikely // Arbitrary value with high bits set. Xor'ing with it is unlikely
...@@ -43,7 +43,7 @@ inline T* UnhidePtr(uintptr_t hidden) { ...@@ -43,7 +43,7 @@ inline T* UnhidePtr(uintptr_t hidden) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_ #endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define ABSL_BASE_INTERNAL_IDENTITY_H_ #define ABSL_BASE_INTERNAL_IDENTITY_H_
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace internal { namespace internal {
template <typename T> template <typename T>
...@@ -29,7 +29,7 @@ template <typename T> ...@@ -29,7 +29,7 @@ template <typename T>
using identity_t = typename identity<T>::type; using identity_t = typename identity<T>::type;
} // namespace internal } // namespace internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_IDENTITY_H_ #endif // ABSL_BASE_INTERNAL_IDENTITY_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "absl/base/internal/inline_variable.h" #include "absl/base/internal/inline_variable.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
struct Foo { struct Foo {
...@@ -40,7 +40,7 @@ const int& get_int_a(); ...@@ -40,7 +40,7 @@ const int& get_int_a();
const int& get_int_b(); const int& get_int_b();
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INLINE_VARIABLE_TESTING_H_ #endif // ABSL_BASE_INLINE_VARIABLE_TESTING_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "absl/meta/type_traits.h"
// The following code is internal implementation detail. See the comment at the // The following code is internal implementation detail. See the comment at the
// top of this file for the API documentation. // top of this file for the API documentation.
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// The five classes below each implement one of the clauses from the definition // The five classes below each implement one of the clauses from the definition
...@@ -68,15 +70,11 @@ struct MemFunAndRef : StrippedAccept<MemFunAndRef> { ...@@ -68,15 +70,11 @@ struct MemFunAndRef : StrippedAccept<MemFunAndRef> {
template <typename... Args> template <typename... Args>
struct AcceptImpl : std::false_type {}; struct AcceptImpl : std::false_type {};
template <typename R, typename C, typename... Params, typename Obj, template <typename MemFunType, typename C, typename Obj, typename... Args>
typename... Args> struct AcceptImpl<MemFunType C::*, Obj, Args...>
struct AcceptImpl<R (C::*)(Params...), Obj, Args...> : std::integral_constant<bool, std::is_base_of<C, Obj>::value &&
: std::is_base_of<C, Obj> {}; absl::is_function<MemFunType>::value> {
};
template <typename R, typename C, typename... Params, typename Obj,
typename... Args>
struct AcceptImpl<R (C::*)(Params...) const, Obj, Args...>
: std::is_base_of<C, Obj> {};
template <typename MemFun, typename Obj, typename... Args> template <typename MemFun, typename Obj, typename... Args>
static decltype((std::declval<Obj>().* static decltype((std::declval<Obj>().*
...@@ -93,15 +91,11 @@ struct MemFunAndPtr : StrippedAccept<MemFunAndPtr> { ...@@ -93,15 +91,11 @@ struct MemFunAndPtr : StrippedAccept<MemFunAndPtr> {
template <typename... Args> template <typename... Args>
struct AcceptImpl : std::false_type {}; struct AcceptImpl : std::false_type {};
template <typename R, typename C, typename... Params, typename Ptr, template <typename MemFunType, typename C, typename Ptr, typename... Args>
typename... Args> struct AcceptImpl<MemFunType C::*, Ptr, Args...>
struct AcceptImpl<R (C::*)(Params...), Ptr, Args...> : std::integral_constant<bool, !std::is_base_of<C, Ptr>::value &&
: std::integral_constant<bool, !std::is_base_of<C, Ptr>::value> {}; absl::is_function<MemFunType>::value> {
};
template <typename R, typename C, typename... Params, typename Ptr,
typename... Args>
struct AcceptImpl<R (C::*)(Params...) const, Ptr, Args...>
: std::integral_constant<bool, !std::is_base_of<C, Ptr>::value> {};
template <typename MemFun, typename Ptr, typename... Args> template <typename MemFun, typename Ptr, typename... Args>
static decltype(((*std::declval<Ptr>()).* static decltype(((*std::declval<Ptr>()).*
...@@ -120,7 +114,9 @@ struct DataMemAndRef : StrippedAccept<DataMemAndRef> { ...@@ -120,7 +114,9 @@ struct DataMemAndRef : StrippedAccept<DataMemAndRef> {
struct AcceptImpl : std::false_type {}; struct AcceptImpl : std::false_type {};
template <typename R, typename C, typename Obj> template <typename R, typename C, typename Obj>
struct AcceptImpl<R C::*, Obj> : std::is_base_of<C, Obj> {}; struct AcceptImpl<R C::*, Obj>
: std::integral_constant<bool, std::is_base_of<C, Obj>::value &&
!absl::is_function<R>::value> {};
template <typename DataMem, typename Ref> template <typename DataMem, typename Ref>
static decltype(std::declval<Ref>().*std::declval<DataMem>()) Invoke( static decltype(std::declval<Ref>().*std::declval<DataMem>()) Invoke(
...@@ -137,7 +133,8 @@ struct DataMemAndPtr : StrippedAccept<DataMemAndPtr> { ...@@ -137,7 +133,8 @@ struct DataMemAndPtr : StrippedAccept<DataMemAndPtr> {
template <typename R, typename C, typename Ptr> template <typename R, typename C, typename Ptr>
struct AcceptImpl<R C::*, Ptr> struct AcceptImpl<R C::*, Ptr>
: std::integral_constant<bool, !std::is_base_of<C, Ptr>::value> {}; : std::integral_constant<bool, !std::is_base_of<C, Ptr>::value &&
!absl::is_function<R>::value> {};
template <typename DataMem, typename Ptr> template <typename DataMem, typename Ptr>
static decltype((*std::declval<Ptr>()).*std::declval<DataMem>()) Invoke( static decltype((*std::declval<Ptr>()).*std::declval<DataMem>()) Invoke(
...@@ -184,7 +181,7 @@ InvokeT<F, Args...> Invoke(F&& f, Args&&... args) { ...@@ -184,7 +181,7 @@ InvokeT<F, Args...> Invoke(F&& f, Args&&... args) {
std::forward<Args>(args)...); std::forward<Args>(args)...);
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_INVOKE_H_ #endif // ABSL_BASE_INTERNAL_INVOKE_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
#endif // __APPLE__ #endif // __APPLE__
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// A first-fit allocator with amortized logarithmic free() time. // A first-fit allocator with amortized logarithmic free() time.
...@@ -295,7 +295,10 @@ class SCOPED_LOCKABLE ArenaLock { ...@@ -295,7 +295,10 @@ class SCOPED_LOCKABLE ArenaLock {
arena_->mu.Unlock(); arena_->mu.Unlock();
#ifndef ABSL_LOW_LEVEL_ALLOC_ASYNC_SIGNAL_SAFE_MISSING #ifndef ABSL_LOW_LEVEL_ALLOC_ASYNC_SIGNAL_SAFE_MISSING
if (mask_valid_) { if (mask_valid_) {
pthread_sigmask(SIG_SETMASK, &mask_, nullptr); const int err = pthread_sigmask(SIG_SETMASK, &mask_, nullptr);
if (err != 0) {
ABSL_RAW_LOG(FATAL, "pthread_sigmask failed: %d", err);
}
} }
#endif #endif
left_ = true; left_ = true;
...@@ -612,7 +615,7 @@ void *LowLevelAlloc::AllocWithArena(size_t request, Arena *arena) { ...@@ -612,7 +615,7 @@ void *LowLevelAlloc::AllocWithArena(size_t request, Arena *arena) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_LOW_LEVEL_ALLOC_MISSING #endif // ABSL_LOW_LEVEL_ALLOC_MISSING
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// IWYU pragma: private, include "base/low_level_alloc.h" // IWYU pragma: private, include "base/low_level_alloc.h"
#include <sys/types.h> #include <sys/types.h>
#include <cstdint> #include <cstdint>
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
...@@ -54,7 +55,7 @@ ...@@ -54,7 +55,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
class LowLevelAlloc { class LowLevelAlloc {
...@@ -119,6 +120,7 @@ class LowLevelAlloc { ...@@ -119,6 +120,7 @@ class LowLevelAlloc {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_LOW_LEVEL_ALLOC_H_ #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_ALLOC_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <utility> #include <utility>
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -138,6 +138,7 @@ static void Test(bool use_new_arena, bool call_malloc_hook, int n) { ...@@ -138,6 +138,7 @@ static void Test(bool use_new_arena, bool call_malloc_hook, int n) {
TEST_ASSERT(LowLevelAlloc::DeleteArena(arena)); TEST_ASSERT(LowLevelAlloc::DeleteArena(arena));
} }
} }
// LowLevelAlloc is designed to be safe to call before main(). // LowLevelAlloc is designed to be safe to call before main().
static struct BeforeMain { static struct BeforeMain {
BeforeMain() { BeforeMain() {
...@@ -149,7 +150,7 @@ static struct BeforeMain { ...@@ -149,7 +150,7 @@ static struct BeforeMain {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -28,7 +28,7 @@ extern "C" bool __google_disable_rescheduling(void); ...@@ -28,7 +28,7 @@ extern "C" bool __google_disable_rescheduling(void);
extern "C" void __google_enable_rescheduling(bool disable_result); extern "C" void __google_enable_rescheduling(bool disable_result);
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
class SchedulingHelper; // To allow use of SchedulingGuard. class SchedulingHelper; // To allow use of SchedulingGuard.
...@@ -87,6 +87,7 @@ class SchedulingGuard { ...@@ -87,6 +87,7 @@ class SchedulingGuard {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// End of public interfaces. // End of public interfaces.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
inline bool SchedulingGuard::ReschedulingIsAllowed() { inline bool SchedulingGuard::ReschedulingIsAllowed() {
return false; return false;
} }
...@@ -99,8 +100,8 @@ inline void SchedulingGuard::EnableRescheduling(bool /* disable_result */) { ...@@ -99,8 +100,8 @@ inline void SchedulingGuard::EnableRescheduling(bool /* disable_result */) {
return; return;
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_ #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -16,13 +16,17 @@ ...@@ -16,13 +16,17 @@
#define ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_ #define ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_
// This header defines two macros: // This header defines two macros:
//
// If the platform supports thread-local storage: // If the platform supports thread-local storage:
// ABSL_PER_THREAD_TLS_KEYWORD is the C keyword needed to declare a //
// thread-local variable ABSL_PER_THREAD_TLS is 1 // * ABSL_PER_THREAD_TLS_KEYWORD is the C keyword needed to declare a
// thread-local variable
// * ABSL_PER_THREAD_TLS is 1
// //
// Otherwise: // Otherwise:
// ABSL_PER_THREAD_TLS_KEYWORD is empty //
// ABSL_PER_THREAD_TLS is 0 // * ABSL_PER_THREAD_TLS_KEYWORD is empty
// * ABSL_PER_THREAD_TLS is 0
// //
// Microsoft C supports thread-local storage. // Microsoft C supports thread-local storage.
// GCC supports it if the appropriate version of glibc is available, // GCC supports it if the appropriate version of glibc is available,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
// This preprocessor token is also defined in raw_io.cc. If you need to copy // This preprocessor token is also defined in raw_io.cc. If you need to copy
// this, consider moving both to config.h instead. // this, consider moving both to config.h instead.
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__Fuchsia__) || defined(__native_client__) defined(__Fuchsia__) || defined(__native_client__) || \
defined(__EMSCRIPTEN__)
#include <unistd.h> #include <unistd.h>
...@@ -181,7 +182,7 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line, ...@@ -181,7 +182,7 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line,
} // namespace } // namespace
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace raw_logging_internal { namespace raw_logging_internal {
void SafeWriteToStderr(const char *s, size_t len) { void SafeWriteToStderr(const char *s, size_t len) {
#if defined(ABSL_HAVE_SYSCALL_WRITE) #if defined(ABSL_HAVE_SYSCALL_WRITE)
...@@ -232,5 +233,5 @@ void RegisterInternalLogFunction(InternalLogFunction func) { ...@@ -232,5 +233,5 @@ void RegisterInternalLogFunction(InternalLogFunction func) {
} }
} // namespace raw_logging_internal } // namespace raw_logging_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
// ABSL_RAW_LOG(ERROR, "Failed foo with %i: %s", status, error); // ABSL_RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
// This will print an almost standard log line like this to stderr only: // This will print an almost standard log line like this to stderr only:
// E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file // E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
#define ABSL_RAW_LOG(severity, ...) \ #define ABSL_RAW_LOG(severity, ...) \
do { \ do { \
constexpr const char* absl_raw_logging_internal_basename = \ constexpr const char* absl_raw_logging_internal_basename = \
...@@ -79,13 +80,13 @@ ...@@ -79,13 +80,13 @@
absl_raw_logging_internal_basename, __LINE__, message); \ absl_raw_logging_internal_basename, __LINE__, message); \
} while (0) } while (0)
#define ABSL_INTERNAL_CHECK(condition, message) \ #define ABSL_INTERNAL_CHECK(condition, message) \
do { \ do { \
if (ABSL_PREDICT_FALSE(!(condition))) { \ if (ABSL_PREDICT_FALSE(!(condition))) { \
std::string death_message = "Check " #condition " failed: "; \ std::string death_message = "Check " #condition " failed: "; \
death_message += std::string(message); \ death_message += std::string(message); \
ABSL_INTERNAL_LOG(FATAL, death_message); \ ABSL_INTERNAL_LOG(FATAL, death_message); \
} \ } \
} while (0) } while (0)
#define ABSL_RAW_LOGGING_INTERNAL_INFO ::absl::LogSeverity::kInfo #define ABSL_RAW_LOGGING_INTERNAL_INFO ::absl::LogSeverity::kInfo
...@@ -96,7 +97,7 @@ ...@@ -96,7 +97,7 @@
::absl::NormalizeLogSeverity(severity) ::absl::NormalizeLogSeverity(severity)
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace raw_logging_internal { namespace raw_logging_internal {
// Helper function to implement ABSL_RAW_LOG // Helper function to implement ABSL_RAW_LOG
...@@ -176,7 +177,7 @@ extern base_internal::AtomicHook<InternalLogFunction> internal_log_function; ...@@ -176,7 +177,7 @@ extern base_internal::AtomicHook<InternalLogFunction> internal_log_function;
void RegisterInternalLogFunction(InternalLogFunction func); void RegisterInternalLogFunction(InternalLogFunction func);
} // namespace raw_logging_internal } // namespace raw_logging_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_RAW_LOGGING_H_ #endif // ABSL_BASE_INTERNAL_RAW_LOGGING_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ #define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// Used to describe how a thread may be scheduled. Typically associated with // Used to describe how a thread may be scheduled. Typically associated with
...@@ -50,7 +50,7 @@ enum SchedulingMode { ...@@ -50,7 +50,7 @@ enum SchedulingMode {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
// Copyright 2019 The Abseil Authors.
//
// 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
//
// https://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.
#include "absl/base/internal/scoped_set_env.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <cstdlib>
#include "absl/base/internal/raw_logging.h"
namespace absl {
inline namespace lts_2019_08_08 {
namespace base_internal {
namespace {
#ifdef _WIN32
const int kMaxEnvVarValueSize = 1024;
#endif
void SetEnvVar(const char* name, const char* value) {
#ifdef _WIN32
SetEnvironmentVariableA(name, value);
#else
if (value == nullptr) {
::unsetenv(name);
} else {
::setenv(name, value, 1);
}
#endif
}
} // namespace
ScopedSetEnv::ScopedSetEnv(const char* var_name, const char* new_value)
: var_name_(var_name), was_unset_(false) {
#ifdef _WIN32
char buf[kMaxEnvVarValueSize];
auto get_res = GetEnvironmentVariableA(var_name_.c_str(), buf, sizeof(buf));
ABSL_INTERNAL_CHECK(get_res < sizeof(buf), "value exceeds buffer size");
if (get_res == 0) {
was_unset_ = (GetLastError() == ERROR_ENVVAR_NOT_FOUND);
} else {
old_value_.assign(buf, get_res);
}
SetEnvironmentVariableA(var_name_.c_str(), new_value);
#else
const char* val = ::getenv(var_name_.c_str());
if (val == nullptr) {
was_unset_ = true;
} else {
old_value_ = val;
}
#endif
SetEnvVar(var_name_.c_str(), new_value);
}
ScopedSetEnv::~ScopedSetEnv() {
SetEnvVar(var_name_.c_str(), was_unset_ ? nullptr : old_value_.c_str());
}
} // namespace base_internal
} // inline namespace lts_2019_08_08
} // namespace absl
//
// Copyright 2019 The Abseil Authors.
//
// 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
//
// https://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.
//
#ifndef ABSL_BASE_INTERNAL_SCOPED_SET_ENV_H_
#define ABSL_BASE_INTERNAL_SCOPED_SET_ENV_H_
#include <string>
namespace absl {
inline namespace lts_2019_08_08 {
namespace base_internal {
class ScopedSetEnv {
public:
ScopedSetEnv(const char* var_name, const char* new_value);
~ScopedSetEnv();
private:
std::string var_name_;
std::string old_value_;
// True if the environment variable was initially not set.
bool was_unset_;
};
} // namespace base_internal
} // inline namespace lts_2019_08_08
} // namespace absl
#endif // ABSL_BASE_INTERNAL_SCOPED_SET_ENV_H_
// Copyright 2019 The Abseil Authors.
//
// 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
//
// https://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.
#ifdef _WIN32
#include <windows.h>
#endif
#include "gtest/gtest.h"
#include "absl/base/internal/scoped_set_env.h"
namespace {
using absl::base_internal::ScopedSetEnv;
std::string GetEnvVar(const char* name) {
#ifdef _WIN32
char buf[1024];
auto get_res = GetEnvironmentVariableA(name, buf, sizeof(buf));
if (get_res >= sizeof(buf)) {
return "TOO_BIG";
}
if (get_res == 0) {
return "UNSET";
}
return std::string(buf, get_res);
#else
const char* val = ::getenv(name);
if (val == nullptr) {
return "UNSET";
}
return val;
#endif
}
TEST(ScopedSetEnvTest, SetNonExistingVarToString) {
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "UNSET");
{
ScopedSetEnv scoped_set("SCOPED_SET_ENV_TEST_VAR", "value");
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "value");
}
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "UNSET");
}
TEST(ScopedSetEnvTest, SetNonExistingVarToNull) {
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "UNSET");
{
ScopedSetEnv scoped_set("SCOPED_SET_ENV_TEST_VAR", nullptr);
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "UNSET");
}
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "UNSET");
}
TEST(ScopedSetEnvTest, SetExistingVarToString) {
ScopedSetEnv scoped_set("SCOPED_SET_ENV_TEST_VAR", "value");
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "value");
{
ScopedSetEnv scoped_set("SCOPED_SET_ENV_TEST_VAR", "new_value");
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "new_value");
}
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "value");
}
TEST(ScopedSetEnvTest, SetExistingVarToNull) {
ScopedSetEnv scoped_set("SCOPED_SET_ENV_TEST_VAR", "value");
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "value");
{
ScopedSetEnv scoped_set("SCOPED_SET_ENV_TEST_VAR", nullptr);
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "UNSET");
}
EXPECT_EQ(GetEnvVar("SCOPED_SET_ENV_TEST_VAR"), "value");
}
} // namespace
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
// holder to acquire the lock. There may be outstanding waiter(s). // holder to acquire the lock. There may be outstanding waiter(s).
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
ABSL_CONST_INIT static base_internal::AtomicHook<void (*)(const void *lock, ABSL_CONST_INIT static base_internal::AtomicHook<void (*)(const void *lock,
...@@ -229,5 +229,5 @@ uint64_t SpinLock::DecodeWaitCycles(uint32_t lock_value) { ...@@ -229,5 +229,5 @@ uint64_t SpinLock::DecodeWaitCycles(uint32_t lock_value) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <atomic> #include <atomic>
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
class LOCKABLE SpinLock { class LOCKABLE SpinLock {
...@@ -58,8 +59,10 @@ class LOCKABLE SpinLock { ...@@ -58,8 +59,10 @@ class LOCKABLE SpinLock {
// //
// static SpinLock lock(base_internal::kLinkerInitialized); // static SpinLock lock(base_internal::kLinkerInitialized);
// //
// When intialized using this constructor, we depend on the fact // When initialized using this constructor, we depend on the fact
// that the linker has already initialized the memory appropriately. // that the linker has already initialized the memory appropriately. The lock
// is initialized in non-cooperative mode.
//
// A SpinLock constructed like this can be freely used from global // A SpinLock constructed like this can be freely used from global
// initializers without worrying about the order in which global // initializers without worrying about the order in which global
// initializers run. // initializers run.
...@@ -235,7 +238,7 @@ inline uint32_t SpinLock::TryLockInternal(uint32_t lock_value, ...@@ -235,7 +238,7 @@ inline uint32_t SpinLock::TryLockInternal(uint32_t lock_value,
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_SPINLOCK_H_ #endif // ABSL_BASE_INTERNAL_SPINLOCK_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -51,17 +51,12 @@ extern "C" { ...@@ -51,17 +51,12 @@ extern "C" {
ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockDelay( ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockDelay(
std::atomic<uint32_t> *w, uint32_t value, int loop, std::atomic<uint32_t> *w, uint32_t value, int loop,
absl::base_internal::SchedulingMode) { absl::base_internal::SchedulingMode) {
if (loop != 0) { int save_errno = errno;
int save_errno = errno; struct timespec tm;
struct timespec tm; tm.tv_sec = 0;
tm.tv_sec = 0; tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop);
// Increase the delay; we expect (but do not rely on) explicit wakeups. syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, &tm);
// We don't rely on explicit wakeups because we intentionally allow for errno = save_errno;
// a race on the kSpinLockSleeper bit.
tm.tv_nsec = 16 * absl::base_internal::SpinLockSuggestedDelayNS(loop);
syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, &tm);
errno = save_errno;
}
} }
ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockWake(std::atomic<uint32_t> *w, ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockWake(std::atomic<uint32_t> *w,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// See spinlock_wait.h for spec. // See spinlock_wait.h for spec.
...@@ -66,19 +66,16 @@ int SpinLockSuggestedDelayNS(int loop) { ...@@ -66,19 +66,16 @@ int SpinLockSuggestedDelayNS(int loop) {
r = 0x5deece66dLL * r + 0xb; // numbers from nrand48() r = 0x5deece66dLL * r + 0xb; // numbers from nrand48()
delay_rand.store(r, std::memory_order_relaxed); delay_rand.store(r, std::memory_order_relaxed);
r <<= 16; // 48-bit random number now in top 48-bits.
if (loop < 0 || loop > 32) { // limit loop to 0..32 if (loop < 0 || loop > 32) { // limit loop to 0..32
loop = 32; loop = 32;
} }
// loop>>3 cannot exceed 4 because loop cannot exceed 32. const int kMinDelay = 128 << 10; // 128us
// Select top 20..24 bits of lower 48 bits, // Double delay every 8 iterations, up to 16x (2ms).
// giving approximately 0ms to 16ms. int delay = kMinDelay << (loop / 8);
// Mean is exponential in loop for first 32 iterations, then 8ms. // Randomize in delay..2*delay range, for resulting 128us..4ms range.
// The futex path multiplies this by 16, since we expect explicit wakeups return delay | ((delay - 1) & static_cast<int>(r));
// almost always on that path.
return static_cast<int>(r >> (44 - (loop >> 3)));
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "absl/base/internal/scheduling_mode.h" #include "absl/base/internal/scheduling_mode.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// SpinLockWait() waits until it can perform one of several transitions from // SpinLockWait() waits until it can perform one of several transitions from
...@@ -63,7 +63,7 @@ void SpinLockDelay(std::atomic<uint32_t> *w, uint32_t value, int loop, ...@@ -63,7 +63,7 @@ void SpinLockDelay(std::atomic<uint32_t> *w, uint32_t value, int loop,
int SpinLockSuggestedDelayNS(int loop); int SpinLockSuggestedDelayNS(int loop);
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
// In some build configurations we pass --detect-odr-violations to the // In some build configurations we pass --detect-odr-violations to the
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include "absl/base/internal/unscaledcycleclock.h" #include "absl/base/internal/unscaledcycleclock.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
static once_flag init_system_info_once; static once_flag init_system_info_once;
...@@ -402,5 +402,5 @@ pid_t GetTID() { ...@@ -402,5 +402,5 @@ pid_t GetTID() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// Nominal core processor cycles per second of each processor. This is _not_ // Nominal core processor cycles per second of each processor. This is _not_
...@@ -59,7 +59,7 @@ using pid_t = DWORD; ...@@ -59,7 +59,7 @@ using pid_t = DWORD;
pid_t GetTID(); pid_t GetTID();
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_SYSINFO_H_ #endif // ABSL_BASE_INTERNAL_SYSINFO_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -38,12 +38,12 @@ TEST(SysinfoTest, NumCPUs) { ...@@ -38,12 +38,12 @@ TEST(SysinfoTest, NumCPUs) {
} }
TEST(SysinfoTest, NominalCPUFrequency) { TEST(SysinfoTest, NominalCPUFrequency) {
#if !(defined(__aarch64__) && defined(__linux__)) #if !(defined(__aarch64__) && defined(__linux__)) && !defined(__EMSCRIPTEN__)
EXPECT_GE(NominalCPUFrequency(), 1000.0) EXPECT_GE(NominalCPUFrequency(), 1000.0)
<< "NominalCPUFrequency() did not return a reasonable value"; << "NominalCPUFrequency() did not return a reasonable value";
#else #else
// TODO(absl-team): Aarch64 cannot read the CPU frequency from sysfs, so we // Aarch64 cannot read the CPU frequency from sysfs, so we get back 1.0.
// get back 1.0. Fix once the value is available. // Emscripten does not have a sysfs to read from at all.
EXPECT_EQ(NominalCPUFrequency(), 1.0) EXPECT_EQ(NominalCPUFrequency(), 1.0)
<< "CPU frequency detection was fixed! Please update unittest."; << "CPU frequency detection was fixed! Please update unittest.";
#endif #endif
...@@ -96,5 +96,5 @@ TEST(SysinfoTest, LinuxGetTID) { ...@@ -96,5 +96,5 @@ TEST(SysinfoTest, LinuxGetTID) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "absl/base/internal/spinlock.h" #include "absl/base/internal/spinlock.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
#if ABSL_THREAD_IDENTITY_MODE != ABSL_THREAD_IDENTITY_MODE_USE_CPP11 #if ABSL_THREAD_IDENTITY_MODE != ABSL_THREAD_IDENTITY_MODE_USE_CPP11
...@@ -131,5 +131,5 @@ ThreadIdentity* CurrentThreadIdentityIfPresent() { ...@@ -131,5 +131,5 @@ ThreadIdentity* CurrentThreadIdentityIfPresent() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "absl/base/internal/per_thread_tls.h" #include "absl/base/internal/per_thread_tls.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
struct SynchLocksHeld; struct SynchLocksHeld;
struct SynchWaitParams; struct SynchWaitParams;
...@@ -43,9 +43,9 @@ namespace base_internal { ...@@ -43,9 +43,9 @@ namespace base_internal {
class SpinLock; class SpinLock;
struct ThreadIdentity; struct ThreadIdentity;
// Used by the implementation of base::Mutex and base::CondVar. // Used by the implementation of absl::Mutex and absl::CondVar.
struct PerThreadSynch { struct PerThreadSynch {
// The internal representation of base::Mutex and base::CondVar rely // The internal representation of absl::Mutex and absl::CondVar rely
// on the alignment of PerThreadSynch. Both store the address of the // on the alignment of PerThreadSynch. Both store the address of the
// PerThreadSynch in the high-order bits of their internal state, // PerThreadSynch in the high-order bits of their internal state,
// which means the low kLowZeroBits of the address of PerThreadSynch // which means the low kLowZeroBits of the address of PerThreadSynch
...@@ -237,6 +237,7 @@ inline ThreadIdentity* CurrentThreadIdentityIfPresent() { ...@@ -237,6 +237,7 @@ inline ThreadIdentity* CurrentThreadIdentityIfPresent() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_ #endif // ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -124,5 +124,5 @@ TEST(ThreadIdentityTest, ReusedThreadIdentityMutexTest) { ...@@ -124,5 +124,5 @@ TEST(ThreadIdentityTest, ReusedThreadIdentityMutexTest) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -104,5 +104,5 @@ void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); } ...@@ -104,5 +104,5 @@ void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); }
void ThrowStdBadAlloc() { Throw(std::bad_alloc()); } void ThrowStdBadAlloc() { Throw(std::bad_alloc()); }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <string> #include <string>
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
// Helper functions that allow throwing exceptions consistently from anywhere. // Helper functions that allow throwing exceptions consistently from anywhere.
...@@ -67,7 +67,7 @@ namespace base_internal { ...@@ -67,7 +67,7 @@ namespace base_internal {
// [[noreturn]] void ThrowStdBadArrayNewLength(); // [[noreturn]] void ThrowStdBadArrayNewLength();
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_ #endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -25,15 +25,6 @@ ...@@ -25,15 +25,6 @@
// unaligned APIs // unaligned APIs
// Portable handling of unaligned loads, stores, and copies. // Portable handling of unaligned loads, stores, and copies.
// On some platforms, like ARM, the copy functions can be more efficient
// then a load and a store.
//
// It is possible to implement all of these these using constant-length memcpy
// calls, which is portable and will usually be inlined into simple loads and
// stores if the architecture supports it. However, such inlining usually
// happens in a pass that's quite late in compilation, which means the resulting
// loads and stores cannot participate in many other optimizations, leading to
// overall worse code.
// The unaligned API is C++ only. The declarations use C++ features // The unaligned API is C++ only. The declarations use C++ features
// (namespaces, inline) which are absent or incompatible in C. // (namespaces, inline) which are absent or incompatible in C.
...@@ -65,7 +56,7 @@ void __sanitizer_unaligned_store64(void *p, uint64_t v); ...@@ -65,7 +56,7 @@ void __sanitizer_unaligned_store64(void *p, uint64_t v);
} // extern "C" } // extern "C"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
inline uint16_t UnalignedLoad16(const void *p) { inline uint16_t UnalignedLoad16(const void *p) {
...@@ -93,7 +84,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { ...@@ -93,7 +84,7 @@ inline void UnalignedStore64(void *p, uint64_t v) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \ #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
...@@ -110,172 +101,10 @@ inline void UnalignedStore64(void *p, uint64_t v) { ...@@ -110,172 +101,10 @@ inline void UnalignedStore64(void *p, uint64_t v) {
#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \ #define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(absl::base_internal::UnalignedStore64(_p, _val)) (absl::base_internal::UnalignedStore64(_p, _val))
#elif defined(UNDEFINED_BEHAVIOR_SANITIZER)
namespace absl {
inline namespace lts_2018_12_18 {
namespace base_internal {
inline uint16_t UnalignedLoad16(const void *p) {
uint16_t t;
memcpy(&t, p, sizeof t);
return t;
}
inline uint32_t UnalignedLoad32(const void *p) {
uint32_t t;
memcpy(&t, p, sizeof t);
return t;
}
inline uint64_t UnalignedLoad64(const void *p) {
uint64_t t;
memcpy(&t, p, sizeof t);
return t;
}
inline void UnalignedStore16(void *p, uint16_t v) { memcpy(p, &v, sizeof v); }
inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); }
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
} // namespace base_internal
} // inline namespace lts_2018_12_18
} // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
(absl::base_internal::UnalignedLoad16(_p))
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) \
(absl::base_internal::UnalignedLoad32(_p))
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) \
(absl::base_internal::UnalignedLoad64(_p))
#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
(absl::base_internal::UnalignedStore16(_p, _val))
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
(absl::base_internal::UnalignedStore32(_p, _val))
#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(absl::base_internal::UnalignedStore64(_p, _val))
#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \
defined(_M_IX86) || defined(__ppc__) || defined(__PPC__) || \
defined(__ppc64__) || defined(__PPC64__)
// x86 and x86-64 can perform unaligned loads/stores directly;
// modern PowerPC hardware can also do unaligned integer loads and stores;
// but note: the FPU still sends unaligned loads and stores to a trap handler!
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
(*reinterpret_cast<const uint16_t *>(_p))
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) \
(*reinterpret_cast<const uint32_t *>(_p))
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) \
(*reinterpret_cast<const uint64_t *>(_p))
#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
(*reinterpret_cast<uint16_t *>(_p) = (_val))
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
(*reinterpret_cast<uint32_t *>(_p) = (_val))
#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(*reinterpret_cast<uint64_t *>(_p) = (_val))
#elif defined(__arm__) && \
!defined(__ARM_ARCH_5__) && \
!defined(__ARM_ARCH_5T__) && \
!defined(__ARM_ARCH_5TE__) && \
!defined(__ARM_ARCH_5TEJ__) && \
!defined(__ARM_ARCH_6__) && \
!defined(__ARM_ARCH_6J__) && \
!defined(__ARM_ARCH_6K__) && \
!defined(__ARM_ARCH_6Z__) && \
!defined(__ARM_ARCH_6ZK__) && \
!defined(__ARM_ARCH_6T2__)
// ARMv7 and newer support native unaligned accesses, but only of 16-bit
// and 32-bit values (not 64-bit); older versions either raise a fatal signal,
// do an unaligned read and rotate the words around a bit, or do the reads very
// slowly (trip through kernel mode). There's no simple #define that says just
// "ARMv7 or higher", so we have to filter away all ARMv5 and ARMv6
// sub-architectures. Newer gcc (>= 4.6) set an __ARM_FEATURE_ALIGNED #define,
// so in time, maybe we can move on to that.
//
// This is a mess, but there's not much we can do about it.
//
// To further complicate matters, only LDR instructions (single reads) are
// allowed to be unaligned, not LDRD (two reads) or LDM (many reads). Unless we
// explicitly tell the compiler that these accesses can be unaligned, it can and
// will combine accesses. On armcc, the way to signal this is done by accessing
// through the type (uint32_t __packed *), but GCC has no such attribute
// (it ignores __attribute__((packed)) on individual variables). However,
// we can tell it that a _struct_ is unaligned, which has the same effect,
// so we do that.
namespace absl {
inline namespace lts_2018_12_18 {
namespace base_internal {
struct Unaligned16Struct {
uint16_t value;
uint8_t dummy; // To make the size non-power-of-two.
} ABSL_ATTRIBUTE_PACKED;
struct Unaligned32Struct {
uint32_t value;
uint8_t dummy; // To make the size non-power-of-two.
} ABSL_ATTRIBUTE_PACKED;
} // namespace base_internal
} // inline namespace lts_2018_12_18
} // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
((reinterpret_cast<const ::absl::base_internal::Unaligned16Struct *>(_p)) \
->value)
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) \
((reinterpret_cast<const ::absl::base_internal::Unaligned32Struct *>(_p)) \
->value)
#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
((reinterpret_cast< ::absl::base_internal::Unaligned16Struct *>(_p)) \
->value = (_val))
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
((reinterpret_cast< ::absl::base_internal::Unaligned32Struct *>(_p)) \
->value = (_val))
namespace absl {
inline namespace lts_2018_12_18 {
namespace base_internal {
inline uint64_t UnalignedLoad64(const void *p) {
uint64_t t;
memcpy(&t, p, sizeof t);
return t;
}
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
} // namespace base_internal
} // inline namespace lts_2018_12_18
} // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) \
(absl::base_internal::UnalignedLoad64(_p))
#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(absl::base_internal::UnalignedStore64(_p, _val))
#else #else
// ABSL_INTERNAL_NEED_ALIGNED_LOADS is defined when the underlying platform
// doesn't support unaligned access.
#define ABSL_INTERNAL_NEED_ALIGNED_LOADS
// These functions are provided for architectures that don't support
// unaligned loads and stores.
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
inline uint16_t UnalignedLoad16(const void *p) { inline uint16_t UnalignedLoad16(const void *p) {
...@@ -303,7 +132,7 @@ inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); } ...@@ -303,7 +132,7 @@ inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); }
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \ #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "absl/base/internal/sysinfo.h" #include "absl/base/internal/sysinfo.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
#if defined(__i386__) #if defined(__i386__)
...@@ -97,7 +97,7 @@ double UnscaledCycleClock::Frequency() { ...@@ -97,7 +97,7 @@ double UnscaledCycleClock::Frequency() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_USE_UNSCALED_CYCLECLOCK #endif // ABSL_USE_UNSCALED_CYCLECLOCK
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -59,7 +59,8 @@ ...@@ -59,7 +59,8 @@
// CycleClock that runs at atleast 1 MHz. We've found some Android // CycleClock that runs at atleast 1 MHz. We've found some Android
// ARM64 devices where this is not the case, so we disable it by // ARM64 devices where this is not the case, so we disable it by
// default on Android ARM64. // default on Android ARM64.
#if defined(__native_client__) || TARGET_OS_IPHONE || \ #if defined(__native_client__) || \
(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
(defined(__ANDROID__) && defined(__aarch64__)) (defined(__ANDROID__) && defined(__aarch64__))
#define ABSL_USE_UNSCALED_CYCLECLOCK_DEFAULT 0 #define ABSL_USE_UNSCALED_CYCLECLOCK_DEFAULT 0
#else #else
...@@ -83,8 +84,9 @@ ...@@ -83,8 +84,9 @@
defined(_M_IX86) || defined(_M_X64)) defined(_M_IX86) || defined(_M_X64))
#define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY #define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace time_internal { namespace time_internal {
class UnscaledCycleClockWrapperForGetCurrentTime; class UnscaledCycleClockWrapperForGetCurrentTime;
} // namespace time_internal } // namespace time_internal
...@@ -114,8 +116,9 @@ class UnscaledCycleClock { ...@@ -114,8 +116,9 @@ class UnscaledCycleClock {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_USE_UNSCALED_CYCLECLOCK #endif // ABSL_USE_UNSCALED_CYCLECLOCK
#endif // ABSL_BASE_INTERNAL_UNSCALEDCYCLECLOCK_H_ #endif // ABSL_BASE_INTERNAL_UNSCALEDCYCLECLOCK_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -71,6 +71,10 @@ struct OverloadedFunctor { ...@@ -71,6 +71,10 @@ struct OverloadedFunctor {
struct Class { struct Class {
int Method(int a, int b) { return a - b; } int Method(int a, int b) { return a - b; }
int ConstMethod(int a, int b) const { return a - b; } int ConstMethod(int a, int b) const { return a - b; }
int RefMethod(int a, int b) & { return a - b; }
int RefRefMethod(int a, int b) && { return a - b; }
int NoExceptMethod(int a, int b) noexcept { return a - b; }
int VolatileMethod(int a, int b) volatile { return a - b; }
int member; int member;
}; };
...@@ -152,8 +156,18 @@ TEST(InvokeTest, ReferenceWrapper) { ...@@ -152,8 +156,18 @@ TEST(InvokeTest, ReferenceWrapper) {
TEST(InvokeTest, MemberFunction) { TEST(InvokeTest, MemberFunction) {
std::unique_ptr<Class> p(new Class); std::unique_ptr<Class> p(new Class);
std::unique_ptr<const Class> cp(new Class); std::unique_ptr<const Class> cp(new Class);
std::unique_ptr<volatile Class> vp(new Class);
EXPECT_EQ(1, Invoke(&Class::Method, p, 3, 2)); EXPECT_EQ(1, Invoke(&Class::Method, p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::Method, p.get(), 3, 2)); EXPECT_EQ(1, Invoke(&Class::Method, p.get(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::Method, *p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::RefMethod, p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::RefMethod, p.get(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::RefMethod, *p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::RefRefMethod, std::move(*p), 3, 2)); // NOLINT
EXPECT_EQ(1, Invoke(&Class::NoExceptMethod, p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::NoExceptMethod, p.get(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::NoExceptMethod, *p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::ConstMethod, p, 3, 2)); EXPECT_EQ(1, Invoke(&Class::ConstMethod, p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::ConstMethod, p.get(), 3, 2)); EXPECT_EQ(1, Invoke(&Class::ConstMethod, p.get(), 3, 2));
...@@ -163,6 +177,13 @@ TEST(InvokeTest, MemberFunction) { ...@@ -163,6 +177,13 @@ TEST(InvokeTest, MemberFunction) {
EXPECT_EQ(1, Invoke(&Class::ConstMethod, cp.get(), 3, 2)); EXPECT_EQ(1, Invoke(&Class::ConstMethod, cp.get(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::ConstMethod, *cp, 3, 2)); EXPECT_EQ(1, Invoke(&Class::ConstMethod, *cp, 3, 2));
EXPECT_EQ(1, Invoke(&Class::VolatileMethod, p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::VolatileMethod, p.get(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::VolatileMethod, *p, 3, 2));
EXPECT_EQ(1, Invoke(&Class::VolatileMethod, vp, 3, 2));
EXPECT_EQ(1, Invoke(&Class::VolatileMethod, vp.get(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::VolatileMethod, *vp, 3, 2));
EXPECT_EQ(1, Invoke(&Class::Method, make_unique<Class>(), 3, 2)); EXPECT_EQ(1, Invoke(&Class::Method, make_unique<Class>(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::ConstMethod, make_unique<Class>(), 3, 2)); EXPECT_EQ(1, Invoke(&Class::ConstMethod, make_unique<Class>(), 3, 2));
EXPECT_EQ(1, Invoke(&Class::ConstMethod, make_unique<const Class>(), 3, 2)); EXPECT_EQ(1, Invoke(&Class::ConstMethod, make_unique<const Class>(), 3, 2));
...@@ -198,5 +219,5 @@ TEST(InvokeTest, SfinaeFriendly) { ...@@ -198,5 +219,5 @@ TEST(InvokeTest, SfinaeFriendly) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -12,15 +12,16 @@ ...@@ -12,15 +12,16 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "absl/types/optional.h" #include "absl/base/log_severity.h"
#ifndef ABSL_HAVE_STD_OPTIONAL #include <ostream>
namespace absl {
inline namespace lts_2018_12_18 {
nullopt_t::init_t nullopt_t::init; namespace absl {
extern const nullopt_t nullopt{nullopt_t::init}; inline namespace lts_2019_08_08 {
} // inline namespace lts_2018_12_18 std::ostream& operator<<(std::ostream& os, absl::LogSeverity s) {
if (s == absl::NormalizeLogSeverity(s)) return os << absl::LogSeverityName(s);
return os << "absl::LogSeverity(" << static_cast<int>(s) << ")";
}
} // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_HAVE_STD_OPTIONAL
...@@ -4,24 +4,24 @@ ...@@ -4,24 +4,24 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
#ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ #ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ #define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
#include <array> #include <array>
#include <ostream>
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
// Four severity levels are defined. Logging APIs should terminate the program // Four severity levels are defined. Logging APIs should terminate the program
// when a message is logged at severity `kFatal`; the other levels have no // when a message is logged at severity `kFatal`; the other levels have no
...@@ -63,7 +63,11 @@ constexpr absl::LogSeverity NormalizeLogSeverity(int s) { ...@@ -63,7 +63,11 @@ constexpr absl::LogSeverity NormalizeLogSeverity(int s) {
return NormalizeLogSeverity(static_cast<absl::LogSeverity>(s)); return NormalizeLogSeverity(static_cast<absl::LogSeverity>(s));
} }
} // inline namespace lts_2018_12_18 // The exact representation of a streamed `absl::LogSeverity` is deliberately
// unspecified; do not rely on it.
std::ostream& operator<<(std::ostream& os, absl::LogSeverity s);
} // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ #endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
// Copyright 2018 The Abseil Authors.
//
// 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
//
// https://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.
#include "absl/base/log_severity.h"
#include <sstream>
#include <string>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace {
using testing::Eq;
std::string StreamHelper(absl::LogSeverity value) {
std::ostringstream stream;
stream << value;
return stream.str();
}
TEST(StreamTest, Works) {
EXPECT_THAT(StreamHelper(static_cast<absl::LogSeverity>(-100)),
Eq("absl::LogSeverity(-100)"));
EXPECT_THAT(StreamHelper(absl::LogSeverity::kInfo), Eq("INFO"));
EXPECT_THAT(StreamHelper(absl::LogSeverity::kWarning), Eq("WARNING"));
EXPECT_THAT(StreamHelper(absl::LogSeverity::kError), Eq("ERROR"));
EXPECT_THAT(StreamHelper(absl::LogSeverity::kFatal), Eq("FATAL"));
EXPECT_THAT(StreamHelper(static_cast<absl::LogSeverity>(4)),
Eq("absl::LogSeverity(4)"));
}
} // namespace
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
// This code is compiled directly on many platforms, including client // This code is compiled directly on many platforms, including client
// platforms like Windows, Mac, and embedded systems. Before making // platforms like Windows, Mac, and embedded systems. Before making
// any changes here, make sure that you're not breaking any platforms. // any changes here, make sure that you're not breaking any platforms.
//
#ifndef ABSL_BASE_MACROS_H_ #ifndef ABSL_BASE_MACROS_H_
#define ABSL_BASE_MACROS_H_ #define ABSL_BASE_MACROS_H_
...@@ -32,6 +31,7 @@ ...@@ -32,6 +31,7 @@
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include "absl/base/optimization.h"
#include "absl/base/port.h" #include "absl/base/port.h"
// ABSL_ARRAYSIZE() // ABSL_ARRAYSIZE()
...@@ -43,14 +43,14 @@ ...@@ -43,14 +43,14 @@
(sizeof(::absl::macros_internal::ArraySizeHelper(array))) (sizeof(::absl::macros_internal::ArraySizeHelper(array)))
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace macros_internal { namespace macros_internal {
// Note: this internal template function declaration is used by ABSL_ARRAYSIZE. // Note: this internal template function declaration is used by ABSL_ARRAYSIZE.
// The function doesn't need a definition, as we only use its type. // The function doesn't need a definition, as we only use its type.
template <typename T, size_t N> template <typename T, size_t N>
auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N];
} // namespace macros_internal } // namespace macros_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
// kLinkerInitialized // kLinkerInitialized
...@@ -74,13 +74,13 @@ auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; ...@@ -74,13 +74,13 @@ auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N];
// // Invocation // // Invocation
// static MyClass my_global(absl::base_internal::kLinkerInitialized); // static MyClass my_global(absl::base_internal::kLinkerInitialized);
namespace absl { namespace absl {
inline namespace lts_2018_12_18 { inline namespace lts_2019_08_08 {
namespace base_internal { namespace base_internal {
enum LinkerInitialized { enum LinkerInitialized {
kLinkerInitialized = 0, kLinkerInitialized = 0,
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_12_18 } // inline namespace lts_2019_08_08
} // namespace absl } // namespace absl
// ABSL_FALLTHROUGH_INTENDED // ABSL_FALLTHROUGH_INTENDED
...@@ -196,10 +196,11 @@ enum LinkerInitialized { ...@@ -196,10 +196,11 @@ enum LinkerInitialized {
// This macro is inspired by // This macro is inspired by
// https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/ // https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/
#if defined(NDEBUG) #if defined(NDEBUG)
#define ABSL_ASSERT(expr) (false ? (void)(expr) : (void)0) #define ABSL_ASSERT(expr) \
(false ? static_cast<void>(expr) : static_cast<void>(0))
#else #else
#define ABSL_ASSERT(expr) \ #define ABSL_ASSERT(expr) \
(ABSL_PREDICT_TRUE((expr)) ? (void)0 \ (ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \
: [] { assert(false && #expr); }()) // NOLINT : [] { assert(false && #expr); }()) // NOLINT
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment