diff --git a/test/syscalls/linux/futex.cc b/test/syscalls/linux/futex.cc index a84787a10..3f108b7d7 100644 --- a/test/syscalls/linux/futex.cc +++ b/test/syscalls/linux/futex.cc @@ -176,7 +176,7 @@ TEST_P(PrivateAndSharedFutexTest, Wait_ZeroTimeout) { } TEST_P(PrivateAndSharedFutexTest, Wait_Timeout) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); MonotonicTimer timer; timer.Start(); @@ -187,7 +187,7 @@ TEST_P(PrivateAndSharedFutexTest, Wait_Timeout) { } TEST_P(PrivateAndSharedFutexTest, Wait_BitsetTimeout) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); MonotonicTimer timer; timer.Start(); @@ -199,7 +199,7 @@ TEST_P(PrivateAndSharedFutexTest, Wait_BitsetTimeout) { } TEST_P(PrivateAndSharedFutexTest, WaitBitset_NegativeTimeout) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); MonotonicTimer timer; timer.Start(); @@ -209,20 +209,20 @@ TEST_P(PrivateAndSharedFutexTest, WaitBitset_NegativeTimeout) { } TEST_P(PrivateAndSharedFutexTest, Wait_WrongVal) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); EXPECT_THAT(futex_wait(IsPrivate(), &a, a + 1), SyscallFailsWithErrno(EAGAIN)); } TEST_P(PrivateAndSharedFutexTest, Wait_ZeroBitset) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); EXPECT_THAT(futex_wait_bitset(IsPrivate(), &a, a, 0), SyscallFailsWithErrno(EINVAL)); } TEST_P(PrivateAndSharedFutexTest, Wake1) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); // Prevent save/restore from interrupting futex_wait, which will cause it to // return EAGAIN instead of the expected result if futex_wait is restarted @@ -242,7 +242,7 @@ TEST_P(PrivateAndSharedFutexTest, Wake1) { TEST_P(PrivateAndSharedFutexTest, Wake0) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); // Prevent save/restore from interrupting futex_wait, which will cause it to // return EAGAIN instead of the expected result if futex_wait is restarted @@ -263,7 +263,7 @@ TEST_P(PrivateAndSharedFutexTest, Wake0) { TEST_P(PrivateAndSharedFutexTest, WakeAll) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); DisableSave ds; constexpr int kThreads = 5; @@ -284,7 +284,7 @@ TEST_P(PrivateAndSharedFutexTest, WakeAll) { TEST_P(PrivateAndSharedFutexTest, WakeSome) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); DisableSave ds; constexpr int kThreads = 5; @@ -333,7 +333,7 @@ TEST_P(PrivateAndSharedFutexTest, WakeSome) { TEST_P(PrivateAndSharedFutexTest, WaitBitset_Wake) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); DisableSave ds; ScopedThread thread([&] { @@ -348,7 +348,7 @@ TEST_P(PrivateAndSharedFutexTest, WaitBitset_Wake) { TEST_P(PrivateAndSharedFutexTest, Wait_WakeBitset) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); DisableSave ds; ScopedThread thread([&] { @@ -363,7 +363,7 @@ TEST_P(PrivateAndSharedFutexTest, Wait_WakeBitset) { TEST_P(PrivateAndSharedFutexTest, WaitBitset_WakeBitsetMatch) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); constexpr int kBitset = 0b01001000; @@ -381,7 +381,7 @@ TEST_P(PrivateAndSharedFutexTest, WaitBitset_WakeBitsetMatch) { TEST_P(PrivateAndSharedFutexTest, WaitBitset_WakeBitsetNoMatch) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); constexpr int kWaitBitset = 0b01000001; constexpr int kWakeBitset = 0b00101000; @@ -403,8 +403,8 @@ TEST_P(PrivateAndSharedFutexTest, WaitBitset_WakeBitsetNoMatch) { TEST_P(PrivateAndSharedFutexTest, WakeOpCondSuccess) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); - std::atomic b = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); + std::atomic b(kInitialValue); DisableSave ds; ScopedThread thread_a([&] { @@ -430,8 +430,8 @@ TEST_P(PrivateAndSharedFutexTest, WakeOpCondSuccess) { TEST_P(PrivateAndSharedFutexTest, WakeOpCondFailure) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); - std::atomic b = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); + std::atomic b(kInitialValue); DisableSave ds; ScopedThread thread_a([&] { @@ -522,7 +522,7 @@ TEST_P(PrivateAndSharedFutexTest, WakeAfterCOWBreak) { TEST_P(PrivateAndSharedFutexTest, WakeWrongKind) { constexpr int kInitialValue = 1; - std::atomic a = ATOMIC_VAR_INIT(kInitialValue); + std::atomic a(kInitialValue); DisableSave ds; ScopedThread thread([&] { @@ -544,7 +544,7 @@ INSTANTIATE_TEST_SUITE_P(SharedPrivate, PrivateAndSharedFutexTest, // Passing null as the address only works for private futexes. TEST(PrivateFutexTest, WakeOp0Set) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); int futex_op = FUTEX_OP(FUTEX_OP_SET, 2, 0, 0); EXPECT_THAT(futex_wake_op(true, nullptr, &a, 0, 0, futex_op), @@ -553,7 +553,7 @@ TEST(PrivateFutexTest, WakeOp0Set) { } TEST(PrivateFutexTest, WakeOp0Add) { - std::atomic a = ATOMIC_VAR_INIT(1); + std::atomic a(1); int futex_op = FUTEX_OP(FUTEX_OP_ADD, 1, 0, 0); EXPECT_THAT(futex_wake_op(true, nullptr, &a, 0, 0, futex_op), SyscallSucceedsWithValue(0)); @@ -561,7 +561,7 @@ TEST(PrivateFutexTest, WakeOp0Add) { } TEST(PrivateFutexTest, WakeOp0Or) { - std::atomic a = ATOMIC_VAR_INIT(0b01); + std::atomic a(0b01); int futex_op = FUTEX_OP(FUTEX_OP_OR, 0b10, 0, 0); EXPECT_THAT(futex_wake_op(true, nullptr, &a, 0, 0, futex_op), SyscallSucceedsWithValue(0)); @@ -569,7 +569,7 @@ TEST(PrivateFutexTest, WakeOp0Or) { } TEST(PrivateFutexTest, WakeOp0Andn) { - std::atomic a = ATOMIC_VAR_INIT(0b11); + std::atomic a(0b11); int futex_op = FUTEX_OP(FUTEX_OP_ANDN, 0b10, 0, 0); EXPECT_THAT(futex_wake_op(true, nullptr, &a, 0, 0, futex_op), SyscallSucceedsWithValue(0)); @@ -577,7 +577,7 @@ TEST(PrivateFutexTest, WakeOp0Andn) { } TEST(PrivateFutexTest, WakeOp0Xor) { - std::atomic a = ATOMIC_VAR_INIT(0b1010); + std::atomic a(0b1010); int futex_op = FUTEX_OP(FUTEX_OP_XOR, 0b1100, 0, 0); EXPECT_THAT(futex_wake_op(true, nullptr, &a, 0, 0, futex_op), SyscallSucceedsWithValue(0)); @@ -650,7 +650,7 @@ TEST(SharedFutexTest, WakeInterprocessFile) { } TEST_P(PrivateAndSharedFutexTest, PIBasic) { - std::atomic a = ATOMIC_VAR_INIT(0); + std::atomic a(0); ASSERT_THAT(futex_lock_pi(IsPrivate(), &a), SyscallSucceeds()); EXPECT_EQ(a.load(), gettid()); @@ -664,7 +664,7 @@ TEST_P(PrivateAndSharedFutexTest, PIBasic) { TEST_P(PrivateAndSharedFutexTest, PIConcurrency) { DisableSave ds; // Too many syscalls. - std::atomic a = ATOMIC_VAR_INIT(0); + std::atomic a(0); const bool is_priv = IsPrivate(); std::unique_ptr threads[100]; @@ -681,7 +681,7 @@ TEST_P(PrivateAndSharedFutexTest, PIConcurrency) { } TEST_P(PrivateAndSharedFutexTest, PIWaiters) { - std::atomic a = ATOMIC_VAR_INIT(0); + std::atomic a(0); const bool is_priv = IsPrivate(); ASSERT_THAT(futex_lock_pi(is_priv, &a), SyscallSucceeds()); @@ -702,7 +702,7 @@ TEST_P(PrivateAndSharedFutexTest, PIWaiters) { } TEST_P(PrivateAndSharedFutexTest, PITryLock) { - std::atomic a = ATOMIC_VAR_INIT(0); + std::atomic a(0); const bool is_priv = IsPrivate(); ASSERT_THAT(futex_trylock_pi(IsPrivate(), &a), SyscallSucceeds()); @@ -720,7 +720,7 @@ TEST_P(PrivateAndSharedFutexTest, PITryLock) { TEST_P(PrivateAndSharedFutexTest, PITryLockConcurrency) { DisableSave ds; // Too many syscalls. - std::atomic a = ATOMIC_VAR_INIT(0); + std::atomic a(0); const bool is_priv = IsPrivate(); std::unique_ptr threads[10]; diff --git a/test/syscalls/linux/itimer.cc b/test/syscalls/linux/itimer.cc index 9fb04eae6..eb093dc44 100644 --- a/test/syscalls/linux/itimer.cc +++ b/test/syscalls/linux/itimer.cc @@ -87,8 +87,7 @@ TEST(ItimerTest, ItimervalUpdatedBeforeExpiration) { << itv.it_value.tv_usec << " microseconds"; } -ABSL_CONST_INIT static thread_local std::atomic_int signal_test_num_samples = - ATOMIC_VAR_INIT(0); +ABSL_CONST_INIT static thread_local std::atomic_int signal_test_num_samples(0); void SignalTestSignalHandler(int /*signum*/) { signal_test_num_samples++; } diff --git a/test/syscalls/linux/semaphore.cc b/test/syscalls/linux/semaphore.cc index 562e559c0..4de8b3a12 100644 --- a/test/syscalls/linux/semaphore.cc +++ b/test/syscalls/linux/semaphore.cc @@ -230,7 +230,7 @@ TEST(SemaphoreTest, SemOpBlock) { AutoSem sem(semget(IPC_PRIVATE, 1, 0600 | IPC_CREAT)); ASSERT_THAT(sem.get(), SyscallSucceeds()); - std::atomic blocked = ATOMIC_VAR_INIT(1); + std::atomic blocked(1); ScopedThread th([&sem, &blocked] { absl::SleepFor(absl::Milliseconds(100)); ASSERT_EQ(blocked.load(), 1); diff --git a/test/syscalls/linux/socket_bind_to_device_distribution.cc b/test/syscalls/linux/socket_bind_to_device_distribution.cc index dc7930bd1..aff222dfa 100644 --- a/test/syscalls/linux/socket_bind_to_device_distribution.cc +++ b/test/syscalls/linux/socket_bind_to_device_distribution.cc @@ -133,7 +133,7 @@ TEST_P(BindToDeviceDistributionTest, Tcp) { } constexpr int kConnectAttempts = 10000; - std::atomic connects_received = ATOMIC_VAR_INIT(0); + std::atomic connects_received(0); std::vector accept_counts(listener_fds.size(), 0); std::vector> listen_threads( listener_fds.size()); @@ -256,7 +256,7 @@ TEST_P(BindToDeviceDistributionTest, Udp) { } constexpr int kConnectAttempts = 10000; - std::atomic packets_received = ATOMIC_VAR_INIT(0); + std::atomic packets_received(0); std::vector packets_per_socket(listener_fds.size(), 0); std::vector> receiver_threads( listener_fds.size()); diff --git a/test/syscalls/linux/socket_inet_loopback.cc b/test/syscalls/linux/socket_inet_loopback.cc index 99e62a875..d2a0b8126 100644 --- a/test/syscalls/linux/socket_inet_loopback.cc +++ b/test/syscalls/linux/socket_inet_loopback.cc @@ -1411,7 +1411,7 @@ TEST_P(SocketInetReusePortTest, TcpPortReuseMultiThread) { ASSERT_NO_ERRNO(SetAddrPort(connector.family(), &conn_addr, port)); } - std::atomic connects_received = ATOMIC_VAR_INIT(0); + std::atomic connects_received(0); std::unique_ptr listen_thread[kThreadCount]; int accept_counts[kThreadCount] = {}; // TODO(avagin): figure how to not disable S/R for the whole test. @@ -1520,7 +1520,7 @@ TEST_P(SocketInetReusePortTest, UdpPortReuseMultiThread) { } constexpr int kConnectAttempts = 10000; - std::atomic packets_received = ATOMIC_VAR_INIT(0); + std::atomic packets_received(0); std::unique_ptr receiver_thread[kThreadCount]; int packets_per_socket[kThreadCount] = {}; // TODO(avagin): figure how to not disable S/R for the whole test. diff --git a/test/util/temp_path.cc b/test/util/temp_path.cc index 11399f372..f7c890302 100644 --- a/test/util/temp_path.cc +++ b/test/util/temp_path.cc @@ -32,7 +32,7 @@ namespace testing { namespace { -std::atomic global_temp_file_number = ATOMIC_VAR_INIT(1); +std::atomic global_temp_file_number(1); void TryDeleteRecursively(std::string const& path) { if (!path.empty()) {