mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
different fix for strict-aliasing problem
This commit is contained in:
parent
c780abfe40
commit
85a920dd41
1 changed files with 8 additions and 5 deletions
|
@ -416,14 +416,17 @@ static void alloc_free(struct st_lf_alloc_node *first,
|
||||||
struct st_lf_alloc_node volatile *last,
|
struct st_lf_alloc_node volatile *last,
|
||||||
LF_ALLOCATOR *allocator)
|
LF_ALLOCATOR *allocator)
|
||||||
{
|
{
|
||||||
struct st_lf_alloc_node * volatile tmp;
|
/*
|
||||||
tmp= allocator->top;
|
we need a union here to access type-punned pointer reliably.
|
||||||
|
otherwise gcc -fstrict-aliasing will not see 'tmp' changed in the loop
|
||||||
|
*/
|
||||||
|
union { struct st_lf_alloc_node * node; void *ptr; } tmp;
|
||||||
|
tmp.node= allocator->top;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
last->next= tmp;
|
last->next= tmp.node;
|
||||||
} while (!my_atomic_casptr((void **)(char *)&allocator->top,
|
} while (!my_atomic_casptr((void **)(char *)&allocator->top,
|
||||||
(void **)(char *)&tmp, first) &&
|
(void **)&tmp.ptr, first) && LF_BACKOFF);
|
||||||
LF_BACKOFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue