Export of internal Abseil changes

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

Remove a floating point division by zero test.

This isn't testing behavior related to the library, and MSVC warns
about it in opt mode.

PiperOrigin-RevId: 285220804

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

This CL introduces following changes to the class FlagImpl:
* We eliminate the CommandLineFlagLocks struct. Instead callback guard and callback function are combined into a single CallbackData struct, while primary data lock is stored separately.
* CallbackData member of class FlagImpl is initially set to be nullptr and is only allocated and initialized when a flag's callback is being set. For most flags we do not pay for the extra space and extra absl::Mutex now.
* Primary data guard is stored in data_guard_ data member. This is a properly aligned character buffer of necessary size. During initialization of the flag we construct absl::Mutex in this space using placement new call.
* We now avoid extra value copy after successful attempt to parse value out of string. Instead we swap flag's current value with tentative value we just produced.

PiperOrigin-RevId: 285132636

--
ed45d118fb818969eb13094cf7827c885dfc562c by Tom Manshreck <shreck@google.com>:

Change null-term* (and nul-term*) to NUL-term* in comments

PiperOrigin-RevId: 285036610

--
729619017944db895ce8d6d29c1995aa2e5628a5 by Derek Mauro <dmauro@google.com>:

Use the Posix implementation of thread identity on MinGW.
Some versions of MinGW suffer from thread_local bugs.

PiperOrigin-RevId: 285022920

--
39a25493503c76885bc3254c28f66a251c5b5bb0 by Greg Falcon <gfalcon@google.com>:

Implementation detail change.

Add further ABSL_NAMESPACE_BEGIN and _END annotation macros to files in Abseil.

PiperOrigin-RevId: 285012012
GitOrigin-RevId: c99f979ad34f155fbeeea69b88bdc7458d89a21c
Change-Id: I4c85d3704e45d11a9ac50d562f39640a6adbedc1
This commit is contained in:
Abseil Team 2019-12-12 10:36:03 -08:00 committed by Matt Calabrese
parent 1e39f8626a
commit 12bc53e031
339 changed files with 948 additions and 82 deletions

View file

