This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 02/13] improve bitmap / sbitmap compatability of bitmap_set_bit
- From: tbsaunde+gcc at tbsaunde dot org
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 9 May 2017 16:52:31 -0400
- Subject: [PATCH 02/13] improve bitmap / sbitmap compatability of bitmap_set_bit
- Authentication-results: sourceware.org; auth=none
- References: <20170509205242.2237-1-tbsaunde+gcc@tbsaunde.org>
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
This make the sbitmap version return true if the bit was previously
unset to make it similar to the bitmap version.
gcc/ChangeLog:
2017-05-09 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* sbitmap.h (bitmap_set_bit): Return bool similar to bitmap
version of this function.
---
gcc/sbitmap.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h
index cba0452cdb9..d4e3177d495 100644
--- a/gcc/sbitmap.h
+++ b/gcc/sbitmap.h
@@ -108,11 +108,14 @@ bitmap_bit_p (const_sbitmap map, int bitno)
/* Set bit number BITNO in the sbitmap MAP. */
-static inline void
+static inline bool
bitmap_set_bit (sbitmap map, int bitno)
{
- map->elms[bitno / SBITMAP_ELT_BITS]
- |= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS;
+ SBITMAP_ELT_TYPE &word = map->elms[bitno / SBITMAP_ELT_BITS];
+ SBITMAP_ELT_TYPE mask = (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS;
+ bool ret = (word & mask) == 0;
+ word |= mask;
+ return ret;
}
/* Reset bit number BITNO in the sbitmap MAP. */
--
2.11.0