mirror of
https://sourceware.org/git/glibc.git
synced 2025-10-27 12:15:39 +03:00
atomic: Remove atomic_forced_read
Remove the odd atomic_forced_read which is neither atomic nor forced. Some uses are completely redundant, so simply remove them. In other cases the intended use is to force a memory ordering, so use acquire load for those. In yet other cases their purpose is unclear, for example __nscd_cache_search appears to allow concurrent accesses to the cache while it is being garbage collected by another thread! Use relaxed atomic loads here to block spills from accidentally reloading memory that is being changed. Passes regress on AArch64, OK for commit?
This commit is contained in:
@@ -155,7 +155,7 @@ static size_t pagesize;
|
||||
static void *
|
||||
__debug_malloc (size_t bytes)
|
||||
{
|
||||
void *(*hook) (size_t, const void *) = atomic_forced_read (__malloc_hook);
|
||||
void *(*hook) (size_t, const void *) = __malloc_hook;
|
||||
if (__glibc_unlikely (hook != NULL))
|
||||
return (*hook)(bytes, RETURN_ADDRESS (0));
|
||||
|
||||
@@ -179,7 +179,7 @@ strong_alias (__debug_malloc, malloc)
|
||||
static void
|
||||
__debug_free (void *mem)
|
||||
{
|
||||
void (*hook) (void *, const void *) = atomic_forced_read (__free_hook);
|
||||
void (*hook) (void *, const void *) = __free_hook;
|
||||
if (__glibc_unlikely (hook != NULL))
|
||||
{
|
||||
(*hook)(mem, RETURN_ADDRESS (0));
|
||||
@@ -201,8 +201,7 @@ strong_alias (__debug_free, free)
|
||||
static void *
|
||||
__debug_realloc (void *oldmem, size_t bytes)
|
||||
{
|
||||
void *(*hook) (void *, size_t, const void *) =
|
||||
atomic_forced_read (__realloc_hook);
|
||||
void *(*hook) (void *, size_t, const void *) = __realloc_hook;
|
||||
if (__glibc_unlikely (hook != NULL))
|
||||
return (*hook)(oldmem, bytes, RETURN_ADDRESS (0));
|
||||
|
||||
@@ -230,8 +229,7 @@ strong_alias (__debug_realloc, realloc)
|
||||
static void *
|
||||
_debug_mid_memalign (size_t alignment, size_t bytes, const void *address)
|
||||
{
|
||||
void *(*hook) (size_t, size_t, const void *) =
|
||||
atomic_forced_read (__memalign_hook);
|
||||
void *(*hook) (size_t, size_t, const void *) = __memalign_hook;
|
||||
if (__glibc_unlikely (hook != NULL))
|
||||
return (*hook)(alignment, bytes, address);
|
||||
|
||||
@@ -330,7 +328,7 @@ __debug_calloc (size_t nmemb, size_t size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *(*hook) (size_t, const void *) = atomic_forced_read (__malloc_hook);
|
||||
void *(*hook) (size_t, const void *) = __malloc_hook;
|
||||
if (__glibc_unlikely (hook != NULL))
|
||||
{
|
||||
void *mem = (*hook)(bytes, RETURN_ADDRESS (0));
|
||||
|
||||
Reference in New Issue
Block a user