This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 02/13] improve bitmap / sbitmap compatability of bitmap_set_bit


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]