Export of internal Abseil changes.
-- 6769c6ebe79804063d68d70a5623a1475d63aeff by Alex Strelnikov <strel@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 202500218 -- c65cc4af08b8c48ca65f0816c1d2f59c7de7b0a5 by Derek Mauro <dmauro@google.com>: Fix DirectMMap on s390x (GitHub #135). This is *untested* because no s390x system is available. PiperOrigin-RevId: 202484458 -- 0ae7b628d7859cb3af169d007c29efd7917bb3ea by Abseil Team <absl-team@google.com>: Changes the Holder's compile-type type decision making to a std::conditional for improved readability PiperOrigin-RevId: 202340646 GitOrigin-RevId: 6769c6ebe79804063d68d70a5623a1475d63aeff Change-Id: I8f9d049ee279b1b1e3381fdf7e6fe9a4ea228306
This commit is contained in:
		
							parent
							
								
									be1e84b988
								
							
						
					
					
						commit
						ba8d6cf077
					
				
					 3 changed files with 35 additions and 46 deletions
				
			
		|  | @ -92,11 +92,13 @@ inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, | ||||||
| #endif | #endif | ||||||
| #elif defined(__s390x__) | #elif defined(__s390x__) | ||||||
|   // On s390x, mmap() arguments are passed in memory.
 |   // On s390x, mmap() arguments are passed in memory.
 | ||||||
|   uint32_t buf[6] = { |   unsigned long buf[6] = {reinterpret_cast<unsigned long>(start),  // NOLINT
 | ||||||
|       reinterpret_cast<uint32_t>(start), static_cast<uint32_t>(length), |                           static_cast<unsigned long>(length),      // NOLINT
 | ||||||
|       static_cast<uint32_t>(prot),       static_cast<uint32_t>(flags), |                           static_cast<unsigned long>(prot),        // NOLINT
 | ||||||
|       static_cast<uint32_t>(fd),         static_cast<uint32_t>(offset)}; |                           static_cast<unsigned long>(flags),       // NOLINT
 | ||||||
|   return reintrepret_cast<void*>(syscall(SYS_mmap, buf)); |                           static_cast<unsigned long>(fd),          // NOLINT
 | ||||||
|  |                           static_cast<unsigned long>(offset)};     // NOLINT
 | ||||||
|  |   return reinterpret_cast<void*>(syscall(SYS_mmap, buf)); | ||||||
| #elif defined(__x86_64__) | #elif defined(__x86_64__) | ||||||
| // The x32 ABI has 32 bit longs, but the syscall interface is 64 bit.
 | // The x32 ABI has 32 bit longs, but the syscall interface is 64 bit.
 | ||||||
| // We need to explicitly cast to an unsigned 64 bit type to avoid implicit
 | // We need to explicitly cast to an unsigned 64 bit type to avoid implicit
 | ||||||
|  |  | ||||||
|  | @ -78,6 +78,8 @@ constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1); | ||||||
| // operators.
 | // operators.
 | ||||||
