Commit 2cb4f952 authored by unknown's avatar unknown

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
parent bbbc4b65
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment