summaryrefslogtreecommitdiff
path: root/mysys/lf_alloc-pin.c
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-10-12 18:46:55 +0200
committerunknown <serg@janus.mylan>2007-10-12 18:46:55 +0200
commit85a920dd41692e3580ac19541ac2072b34901a85 (patch)
tree35988e04edd41f2e1f29c7c413706e07c0e8ec3c /mysys/lf_alloc-pin.c
parentc780abfe40da423d06ac61461abe1be82a93cdac (diff)
downloadmariadb-git-85a920dd41692e3580ac19541ac2072b34901a85.tar.gz
different fix for strict-aliasing problem
Diffstat (limited to 'mysys/lf_alloc-pin.c')
-rw-r--r--mysys/lf_alloc-pin.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index e89e071d8bd..a847d722023 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -416,14 +416,17 @@ static void alloc_free(struct st_lf_alloc_node *first,
struct st_lf_alloc_node volatile *last,
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
{
- last->next= tmp;
+ last->next= tmp.node;
} while (!my_atomic_casptr((void **)(char *)&allocator->top,
- (void **)(char *)&tmp, first) &&
- LF_BACKOFF);
+ (void **)&tmp.ptr, first) && LF_BACKOFF);
}
/*