| template <typename T, size_t inlined = kFixedArrayUseDefault> | template <typename T, size_t inlined = kFixedArrayUseDefault> | ||||||
| class FixedArray { | class FixedArray { | ||||||
|  |   static_assert(!std::is_array<T>::value || std::extent<T>::value > 0, | ||||||
|  |                 "Arrays with unknown bounds cannot be used with FixedArray."); | ||||||
|   static constexpr size_t kInlineBytesDefault = 256; |   static constexpr size_t kInlineBytesDefault = 256; | ||||||
| 
 | 
 | ||||||
|   // std::iterator_traits isn't guaranteed to be SFINAE-friendly until C++17,
 |   // std::iterator_traits isn't guaranteed to be SFINAE-friendly until C++17,
 | ||||||
|  | @ -337,11 +339,12 @@ class FixedArray { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  private: |  private: | ||||||
|   // HolderTraits
 |   // Holder
 | ||||||
|   //
 |   //
 | ||||||
|   // Wrapper to hold elements of type T for the case where T is an array type.
 |   // Wrapper for holding elements of type T for both the case where T is a
 | ||||||
|   // If 'T' is an array type, HolderTraits::type is a struct with a 'T v;'.
 |   // C-style array type and the general case where it is not. This is needed for
 | ||||||
|   // Otherwise, HolderTraits::type is simply 'T'.
 |   // construction and destruction of the entire array regardless of how many
 | ||||||
|  |   // dimensions it has.
 | ||||||
|   //
 |   //
 | ||||||
|   // Maintainer's Note: The simpler solution would be to simply wrap T in a
 |   // Maintainer's Note: The simpler solution would be to simply wrap T in a
 | ||||||
|   // struct whether it's an array or not: 'struct Holder { T v; };', but
 |   // struct whether it's an array or not: 'struct Holder { T v; };', but
 | ||||||
|  | @ -356,35 +359,23 @@ class FixedArray { | ||||||
|   //     error: call to int __builtin___sprintf_chk(etc...)
 |   //     error: call to int __builtin___sprintf_chk(etc...)
 | ||||||
|   //     will always overflow destination buffer [-Werror]
 |   //     will always overflow destination buffer [-Werror]
 | ||||||
|   //
 |   //
 | ||||||
|   class HolderTraits { |   template <typename OuterT = value_type, | ||||||
|     template <typename U> |             typename InnerT = absl::remove_extent_t<OuterT>, | ||||||
|     struct SelectImpl { |             size_t InnerN = std::extent<OuterT>::value> | ||||||
|       using type = U; |   struct ArrayHolder { | ||||||
|       static pointer AsValue(type* p) { return p; } |     InnerT array[InnerN]; | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     // Partial specialization for elements of array type.
 |  | ||||||
|     template <typename U, size_t N> |  | ||||||
|     struct SelectImpl<U[N]> { |  | ||||||
|       struct Holder { U v[N]; }; |  | ||||||
|       using type = Holder; |  | ||||||
|       static pointer AsValue(type* p) { return &p->v; } |  | ||||||
|     }; |  | ||||||
|     using Impl = SelectImpl<value_type>; |  | ||||||
| 
 |  | ||||||
|    public: |  | ||||||
|     using type = typename Impl::type; |  | ||||||
| 
 |  | ||||||
|     static pointer AsValue(type *p) { return Impl::AsValue(p); } |  | ||||||
| 
 |  | ||||||
|     // TODO(billydonahue): fix the type aliasing violation
 |  | ||||||
|     // this assertion hints at.
 |  | ||||||
|     static_assert(sizeof(type) == sizeof(value_type), |  | ||||||
|                   "Holder must be same size as value_type"); |  | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   using Holder = typename HolderTraits::type; |   using Holder = absl::conditional_t<std::is_array<value_type>::value, | ||||||
|   static pointer AsValue(Holder *p) { return HolderTraits::AsValue(p); } |                                      ArrayHolder<value_type>, value_type>; | ||||||
|  | 
 | ||||||
|  |   static_assert(sizeof(Holder) == sizeof(value_type), ""); | ||||||
|  |   static_assert(alignof(Holder) == alignof(value_type), ""); | ||||||
|  | 
 | ||||||
|  |   static pointer AsValue(pointer ptr) { return ptr; } | ||||||
|  |   static pointer AsValue(ArrayHolder<value_type>* ptr) { | ||||||
|  |     return std::addressof(ptr->array); | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   // InlineSpace
 |   // InlineSpace
 | ||||||
|   //
 |   //
 | ||||||
|  |  | ||||||
|  | @ -403,20 +403,16 @@ class civil_time { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Binary arithmetic operators.
 |   // Binary arithmetic operators.
 | ||||||
|   inline friend CONSTEXPR_M civil_time operator+(civil_time a, |   friend CONSTEXPR_F civil_time operator+(civil_time a, diff_t n) noexcept { | ||||||
|                                                  diff_t n) noexcept { |  | ||||||
|     return a += n; |     return a += n; | ||||||
|   } |   } | ||||||
|   inline friend CONSTEXPR_M civil_time operator+(diff_t n, |   friend CONSTEXPR_F civil_time operator+(diff_t n, civil_time a) noexcept { | ||||||
|                                                  civil_time a) noexcept { |  | ||||||
|     return a += n; |     return a += n; | ||||||
|   } |   } | ||||||
|   inline friend CONSTEXPR_M civil_time operator-(civil_time a, |   friend CONSTEXPR_F civil_time operator-(civil_time a, diff_t n) noexcept { | ||||||
|                                                  diff_t n) noexcept { |  | ||||||
|     return a -= n; |     return a -= n; | ||||||
|   } |   } | ||||||
|   inline friend CONSTEXPR_M diff_t operator-(const civil_time& lhs, |   friend CONSTEXPR_F diff_t operator-(civil_time lhs, civil_time rhs) noexcept { | ||||||
|                                              const civil_time& rhs) noexcept { |  | ||||||
|     return difference(T{}, lhs.f_, rhs.f_); |     return difference(T{}, lhs.f_, rhs.f_); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -434,8 +430,8 @@ class civil_time { | ||||||
| 
 | 
 | ||||||
| // Disallows difference between differently aligned types.
 | // Disallows difference between differently aligned types.
 | ||||||
| // auto n = civil_day(...) - civil_hour(...);  // would be confusing.
 | // auto n = civil_day(...) - civil_hour(...);  // would be confusing.
 | ||||||
| template <typename Tag1, typename Tag2> | template <typename T, typename U> | ||||||
| CONSTEXPR_F diff_t operator-(civil_time<Tag1>, civil_time<Tag2>) = delete; | CONSTEXPR_F diff_t operator-(civil_time<T>, civil_time<U>) = delete; | ||||||
| 
 | 
 | ||||||
| using civil_year = civil_time<year_tag>; | using civil_year = civil_time<year_tag>; | ||||||
| using civil_month = civil_time<month_tag>; | using civil_month = civil_time<month_tag>; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue