Export of internal Abseil changes.
-- 5f1ab09522226336830d9ea6ef7276d37f536ac5 by Abseil Team <absl-team@google.com>: Clarify the documentation of ABSL_MUST_USE_RESULT. PiperOrigin-RevId: 221663609 -- af4c8359a20d56369fd1dce318220cf3be03ca66 by Greg Falcon <gfalcon@google.com>: Internal change PiperOrigin-RevId: 221538448 -- 487cd09bd1942bf607080deeae38fee6ce66f294 by Eric Fiselier <ericwf@google.com>: Work around emscripten bugs and missing features in absl/time:time_test. The emscripten toolchain has a couple of issues that cause time_test to fail. Specifically: 1) emscripten doesn't support signals. 2) The javascript implementation of strftime/strptime use different expansions of '%c' that mean it doesn't round-trip. PiperOrigin-RevId: 221523701 -- 5823652e6a200b97b07334bc47128dfac40e20fc by Xiaoyi Zhang <zhangxy@google.com>: Fix MSVC compiler warning by explicitly casting to char. Currently our MSVC build breaks with the following error: raw_hash_set.h(406): warning C4309: 'argument': truncation of constant value PiperOrigin-RevId: 221492585 -- c5806358320711a5efbe5c523df13e14ab53a17d by Greg Falcon <gfalcon@google.com>: Replace calls to getpagesize() with the more portable sysconf(_SC_PAGESIZE); the latter is in POSIX 1.0 and is called out in the Linux `getpagesize` man page as a more portable spelling. PiperOrigin-RevId: 221492471 -- 19ffe82851072229bb7ce73f754ffe4c18e8c575 by Abseil Team <absl-team@google.com>: Fix -Wundef error in absl/hash/internal/hash.h. PiperOrigin-RevId: 221444120 -- b30f3d0a848563b6e4ec33f3dc085831dfabb748 by Jon Cohen <cohenjon@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 221339736 GitOrigin-RevId: 5f1ab09522226336830d9ea6ef7276d37f536ac5 Change-Id: I96223d522d98bf6616dea88eb047c2d536eeddd0
This commit is contained in:
		
							parent
							
								
									7b46e1d31a
								
							
						
					
					
						commit
						a06c4a1d90
					
				
					 10 changed files with 47 additions and 24 deletions
				
			
		|  | @ -402,17 +402,28 @@ | ||||||
| 
 | 
 | ||||||
| // ABSL_MUST_USE_RESULT
 | // ABSL_MUST_USE_RESULT
 | ||||||
| //
 | //
 | ||||||
| // Tells the compiler to warn about unused return values for functions declared
 | // Tells the compiler to warn about unused results.
 | ||||||
| // with this macro. The macro must appear as the very first part of a function
 |  | ||||||
| // declaration or definition:
 |  | ||||||
| //
 | //
 | ||||||
| // Example:
 | // When annotating a function, it must appear as the first part of the
 | ||||||
|  | // declaration or definition. The compiler will warn if the return value from
 | ||||||
|  | // such a function is unused:
 | ||||||
| //
 | //
 | ||||||
| //   ABSL_MUST_USE_RESULT Sprocket* AllocateSprocket();
 | //   ABSL_MUST_USE_RESULT Sprocket* AllocateSprocket();
 | ||||||
|  | //   AllocateSprocket();  // Triggers a warning.
 | ||||||
| //
 | //
 | ||||||
| // This placement has the broadest compatibility with GCC, Clang, and MSVC, with
 | // When annotating a class, it is equivalent to annotating every function which
 | ||||||
| // both defs and decls, and with GCC-style attributes, MSVC declspec, C++11
 | // returns an instance.
 | ||||||
| // and C++17 attributes.
 | //
 | ||||||
|  | //   class ABSL_MUST_USE_RESULT Sprocket {};
 | ||||||
|  | //   Sprocket();  // Triggers a warning.
 | ||||||
|  | //
 | ||||||
|  | //   Sprocket MakeSprocket();
 | ||||||
|  | //   MakeSprocket();  // Triggers a warning.
 | ||||||
|  | //
 | ||||||
|  | // Note that references and pointers are not instances:
 | ||||||
|  | //
 | ||||||
|  | //   Sprocket* SprocketPointer();
 | ||||||
|  | //   SprocketPointer();  // Does *not* trigger a warning.
 | ||||||
| //
 | //
 | ||||||
| // ABSL_MUST_USE_RESULT allows using cast-to-void to suppress the unused result
 | // ABSL_MUST_USE_RESULT allows using cast-to-void to suppress the unused result
 | ||||||
| // warning. For that, warn_unused_result is used only for clang but not for gcc.
 | // warning. For that, warn_unused_result is used only for clang but not for gcc.
 | ||||||
|  |  | ||||||
|  | @ -274,7 +274,8 @@ | ||||||
| #error ABSL_HAVE_MMAP cannot be directly set | #error ABSL_HAVE_MMAP cannot be directly set | ||||||
| #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) ||   \ | #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) ||   \ | ||||||
|     defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \ |     defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \ | ||||||
|     defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) |     defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \ | ||||||
|  |     defined(__ASYLO__) | ||||||
| #define ABSL_HAVE_MMAP 1 | #define ABSL_HAVE_MMAP 1 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | @ -328,6 +329,8 @@ | ||||||
| #define ABSL_HAVE_ALARM 1 | #define ABSL_HAVE_ALARM 1 | ||||||
| #elif defined(_MSC_VER) | #elif defined(_MSC_VER) | ||||||
| // feature tests for Microsoft's library
 | // feature tests for Microsoft's library
 | ||||||
|  | #elif defined(__EMSCRIPTEN__) | ||||||
|  | // emscripten doesn't support signals
 | ||||||
| #elif defined(__native_client__) | #elif defined(__native_client__) | ||||||
| #else | #else | ||||||
| // other standard libraries
 | // other standard libraries
 | ||||||
|  |  | ||||||
|  | @ -75,7 +75,7 @@ inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, | ||||||
|   // On these architectures, implement mmap with mmap2.
 |   // On these architectures, implement mmap with mmap2.
 | ||||||
