- b76f5d50e1cb55050ef6004d6097dfdf0a806ff5 Fix ABSL_HAVE_THREAD_LOCAL for iOS < 8.0. by Matt Armstrong <marmstrong@google.com> - 1dc71788a3f4ef601e03cbea59e36901479cde35 Add missing #include <intrin.h> to use __nop() on MSVC. by Derek Mauro <dmauro@google.com> - f63ca6c7e87a7961912995b518b93af41b04bfa1 Fix typo (implict -> implicit) by Abseil Team <absl-team@google.com> - 8096006dc52368f166ccd22e25fcee334e142508 Fix a typo. by Abseil Team <absl-team@google.com> - c673a4a59790329fab33536caed6733dc03ec2a1 Add missing ":" in TODO. by Abseil Team <absl-team@google.com> - 8125d214356501af0f3a8b3bb577eed083f0493f Fix comment nit. by Abseil Team <absl-team@google.com> GitOrigin-RevId: b76f5d50e1cb55050ef6004d6097dfdf0a806ff5 Change-Id: I0168eb0c92b20ece2fe5ee54573c7720d00fd0b3
		
			
				
	
	
		
			60 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright 2017 The Abseil Authors.
 | |
| //
 | |
| // Licensed under the Apache License, Version 2.0 (the "License");
 | |
| // you may not use this file except in compliance with the License.
 | |
| // You may obtain a copy of the License at
 | |
| //
 | |
| //      http://www.apache.org/licenses/LICENSE-2.0
 | |
| //
 | |
| // Unless required by applicable law or agreed to in writing, software
 | |
| // distributed under the License is distributed on an "AS IS" BASIS,
 | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| // See the License for the specific language governing permissions and
 | |
| // limitations under the License.
 | |
| 
 | |
| #include "absl/base/config.h"
 | |
| 
 | |
| #include <cstdint>
 | |
| 
 | |
| #include "gtest/gtest.h"
 | |
| #include "absl/synchronization/internal/thread_pool.h"
 | |
| 
 | |
| namespace {
 | |
| 
 | |
| TEST(ConfigTest, Endianness) {
 | |
|   union {
 | |
|     uint32_t value;
 | |
|     uint8_t data[sizeof(uint32_t)];
 | |
|   } number;
 | |
|   number.data[0] = 0x00;
 | |
|   number.data[1] = 0x01;
 | |
|   number.data[2] = 0x02;
 | |
|   number.data[3] = 0x03;
 | |
| #if defined(ABSL_IS_LITTLE_ENDIAN) && defined(ABSL_IS_BIG_ENDIAN)
 | |
| #error Both ABSL_IS_LITTLE_ENDIAN and ABSL_IS_BIG_ENDIAN are defined
 | |
| #elif defined(ABSL_IS_LITTLE_ENDIAN)
 | |
|   EXPECT_EQ(UINT32_C(0x03020100), number.value);
 | |
| #elif defined(ABSL_IS_BIG_ENDIAN)
 | |
|   EXPECT_EQ(UINT32_C(0x00010203), number.value);
 | |
| #else
 | |
| #error Unknown endianness
 | |
| #endif
 | |
| }
 | |
| 
 | |
| #if defined(ABSL_HAVE_THREAD_LOCAL)
 | |
| TEST(ConfigTest, ThreadLocal) {
 | |
|   static thread_local int mine_mine_mine = 16;
 | |
|   EXPECT_EQ(16, mine_mine_mine);
 | |
|   {
 | |
|     absl::synchronization_internal::ThreadPool pool(1);
 | |
|     pool.Schedule([&] {
 | |
|       EXPECT_EQ(16, mine_mine_mine);
 | |
|       mine_mine_mine = 32;
 | |
|       EXPECT_EQ(32, mine_mine_mine);
 | |
|     });
 | |
|   }
 | |
|   EXPECT_EQ(16, mine_mine_mine);
 | |
| }
 | |
| #endif
 | |
| 
 | |
| }  // namespace
 |