@ -51,6 +51,7 @@ cc_library(
visibility = [
"//absl/random:__pkg__",
],
deps = ["//absl/base:config"],
)
cc_library(
@ -78,6 +79,7 @@ cc_library(
visibility = [
"//absl/random:__pkg__",
],
deps = ["//absl/base:config"],
)
cc_library(
@ -138,6 +140,7 @@ cc_library(
],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = ["//absl/base:config"],
)
cc_library(
@ -148,6 +151,7 @@ cc_library(
],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = ["//absl/base:config"],
)
cc_library(
@ -269,6 +273,7 @@ cc_library(
"randen-keys.inc",
"platform.h",
],
deps = ["//absl/base:config"],
)
cc_library(
@ -297,6 +302,7 @@ cc_library(
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":platform",
"//absl/base:config",
"//absl/base:core_headers",
],
)
@ -317,6 +323,7 @@ cc_library(
deps = [
":platform",
":randen_hwaes_impl",
"//absl/base:config",
],
)
@ -338,6 +345,7 @@ cc_library(
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":platform",
"//absl/base:config",
"//absl/base:core_headers",
],
)
@ -368,6 +376,7 @@ cc_library(
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:raw_logging_internal",
"//absl/strings",

View file

@ -19,6 +19,7 @@
#include "absl/random/internal/distribution_test_util.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -227,4 +228,5 @@ double ChiSquarePValue(double chi_square, int dof) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -26,7 +26,10 @@
#include <cassert>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
constexpr const char kChiSquared[] = "chi-squared";
@ -80,6 +83,7 @@ double ChiSquareValue(int dof, double p);
double ChiSquarePValue(double chi_square, int dof);
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_CHI_SQUARE_H_

View file

@ -19,7 +19,10 @@
#include <utility>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// DistributionCaller provides an opportunity to overload the general
@ -51,6 +54,7 @@ struct DistributionCaller {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_

View file

@ -25,6 +25,7 @@
#include "absl/strings/str_format.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -413,4 +414,5 @@ double MaxErrorTolerance(double acceptance_probability) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -26,6 +26,7 @@
// non-test code.
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// http://webspace.ship.edu/pgmarr/Geo441/Lectures/Lec%205%20-%20Normality%20Testing.pdf
@ -106,6 +107,7 @@ double BetaIncomplete(double x, double p, double q);
double BetaIncompleteInv(double p, double q, double alpha);
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_DISTRIBUTION_TEST_UTIL_H_

View file

@ -23,6 +23,7 @@
#include "absl/random/internal/uniform_helper.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// In the absence of an explicitly provided return-type, the template
@ -45,6 +46,7 @@ using uniform_inferred_return_t =
is_widening_convertible<A, B>::value, B, A>::type>;
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_DISTRIBUTIONS_H_

View file

@ -22,7 +22,10 @@
#include <iterator>
#include <vector>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// This class conforms to the C++ Standard "Seed Sequence" concept
@ -82,6 +85,7 @@ class ExplicitSeedSeq {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_EXPLICIT_SEED_SEQ_H_

View file

@ -20,7 +20,10 @@
#include <limits>
#include <type_traits>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Returns true if the input value is zero or a power of two. Useful for
// determining if the range of output values in a URBG
@ -255,6 +258,7 @@ FastUniformBits<UIntType>::Generate(URBG& g, // NOLINT(runtime/references)
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_FAST_UNIFORM_BITS_H_

View file

@ -19,6 +19,7 @@
#include "gtest/gtest.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -269,4 +270,5 @@ TEST(FastUniformBitsTest, URBG32bitRegression) {
} // namespace
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -25,6 +25,7 @@
#include "absl/base/internal/bits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Returns the position of the first bit set.
@ -67,6 +68,7 @@ inline constexpr uint64_t rotr(uint64_t value, uint8_t bits) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_FASTMATH_H_

View file

@ -27,6 +27,7 @@
#include "absl/base/macros.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -135,6 +136,7 @@ void TableGenerator::Print(std::ostream* os) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
int main(int, char**) {

View file

@ -29,6 +29,7 @@
#include "absl/random/internal/traits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Tristate tag types controlling the output of GenerateRealFromBits.
@ -139,6 +140,7 @@ inline RealType GenerateRealFromBits(uint64_t bits, int exp_bias = 0) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_GENERATE_REAL_H_

View file

@ -24,6 +24,7 @@
#include "absl/numeric/int128.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// The null_state_saver does nothing.
@ -238,6 +239,7 @@ inline FloatType read_floating_point(IStream& is) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_IOSTREAM_STATE_SAVER_H_

View file

@ -23,6 +23,7 @@
#include "absl/random/mocking_bit_gen.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
template <typename DistrT, typename Fn>
@ -85,5 +86,6 @@ struct MockOverloadSet<DistrT, FirstSig, Rest...>
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_MOCK_OVERLOAD_SET_H_

View file

@ -25,6 +25,7 @@
#include "absl/strings/str_cat.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// MockingBitGenExpectationFormatter is invoked to format unsatisfied mocks
@ -113,6 +114,7 @@ class MockingBitGenBase {
}; // namespace random_internal
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_MOCKING_BIT_GEN_BASE_H_

View file

@ -70,6 +70,7 @@
#endif
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal_nanobenchmark {
namespace {
@ -799,4 +800,5 @@ size_t Measure(const Func func, const void* arg, const FuncInput* inputs,
}
} // namespace random_internal_nanobenchmark
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -50,7 +50,10 @@
#include <stddef.h>
#include <stdint.h>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal_nanobenchmark {
// Input influencing the function being measured (e.g. number of bytes to copy).
@ -163,6 +166,7 @@ static inline size_t MeasureClosure(const Closure& closure,
}
} // namespace random_internal_nanobenchmark
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_NANOBENCHMARK_H_

View file

@ -18,6 +18,7 @@
#include "absl/strings/numbers.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal_nanobenchmark {
namespace {
@ -67,6 +68,7 @@ void RunAll(const int argc, char* argv[]) {
} // namespace
} // namespace random_internal_nanobenchmark
ABSL_NAMESPACE_END
} // namespace absl
int main(int argc, char* argv[]) {

View file

@ -33,6 +33,7 @@
#include "absl/types/span.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Each instance of NonsecureURBGBase<URBG> will be seeded by variates produced
@ -143,6 +144,7 @@ class NonsecureURBGBase {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_NONSECURE_BASE_H_

View file

@ -24,6 +24,7 @@
#include "absl/random/internal/iostream_state_saver.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// pcg_engine is a simplified implementation of Melissa O'Neil's PCG engine in
@ -300,6 +301,7 @@ using pcg32_2018_engine = pcg_engine<
random_internal::pcg_xsh_rr_64_32>;
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_

View file

@ -37,6 +37,7 @@ using absl::base_internal::SpinLock;
using absl::base_internal::SpinLockHolder;
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -249,4 +250,5 @@ template class RandenPool<uint32_t>;
template class RandenPool<uint64_t>;
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -22,6 +22,7 @@
#include "absl/types/span.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// RandenPool is a thread-safe random number generator [random.req.urbg] that
@ -124,6 +125,7 @@ class PoolURBG {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_POOL_URBG_H_

View file

@ -41,6 +41,7 @@
// structured/low-entropy counters to digits of Pi.
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -86,4 +87,5 @@ Randen::Randen() {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -23,6 +23,7 @@
#include "absl/random/internal/randen_traits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// RANDen = RANDom generator or beetroots in Swiss German.
@ -95,6 +96,7 @@ class Randen {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_RANDEN_H_

View file

@ -95,6 +95,7 @@ static uint32_t GetAuxval(uint32_t hwcap_type) {
#endif
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// The default return at the end of the function might be unreachable depending
@ -216,4 +217,5 @@ bool CPUSupportsRandenHwAes() {
#endif
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -15,7 +15,10 @@
#ifndef ABSL_RANDOM_INTERNAL_RANDEN_DETECT_H_
#define ABSL_RANDOM_INTERNAL_RANDEN_DETECT_H_
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Returns whether the current CPU supports RandenHwAes implementation.
@ -24,6 +27,7 @@ namespace random_internal {
bool CPUSupportsRandenHwAes();
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_RANDEN_DETECT_H_

View file

@ -28,6 +28,7 @@
#include "absl/random/internal/randen.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Deterministic pseudorandom byte generator with backtracking resistance
@ -223,6 +224,7 @@ class alignas(16) randen_engine {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_RANDEN_ENGINE_H_

View file

@ -75,6 +75,7 @@
#include <cstdlib>
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// No accelerated implementation.
@ -106,6 +107,7 @@ void RandenHwAes::Generate(const void*, void*) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#else // defined(ABSL_RANDEN_HWAES_IMPL)
@ -518,6 +520,7 @@ inline ABSL_TARGET_CRYPTO void Permute(
} // namespace
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
bool HasRandenHwAesImplementation() { return true; }
@ -629,6 +632,7 @@ void ABSL_TARGET_CRYPTO RandenHwAes::Generate(const void* keys,
#endif
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // (ABSL_RANDEN_HWAES_IMPL)

View file

@ -15,12 +15,15 @@
#ifndef ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_
#define ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_
#include "absl/base/config.h"
// HERMETIC NOTE: The randen_hwaes target must not introduce duplicate
// symbols from arbitrary system and other headers, since it may be built
// with different flags from other targets, using different levels of
// optimization, potentially introducing ODR violations.
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// RANDen = RANDom generator or beetroots in Swiss German.
@ -41,6 +44,7 @@ class RandenHwAes {
bool HasRandenHwAesImplementation();
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_

View file

@ -462,6 +462,7 @@ inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void Permute(
} // namespace
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
const void* RandenSlow::GetKeys() {
@ -501,4 +502,5 @@ void RandenSlow::Generate(const void* keys, void* state_void) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -17,7 +17,10 @@
#include <cstddef>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// RANDen = RANDom generator or beetroots in Swiss German.
@ -38,6 +41,7 @@ class RandenSlow {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_RANDEN_SLOW_H_

View file

@ -22,7 +22,10 @@
#include <cstddef>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// RANDen = RANDom generator or beetroots in Swiss German.
@ -54,6 +57,7 @@ struct RandenTraits {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_RANDEN_TRAITS_H_

View file

@ -30,6 +30,7 @@
#include "absl/types/span.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// This class conforms to the C++ Standard "Seed Sequence" concept
@ -160,6 +161,7 @@ SaltedSeedSeq<typename std::decay<SSeq>::type> MakeSaltedSeedSeq(SSeq&& seq) {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_SALTED_SEED_SEQ_H_

View file

@ -61,6 +61,7 @@
#endif
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {
@ -214,4 +215,5 @@ absl::optional<uint32_t> GetSaltMaterial() {
}
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl

View file

@ -27,6 +27,7 @@
#include "absl/types/span.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Returns the number of 32-bit blocks needed to contain the given number of
@ -97,6 +98,7 @@ void MixIntoSeedMaterial(absl::Span<const uint32_t> sequence,
absl::optional<uint32_t> GetSaltMaterial();
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_SEED_MATERIAL_H_

View file

@ -21,7 +21,10 @@
#include <type_traits>
#include <vector>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// `sequence_urbg` is a simple random number generator which meets the
@ -51,6 +54,7 @@ class sequence_urbg {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_SEQUENCE_URBG_H_

View file

@ -22,6 +22,7 @@
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// random_internal::is_widening_convertible<A, B>
@ -94,6 +95,7 @@ struct make_unsigned_bits {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_TRAITS_H_

View file

@ -22,6 +22,7 @@
#include "absl/meta/type_traits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
template <typename IntType>
class uniform_int_distribution;
@ -173,6 +174,7 @@ struct UniformDistributionWrapper : public UniformDistribution<NumType> {
};
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_UNIFORM_HELPER_H_

View file

@ -31,6 +31,7 @@
#include "absl/random/internal/traits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
// Helper object to multiply two 64-bit values to a 128-bit value.
@ -104,6 +105,7 @@ struct wide_multiply<uint64_t> {
#endif
} // namespace random_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_RANDOM_INTERNAL_WIDE_MULTIPLY_H_