Changes imported from Abseil "staging" branch:
- 53419b5e123c4c9c47ecfe52ba747a271b03ae9c Add the sampling weight to MallocHook_SampledAlloc, so th... by Abseil Team <absl-team@google.com> - 8689c9a0dc685f50ba843a8d0d7d4274a1ec656a Factor out inline variable detection to separate macro. by Matt Calabrese <calabrese@google.com> - 0eac39ee9d81c03b8335c1cd3871d0dc4ec7bca7 Log the actual and expected durations for failed timing t... by Abseil Team <absl-team@google.com> GitOrigin-RevId: 53419b5e123c4c9c47ecfe52ba747a271b03ae9c Change-Id: I4ae8f5c0e924cdeee253fdf37d483d47893fc64c
This commit is contained in:
		
							parent
							
								
									46ed9d96d1
								
							
						
					
					
						commit
						26d8858ecc
					
				
					 4 changed files with 37 additions and 11 deletions
				
			
		|  | @ -53,7 +53,24 @@ | ||||||
| //   it will likely be a reference type).
 | //   it will likely be a reference type).
 | ||||||
| ////////////////////////////////////////////////////////////////////////////////
 | ////////////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| #ifdef __cpp_inline_variables | // ABSL_INTERNAL_HAS_WARNING()
 | ||||||
|  | //
 | ||||||
|  | // If the compiler supports the `__has_warning` extension for detecting
 | ||||||
|  | // warnings, then this macro is defined to be `__has_warning`.
 | ||||||
|  | //
 | ||||||
|  | // If the compiler does not support `__has_warning`, invocations expand to 0.
 | ||||||
|  | //
 | ||||||
|  | // For clang's documentation of `__has_warning`, see
 | ||||||
|  | // https://clang.llvm.org/docs/LanguageExtensions.html#has-warning
 | ||||||
|  | #if defined(__has_warning) | ||||||
|  | #define ABSL_INTERNAL_HAS_WARNING __has_warning | ||||||
|  | #else  // Otherwise, be optimistic and assume the warning is not enabled.
 | ||||||
|  | #define ABSL_INTERNAL_HAS_WARNING(warning) 0 | ||||||
|  | #endif  // defined(__has_warning)
 | ||||||
|  | 
 | ||||||
|  | // If the compiler supports inline variables and does not warn when used...
 | ||||||
|  | #if defined(__cpp_inline_variables) && \ | ||||||
|  |     !ABSL_INTERNAL_HAS_WARNING("-Wc++98-c++11-c++14-compat") | ||||||
| 
 | 
 | ||||||
| // Clang's -Wmissing-variable-declarations option erroneously warned that
 | // Clang's -Wmissing-variable-declarations option erroneously warned that
 | ||||||
| // inline constexpr objects need to be pre-declared. This has now been fixed,
 | // inline constexpr objects need to be pre-declared. This has now been fixed,
 | ||||||
|  | @ -66,19 +83,21 @@ | ||||||
| //   identity_t is used here so that the const and name are in the
 | //   identity_t is used here so that the const and name are in the
 | ||||||
| //   appropriate place for pointer types, reference types, function pointer
 | //   appropriate place for pointer types, reference types, function pointer
 | ||||||
| //   types, etc..
 | //   types, etc..
 | ||||||
| #if defined(__clang__) | #if defined(__clang__) && \ | ||||||
|  |     ABSL_INTERNAL_HAS_WARNING("-Wmissing-variable-declarations") | ||||||
| #define ABSL_INTERNAL_EXTERN_DECL(type, name) \ | #define ABSL_INTERNAL_EXTERN_DECL(type, name) \ | ||||||
|   extern const ::absl::internal::identity_t<type> name; |   extern const ::absl::internal::identity_t<type> name; | ||||||
| #else  // Otherwise, just define the macro to do nothing.
 | #else  // Otherwise, just define the macro to do nothing.
 | ||||||
| #define ABSL_INTERNAL_EXTERN_DECL(type, name) | #define ABSL_INTERNAL_EXTERN_DECL(type, name) | ||||||
| #endif  // defined(__clang__)
 | #endif  // defined(__clang__) &&
 | ||||||
|  |         // ABSL_INTERNAL_HAS_WARNING("-Wmissing-variable-declarations")
 | ||||||
| 
 | 
 | ||||||
| // See above comment at top of file for details.
 | // See above comment at top of file for details.
 | ||||||
