Commit 4611a601 by Abseil Team Committed by Derek Mauro

Export of internal Abseil changes

--
be02479c8f5ddf18f0d711e86648a2a0a9823fb6 by Gennadiy Rozental <rogeeff@google.com>:

Suppress MSVC warning about unused return value

PiperOrigin-RevId: 348624511

--
10e6da15e34d84d314fc1eca1bcdeb96538a04d1 by Derek Mauro <dmauro@google.com>:

Add additional information to README.md

PiperOrigin-RevId: 348562436

--
57283e13d221d9a3f6678a1c6db1a41b4421b938 by Jorg Brown <jorg@google.com>:

Tweaks for better AArch64 support under MSVC

PiperOrigin-RevId: 348518028

--
48cb64ed90c71db6342dcf478a03bbb419b98500 by Christian Blichmann <cblichmann@google.com>:

Internal change

PiperOrigin-RevId: 348480642
GitOrigin-RevId: be02479c8f5ddf18f0d711e86648a2a0a9823fb6
Change-Id: I3614bf846ad1b99e34f507346da1252c6bbc13ba
parent 8a9ef3c5
...@@ -9,7 +9,9 @@ standard library. ...@@ -9,7 +9,9 @@ standard library.
- [About Abseil](#about) - [About Abseil](#about)
- [Quickstart](#quickstart) - [Quickstart](#quickstart)
- [Building Abseil](#build) - [Building Abseil](#build)
- [Support](#support)
- [Codemap](#codemap) - [Codemap](#codemap)
- [Releases](#releases)
- [License](#license) - [License](#license)
- [Links](#links) - [Links](#links)
...@@ -42,14 +44,22 @@ the Abseil code, running tests, and getting a simple binary working. ...@@ -42,14 +44,22 @@ the Abseil code, running tests, and getting a simple binary working.
<a name="build"></a> <a name="build"></a>
## Building Abseil ## Building Abseil
[Bazel](https://bazel.build) is the official build system for Abseil, [Bazel](https://bazel.build) and [CMake](https://cmake.org/) are the official
which is supported on most major platforms (Linux, Windows, macOS, for example) build systems for Abseil.
and compilers. See the [quickstart](https://abseil.io/docs/cpp/quickstart) for
more information on building Abseil using the Bazel build system.
<a name="cmake"></a> See the [quickstart](https://abseil.io/docs/cpp/quickstart) for more information
If you require CMake support, please check the on building Abseil using the Bazel build system.
[CMake build instructions](CMake/README.md).
If you require CMake support, please check the [CMake build
instructions](CMake/README.md) and [CMake
Quickstart](https://abseil.io/docs/cpp/quickstart-cmake).
## Support
Abseil is officially supported on many platforms. See the [Abseil
platform support
guide](https://abseil.io/docs/cpp/platforms/platforms) for details on
supported operating systems, compilers, CPUs, etc.
## Codemap ## Codemap
...@@ -100,6 +110,15 @@ Abseil contains the following C++ library components: ...@@ -100,6 +110,15 @@ Abseil contains the following C++ library components:
* [`utility`](absl/utility/) * [`utility`](absl/utility/)
<br /> The `utility` library contains utility and helper code. <br /> The `utility` library contains utility and helper code.
## Releases
Abseil recommends users "live-at-head" (update to the latest commit from the
master branch as often as possible). However, we realize this philosophy doesn't
work for every project, so we also provide [Long Term Support
Releases](https://github.com/abseil/abseil-cpp/releases) to which we backport
fixes for severe bugs. See our [release
management](https://abseil.io/about/releases) document for more details.
## License ## License
The Abseil C++ library is licensed under the terms of the Apache The Abseil C++ library is licensed under the terms of the Apache
......
...@@ -23,12 +23,6 @@ ...@@ -23,12 +23,6 @@
// windows intrinsic functions. // windows intrinsic functions.
#if defined(_MSC_VER) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h> #include <intrin.h>
#if defined(_M_X64)
#pragma intrinsic(_BitScanReverse64)
#pragma intrinsic(_BitScanForward64)
#endif
#pragma intrinsic(_BitScanReverse)
#pragma intrinsic(_BitScanForward)
#endif #endif
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
...@@ -185,7 +179,8 @@ CountLeadingZeroes64(uint64_t x) { ...@@ -185,7 +179,8 @@ CountLeadingZeroes64(uint64_t x) {
// Handle 0 as a special case because __builtin_clzll(0) is undefined. // Handle 0 as a special case because __builtin_clzll(0) is undefined.
return x == 0 ? 64 : __builtin_clzll(x); return x == 0 ? 64 : __builtin_clzll(x);
#elif defined(_MSC_VER) && !defined(__clang__) && defined(_M_X64) #elif defined(_MSC_VER) && !defined(__clang__) && \
(defined(_M_X64) || defined(_M_ARM64))
// MSVC does not have __buitin_clzll. Use _BitScanReverse64. // MSVC does not have __buitin_clzll. Use _BitScanReverse64.
unsigned long result = 0; // NOLINT(runtime/int) unsigned long result = 0; // NOLINT(runtime/int)
if (_BitScanReverse64(&result, x)) { if (_BitScanReverse64(&result, x)) {
...@@ -271,7 +266,8 @@ CountTrailingZeroesNonzero64(uint64_t x) { ...@@ -271,7 +266,8 @@ CountTrailingZeroesNonzero64(uint64_t x) {
static_assert(sizeof(unsigned long long) == sizeof(x), // NOLINT(runtime/int) static_assert(sizeof(unsigned long long) == sizeof(x), // NOLINT(runtime/int)
"__builtin_ctzll does not take 64-bit arg"); "__builtin_ctzll does not take 64-bit arg");
return __builtin_ctzll(x); return __builtin_ctzll(x);
#elif defined(_MSC_VER) && !defined(__clang__) && defined(_M_X64) #elif defined(_MSC_VER) && !defined(__clang__) && \
(defined(_M_X64) || defined(_M_ARM64))
unsigned long result = 0; // NOLINT(runtime/int) unsigned long result = 0; // NOLINT(runtime/int)
_BitScanForward64(&result, x); _BitScanForward64(&result, x);
return result; return result;
......
//
// Copyright 2017 The Abseil Authors. // Copyright 2017 The Abseil Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
...@@ -244,6 +245,13 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) { ...@@ -244,6 +245,13 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) {
} // namespace numbers_internal } // namespace numbers_internal
// SimpleAtoi()
//
// Converts a string to an integer, using `safe_strto?()` functions for actual
// parsing, returning `true` if successful. The `safe_strto?()` functions apply
// strict checking; the string must be a base-10 integer, optionally followed or
// preceded by ASCII whitespace, with a value in the range of the corresponding
// integer type.
template <typename int_type> template <typename int_type>
ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out) { ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out) {
return numbers_internal::safe_strtoi_base(str, out, 10); return numbers_internal::safe_strtoi_base(str, out, 10);
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
namespace { namespace {
using absl::SimpleAtoi;
using absl::numbers_internal::kSixDigitsToBufferSize; using absl::numbers_internal::kSixDigitsToBufferSize;
using absl::numbers_internal::safe_strto32_base; using absl::numbers_internal::safe_strto32_base;
using absl::numbers_internal::safe_strto64_base; using absl::numbers_internal::safe_strto64_base;
...@@ -56,6 +55,7 @@ using absl::numbers_internal::SixDigitsToBuffer; ...@@ -56,6 +55,7 @@ using absl::numbers_internal::SixDigitsToBuffer;
using absl::strings_internal::Itoa; using absl::strings_internal::Itoa;
using absl::strings_internal::strtouint32_test_cases; using absl::strings_internal::strtouint32_test_cases;
using absl::strings_internal::strtouint64_test_cases; using absl::strings_internal::strtouint64_test_cases;
using absl::SimpleAtoi;
using testing::Eq; using testing::Eq;
using testing::MatchesRegex; using testing::MatchesRegex;
...@@ -380,7 +380,7 @@ TEST(NumbersTest, Atoi) { ...@@ -380,7 +380,7 @@ TEST(NumbersTest, Atoi) {
VerifySimpleAtoiGood<uint32_t>(42, 42); VerifySimpleAtoiGood<uint32_t>(42, 42);
VerifySimpleAtoiGood<unsigned int>(42, 42); VerifySimpleAtoiGood<unsigned int>(42, 42);
VerifySimpleAtoiGood<int64_t>(-42, -42); VerifySimpleAtoiGood<int64_t>(-42, -42);
VerifySimpleAtoiGood<long>(-42, -42); // NOLINT: runtime-int VerifySimpleAtoiGood<long>(-42, -42); // NOLINT(runtime/int)
VerifySimpleAtoiGood<uint64_t>(42, 42); VerifySimpleAtoiGood<uint64_t>(42, 42);
VerifySimpleAtoiGood<size_t>(42, 42); VerifySimpleAtoiGood<size_t>(42, 42);
VerifySimpleAtoiGood<std::string::size_type>(42, 42); VerifySimpleAtoiGood<std::string::size_type>(42, 42);
......
...@@ -915,9 +915,9 @@ TEST(StringViewTest, At) { ...@@ -915,9 +915,9 @@ TEST(StringViewTest, At) {
EXPECT_EQ(abc.at(1), 'b'); EXPECT_EQ(abc.at(1), 'b');
EXPECT_EQ(abc.at(2), 'c'); EXPECT_EQ(abc.at(2), 'c');
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
EXPECT_THROW(abc.at(3), std::out_of_range); EXPECT_THROW((void)abc.at(3), std::out_of_range);
#else #else
ABSL_EXPECT_DEATH_IF_SUPPORTED(abc.at(3), "absl::string_view::at"); ABSL_EXPECT_DEATH_IF_SUPPORTED((void)abc.at(3), "absl::string_view::at");
#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