diff options
author | tomas@poseidon.ndb.mysql.com <> | 2005-07-12 20:01:22 +0200 |
---|---|---|
committer | tomas@poseidon.ndb.mysql.com <> | 2005-07-12 20:01:22 +0200 |
commit | 674b6bb15140673107bacb1574e8e26f51ff002e (patch) | |
tree | 8fd7b30e9e4cce3fdfc60e700fdb2d668f2f6449 /mysys/my_bitmap.c | |
parent | 9743190cd90c7a51dfb23d5cbdca4b04fb7e6ae0 (diff) | |
parent | e06e06ffeb8dbcd2737720be9f78c5fe75b9c0f5 (diff) | |
download | mariadb-git-674b6bb15140673107bacb1574e8e26f51ff002e.tar.gz |
Merge
Diffstat (limited to 'mysys/my_bitmap.c')
-rw-r--r-- | mysys/my_bitmap.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 0260bc2ee41..6cfabad1d3b 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -159,6 +159,51 @@ void bitmap_free(MY_BITMAP *map) } +/* + test if bit already set and set it if it was not (thread unsafe method) + + SYNOPSIS + bitmap_fast_test_and_set() + MAP bit map struct + BIT bit number + + RETURN + 0 bit was not set + !=0 bit was set +*/ + +my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit) +{ + uchar *byte= map->bitmap + (bitmap_bit / 8); + uchar bit= 1 << ((bitmap_bit) & 7); + uchar res= (*byte) & bit; + *byte|= bit; + return res; +} + + +/* + test if bit already set and set it if it was not (thread safe method) + + SYNOPSIS + bitmap_fast_test_and_set() + map bit map struct + bitmap_bit bit number + + RETURN + 0 bit was not set + !=0 bit was set +*/ + +my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit) +{ + my_bool res; + DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8); + bitmap_lock(map); + res= bitmap_fast_test_and_set(map, bitmap_bit); + bitmap_unlock(map); +} + uint bitmap_set_next(MY_BITMAP *map) { uint bit_found; |