summaryrefslogtreecommitdiff
path: root/mysys/lf_hash.c
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2015-11-06 17:24:23 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2015-11-06 17:27:24 +0100
commitf1daf9ced46ba65b025a92f512833c86d04e7cf2 (patch)
treed8c63373681dde1e5db37d76019df110eb75b4cf /mysys/lf_hash.c
parenta36048d143c2e3cd956009849dc28f4a714d00d0 (diff)
downloadmariadb-git-f1daf9ced46ba65b025a92f512833c86d04e7cf2.tar.gz
MDEV-9024 Build fails with VS2015
Fix build failures caused by new C runtime library - isnan, snprintf, struct timespec are now defined, attempt to redefine them leads - P_tmpdir, tzname are no more defined - lfind() and lsearch() in lf_hash.c had to be renamed, declaration conflicts with some C runtime functions with the same name declared in a header included by stdlib.h Also fix couple of annoying warnings : - remove #define NOMINMAX from config.h to avoid "redefined" compiler warnings(NOMINMAX is already in compile flags) - disable incremental linker in Debug as well (feature not used much and compiler crashes often) Also simplify package building with Wix, require Wix 3.9 or later (VS2015 is not compatible with old Wix 3.5/3.6)
Diffstat (limited to 'mysys/lf_hash.c')
-rw-r--r--mysys/lf_hash.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index aa96ca94198..eb0c252edb1 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -43,7 +43,7 @@ const int LF_HASH_OVERHEAD= sizeof(LF_SLIST);
/*
a structure to pass the context (pointers two the three successive elements
- in a list) from lfind to linsert/ldelete
+ in a list) from l_find to l_insert/l_delete
*/
typedef struct {
intptr volatile *prev;
@@ -70,7 +70,7 @@ typedef struct {
cursor is positioned in either case
pins[0..2] are used, they are NOT removed on return
*/
-static int lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
+static int l_find(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
const uchar *key, uint keylen, CURSOR *cursor, LF_PINS *pins)
{
uint32 cur_hashnr;
@@ -138,7 +138,7 @@ retry:
/*
DESCRIPTION
insert a 'node' in the list that starts from 'head' in the correct
- position (as found by lfind)
+ position (as found by l_find)
RETURN
0 - inserted
@@ -148,7 +148,7 @@ retry:
it uses pins[0..2], on return all pins are removed.
if there're nodes with the same key value, a new node is added before them.
*/
-static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
+static LF_SLIST *l_insert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
LF_SLIST *node, LF_PINS *pins, uint flags)
{
CURSOR cursor;
@@ -156,7 +156,7 @@ static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
for (;;)
{
- if (lfind(head, cs, node->hashnr, node->key, node->keylen,
+ if (l_find(head, cs, node->hashnr, node->key, node->keylen,
&cursor, pins) &&
(flags & LF_HASH_UNIQUE))
{
@@ -200,7 +200,7 @@ static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
NOTE
it uses pins[0..2], on return all pins are removed.
*/
-static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
+static int l_delete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
const uchar *key, uint keylen, LF_PINS *pins)
{
CURSOR cursor;
@@ -208,7 +208,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
for (;;)
{
- if (!lfind(head, cs, hashnr, key, keylen, &cursor, pins))
+ if (!l_find(head, cs, hashnr, key, keylen, &cursor, pins))
{
res= 1; /* not found */
break;
@@ -232,7 +232,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
(to ensure the number of "set DELETED flag" actions
is equal to the number of "remove from the list" actions)
*/
- lfind(head, cs, hashnr, key, keylen, &cursor, pins);
+ l_find(head, cs, hashnr, key, keylen, &cursor, pins);
}
res= 0;
break;
@@ -258,12 +258,12 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
it uses pins[0..2], on return the pin[2] keeps the node found
all other pins are removed.
*/
-static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs,
+static LF_SLIST *l_search(LF_SLIST * volatile *head, CHARSET_INFO *cs,
uint32 hashnr, const uchar *key, uint keylen,
LF_PINS *pins)
{
CURSOR cursor;
- int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins);
+ int res= l_find(head, cs, hashnr, key, keylen, &cursor, pins);
if (res)
_lf_pin(pins, 2, cursor.curr);
else
@@ -363,7 +363,7 @@ void lf_hash_destroy(LF_HASH *hash)
-1 - out of memory
NOTE
- see linsert() for pin usage notes
+ see l_insert() for pin usage notes
*/
int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data)
{
@@ -384,7 +384,7 @@ int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data)
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
return -1;
node->hashnr= my_reverse_bits(hashnr) | 1; /* normal node */
- if (linsert(el, hash->charset, node, pins, hash->flags))
+ if (l_insert(el, hash->charset, node, pins, hash->flags))
{
_lf_alloc_free(pins, node);
lf_rwunlock_by_pins(pins);
@@ -407,7 +407,7 @@ int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data)
1 - didn't (not found)
-1 - out of memory
NOTE
- see ldelete() for pin usage notes
+ see l_delete() for pin usage notes
*/
int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
{
@@ -427,7 +427,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
*/
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
return -1;
- if (ldelete(el, hash->charset, my_reverse_bits(hashnr) | 1,
+ if (l_delete(el, hash->charset, my_reverse_bits(hashnr) | 1,
(uchar *)key, keylen, pins))
{
lf_rwunlock_by_pins(pins);
@@ -446,7 +446,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
MY_ERRPTR if OOM
NOTE
- see lsearch() for pin usage notes
+ see l_search() for pin usage notes
*/
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
{
@@ -460,7 +460,7 @@ void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
return MY_ERRPTR;
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
return MY_ERRPTR;
- found= lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1,
+ found= l_search(el, hash->charset, my_reverse_bits(hashnr) | 1,
(uchar *)key, keylen, pins);
lf_rwunlock_by_pins(pins);
return found ? found+1 : 0;
@@ -488,16 +488,16 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node,
dummy->hashnr= my_reverse_bits(bucket) | 0; /* dummy node */
dummy->key= dummy_key;
dummy->keylen= 0;
- if ((cur= linsert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE)))
+ if ((cur= l_insert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE)))
{
my_free(dummy);
dummy= cur;
}
my_atomic_casptr((void **)node, (void **)(char*) &tmp, dummy);
/*
- note that if the CAS above failed (after linsert() succeeded),
- it would mean that some other thread has executed linsert() for
- the same dummy node, its linsert() failed, it picked up our
+ note that if the CAS above failed (after l_insert() succeeded),
+ it would mean that some other thread has executed l_insert() for
+ the same dummy node, its l_insert() failed, it picked up our
dummy node (in "dummy= cur") and executed the same CAS as above.
Which means that even if CAS above failed we don't need to retry,
and we should not free(dummy) - there's no memory leak here