This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] Remove volatile qualifiers from mt_allocator
- From: Richard Guenther <rguenther at suse dot de>
- To: libstdc++ at gcc dot gnu dot org
- Date: Wed, 30 Aug 2006 14:04:35 +0200 (CEST)
- Subject: [PATCH] Remove volatile qualifiers from mt_allocator
This patch removes volatile qualifiers from pointer members in
mt_allocator.h. It doesn't change function signatures and so
should be ABI safe.
Bootstrapped and tested on x86_64-unknown-linux-gnu some time ago.
_M_free and _M_used pointers need not be volatile, they are written
in __pool::_M_initialize() only.
Likewise for the _M_bin pointer to the bins.
The _M_next and _M_first pointers shall not be volatile as list
modification is under proper locking or otherwise guaranteed to
be thread-safe.
In all this cases, volatile does not provide more guarantees or
imposes well-defined optimization barriers to the compiler.
2006-07-08 Richard Guenther <rguenther@suse.de>
* include/ext/pool_allocator.h: Remove volatile qualifiers
from data members and corresponding locals.
Index: include/ext/mt_allocator.h
===================================================================
*** include/ext/mt_allocator.h (revision 115286)
--- include/ext/mt_allocator.h (working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 195,207 ****
union _Block_record
{
// Points to the block_record of the next free block.
! _Block_record* volatile _M_next;
};
struct _Bin_record
{
// An "array" of pointers to the first free block.
! _Block_record** volatile _M_first;
// A list of the initial addresses of all allocated blocks.
_Block_address* _M_address;
--- 195,207 ----
union _Block_record
{
// Points to the block_record of the next free block.
! _Block_record* _M_next;
};
struct _Bin_record
{
// An "array" of pointers to the first free block.
! _Block_record** _M_first;
// A list of the initial addresses of all allocated blocks.
_Block_address* _M_address;
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 244,250 ****
// An "array" of bin_records each of which represents a specific
// power of 2 size. Memory to this "array" is allocated in
// _M_initialize().
! _Bin_record* volatile _M_bin;
// Actual value calculated in _M_initialize().
size_t _M_bin_size;
--- 244,250 ----
// An "array" of bin_records each of which represents a specific
// power of 2 size. Memory to this "array" is allocated in
// _M_initialize().
! _Bin_record* _M_bin;
// Actual value calculated in _M_initialize().
size_t _M_bin_size;
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 271,277 ****
struct _Thread_record
{
// Points to next free thread id record. NULL if last record in list.
! _Thread_record* volatile _M_next;
// Thread id ranging from 1 to _S_max_threads.
size_t _M_id;
--- 271,277 ----
struct _Thread_record
{
// Points to next free thread id record. NULL if last record in list.
! _Thread_record* _M_next;
// Thread id ranging from 1 to _S_max_threads.
size_t _M_id;
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 280,286 ****
union _Block_record
{
// Points to the block_record of the next free block.
! _Block_record* volatile _M_next;
// The thread id of the thread which has requested this block.
size_t _M_thread_id;
--- 280,286 ----
union _Block_record
{
// Points to the block_record of the next free block.
! _Block_record* _M_next;
// The thread id of the thread which has requested this block.
size_t _M_thread_id;
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 291,297 ****
// An "array" of pointers to the first free block for each
// thread id. Memory to this "array" is allocated in
// _S_initialize() for _S_max_threads + global pool 0.
! _Block_record** volatile _M_first;
// A list of the initial addresses of all allocated blocks.
_Block_address* _M_address;
--- 291,297 ----
// An "array" of pointers to the first free block for each
// thread id. Memory to this "array" is allocated in
// _S_initialize() for _S_max_threads + global pool 0.
! _Block_record** _M_first;
// A list of the initial addresses of all allocated blocks.
_Block_address* _M_address;
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 300,307 ****
// blocks that are on the freelist/used for each thread id.
// Memory to these "arrays" is allocated in _S_initialize() for
// _S_max_threads + global pool 0.
! size_t* volatile _M_free;
! size_t* volatile _M_used;
// Each bin has its own mutex which is used to ensure data
// integrity while changing "ownership" on a block. The mutex
--- 300,307 ----
// blocks that are on the freelist/used for each thread id.
// Memory to these "arrays" is allocated in _S_initialize() for
// _S_max_threads + global pool 0.
! size_t* _M_free;
! size_t* _M_used;
// Each bin has its own mutex which is used to ensure data
// integrity while changing "ownership" on a block. The mutex
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 365,371 ****
// An "array" of bin_records each of which represents a specific
// power of 2 size. Memory to this "array" is allocated in
// _M_initialize().
! _Bin_record* volatile _M_bin;
// Actual value calculated in _M_initialize().
size_t _M_bin_size;
--- 365,371 ----
// An "array" of bin_records each of which represents a specific
// power of 2 size. Memory to this "array" is allocated in
// _M_initialize().
! _Bin_record* _M_bin;
// Actual value calculated in _M_initialize().
size_t _M_bin_size;