From b4c065f803b9177d8c1c773989de0923313894d2 Mon Sep 17 00:00:00 2001 From: Rot127 Date: Sat, 16 Mar 2024 23:17:13 -0500 Subject: [PATCH] Remove old bitmap implementation. --- librz/include/rz_util/rz_bits.h | 95 --------------------------------- test/unit/test_util.c | 22 -------- 2 files changed, 117 deletions(-) diff --git a/librz/include/rz_util/rz_bits.h b/librz/include/rz_util/rz_bits.h index 9faff173dfd..113f88ae7a9 100644 --- a/librz/include/rz_util/rz_bits.h +++ b/librz/include/rz_util/rz_bits.h @@ -11,101 +11,6 @@ extern "C" { #include #include -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 diff --git a/test/unit/test_util.c b/test/unit/test_util.c index 165d90577a1..4851e91cdff 100644 --- a/test/unit/test_util.c +++ b/test/unit/test_util.c @@ -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; }