Skip to content

Commit

Permalink
Remove old bitmap implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Mar 17, 2024
1 parent 5f39d0e commit e3e5975
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 117 deletions.
95 changes: 0 additions & 95 deletions librz/include/rz_util/rz_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,101 +11,6 @@ extern "C" {
#include <rz_util/rz_assert.h>
#include <rz_types_base.h>

typedef ut64 RzBitmap64;
typedef ut32 RzBitmap32;

/**
* \brief Init the 64bit bitmap \p map.
*
* \param map The bitmap to edit.
*/
static inline void rz_bits_map_init_64(RZ_OUT RzBitmap64 *map) {
rz_return_if_fail(map);
*map = 0;
}

/**
* \brief Init the 32bit bitmap \p map.
*
* \param map The bitmap to edit.
*/
static inline void rz_bits_map_init_32(RZ_OUT RzBitmap32 *map) {
rz_return_if_fail(map);
*map = 0;
}

/**
* \brief Set the bit at \p pos in the 64bit bitmap \p map.
*
* \param map The bitmap to edit.
* \param pos Bit index to set.
*/
static inline void rz_bits_map_set_64(RZ_OUT RzBitmap64 *map, ut32 pos) {
rz_return_if_fail(map && pos < 64);
*map = *map | ((1ULL) << pos);
}

/**
* \brief Set the bit at \p pos in the 32bit bitmap \p map.
*
* \param map The bitmap to edit.
* \param pos Bit index to set.
*/
static inline void rz_bits_map_set_32(RZ_OUT RzBitmap32 *map, ut32 pos) {
rz_return_if_fail(map && pos < 32);
*map = *map | ((1UL) << pos);
}

/**
* \brief Unset the bit at \p pos in the 64bit bitmap \p map.
*
* \param map The bitmap to edit.
* \param pos Bit index to unset.
*/
static inline void rz_bits_map_unset_64(RZ_OUT RzBitmap64 *map, ut32 pos) {
rz_return_if_fail(map && pos < 64);
*map = *map & ~((ut64)(1ULL) << pos);
}

/**
* \brief Unset the bit at \p pos in the 32bit bitmap \p map.
*
* \param map The bitmap to edit.
* \param pos Bit index to unset.
*/
static inline void rz_bits_map_unset_32(RZ_OUT RzBitmap32 *map, ut32 pos) {
rz_return_if_fail(map && pos < 32);
*map = *map & ~((ut32)(1UL) << pos);
}

/**
* \brief Get the bit at \p pos in the 64bit bitmap \p map.
*
* \param map The bitmap to check.
* \param pos Bit index to check.
*
* \return true If bit is set.
* \return false If bit is unset.
*/
static inline bool rz_bits_map_get_64(const RzBitmap64 *map, ut32 pos) {
rz_return_val_if_fail(map && pos < 64, false);
return (*map & ((1ULL) << pos)) != 0;
}

/**
* \brief Get the bit at \p pos in the 32bit bitmap \p map.
*
* \param map The bitmap to check.
* \param pos Bit index to check.
*
* \return true If bit is set.
* \return false If bit is unset.
*/
static inline bool rz_bits_map_get_32(const RzBitmap32 *map, ut32 pos) {
rz_return_val_if_fail(map && pos < 32, false);
return (*map & ((1UL) << pos)) != 0;
}

/**
* \brief Get the number of leading zeros of a 64-bit integer in binary representation.
* \param x the 64-bit integer
Expand Down
22 changes: 0 additions & 22 deletions test/unit/test_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,9 @@ bool test_leading_zeros(void) {
mu_end;
}

bool test_bitmaps(void) {
RzBitmap32 map32;
rz_bits_map_init_32(&map32);
RzBitmap64 map64;
rz_bits_map_init_64(&map64);

rz_bits_map_set_32(&map32, 31);
mu_assert_true(rz_bits_map_get_32(&map32, 31), "Bitmap get set");
mu_assert_false(rz_bits_map_get_32(&map32, 0), "Bitmap not touched");
rz_bits_map_unset_32(&map32, 31);
mu_assert_false(rz_bits_map_get_32(&map32, 31), "Bitmap unset");

rz_bits_map_set_64(&map64, 63);
mu_assert_true(rz_bits_map_get_64(&map64, 63), "Bitmap get set");
mu_assert_false(rz_bits_map_get_64(&map64, 0), "Bitmap not touched");
rz_bits_map_unset_64(&map64, 63);
mu_assert_false(rz_bits_map_get_64(&map64, 63), "Bitmap unset");

mu_end;
}

int all_tests() {
mu_run_test(test_file_slurp);
mu_run_test(test_leading_zeros);
mu_run_test(test_bitmaps);
return tests_passed != tests_run;
}

Expand Down

0 comments on commit e3e5975

Please sign in to comment.