Skip to content

Commit 1c417da

Browse files
committed
Remove uses of ATOMIC_VAR_INIT
ATOMIC_VAR_INIT has a trivial definition `#define ATOMIC_VAR_INIT(value) (value)`, is deprecated in C17/C++20, and will be removed in newer standards.
1 parent 8f0814f commit 1c417da

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

lldb/test/API/tools/lldb-server/vCont-threads/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
pseudo_barrier_t barrier;
1616
std::mutex print_mutex;
17-
std::atomic<bool> can_work = ATOMIC_VAR_INIT(false);
17+
std::atomic<bool> can_work = false;
1818
thread_local volatile sig_atomic_t can_exit_now = false;
1919

2020
static void sigint_handler(int signo) {}

llvm/lib/Support/PrettyStackTrace.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ static LLVM_THREAD_LOCAL PrettyStackTraceEntry *PrettyStackTraceHead = nullptr;
6464
// the current thread". If the user happens to overflow an 'unsigned' with
6565
// SIGINFO requests, it's possible that some threads will stop responding to it,
6666
// but the program won't crash.
67-
static volatile std::atomic<unsigned> GlobalSigInfoGenerationCounter =
68-
ATOMIC_VAR_INIT(1);
67+
static volatile std::atomic<unsigned> GlobalSigInfoGenerationCounter = 1;
6968
static LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter = 0;
7069

7170
namespace llvm {

llvm/lib/Support/Unix/Signals.inc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,20 @@ static void InfoSignalHandler(int Sig); // defined below.
8484

8585
using SignalHandlerFunctionType = void (*)();
8686
/// The function to call if ctrl-c is pressed.
87-
static std::atomic<SignalHandlerFunctionType> InterruptFunction =
88-
ATOMIC_VAR_INIT(nullptr);
89-
static std::atomic<SignalHandlerFunctionType> InfoSignalFunction =
90-
ATOMIC_VAR_INIT(nullptr);
87+
static std::atomic<SignalHandlerFunctionType> InterruptFunction = nullptr;
88+
static std::atomic<SignalHandlerFunctionType> InfoSignalFunction = nullptr;
9189
/// The function to call on SIGPIPE (one-time use only).
9290
static std::atomic<SignalHandlerFunctionType> OneShotPipeSignalFunction =
93-
ATOMIC_VAR_INIT(nullptr);
91+
nullptr;
9492

9593
namespace {
9694
/// Signal-safe removal of files.
9795
/// Inserting and erasing from the list isn't signal-safe, but removal of files
9896
/// themselves is signal-safe. Memory is freed when the head is freed, deletion
9997
/// is therefore not signal-safe either.
10098
class FileToRemoveList {
101-
std::atomic<char *> Filename = ATOMIC_VAR_INIT(nullptr);
102-
std::atomic<FileToRemoveList *> Next = ATOMIC_VAR_INIT(nullptr);
99+
std::atomic<char *> Filename = nullptr;
100+
std::atomic<FileToRemoveList *> Next = nullptr;
103101

104102
FileToRemoveList() = default;
105103
// Not signal-safe.
@@ -188,7 +186,7 @@ public:
188186
Head.exchange(OldHead);
189187
}
190188
};
191-
static std::atomic<FileToRemoveList *> FilesToRemove = ATOMIC_VAR_INIT(nullptr);
189+
static std::atomic<FileToRemoveList *> FilesToRemove = nullptr;
192190

193191
/// Clean up the list in a signal-friendly manner.
194192
/// Recall that signals can fire during llvm_shutdown. If this occurs we should
@@ -248,7 +246,7 @@ static const int InfoSigs[] = {SIGUSR1
248246
static const size_t NumSigs = std::size(IntSigs) + std::size(KillSigs) +
249247
std::size(InfoSigs) + 1 /* SIGPIPE */;
250248

251-
static std::atomic<unsigned> NumRegisteredSignals = ATOMIC_VAR_INIT(0);
249+
static std::atomic<unsigned> NumRegisteredSignals = 0;
252250
static struct {
253251
struct sigaction SA;
254252
int SigNo;

0 commit comments

Comments
 (0)