修改pods

This commit is contained in:
2025-09-20 17:13:38 +08:00
parent 7787b3ee30
commit 28ff2b0264
5251 changed files with 345029 additions and 285168 deletions

View File

@@ -55,7 +55,7 @@
// Example:
//
// // Construct a civil-time object for a specific day
// const absl::CivilDay cd(1969, 07, 20);
// const absl::CivilDay cd(1969, 7, 20);
//
// // Construct a civil-time object for a specific second
// const absl::CivilSecond cd(2018, 8, 1, 12, 0, 1);
@@ -65,7 +65,7 @@
// Example:
//
// // Valid in C++14
// constexpr absl::CivilDay cd(1969, 07, 20);
// constexpr absl::CivilDay cd(1969, 7, 20);
#ifndef ABSL_TIME_CIVIL_TIME_H_
#define ABSL_TIME_CIVIL_TIME_H_

View File

@@ -88,11 +88,25 @@ ABSL_NAMESPACE_END
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace time_internal {
// On some processors, consecutive reads of the cycle counter may yield the
// same value (weakly-increasing). In debug mode, clear the least significant
// bits to discourage depending on a strictly-increasing Now() value.
// In x86-64's debug mode, discourage depending on a strictly-increasing Now()
// value.
#if !defined(NDEBUG) && defined(__x86_64__)
constexpr int64_t kCycleClockNowMask = ~int64_t{0xff};
#else
constexpr int64_t kCycleClockNowMask = ~int64_t{0};
#endif
// This is a friend wrapper around UnscaledCycleClock::Now()
// (needed to access UnscaledCycleClock).
class UnscaledCycleClockWrapperForGetCurrentTime {
public:
static int64_t Now() { return base_internal::UnscaledCycleClock::Now(); }
static int64_t Now() {
return base_internal::UnscaledCycleClock::Now() & kCycleClockNowMask;
}
};
} // namespace time_internal

View File

@@ -219,7 +219,7 @@ struct SafeMultiply {
? static_cast<uint128>(Uint128Low64(a) * Uint128Low64(b))
: a * b;
}
return b == 0 ? b : (a > kuint128max / b) ? kuint128max : a * b;
return b == 0 ? b : (a > Uint128Max() / b) ? Uint128Max() : a * b;
}
};
@@ -280,33 +280,35 @@ inline bool IDivFastPath(const Duration num, const Duration den, int64_t* q,
int64_t den_hi = time_internal::GetRepHi(den);
uint32_t den_lo = time_internal::GetRepLo(den);
if (den_hi == 0 && den_lo == kTicksPerNanosecond) {
// Dividing by 1ns
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 1000000000) {
*q = num_hi * 1000000000 + num_lo / kTicksPerNanosecond;
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
} else if (den_hi == 0 && den_lo == 100 * kTicksPerNanosecond) {
// Dividing by 100ns (common when converting to Universal time)
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 10000000) {
*q = num_hi * 10000000 + num_lo / (100 * kTicksPerNanosecond);
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
} else if (den_hi == 0 && den_lo == 1000 * kTicksPerNanosecond) {
// Dividing by 1us
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 1000000) {
*q = num_hi * 1000000 + num_lo / (1000 * kTicksPerNanosecond);
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
} else if (den_hi == 0 && den_lo == 1000000 * kTicksPerNanosecond) {
// Dividing by 1ms
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 1000) {
*q = num_hi * 1000 + num_lo / (1000000 * kTicksPerNanosecond);
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
if (den_hi == 0) {
if (den_lo == kTicksPerNanosecond) {
// Dividing by 1ns
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 1000000000) {
*q = num_hi * 1000000000 + num_lo / kTicksPerNanosecond;
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
} else if (den_lo == 100 * kTicksPerNanosecond) {
// Dividing by 100ns (common when converting to Universal time)
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 10000000) {
*q = num_hi * 10000000 + num_lo / (100 * kTicksPerNanosecond);
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
} else if (den_lo == 1000 * kTicksPerNanosecond) {
// Dividing by 1us
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 1000000) {
*q = num_hi * 1000000 + num_lo / (1000 * kTicksPerNanosecond);
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
} else if (den_lo == 1000000 * kTicksPerNanosecond) {
// Dividing by 1ms
if (num_hi >= 0 && num_hi < (kint64max - kTicksPerSecond) / 1000) {
*q = num_hi * 1000 + num_lo / (1000000 * kTicksPerNanosecond);
*rem = time_internal::MakeDuration(0, num_lo % den_lo);
return true;
}
}
} else if (den_hi > 0 && den_lo == 0) {
// Dividing by positive multiple of 1s
@@ -342,19 +344,10 @@ inline bool IDivFastPath(const Duration num, const Duration den, int64_t* q,
} // namespace
namespace time_internal {
namespace {
// The 'satq' argument indicates whether the quotient should saturate at the
// bounds of int64_t. If it does saturate, the difference will spill over to
// the remainder. If it does not saturate, the remainder remain accurate,
// but the returned quotient will over/underflow int64_t and should not be used.
int64_t IDivDuration(bool satq, const Duration num, const Duration den,
int64_t IDivSlowPath(bool satq, const Duration num, const Duration den,
Duration* rem) {
int64_t q = 0;
if (IDivFastPath(num, den, &q, rem)) {
return q;
}
const bool num_neg = num < ZeroDuration();
const bool den_neg = den < ZeroDuration();
const bool quotient_neg = num_neg != den_neg;
@@ -391,7 +384,27 @@ int64_t IDivDuration(bool satq, const Duration num, const Duration den,
return -static_cast<int64_t>(Uint128Low64(quotient128 - 1) & kint64max) - 1;
}
} // namespace time_internal
// The 'satq' argument indicates whether the quotient should saturate at the
// bounds of int64_t. If it does saturate, the difference will spill over to
// the remainder. If it does not saturate, the remainder remain accurate,
// but the returned quotient will over/underflow int64_t and should not be used.
ABSL_ATTRIBUTE_ALWAYS_INLINE inline int64_t IDivDurationImpl(bool satq,
const Duration num,
const Duration den,
Duration* rem) {
int64_t q = 0;
if (IDivFastPath(num, den, &q, rem)) {
return q;
}
return IDivSlowPath(satq, num, den, rem);
}
} // namespace
int64_t IDivDuration(Duration num, Duration den, Duration* rem) {
return IDivDurationImpl(true, num, den,
rem); // trunc towards zero
}
//
// Additive operators.
@@ -475,7 +488,7 @@ Duration& Duration::operator/=(double r) {
}
Duration& Duration::operator%=(Duration rhs) {
time_internal::IDivDuration(false, *this, rhs, this);
IDivDurationImpl(false, *this, rhs, this);
return *this;
}
@@ -501,9 +514,7 @@ double FDivDuration(Duration num, Duration den) {
// Trunc/Floor/Ceil.
//
Duration Trunc(Duration d, Duration unit) {
return d - (d % unit);
}
Duration Trunc(Duration d, Duration unit) { return d - (d % unit); }
Duration Floor(const Duration d, const Duration unit) {
const absl::Duration td = Trunc(d, unit);
@@ -591,15 +602,9 @@ double ToDoubleMicroseconds(Duration d) {
double ToDoubleMilliseconds(Duration d) {
return FDivDuration(d, Milliseconds(1));
}
double ToDoubleSeconds(Duration d) {
return FDivDuration(d, Seconds(1));
}
double ToDoubleMinutes(Duration d) {
return FDivDuration(d, Minutes(1));
}
double ToDoubleHours(Duration d) {
return FDivDuration(d, Hours(1));
}
double ToDoubleSeconds(Duration d) { return FDivDuration(d, Seconds(1)); }
double ToDoubleMinutes(Duration d) { return FDivDuration(d, Minutes(1)); }
double ToDoubleHours(Duration d) { return FDivDuration(d, Hours(1)); }
timespec ToTimespec(Duration d) {
timespec ts;

View File

@@ -16,6 +16,7 @@
#include <cctype>
#include <cstdint>
#include <utility>
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
@@ -136,7 +137,7 @@ bool ParseTime(absl::string_view format, absl::string_view input,
if (b) {
*time = Join(parts);
} else if (err != nullptr) {
*err = error;
*err = std::move(error);
}
return b;
}

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#if defined(_WIN32) || defined(_WIN64)
#if !defined(_CRT_SECURE_NO_WARNINGS) && defined(_WIN32)
#define _CRT_SECURE_NO_WARNINGS 1
#endif

View File

@@ -17,9 +17,6 @@
#if defined(__ANDROID__)
#include <sys/system_properties.h>
#if defined(__ANDROID_API__) && __ANDROID_API__ >= 21
#include <dlfcn.h>
#endif
#endif
#if defined(__APPLE__)
@@ -66,32 +63,6 @@ namespace time_internal {
namespace cctz {
namespace {
#if defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__ >= 21
// Android 'L' removes __system_property_get() from the NDK, however
// it is still a hidden symbol in libc so we use dlsym() to access it.
// See Chromium's base/sys_info_android.cc for a similar example.
using property_get_func = int (*)(const char*, char*);
property_get_func LoadSystemPropertyGet() {
int flag = RTLD_LAZY | RTLD_GLOBAL;
#if defined(RTLD_NOLOAD)
flag |= RTLD_NOLOAD; // libc.so should already be resident
#endif
if (void* handle = dlopen("libc.so", flag)) {
void* sym = dlsym(handle, "__system_property_get");
dlclose(handle);
return reinterpret_cast<property_get_func>(sym);
}
return nullptr;
}
int __system_property_get(const char* name, char* value) {
static property_get_func system_property_get = LoadSystemPropertyGet();
return system_property_get ? system_property_get(name, value) : -1;
}
#endif
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
// Calls the WinRT Calendar.GetTimeZone method to obtain the IANA ID of the
// local time zone. Returns an empty vector in case of an error.

View File

@@ -77,11 +77,11 @@ struct tzhead {
** time uses 8 rather than 4 chars,
** then a POSIX-TZ-environment-variable-style string for use in handling
** instants after the last transition time stored in the file
** (with nothing between the newlines if there is no POSIX representation for
** such instants).
** (with nothing between the newlines if there is no POSIX.1-2017
** representation for such instants).
**
** If tz_version is '3' or greater, the above is extended as follows.
** First, the POSIX TZ string's hour offset may range from -167
** First, the TZ string's hour offset may range from -167
** through 167 as compared to the POSIX-required 0 through 24.
** Second, its DST start time may be January 1 at 00:00 and its stop
** time December 31 at 24:00 plus the difference between DST and

View File

@@ -75,15 +75,22 @@
struct timeval;
#endif
#include <chrono> // NOLINT(build/c++11)
#ifdef __cpp_impl_three_way_comparison
#include <compare>
#endif // __cpp_impl_three_way_comparison
#include <cmath>
#include <cstdint>
#include <ctime>
#include <limits>
#include <ostream>
#include <ratio> // NOLINT(build/c++11)
#include <string>
#include <type_traits>
#include <utility>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
@@ -98,7 +105,6 @@ class Time; // Defined below
class TimeZone; // Defined below
namespace time_internal {
int64_t IDivDuration(bool satq, Duration num, Duration den, Duration* rem);
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr Time FromUnixDuration(Duration d);
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr Duration ToUnixDuration(Time t);
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr int64_t GetRepHi(Duration d);
@@ -306,6 +312,14 @@ class Duration {
};
// Relational Operators
#ifdef __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr std::strong_ordering operator<=>(
Duration lhs, Duration rhs);
#endif // __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator<(Duration lhs,
Duration rhs);
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator>(Duration lhs,
@@ -338,30 +352,6 @@ ABSL_ATTRIBUTE_CONST_FUNCTION inline Duration operator-(Duration lhs,
return lhs -= rhs;
}
// Multiplicative Operators
// Integer operands must be representable as int64_t.
template <typename T>
ABSL_ATTRIBUTE_CONST_FUNCTION Duration operator*(Duration lhs, T rhs) {
return lhs *= rhs;
}
template <typename T>
ABSL_ATTRIBUTE_CONST_FUNCTION Duration operator*(T lhs, Duration rhs) {
return rhs *= lhs;
}
template <typename T>
ABSL_ATTRIBUTE_CONST_FUNCTION Duration operator/(Duration lhs, T rhs) {
return lhs /= rhs;
}
ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t operator/(Duration lhs,
Duration rhs) {
return time_internal::IDivDuration(true, lhs, rhs,
&lhs); // trunc towards zero
}
ABSL_ATTRIBUTE_CONST_FUNCTION inline Duration operator%(Duration lhs,
Duration rhs) {
return lhs %= rhs;
}
// IDivDuration()
//
// Divides a numerator `Duration` by a denominator `Duration`, returning the
@@ -390,10 +380,7 @@ ABSL_ATTRIBUTE_CONST_FUNCTION inline Duration operator%(Duration lhs,
// // Here, q would overflow int64_t, so rem accounts for the difference.
// int64_t q = absl::IDivDuration(a, b, &rem);
// // q == std::numeric_limits<int64_t>::max(), rem == a - b * q
inline int64_t IDivDuration(Duration num, Duration den, Duration* rem) {
return time_internal::IDivDuration(true, num, den,
rem); // trunc towards zero
}
int64_t IDivDuration(Duration num, Duration den, Duration* rem);
// FDivDuration()
//
@@ -409,6 +396,30 @@ inline int64_t IDivDuration(Duration num, Duration den, Duration* rem) {
// // d == 1.5
ABSL_ATTRIBUTE_CONST_FUNCTION double FDivDuration(Duration num, Duration den);
// Multiplicative Operators
// Integer operands must be representable as int64_t.
template <typename T>
ABSL_ATTRIBUTE_CONST_FUNCTION Duration operator*(Duration lhs, T rhs) {
return lhs *= rhs;
}
template <typename T>
ABSL_ATTRIBUTE_CONST_FUNCTION Duration operator*(T lhs, Duration rhs) {
return rhs *= lhs;
}
template <typename T>
ABSL_ATTRIBUTE_CONST_FUNCTION Duration operator/(Duration lhs, T rhs) {
return lhs /= rhs;
}
ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t operator/(Duration lhs,
Duration rhs) {
return IDivDuration(lhs, rhs,
&lhs); // trunc towards zero
}
ABSL_ATTRIBUTE_CONST_FUNCTION inline Duration operator%(Duration lhs,
Duration rhs) {
return lhs %= rhs;
}
// ZeroDuration()
//
// Returns a zero-length duration. This function behaves just like the default
@@ -841,6 +852,11 @@ class Time {
private:
friend constexpr Time time_internal::FromUnixDuration(Duration d);
friend constexpr Duration time_internal::ToUnixDuration(Time t);
#ifdef __cpp_impl_three_way_comparison
friend constexpr std::strong_ordering operator<=>(Time lhs, Time rhs);
#endif // __cpp_impl_three_way_comparison
friend constexpr bool operator<(Time lhs, Time rhs);
friend constexpr bool operator==(Time lhs, Time rhs);
friend Duration operator-(Time lhs, Time rhs);
@@ -852,6 +868,15 @@ class Time {
};
// Relational Operators
#ifdef __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr std::strong_ordering operator<=>(
Time lhs, Time rhs) {
return lhs.rep_ <=> rhs.rep_;
}
#endif // __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator<(Time lhs, Time rhs) {
return lhs.rep_ < rhs.rep_;
}
@@ -1727,6 +1752,25 @@ ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator<(Duration lhs,
: time_internal::GetRepLo(lhs) < time_internal::GetRepLo(rhs);
}
#ifdef __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr std::strong_ordering operator<=>(
Duration lhs, Duration rhs) {
const int64_t lhs_hi = time_internal::GetRepHi(lhs);
const int64_t rhs_hi = time_internal::GetRepHi(rhs);
if (auto c = lhs_hi <=> rhs_hi; c != std::strong_ordering::equal) {
return c;
}
const uint32_t lhs_lo = time_internal::GetRepLo(lhs);
const uint32_t rhs_lo = time_internal::GetRepLo(rhs);
return (lhs_hi == (std::numeric_limits<int64_t>::min)())
? (lhs_lo + 1) <=> (rhs_lo + 1)
: lhs_lo <=> rhs_lo;
}
#endif // __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator==(Duration lhs,
Duration rhs) {
return time_internal::GetRepHi(lhs) == time_internal::GetRepHi(rhs) &&