summaryrefslogtreecommitdiff
path: root/include/lf.h
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2006-11-16 15:40:08 +0100
committerunknown <serg@janus.mylan>2006-11-16 15:40:08 +0100
commit915cebdd53fe5071dc9443a236a798764f504c22 (patch)
tree4caaa7043f4421f3b849b7ad0452294ac15eff86 /include/lf.h
parent966e4b4425e66bf57683a764d1d21a5d99ac2138 (diff)
downloadmariadb-git-915cebdd53fe5071dc9443a236a798764f504c22.tar.gz
post-review fixes.
tablockman: fixed a bug in finding a blocker lock mysys/my_getsystime.c: this is no longer true storage/maria/lockman.h: post-review fixes storage/maria/tablockman.h: post-review fixes storage/maria/unittest/lockman-t.c: post-review fixes storage/maria/unittest/lockman1-t.c: post-review fixes storage/maria/unittest/lockman2-t.c: post-review fixes include/my_atomic.h: moved intptr definition to my_global.h storage/maria/tablockman.c: post-review fixes BUILD/SETUP.sh: add -DMY_LF_EXTRA_DEBUG to debug builds include/atomic/nolock.h: suppress warning include/my_global.h: suppress warning mysys/lf_alloc-pin.c: post-review fixes mysys/lf_dynarray.c: post-review fixes mysys/lf_hash.c: post-review fixes storage/maria/trnman.c: suppress warning include/lf.h: post-review fix
Diffstat (limited to 'include/lf.h')
-rw-r--r--include/lf.h47
1 files changed, 32 insertions, 15 deletions
diff --git a/include/lf.h b/include/lf.h
index 3a3b5b28ade..c7198ab75b6 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -24,7 +24,7 @@
func() is a _func() protected by my_atomic_rwlock_wrlock()
*/
-#define lock_wrap(f,t,proto_args, args, lock) \
+#define lock_wrap(f, t, proto_args, args, lock) \
t _ ## f proto_args; \
static inline t f proto_args \
{ \
@@ -35,7 +35,7 @@ static inline t f proto_args \
return ret; \
}
-#define lock_wrap_void(f,proto_args, args, lock) \
+#define lock_wrap_void(f, proto_args, args, lock) \
void _ ## f proto_args; \
static inline void f proto_args \
{ \
@@ -44,14 +44,14 @@ static inline void f proto_args \
my_atomic_rwlock_wrunlock(lock); \
}
-#define nolock_wrap(f,t,proto_args, args) \
+#define nolock_wrap(f, t, proto_args, args) \
t _ ## f proto_args; \
static inline t f proto_args \
{ \
return _ ## f args; \
}
-#define nolock_wrap_void(f,proto_args, args) \
+#define nolock_wrap_void(f, proto_args, args) \
void _ ## f proto_args; \
static inline void f proto_args \
{ \
@@ -80,14 +80,14 @@ void lf_dynarray_destroy(LF_DYNARRAY *array);
nolock_wrap(lf_dynarray_value, void *,
(LF_DYNARRAY *array, uint idx),
- (array,idx));
+ (array, idx));
lock_wrap(lf_dynarray_lvalue, void *,
(LF_DYNARRAY *array, uint idx),
- (array,idx),
+ (array, idx),
&array->lock);
nolock_wrap(lf_dynarray_iterate, int,
(LF_DYNARRAY *array, lf_dynarray_func func, void *arg),
- (array,func,arg));
+ (array, func, arg));
/*
pin manager for memory allocator, lf_alloc-pin.c
@@ -115,9 +115,14 @@ typedef struct {
uint32 volatile link;
/* we want sizeof(LF_PINS) to be 128 to avoid false sharing */
char pad[128-sizeof(uint32)*2
- -sizeof(void *)*(LF_PINBOX_PINS+2)];
+ -sizeof(LF_PINBOX *)
+ -sizeof(void *)*(LF_PINBOX_PINS+1)];
} LF_PINS;
+/*
+ shortcut macros to do an atomic_wrlock on a structure that uses pins
+ (e.g. lf_hash).
+*/
#define lf_rwlock_by_pins(PINS) \
my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinstack.lock)
#define lf_rwunlock_by_pins(PINS) \
@@ -131,11 +136,11 @@ typedef struct {
#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
#define LF_REQUIRE_PINS(N) \
static const char require_pins[LF_PINBOX_PINS-N]; \
- static const int LF_NUM_PINS_IN_THIS_FILE=N;
+ static const int LF_NUM_PINS_IN_THIS_FILE= N;
#define _lf_pin(PINS, PIN, ADDR) \
( \
- my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)), \
- assert(PIN < LF_NUM_PINS_IN_THIS_FILE) \
+ assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
+ my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
)
#else
#define LF_REQUIRE_PINS(N)
@@ -151,7 +156,7 @@ typedef struct {
} while (0)
#define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL)
#define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0)
-#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN]==0)
+#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN] == 0)
void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset,
lf_pinbox_free_func *free_func, void * free_func_arg);
@@ -167,16 +172,20 @@ lock_wrap_void(lf_pinbox_put_pins,
&pins->pinbox->pinstack.lock);
lock_wrap_void(lf_pinbox_free,
(LF_PINS *pins, void *addr),
- (pins,addr),
+ (pins, addr),
&pins->pinbox->pinstack.lock);
/*
memory allocator, lf_alloc-pin.c
*/
+struct st_lf_alloc_node {
+ struct st_lf_alloc_node *next;
+};
+
typedef struct st_lf_allocator {
LF_PINBOX pinbox;
- void * volatile top;
+ struct st_lf_alloc_node * volatile top;
uint element_size;
uint32 volatile mallocs;
} LF_ALLOCATOR;
@@ -184,13 +193,17 @@ typedef struct st_lf_allocator {
void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset);
void lf_alloc_destroy(LF_ALLOCATOR *allocator);
uint lf_alloc_in_pool(LF_ALLOCATOR *allocator);
+/*
+ shortcut macros to access underlying pinbox functions from an LF_ALLOCATOR
+ see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
+*/
#define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR))
#define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR))
#define _lf_alloc_get_pins(ALLOC) _lf_pinbox_get_pins(&(ALLOC)->pinbox)
#define lf_alloc_get_pins(ALLOC) lf_pinbox_get_pins(&(ALLOC)->pinbox)
#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
-#define lf_alloc_real_free(ALLOC,ADDR) my_free((gptr)(ADDR), MYF(0))
+#define lf_alloc_real_free(ALLOC, ADDR) my_free((gptr)(ADDR), MYF(0))
lock_wrap(lf_alloc_new, void *,
(LF_PINS *pins),
@@ -222,6 +235,10 @@ void lf_hash_destroy(LF_HASH *hash);
int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data);
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
+/*
+ shortcut macros to access underlying pinbox functions from an LF_HASH
+ see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
+*/
#define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc)
#define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc)
#define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS)