diff options
Diffstat (limited to 'absl')
-rw-r--r-- | absl/base/attributes.h | 21 | ||||
-rw-r--r-- | absl/debugging/internal/stacktrace_powerpc-inl.inc | 5 | ||||
-rw-r--r-- | absl/time/time.h | 24 |
3 files changed, 36 insertions, 14 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h index faa5b27e..cf2cb550 100644 --- a/absl/base/attributes.h +++ b/absl/base/attributes.h @@ -678,4 +678,25 @@ #define ABSL_CONST_INIT #endif // ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) +// ABSL_ATTRIBUTE_PURE_FUNCTION +// +// ABSL_ATTRIBUTE_PURE_FUNCTION is used to annotate declarations of "pure" +// functions. A function is pure if its return value is only a function of its +// arguments. The pure attribute prohibits a function from modifying the state +// of the program that is observable by means other than inspecting the +// function's return value. Declaring such functions with the pure attribute +// allows the compiler to avoid emitting some calls in repeated invocations of +// the function with the same argument values. +// +// Example: +// +// ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Milliseconds(Duration d); +#if ABSL_HAVE_CPP_ATTRIBUTE(gnu::pure) +#define ABSL_ATTRIBUTE_PURE_FUNCTION [[gnu::pure]] +#elif ABSL_HAVE_ATTRIBUTE(pure) +#define ABSL_ATTRIBUTE_PURE_FUNCTION __attribute__((pure)) +#else +#define ABSL_ATTRIBUTE_PURE_FUNCTION +#endif + #endif // ABSL_BASE_ATTRIBUTES_H_ diff --git a/absl/debugging/internal/stacktrace_powerpc-inl.inc b/absl/debugging/internal/stacktrace_powerpc-inl.inc index 5b2cdc2a..cf8c0516 100644 --- a/absl/debugging/internal/stacktrace_powerpc-inl.inc +++ b/absl/debugging/internal/stacktrace_powerpc-inl.inc @@ -132,9 +132,10 @@ static void **NextStackFrame(void **old_sp, const void *uc) { reinterpret_cast<const ucontext_t*>(uc); void **const sp_before_signal = #if defined(__PPC64__) - reinterpret_cast<void**>(signal_context->uc_mcontext.gp_regs[PT_R1]); + reinterpret_cast<void **>(signal_context->uc_mcontext.gp_regs[PT_R1]); #else - reinterpret_cast<void**>(signal_context->uc_mcontext.uc_regs->gregs[PT_R1]); + reinterpret_cast<void **>( + signal_context->uc_mcontext.uc_regs->gregs[PT_R1]); #endif // Check that alleged sp before signal is nonnull and is reasonably // aligned. diff --git a/absl/time/time.h b/absl/time/time.h index 72508031..d9ad1aed 100644 --- a/absl/time/time.h +++ b/absl/time/time.h @@ -458,12 +458,12 @@ Duration Hours(T n) { // // absl::Duration d = absl::Milliseconds(1500); // int64_t isec = absl::ToInt64Seconds(d); // isec == 1 -int64_t ToInt64Nanoseconds(Duration d); -int64_t ToInt64Microseconds(Duration d); -int64_t ToInt64Milliseconds(Duration d); -int64_t ToInt64Seconds(Duration d); -int64_t ToInt64Minutes(Duration d); -int64_t ToInt64Hours(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Nanoseconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Microseconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Milliseconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Seconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Minutes(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION int64_t ToInt64Hours(Duration d); // ToDoubleNanoSeconds() // ToDoubleMicroseconds() @@ -480,12 +480,12 @@ int64_t ToInt64Hours(Duration d); // // absl::Duration d = absl::Milliseconds(1500); // double dsec = absl::ToDoubleSeconds(d); // dsec == 1.5 -double ToDoubleNanoseconds(Duration d); -double ToDoubleMicroseconds(Duration d); -double ToDoubleMilliseconds(Duration d); -double ToDoubleSeconds(Duration d); -double ToDoubleMinutes(Duration d); -double ToDoubleHours(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION double ToDoubleNanoseconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION double ToDoubleMicroseconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION double ToDoubleMilliseconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION double ToDoubleSeconds(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION double ToDoubleMinutes(Duration d); +ABSL_ATTRIBUTE_PURE_FUNCTION double ToDoubleHours(Duration d); // FromChrono() // |