|   static int pagesize = 0; |   static int pagesize = 0; | ||||||
|   if (pagesize == 0) { |   if (pagesize == 0) { | ||||||
|     pagesize = getpagesize(); |     pagesize = sysconf(_SC_PAGESIZE); | ||||||
|   } |   } | ||||||
|   if (offset < 0 || offset % pagesize != 0) { |   if (offset < 0 || offset % pagesize != 0) { | ||||||
|     errno = EINVAL; |     errno = EINVAL; | ||||||
|  |  | ||||||
|  | @ -208,7 +208,7 @@ struct LowLevelAlloc::Arena { | ||||||
|   int32_t allocation_count GUARDED_BY(mu); |   int32_t allocation_count GUARDED_BY(mu); | ||||||
|   // flags passed to NewArena
 |   // flags passed to NewArena
 | ||||||
|   const uint32_t flags; |   const uint32_t flags; | ||||||
|   // Result of getpagesize()
 |   // Result of sysconf(_SC_PAGESIZE)
 | ||||||
|   const size_t pagesize; |   const size_t pagesize; | ||||||
|   // Lowest power of two >= max(16, sizeof(AllocList))
 |   // Lowest power of two >= max(16, sizeof(AllocList))
 | ||||||
|   const size_t roundup; |   const size_t roundup; | ||||||
|  | @ -325,7 +325,7 @@ size_t GetPageSize() { | ||||||
|   GetSystemInfo(&system_info); |   GetSystemInfo(&system_info); | ||||||
|   return std::max(system_info.dwPageSize, system_info.dwAllocationGranularity); |   return std::max(system_info.dwPageSize, system_info.dwAllocationGranularity); | ||||||
| #else | #else | ||||||
|   return getpagesize(); |   return sysconf(_SC_PAGESIZE); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -403,7 +403,7 @@ struct GroupSse2Impl { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const { |   void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const { | ||||||
|     auto msbs = _mm_set1_epi8(0x80); |     auto msbs = _mm_set1_epi8(static_cast<char>(-128)); | ||||||
|     auto x126 = _mm_set1_epi8(126); |     auto x126 = _mm_set1_epi8(126); | ||||||
| #if SWISSTABLE_HAVE_SSSE3 | #if SWISSTABLE_HAVE_SSSE3 | ||||||
|     auto res = _mm_or_si128(_mm_shuffle_epi8(x126, ctrl), msbs); |     auto res = _mm_or_si128(_mm_shuffle_epi8(x126, ctrl), msbs); | ||||||
|  |  | ||||||
|  | @ -119,7 +119,7 @@ const char* FailureSignalToString(int signo) { | ||||||
| #ifndef _WIN32 | #ifndef _WIN32 | ||||||
| 
 | 
 | ||||||
| static bool SetupAlternateStackOnce() { | static bool SetupAlternateStackOnce() { | ||||||
|   const size_t page_mask = getpagesize() - 1; |   const size_t page_mask = sysconf(_SC_PAGESIZE) - 1; | ||||||
|   size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask; |   size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask; | ||||||
| #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ | #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ | ||||||
|     defined(THREAD_SANITIZER) |     defined(THREAD_SANITIZER) | ||||||
|  |  | ||||||
|  | @ -333,7 +333,7 @@ static std::atomic<Symbolizer *> g_cached_symbolizer; | ||||||
| }  // namespace
 | }  // namespace
 | ||||||
| 
 | 
 | ||||||
| static int SymbolizerSize() { | static int SymbolizerSize() { | ||||||
|   int pagesize = getpagesize(); |   int pagesize = sysconf(_SC_PAGESIZE); | ||||||
|   return ((sizeof(Symbolizer) - 1) / pagesize + 1) * pagesize; |   return ((sizeof(Symbolizer) - 1) / pagesize + 1) * pagesize; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -303,13 +303,13 @@ H hash_tuple(H hash_state, const Tuple& t, absl::index_sequence<Is...>) { | ||||||
| 
 | 
 | ||||||
| // AbslHashValue for hashing tuples
 | // AbslHashValue for hashing tuples
 | ||||||
| template <typename H, typename... Ts> | template <typename H, typename... Ts> | ||||||
| #if _MSC_VER | #if defined(_MSC_VER) | ||||||
| // This SFINAE gets MSVC confused under some conditions. Let's just disable it
 | // This SFINAE gets MSVC confused under some conditions. Let's just disable it
 | ||||||
| // for now.
 | // for now.
 | ||||||
| H | H | ||||||
| #else | #else  // _MSC_VER
 | ||||||
| typename std::enable_if<absl::conjunction<is_hashable<Ts>...>::value, H>::type | typename std::enable_if<absl::conjunction<is_hashable<Ts>...>::value, H>::type | ||||||
| #endif | #endif  // _MSC_VER
 | ||||||
| AbslHashValue(H hash_state, const std::tuple<Ts...>& t) { | AbslHashValue(H hash_state, const std::tuple<Ts...>& t) { | ||||||
|   return hash_internal::hash_tuple(std::move(hash_state), t, |   return hash_internal::hash_tuple(std::move(hash_state), t, | ||||||
|                                    absl::make_index_sequence<sizeof...(Ts)>()); |                                    absl::make_index_sequence<sizeof...(Ts)>()); | ||||||
|  | @ -545,7 +545,7 @@ hash_range_or_bytes(H hash_state, const T* data, size_t size) { | ||||||
| // In MSVC we can't probe std::hash or stdext::hash because it triggers a
 | // In MSVC we can't probe std::hash or stdext::hash because it triggers a
 | ||||||
| // static_assert instead of failing substitution.
 | // static_assert instead of failing substitution.
 | ||||||
| #if defined(_MSC_VER) | #if defined(_MSC_VER) | ||||||
| #undef ABSL_HASH_INTERNAL_CAN_POISON_ | #define ABSL_HASH_INTERNAL_CAN_POISON_ 0 | ||||||
| #else   // _MSC_VER
 | #else   // _MSC_VER
 | ||||||
| #define ABSL_HASH_INTERNAL_CAN_POISON_ 1 | #define ABSL_HASH_INTERNAL_CAN_POISON_ 1 | ||||||
| #endif  // _MSC_VER
 | #endif  // _MSC_VER
 | ||||||
|  | @ -553,6 +553,8 @@ hash_range_or_bytes(H hash_state, const T* data, size_t size) { | ||||||
| #if defined(ABSL_INTERNAL_LEGACY_HASH_NAMESPACE) && \ | #if defined(ABSL_INTERNAL_LEGACY_HASH_NAMESPACE) && \ | ||||||
|     ABSL_HASH_INTERNAL_CAN_POISON_ |     ABSL_HASH_INTERNAL_CAN_POISON_ | ||||||
| #define ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_ 1 | #define ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_ 1 | ||||||
|  | #else | ||||||
|  | #define ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_ 0 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| enum class InvokeHashTag { | enum class InvokeHashTag { | ||||||
|  |  | ||||||
|  | @ -394,7 +394,12 @@ TEST(FormatParse, RoundTrip) { | ||||||
|   // work. On Windows, `absl::ParseTime()` falls back to std::get_time() which
 |   // work. On Windows, `absl::ParseTime()` falls back to std::get_time() which
 | ||||||
|   // appears to fail on "%c" (or at least on the "%c" text produced by
 |   // appears to fail on "%c" (or at least on the "%c" text produced by
 | ||||||
|   // `strftime()`). This makes it fail the round-trip test.
 |   // `strftime()`). This makes it fail the round-trip test.
 | ||||||
| #ifndef _MSC_VER |   //
 | ||||||
|  |   // Under the emscripten compiler `absl::ParseTime() falls back to
 | ||||||
|  |   // `strptime()`, but that ends up using a different definition for "%c"
 | ||||||
|  |   // compared to `strftime()`, also causing the round-trip test to fail
 | ||||||
|  |   // (see https://github.com/kripken/emscripten/pull/7491).
 | ||||||
|  | #if !defined(_MSC_VER) && !defined(__EMSCRIPTEN__) | ||||||
|   // Even though we don't know what %c will produce, it should roundtrip,
 |   // Even though we don't know what %c will produce, it should roundtrip,
 | ||||||
|   // but only in the 0-offset timezone.
 |   // but only in the 0-offset timezone.
 | ||||||
|   { |   { | ||||||
|  | @ -403,7 +408,7 @@ TEST(FormatParse, RoundTrip) { | ||||||
|     EXPECT_TRUE(absl::ParseTime("%c", s, &out, &err)) << s << ": " << err; |     EXPECT_TRUE(absl::ParseTime("%c", s, &out, &err)) << s << ": " << err; | ||||||
|     EXPECT_EQ(in, out); |     EXPECT_EQ(in, out); | ||||||
|   } |   } | ||||||
| #endif  // _MSC_VER
 | #endif  // !_MSC_VER && !__EMSCRIPTEN__
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST(FormatParse, RoundTripDistantFuture) { | TEST(FormatParse, RoundTripDistantFuture) { | ||||||
|  |  | ||||||
|  | @ -506,7 +506,9 @@ enum class weekday { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| CONSTEXPR_F weekday get_weekday(const civil_day& cd) noexcept { | CONSTEXPR_F weekday get_weekday(const civil_day& cd) noexcept { | ||||||
|   CONSTEXPR_D weekday k_weekday_by_sun_off[7] = { |   CONSTEXPR_D weekday k_weekday_by_mon_off[13] = { | ||||||
|  |       weekday::monday,    weekday::tuesday,  weekday::wednesday, | ||||||
|  |       weekday::thursday,  weekday::friday,   weekday::saturday, | ||||||
|       weekday::sunday,    weekday::monday,   weekday::tuesday, |       weekday::sunday,    weekday::monday,   weekday::tuesday, | ||||||
|       weekday::wednesday, weekday::thursday, weekday::friday, |       weekday::wednesday, weekday::thursday, weekday::friday, | ||||||
|       weekday::saturday, |       weekday::saturday, | ||||||
|  | @ -517,7 +519,7 @@ CONSTEXPR_F weekday get_weekday(const civil_day& cd) noexcept { | ||||||
|   year_t wd = 2400 + (cd.year() % 400) - (cd.month() < 3); |   year_t wd = 2400 + (cd.year() % 400) - (cd.month() < 3); | ||||||
|   wd += wd / 4 - wd / 100 + wd / 400; |   wd += wd / 4 - wd / 100 + wd / 400; | ||||||
|   wd += k_weekday_offsets[cd.month()] + cd.day(); |   wd += k_weekday_offsets[cd.month()] + cd.day(); | ||||||
|   return k_weekday_by_sun_off[(wd % 7 + 7) % 7]; |   return k_weekday_by_mon_off[wd % 7 + 6]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ////////////////////////////////////////////////////////////////////////
 | ////////////////////////////////////////////////////////////////////////
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue