diff options
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 10384b3b9b6..5b2351975b9 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1823,7 +1823,7 @@ get_guard (tree decl) /* We use a type that is big enough to contain a mutex as well as an integer counter. */ - guard_type = long_long_integer_type_node; + guard_type = targetm.cxx.guard_type (); guard = build_decl (VAR_DECL, sname, guard_type); /* The guard should have the same linkage as what it guards. */ @@ -1847,15 +1847,18 @@ get_guard (tree decl) static tree get_guard_bits (tree guard) { - /* We only set the first byte of the guard, in order to leave room - for a mutex in the high-order bits. */ - guard = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (guard)), - guard); - guard = build1 (NOP_EXPR, - build_pointer_type (char_type_node), - guard); - guard = build1 (INDIRECT_REF, char_type_node, guard); + if (!targetm.cxx.guard_mask_bit ()) + { + /* We only set the first byte of the guard, in order to leave room + for a mutex in the high-order bits. */ + guard = build1 (ADDR_EXPR, + build_pointer_type (TREE_TYPE (guard)), + guard); + guard = build1 (NOP_EXPR, + build_pointer_type (char_type_node), + guard); + guard = build1 (INDIRECT_REF, char_type_node, guard); + } return guard; } @@ -1870,6 +1873,16 @@ get_guard_cond (tree guard) /* Check to see if the GUARD is zero. */ guard = get_guard_bits (guard); + + /* Mask off all but the low bit. */ + if (targetm.cxx.guard_mask_bit ()) + { + guard_value = integer_one_node; + if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard))) + guard_value = convert (TREE_TYPE (guard), guard_value); + guard = cp_build_binary_op (BIT_AND_EXPR, guard, guard_value); + } + guard_value = integer_zero_node; if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard))) guard_value = convert (TREE_TYPE (guard), guard_value); |