Skip to content

Commit

Permalink
Export of internal Abseil changes.
Browse files Browse the repository at this point in the history
--
fcf9d3facb12451964ad1850073cbfb6f9739379 by CJ Johnson <[email protected]>:

Makes it obvious to readers that the comparison operators do not branch more than needed

PiperOrigin-RevId: 240811527

--
680c586f81f805be68e96caffb28d5f46b6a6511 by Jon Cohen <[email protected]>:

Consistently use "if(" instead of "if (" in CMake files

PiperOrigin-RevId: 240621819

--
c4acc506648622389f33f564fd94f8dda08cb61a by Tom Manshreck <[email protected]>:

Internal change

PiperOrigin-RevId: 240619556

--
ddbc1894944aae96767c876a1ae8696ddaba42a2 by Jon Cohen <[email protected]>:

Remove the warning about install prefixes when we aren't installing abseil

PiperOrigin-RevId: 240614750

--
086c4fad213d99e875038bc8a1c7268e28a7ebf3 by Abseil Team <[email protected]>:

Adjust some tests and test cases which fail on WebAssembly

PiperOrigin-RevId: 240592367

--
46c2c09723a37ef4911ae3c64aab92e3f0fdba79 by Abseil Team <[email protected]>:

CMake install target update
- Add prefix absl_ to each target when install rule are disabled.
- Disable all install commands when absl is used as subdirectory (Fix abseil#287)

PiperOrigin-RevId: 240575083

--
8d88063ed5b16f982a91950693d37ca18fdd46d8 by Jon Cohen <[email protected]>:

Correctly link to Threads::Threads for a few cmake targets which were missing it.

PiperOrigin-RevId: 240574513
GitOrigin-RevId: fcf9d3facb12451964ad1850073cbfb6f9739379
Change-Id: I031c57de8cd88554348eb8bd1371d01d15ff1fc7
  • Loading branch information
Abseil Team authored and gennadiycivil committed Mar 28, 2019
1 parent 5b65c4a commit 2c8421e
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 149 deletions.
16 changes: 10 additions & 6 deletions CMake/AbseilHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ set(ABSL_IDE_FOLDER Abseil)
# SRCS
# "b.cc"
# DEPS
# absl_internal_awesome # not "awesome"!
# absl::awesome # not "awesome" !
# PUBLIC
# )
#
Expand All @@ -68,7 +68,7 @@ set(ABSL_IDE_FOLDER Abseil)
# main_lib
# ...
# DEPS
# absl::fantastic_lib # since fantastic_lib is public
# absl::fantastic_lib
# )
#
# TODO: Implement "ALWAYSLINK"
Expand All @@ -80,8 +80,12 @@ function(absl_cc_library)
${ARGN}
)

if (NOT ABSL_CC_LIB_TESTONLY OR ABSL_RUN_TESTS)
set(_NAME "${ABSL_CC_LIB_NAME}")
if(NOT ABSL_CC_LIB_TESTONLY OR ABSL_RUN_TESTS)
if(ABSL_ENABLE_INSTALL)
set(_NAME "${ABSL_CC_LIB_NAME}")
else()
set(_NAME "absl_${ABSL_CC_LIB_NAME}")
endif()

# Check if this is a header-only library
# Note that as of February 2019, many popular OS's (for example, Ubuntu
Expand All @@ -93,7 +97,7 @@ function(absl_cc_library)
list(REMOVE_ITEM ABSL_CC_SRCS "${src_file}")
endif()
endforeach()
if ("${ABSL_CC_SRCS}" STREQUAL "")
if("${ABSL_CC_SRCS}" STREQUAL "")
set(ABSL_CC_LIB_IS_INTERFACE 1)
else()
set(ABSL_CC_LIB_IS_INTERFACE 0)
Expand Down Expand Up @@ -155,7 +159,7 @@ function(absl_cc_library)

# TODO currently we don't install googletest alongside abseil sources, so
# installed abseil can't be tested.
if (NOT ABSL_CC_LIB_TESTONLY)
if(NOT ABSL_CC_LIB_TESTONLY AND ABSL_ENABLE_INSTALL)
install(TARGETS ${_NAME} EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR}
LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR}
Expand Down
2 changes: 1 addition & 1 deletion CMake/AbseilInstallDirs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include(GNUInstallDirs)
# Abseil's internal Copybara (https://github.com/google/copybara) workflows and
# isn't visible in the CMake buildsystem itself.

if (absl_VERSION)
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}")
Expand Down
5 changes: 3 additions & 2 deletions CMake/abslConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## absl CMake configuration file. Note that there is no corresponding
# abslConfigVersion.cmake since non-LTS Abseil isn't versioned.
# absl CMake configuration file.

include(FindThreads)

@PACKAGE_INIT@

Expand Down
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ if(${ABSL_RUN_TESTS})
enable_testing()
endif()

# absl:lts-remove-begin(system installation is supported for LTS releases)
# We don't support system-wide installation
list(APPEND SYSTEM_INSTALL_DIRS "/usr/local" "/usr" "/opt/" "/opt/local" "c:/Program Files/${PROJECT_NAME}")
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX IN_LIST SYSTEM_INSTALL_DIRS)
message(WARNING "\
The default and system-level install directories are unsupported except in LTS \
releases of Abseil. Please set CMAKE_INSTALL_PREFIX to install Abseil in your \
source or build tree directly.\
")
endif()
# absl:lts-remove-end

## check targets
if(BUILD_TESTING)

Expand All @@ -121,7 +109,19 @@ endif()

add_subdirectory(absl)

if (ABSL_ENABLE_INSTALL)
if(ABSL_ENABLE_INSTALL)
# absl:lts-remove-begin(system installation is supported for LTS releases)
# We don't support system-wide installation
list(APPEND SYSTEM_INSTALL_DIRS "/usr/local" "/usr" "/opt/" "/opt/local" "c:/Program Files/${PROJECT_NAME}")
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX IN_LIST SYSTEM_INSTALL_DIRS)
message(WARNING "\
The default and system-level install directories are unsupported except in LTS \
releases of Abseil. Please set CMAKE_INSTALL_PREFIX to install Abseil in your \
source or build tree directly.\
")
endif()
# absl:lts-remove-end

# install as a subdirectory only
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE absl::
Expand All @@ -140,7 +140,7 @@ if (ABSL_ENABLE_INSTALL)
# 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)
if(absl_VERSION)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY ExactVersion
Expand Down
11 changes: 11 additions & 0 deletions absl/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ absl_cc_library(
absl::core_headers
absl::dynamic_annotations
absl::spinlock_wait
Threads::Threads
)

absl_cc_library(
Expand Down Expand Up @@ -134,6 +135,7 @@ absl_cc_library(
absl::core_headers
absl::dynamic_annotations
absl::spinlock_wait
Threads::Threads
PUBLIC
)

Expand Down Expand Up @@ -438,3 +440,12 @@ absl_cc_test(
absl::scoped_set_env
gtest_main
)

absl_cc_test(
NAME
cmake_thread_test
SRCS
"internal/cmake_thread_test.cc"
DEPS
absl::base
)
22 changes: 22 additions & 0 deletions absl/base/internal/cmake_thread_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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;
}
53 changes: 32 additions & 21 deletions absl/container/inlined_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ class InlinedVector {

private:
template <typename H, typename TheT, size_t TheN, typename TheA>
friend auto AbslHashValue(H h, const InlinedVector<TheT, TheN, TheA>& v) -> H;
friend H AbslHashValue(H h, const absl::InlinedVector<TheT, TheN, TheA>& a);

const Tag& tag() const { return storage_.allocator_and_tag_.tag(); }

Expand Down Expand Up @@ -1231,26 +1231,30 @@ class InlinedVector {
// Swaps the contents of two inlined vectors. This convenience function
// simply calls `InlinedVector::swap()`.
template <typename T, size_t N, typename A>
auto swap(InlinedVector<T, N, A>& a,
InlinedVector<T, N, A>& b) noexcept(noexcept(a.swap(b))) -> void {
void swap(absl::InlinedVector<T, N, A>& a,
absl::InlinedVector<T, N, A>& b) noexcept(noexcept(a.swap(b))) {
a.swap(b);
}

// `operator==()`
//
// Tests the equivalency of the contents of two inlined vectors.
template <typename T, size_t N, typename A>
auto operator==(const InlinedVector<T, N, A>& a,
const InlinedVector<T, N, A>& b) -> bool {
return absl::equal(a.begin(), a.end(), b.begin(), b.end());
bool operator==(const absl::InlinedVector<T, N, A>& a,
const absl::InlinedVector<T, N, A>& b) {
auto a_data = a.data();
auto a_size = a.size();
auto b_data = b.data();
auto b_size = b.size();
return absl::equal(a_data, a_data + a_size, b_data, b_data + b_size);
}

// `operator!=()`
//
// Tests the inequality of the contents of two inlined vectors.
template <typename T, size_t N, typename A>
auto operator!=(const InlinedVector<T, N, A>& a,
const InlinedVector<T, N, A>& b) -> bool {
bool operator!=(const absl::InlinedVector<T, N, A>& a,
const absl::InlinedVector<T, N, A>& b) {
return !(a == b);
}

Expand All @@ -1259,18 +1263,23 @@ auto operator!=(const InlinedVector<T, N, A>& a,
// Tests whether the contents of one inlined vector are less than the contents
// of another through a lexicographical comparison operation.
template <typename T, size_t N, typename A>
auto operator<(const InlinedVector<T, N, A>& a, const InlinedVector<T, N, A>& b)
-> bool {
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
bool operator<(const absl::InlinedVector<T, N, A>& a,
const absl::InlinedVector<T, N, A>& b) {
auto a_data = a.data();
auto a_size = a.size();
auto b_data = b.data();
auto b_size = b.size();
return std::lexicographical_compare(a_data, a_data + a_size, b_data,
b_data + b_size);
}

// `operator>()`
//
// Tests whether the contents of one inlined vector are greater than the
// contents of another through a lexicographical comparison operation.
template <typename T, size_t N, typename A>
auto operator>(const InlinedVector<T, N, A>& a, const InlinedVector<T, N, A>& b)
-> bool {
bool operator>(const absl::InlinedVector<T, N, A>& a,
const absl::InlinedVector<T, N, A>& b) {
return b < a;
}

Expand All @@ -1279,8 +1288,8 @@ auto operator>(const InlinedVector<T, N, A>& a, const InlinedVector<T, N, A>& b)
// Tests whether the contents of one inlined vector are less than or equal to
// the contents of another through a lexicographical comparison operation.
template <typename T, size_t N, typename A>
auto operator<=(const InlinedVector<T, N, A>& a,
const InlinedVector<T, N, A>& b) -> bool {
bool operator<=(const absl::InlinedVector<T, N, A>& a,
const absl::InlinedVector<T, N, A>& b) {
return !(b < a);
}

Expand All @@ -1289,8 +1298,8 @@ auto operator<=(const InlinedVector<T, N, A>& a,
// Tests whether the contents of one inlined vector are greater than or equal to
// the contents of another through a lexicographical comparison operation.
template <typename T, size_t N, typename A>
auto operator>=(const InlinedVector<T, N, A>& a,
const InlinedVector<T, N, A>& b) -> bool {
bool operator>=(const absl::InlinedVector<T, N, A>& a,
const absl::InlinedVector<T, N, A>& b) {
return !(a < b);
}

Expand All @@ -1299,11 +1308,13 @@ auto operator>=(const InlinedVector<T, N, A>& a,
// Provides `absl::Hash` support for inlined vectors. You do not normally call
// this function directly.
template <typename H, typename TheT, size_t TheN, typename TheA>
auto AbslHashValue(H h, const InlinedVector<TheT, TheN, TheA>& v) -> H {
auto p = v.data();
auto n = v.size();
return H::combine(H::combine_contiguous(std::move(h), p, n), n);
H AbslHashValue(H h, const absl::InlinedVector<TheT, TheN, TheA>& a) {
auto a_data = a.data();
auto a_size = a.size();
return H::combine(H::combine_contiguous(std::move(h), a_data, a_size),
a_size);
}

} // namespace absl

#endif // ABSL_CONTAINER_INLINED_VECTOR_H_
4 changes: 2 additions & 2 deletions absl/container/internal/raw_hash_set_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ TEST(Table, Prefetch) {
t.prefetch(2);

// Do not run in debug mode, when prefetch is not implemented, or when
// sanitizers are enabled.
// sanitizers are enabled, or on WebAssembly.
#if defined(NDEBUG) && defined(__GNUC__) && !defined(ADDRESS_SANITIZER) && \
!defined(MEMORY_SANITIZER) && !defined(THREAD_SANITIZER) && \
!defined(UNDEFINED_BEHAVIOR_SANITIZER)
!defined(UNDEFINED_BEHAVIOR_SANITIZER) && !defined(__EMSCRIPTEN__)
const auto now = [] { return absl::base_internal::CycleClock::Now(); };

// Make size enough to not fit in L2 cache (16.7 Mb)
Expand Down
6 changes: 3 additions & 3 deletions absl/copts/AbseilConfigureCopts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ set(ABSL_LSAN_LINKOPTS "")
set(ABSL_HAVE_LSAN OFF)
set(ABSL_DEFAULT_LINKOPTS "")

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(ABSL_DEFAULT_COPTS "${ABSL_GCC_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_GCC_FLAGS};${ABSL_GCC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${ABSL_GCC_EXCEPTIONS_FLAGS}")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# MATCHES so we get both Clang and AppleClang
if (MSVC)
if(MSVC)
# clang-cl is half MSVC, half LLVM
set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_FLAGS};${ABSL_CLANG_CL_TEST_FLAGS}")
Expand All @@ -21,7 +21,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(ABSL_TEST_COPTS "${ABSL_LLVM_FLAGS};${ABSL_LLVM_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${ABSL_LLVM_EXCEPTIONS_FLAGS}")
set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# AppleClang doesn't have lsan
# https://developer.apple.com/documentation/code_diagnostics
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)
Expand Down
2 changes: 1 addition & 1 deletion absl/synchronization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ absl_cc_library(
absl::stacktrace
absl::symbolize
absl::time
Threads::Threads
PUBLIC
)

Expand Down Expand Up @@ -191,5 +192,4 @@ absl_cc_test(
absl::synchronization
absl::base
absl::core_headers
Threads::Threads
)
7 changes: 6 additions & 1 deletion absl/types/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ cc_test(

cc_library(
name = "span",
hdrs = ["span.h"],
srcs = [
"internal/span.h",
],
hdrs = [
"span.h",
],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
Expand Down
2 changes: 2 additions & 0 deletions absl/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ absl_cc_library(
span
HDRS
"span.h"
SRCS
"internal/span.h"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
Expand Down
Loading

0 comments on commit 2c8421e

Please sign in to comment.