| #define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ | #define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ | ||||||
|   ABSL_INTERNAL_EXTERN_DECL(type, name)                  \ |   ABSL_INTERNAL_EXTERN_DECL(type, name)                  \ | ||||||
|   inline constexpr ::absl::internal::identity_t<type> name = init |   inline constexpr ::absl::internal::identity_t<type> name = init | ||||||
| 
 | 
 | ||||||
| #else | #else  // Otherwise, we need to emulate inline variables...
 | ||||||
| 
 | 
 | ||||||
| // See above comment at top of file for details.
 | // See above comment at top of file for details.
 | ||||||
| //
 | //
 | ||||||
|  | @ -102,6 +121,7 @@ | ||||||
|   static_assert(sizeof(void (*)(decltype(name))) != 0,                        \ |   static_assert(sizeof(void (*)(decltype(name))) != 0,                        \ | ||||||
|                 "Silence unused variable warnings.") |                 "Silence unused variable warnings.") | ||||||
| 
 | 
 | ||||||
| #endif  // __cpp_inline_variables
 | #endif  // defined(__cpp_inline_variables) &&
 | ||||||
|  |         // !ABSL_INTERNAL_HAS_WARNING("-Wc++98-c++11-c++14-compat")
 | ||||||
| 
 | 
 | ||||||
| #endif  // ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_
 | #endif  // ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_
 | ||||||
|  |  | ||||||
|  | @ -91,8 +91,11 @@ class MallocHook { | ||||||
|   // SampledAlloc has the following fields:
 |   // SampledAlloc has the following fields:
 | ||||||
|   //  * AllocHandle handle: to be set to an effectively unique value (in this
 |   //  * AllocHandle handle: to be set to an effectively unique value (in this
 | ||||||
|   //    process) by allocator.
 |   //    process) by allocator.
 | ||||||
|   //  * size_t allocated_size: space actually used by allocator to host
 |   //  * size_t allocated_size: space actually used by allocator to host the
 | ||||||
|   //    the object.
 |   //    object. Not necessarily equal to the requested size due to alignment
 | ||||||
|  |   //    and other reasons.
 | ||||||
|  |   //  * double weight: the expected number of allocations matching this profile
 | ||||||
|  |   //    that this sample represents.
 | ||||||
|   //  * int stack_depth and const void* stack: invocation stack for
 |   //  * int stack_depth and const void* stack: invocation stack for
 | ||||||
|   //    the allocation.
 |   //    the allocation.
 | ||||||
|   // The allocator invoking the hook should record the handle value and later
 |   // The allocator invoking the hook should record the handle value and later
 | ||||||
|  |  | ||||||
|  | @ -37,6 +37,7 @@ typedef struct { | ||||||
|   /* See malloc_hook.h  for documentation for this struct. */ |   /* See malloc_hook.h  for documentation for this struct. */ | ||||||
|   MallocHook_AllocHandle handle; |   MallocHook_AllocHandle handle; | ||||||
|   size_t allocated_size; |   size_t allocated_size; | ||||||
|  |   double weight; | ||||||
|   int stack_depth; |   int stack_depth; | ||||||
|   const void* stack; |   const void* stack; | ||||||
| } MallocHook_SampledAlloc; | } MallocHook_SampledAlloc; | ||||||
|  |  | ||||||
|  | @ -1234,10 +1234,12 @@ static void CheckResults(bool exp_result, bool act_result, | ||||||
|                          absl::Duration act_duration) { |                          absl::Duration act_duration) { | ||||||
|   ABSL_RAW_CHECK(exp_result == act_result, "CheckResults failed"); |   ABSL_RAW_CHECK(exp_result == act_result, "CheckResults failed"); | ||||||
|   // Allow for some worse-case scheduling delay and clock skew.
 |   // Allow for some worse-case scheduling delay and clock skew.
 | ||||||
|   ABSL_RAW_CHECK(exp_duration - absl::Milliseconds(40) <= act_duration, |   if ((exp_duration - absl::Milliseconds(40) > act_duration) || | ||||||
|                  "CheckResults failed"); |       (exp_duration + absl::Milliseconds(150) < act_duration)) { | ||||||
|   ABSL_RAW_CHECK(exp_duration + absl::Milliseconds(150) >= act_duration, |     ABSL_RAW_LOG(FATAL, "CheckResults failed: operation took %s, expected %s", | ||||||
|                  "CheckResults failed"); |                  absl::FormatDuration(act_duration).c_str(), | ||||||
|  |                  absl::FormatDuration(exp_duration).c_str()); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void TestAwaitTimeout(Cond *cp, absl::Duration timeout, bool exp_result, | static void TestAwaitTimeout(Cond *cp, absl::Duration timeout, bool exp_result, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue