mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
[MDEV-28162] Replace PFS_atomic with std::atomic<T>
PFS_atomic class contains wrappers around my_atomic_* operations, which are macros to GNU atomic operations (__atomic_*). Due to different implementations of compilers, clang may encounter errors when compiling on x86_32 architecture. The following functions are replaced with C++ std::atomic type in performance schema code base: - PFS_atomic::store_*() -> my_atomic_store* -> __atomic_store_n() => std::atomic<T>::store() - PFS_atomic::load_*() -> my_atomic_load* -> __atomic_load_n() => std::atomic<T>::load() - PFS_atomic::add_*() -> my_atomic_add* -> __atomic_fetch_add() => std::atomic<T>::fetch_add() - PFS_atomic::cas_*() -> my_atomic_cas* -> __atomic_compare_exchange_n() => std::atomic<T>::compare_exchange_strong() and PFS_atomic class could be dropped completely. Note that in the wrapper memory order passed to original GNU atomic extensions are hard-coded as `__ATOMIC_SEQ_CST`, which is equivalent to `std::memory_order_seq_cst` in C++, and is the default parameter for std::atomic_* functions. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services.
This commit is contained in:
committed by
Marko Mäkelä
parent
d5bad49011
commit
55db59f16d
@@ -87,7 +87,7 @@ public:
|
||||
if (m_full)
|
||||
return NULL;
|
||||
|
||||
monotonic= PFS_atomic::add_u32(& m_monotonic.m_u32, 1);
|
||||
monotonic= m_monotonic.m_u32.fetch_add(1);
|
||||
monotonic_max= monotonic + static_cast<uint>(m_max);
|
||||
|
||||
while (monotonic < monotonic_max)
|
||||
@@ -99,7 +99,8 @@ public:
|
||||
{
|
||||
return pfs;
|
||||
}
|
||||
monotonic= PFS_atomic::add_u32(& m_monotonic.m_u32, 1);
|
||||
monotonic= m_monotonic.m_u32.fetch_add(1);
|
||||
|
||||
}
|
||||
|
||||
m_full= true;
|
||||
@@ -517,7 +518,7 @@ public:
|
||||
|
||||
ulong get_row_count()
|
||||
{
|
||||
ulong page_count= PFS_atomic::load_u32(& m_max_page_index.m_u32);
|
||||
ulong page_count= m_max_page_index.m_u32.load();
|
||||
|
||||
return page_count * PFS_PAGE_SIZE;
|
||||
}
|
||||
@@ -554,11 +555,11 @@ public:
|
||||
/*
|
||||
1: Try to find an available record within the existing pages
|
||||
*/
|
||||
current_page_count= PFS_atomic::load_u32(& m_max_page_index.m_u32);
|
||||
current_page_count= m_max_page_index.m_u32.load();
|
||||
|
||||
if (current_page_count != 0)
|
||||
{
|
||||
monotonic= PFS_atomic::load_u32(& m_monotonic.m_u32);
|
||||
monotonic= m_monotonic.m_u32.load();
|
||||
monotonic_max= monotonic + current_page_count;
|
||||
|
||||
while (monotonic < monotonic_max)
|
||||
@@ -602,7 +603,7 @@ public:
|
||||
counter faster and then move on to the detection of new pages,
|
||||
in part 2: below.
|
||||
*/
|
||||
monotonic= PFS_atomic::add_u32(& m_monotonic.m_u32, 1);
|
||||
monotonic= m_monotonic.m_u32.fetch_add(1);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -683,7 +684,7 @@ public:
|
||||
my_atomic_storeptr(typed_addr, ptr);
|
||||
|
||||
/* Advertise the new page */
|
||||
PFS_atomic::add_u32(& m_max_page_index.m_u32, 1);
|
||||
m_max_page_index.m_u32.fetch_add(1);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(& m_critical_section);
|
||||
|
Reference in New Issue
Block a user