diff options
author | unknown <serg@janus.mylan> | 2007-10-12 16:17:18 +0200 |
---|---|---|
committer | unknown <serg@janus.mylan> | 2007-10-12 16:17:18 +0200 |
commit | c780abfe40da423d06ac61461abe1be82a93cdac (patch) | |
tree | 07244256dd802c018e8b7e82a88765d96dda8fa1 /mysys/lf_alloc-pin.c | |
parent | 58cd4a522dd84e4be3d6b8f4ab06635d7de7ef4f (diff) | |
download | mariadb-git-c780abfe40da423d06ac61461abe1be82a93cdac.tar.gz |
bugs/warnings fixed in lf_alloc-pin.c:
1. available_stack_size() was getting the direction wrong,
so alloca() was never used
2. (char*) casts added to kill "break strict-aliasing rules" warnings
3. s/node/node=0/ to kill "pointer casted to integer" warning
4. added volatiles as appropriate to prevent gcc from moving
assignment out of the loop
mysys/lf_alloc-pin.c:
bugs/warnings fixed:
1. available_stack_size() was getting the direction wrong,
so alloca() was never used
2. (char*) casts added to kill "break strict-aliasing rules" warnings
3. s/node/node=0/ to kill "pointer casted to integer" warning
4. added volatiles as appropriate to prevent gcc from moving
assignment out of the loop
Diffstat (limited to 'mysys/lf_alloc-pin.c')
-rw-r--r-- | mysys/lf_alloc-pin.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index 51c4df7c94a..e89e071d8bd 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -318,9 +318,9 @@ static int match_pins(LF_PINS *el, void *addr) } #if STACK_DIRECTION < 0 -#define available_stack_size(END,CUR) (long) ((char*)(CUR) - (char*)(END)) +#define available_stack_size(CUR,END) (long) ((char*)(CUR) - (char*)(END)) #else -#define available_stack_size(END,CUR) (long) ((char*)(END) - (char*)(CUR)) +#define available_stack_size(CUR,END) (long) ((char*)(END) - (char*)(CUR)) #endif /* @@ -413,15 +413,16 @@ LF_REQUIRE_PINS(1); first->el->el->....->el->last. Use first==last to free only one element. */ static void alloc_free(struct st_lf_alloc_node *first, - struct st_lf_alloc_node *last, + struct st_lf_alloc_node volatile *last, LF_ALLOCATOR *allocator) { - struct st_lf_alloc_node *tmp; + struct st_lf_alloc_node * volatile tmp; tmp= allocator->top; do { last->next= tmp; - } while (!my_atomic_casptr((void **)&allocator->top, (void **)&tmp, first) && + } while (!my_atomic_casptr((void **)(char *)&allocator->top, + (void **)(char *)&tmp, first) && LF_BACKOFF); } @@ -494,12 +495,13 @@ void *_lf_alloc_new(LF_PINS *pins) { node= (void *)my_malloc(allocator->element_size, MYF(MY_WME)); #ifdef MY_LF_EXTRA_DEBUG - if (likely(node)) + if (likely(node != 0)) my_atomic_add32(&allocator->mallocs, 1); #endif break; } - if (my_atomic_casptr((void **)&allocator->top, (void *)&node, node->next)) + if (my_atomic_casptr((void **)(char *)&allocator->top, + (void *)&node, node->next)) break; } _lf_unpin(pins, 0); |