Skip to content

Commit

Permalink
Suppress clang warning "ATOMIC_FLAG_INIT marked deprecated"
Browse files Browse the repository at this point in the history
In C++20, macro 'ATOMIC_FLAG_INIT' has been marked as deprecated.
We need still to use it to be able to compile for C++17.
For now, just suppress this warning.
  • Loading branch information
tolk-vm committed Jan 27, 2025
1 parent c720204 commit 1397ff3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tdutils/td/utils/SpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class SpinLock {
}

private:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
std::atomic_flag flag_ = ATOMIC_FLAG_INIT;
#pragma clang diagnostic pop
void unlock() {
flag_.clear(std::memory_order_release);
}
Expand Down
3 changes: 3 additions & 0 deletions tdutils/td/utils/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ void TsCerr::enterCritical() {
void TsCerr::exitCritical() {
lock_.clear(std::memory_order_release);
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
TsCerr::Lock TsCerr::lock_ = ATOMIC_FLAG_INIT;
#pragma clang diagnostic pop

class DefaultLog : public LogInterface {
public:
Expand Down
3 changes: 3 additions & 0 deletions tdutils/td/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ class TsLog : public LogInterface {

private:
LogInterface *log_ = nullptr;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
#pragma clang diagnostic pop
void enter_critical() {
while (lock_.test_and_set(std::memory_order_acquire)) {
// spin
Expand Down
3 changes: 3 additions & 0 deletions tdutils/td/utils/port/detail/PollableFd.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class PollableFdInfo : private ListNode {

private:
NativeFd fd_{};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
#pragma clang diagnostic pop
PollFlagsSet flags_;
#if TD_PORT_WINDOWS
SpinLock observer_lock_;
Expand Down

0 comments on commit 1397ff3

Please sign in to comment.