Commit d5269a8b by Abseil Team Committed by Gennadiy Rozental

Export of internal Abseil changes

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

Import of CCTZ from GitHub.

PiperOrigin-RevId: 320398694

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

Update CMakeLists.txt

Import of https://github.com/abseil/abseil-cpp/pull/737

PiperOrigin-RevId: 320391906

--
b529c45856fe7a3447f1f3259286d57e13b1f292 by Abseil Team <absl-team@google.com>:

Improves a comment about use of absl::Condition.

PiperOrigin-RevId: 320384329

--
c7b1dacda2739c10dc1ccbfb56b07ed7fe2464a4 by Laramie Leavitt <lar@google.com>:

Improve FastUniformBits performance for std::minstd_rand.

The rejection algorithm was too pessimistic before, and not in line with the [rand.adapt.ibits]. Specifically, when sampling from an URBG with a non power of 2 range, FastUniformBits constructed a rejection threshold with a power-of-2 range that was too restrictive.

For example, minstd_rand has a range of
  [1, 2147483646], which has a range of 2145386495, or about 30.999 bits.

Before FastUniformBits rejected values between 1<<30 and 2145386495, which includes approximately 50% of the generated values. However, since a minimum of 3 calls are required to generate a full 64-bit value from an entropy pool of 30.9 bits, the correct value for rejection sampling is the range value which masks 21 (0x7fe00000) or 22 bits and rejects values greater than that.  This reduces the probability of rejecting a sample to about 0.1%

NOTE: Abseil random does not guarantee sequence stability over time, and this is expected to change sequences in some cases.
PiperOrigin-RevId: 320285836

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

Internal change.

PiperOrigin-RevId: 320220913

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

Internal change

PiperOrigin-RevId: 320181729

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

Internal change

PiperOrigin-RevId: 320176084

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

Internal change

PiperOrigin-RevId: 320176070

--
b35b055ab1f41e6056031ff0641cabab23530027 by Abseil Team <absl-team@google.com>:

Disabling using header module as well as building one for randen_hwaes_impl

PiperOrigin-RevId: 320024299
GitOrigin-RevId: 4833151c207fac9f57a735efe6d5db4c83368415
Change-Id: I9cf102dbf46ed07752a508b7cda3ab3858857d0d
parent bf655de0
......@@ -23,7 +23,9 @@ include(AbseilInstallDirs)
# project that sets
# set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# For example, Visual Studio supports folders.
set(ABSL_IDE_FOLDER Abseil)
if(NOT DEFINED ABSL_IDE_FOLDER)
set(ABSL_IDE_FOLDER Abseil)
endif()
# absl_cc_library()
#
......
......@@ -10,7 +10,7 @@ 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_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${ABSL_SUBDIR}")
set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${ABSL_SUBDIR}")
else()
set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
......
......@@ -64,7 +64,7 @@ ABSL_NAMESPACE_BEGIN
// `std::vector` for use cases where the vector's size is sufficiently small
// that it can be inlined. If the inlined vector does grow beyond its estimated
// capacity, it will trigger an initial allocation on the heap, and will behave
// as a `std:vector`. The API of the `absl::InlinedVector` within this file is
// as a `std::vector`. The API of the `absl::InlinedVector` within this file is
// designed to cover the same API footprint as covered by `std::vector`.
template <typename T, size_t N, typename A = std::allocator<T>>
class InlinedVector {
......
......@@ -58,10 +58,6 @@ class FlagRegistry {
// Will emit a warning if a 'retired' flag is specified.
CommandLineFlag* FindFlagLocked(absl::string_view name);
// Returns the retired flag object for the specified name, or nullptr if not
// found or not retired. Does not emit a warning.
CommandLineFlag* FindRetiredFlagLocked(absl::string_view name);
static FlagRegistry& GlobalRegistry(); // returns a singleton registry
private:
......@@ -88,14 +84,6 @@ CommandLineFlag* FlagRegistry::FindFlagLocked(absl::string_view name) {
if (i == flags_.end()) {
return nullptr;
}
return i->second;
}
CommandLineFlag* FlagRegistry::FindRetiredFlagLocked(absl::string_view name) {
FlagConstIterator i = flags_.find(name);
if (i == flags_.end() || !i->second->IsRetired()) {
return nullptr;
}
return i->second;
}
......
......@@ -59,7 +59,10 @@ cc_library(
],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = ["//absl/base:config"],
deps = [
"//absl/base:config",
"//absl/meta:type_traits",
],
)
cc_library(
......@@ -319,10 +322,6 @@ cc_library(
"//absl:windows": [],
"//conditions:default": ["-Wno-pass-failed"],
}),
# copts in RANDEN_HWAES_COPTS can make this target unusable as a module
# leading to a Clang diagnostic. Furthermore, it only has a private header
# anyway and thus there wouldn't be any gain from using it as a module.
features = ["-header_modules"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":platform",
......
......@@ -685,6 +685,11 @@ class Condition {
// return processed_ >= current;
// };
// mu_.Await(Condition(&reached));
//
// NOTE: never use "mu_.AssertHeld()" instead of "mu_.AssertReadHeld()" in the
// lambda as it may be called when the mutex is being unlocked from a scope
// holding only a reader lock, which will make the assertion not fulfilled and
// crash the binary.
// See class comment for performance advice. In particular, if there
// might be more than one waiter for the same condition, make sure
......
......@@ -654,14 +654,23 @@ const char* ParseTM(const char* dp, const char* fmt, std::tm* tm) {
}
// Sets year, tm_mon and tm_mday given the year, week_num, and tm_wday,
// and the day on which weeks are defined to start.
void FromWeek(int week_num, weekday week_start, year_t* year, std::tm* tm) {
// and the day on which weeks are defined to start. Returns false if year
// would need to move outside its bounds.
bool FromWeek(int week_num, weekday week_start, year_t* year, std::tm* tm) {
const civil_year y(*year % 400);
civil_day cd = prev_weekday(y, week_start); // week 0
cd = next_weekday(cd - 1, FromTmWday(tm->tm_wday)) + (week_num * 7);
*year += cd.year() - y.year();
if (const year_t shift = cd.year() - y.year()) {
if (shift > 0) {
if (*year > std::numeric_limits<year_t>::max() - shift) return false;
} else {
if (*year < std::numeric_limits<year_t>::min() - shift) return false;
}
*year += shift;
}
tm->tm_mon = cd.month() - 1;
tm->tm_mday = cd.day();
return true;
}
} // namespace
......@@ -965,7 +974,12 @@ bool parse(const std::string& format, const std::string& input,
}
// Compute year, tm.tm_mon and tm.tm_mday if we parsed a week number.
if (week_num != -1) FromWeek(week_num, week_start, &year, &tm);
if (week_num != -1) {
if (!FromWeek(week_num, week_start, &year, &tm)) {
if (err != nullptr) *err = "Out-of-range field";
return false;
}
}
const int month = tm.tm_mon + 1;
civil_second cs(year, month, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
......
......@@ -1481,6 +1481,11 @@ TEST(Parse, WeekYearShift) {
EXPECT_EQ(exp, tp);
EXPECT_TRUE(parse("%Y-%W-%w", "2020-52-5", utc, &tp));
EXPECT_EQ(exp, tp);
// Slipping into the previous/following calendar years should fail when
// we're already at the extremes.
EXPECT_FALSE(parse("%Y-%U-%u", "-9223372036854775808-0-7", utc, &tp));
EXPECT_FALSE(parse("%Y-%U-%u", "9223372036854775807-53-7", utc, &tp));
}
TEST(Parse, MaxRange) {
......
......@@ -223,10 +223,9 @@ time_zone::civil_lookup TimeZoneLibC::MakeTime(const civil_second& cs) const {
civil_second() + ToUnixSeconds(time_point<seconds>::min());
static const civil_second max_tp_cs =
civil_second() + ToUnixSeconds(time_point<seconds>::max());
const time_point<seconds> tp =
(cs < min_tp_cs)
? time_point<seconds>::min()
: (cs > max_tp_cs) ? time_point<seconds>::max()
const time_point<seconds> tp = (cs < min_tp_cs) ? time_point<seconds>::min()
: (cs > max_tp_cs)
? time_point<seconds>::max()
: FromUnixSeconds(cs - civil_second());
return {time_zone::civil_lookup::UNIQUE, tp, tp, tp};
}
......
......@@ -112,7 +112,7 @@ struct tzhead {
#ifndef TZ_MAX_CHARS
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
/* (limited by what unsigned chars can hold) */
/* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */
#ifndef TZ_MAX_LEAPS
......
......@@ -259,7 +259,7 @@ absl_cc_library(
absl::strings
absl::utility
gmock_main
PUBLIC
TESTONLY
)
absl_cc_test(
......
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