Skip to content

Commit

Permalink
Work around GTest 1.13.x Conditional symbol conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
nicowilliams committed Apr 6, 2023
1 parent 17b95ee commit 11b9608
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/oopStorage.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ inline bool OopStorage::iterate_impl(F f, Storage* storage) {
assert_at_safepoint();
// Propagate const/non-const iteration to the block layer, by using
// const or non-const blocks as corresponding to Storage.
typedef typename Conditional<IsConst<Storage>::value, const Block*, Block*>::type BlockPtr;
typedef typename ConditionalPrime<IsConst<Storage>::value, const Block*, Block*>::type BlockPtr;
ActiveArray* blocks = storage->_active_array;
size_t limit = blocks->block_count();
for (size_t i = 0; i < limit; ++i) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/oopStorageParState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ template<bool concurrent, bool is_const>
class OopStorage::ParState {
BasicParState _basic_state;

typedef typename Conditional<is_const,
const OopStorage*,
OopStorage*>::type StoragePtr;
typedef typename ConditionalPrime<is_const,
const OopStorage*,
OopStorage*>::type StoragePtr;

public:
ParState(StoragePtr storage,
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/oopStorageParState.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline void OopStorage::BasicParState::iterate(F f) {
while (claim_next_segment(&data)) {
assert(data._segment_start < data._segment_end, "invariant");
assert(data._segment_end <= _block_count, "invariant");
typedef typename Conditional<is_const, const Block*, Block*>::type BlockPtr;
typedef typename ConditionalPrime<is_const, const Block*, Block*>::type BlockPtr;
size_t i = data._segment_start;
do {
BlockPtr block = _active_array->at(i);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/metaprogramming/conditional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
// is true. Otherwise it evaluates to FalseType.

template <bool condition, typename TrueType, typename FalseType>
struct Conditional: AllStatic {
struct ConditionalPrime: AllStatic {
typedef TrueType type;
};

template <typename TrueType, typename FalseType>
struct Conditional<false, TrueType, FalseType>: AllStatic {
struct ConditionalPrime<false, TrueType, FalseType>: AllStatic {
typedef FalseType type;
};

Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/oops/accessBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template <DecoratorSet decorators>
struct HeapOopType: AllStatic {
static const bool needs_oop_compress = HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value &&
HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value;
typedef typename Conditional<needs_oop_compress, narrowOop, oop>::type type;
typedef typename ConditionalPrime<needs_oop_compress, narrowOop, oop>::type type;
};

namespace AccessInternal {
Expand All @@ -76,7 +76,7 @@ namespace AccessInternal {
// and otherwise returns the same type T.
template <DecoratorSet decorators, typename T>
struct EncodedType: AllStatic {
typedef typename Conditional<
typedef typename ConditionalPrime<
HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
typename HeapOopType<decorators>::type, T>::type type;
};
Expand Down Expand Up @@ -1114,7 +1114,7 @@ namespace AccessInternal {
inline T load(P* addr) {
verify_types<decorators, T>();
typedef typename Decay<P>::type DecayedP;
typedef typename Conditional<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
typedef typename ConditionalPrime<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
typename OopOrNarrowOop<T>::type,
typename Decay<T>::type>::type DecayedT;
// If a volatile address is passed in but no memory ordering decorator,
Expand All @@ -1128,7 +1128,7 @@ namespace AccessInternal {
template <DecoratorSet decorators, typename T>
inline T load_at(oop base, ptrdiff_t offset) {
verify_types<decorators, T>();
typedef typename Conditional<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
typedef typename ConditionalPrime<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
typename OopOrNarrowOop<T>::type,
typename Decay<T>::type>::type DecayedT;
// Expand the decorators (figure out sensible defaults)
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/runtime/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,14 @@ struct Atomic::PlatformStore {
template<typename D>
inline void Atomic::inc(D volatile* dest, atomic_memory_order order) {
STATIC_ASSERT(IsPointer<D>::value || IsIntegral<D>::value);
typedef typename Conditional<IsPointer<D>::value, ptrdiff_t, D>::type I;
typedef typename ConditionalPrime<IsPointer<D>::value, ptrdiff_t, D>::type I;
Atomic::add(dest, I(1), order);
}

template<typename D>
inline void Atomic::dec(D volatile* dest, atomic_memory_order order) {
STATIC_ASSERT(IsPointer<D>::value || IsIntegral<D>::value);
typedef typename Conditional<IsPointer<D>::value, ptrdiff_t, D>::type I;
typedef typename ConditionalPrime<IsPointer<D>::value, ptrdiff_t, D>::type I;
// Assumes two's complement integer representation.
#pragma warning(suppress: 4146)
Atomic::add(dest, I(-1), order);
Expand All @@ -522,8 +522,8 @@ inline D Atomic::sub(D volatile* dest, I sub_value, atomic_memory_order order) {
STATIC_ASSERT(IsIntegral<I>::value);
// If D is a pointer type, use [u]intptr_t as the addend type,
// matching signedness of I. Otherwise, use D as the addend type.
typedef typename Conditional<IsSigned<I>::value, intptr_t, uintptr_t>::type PI;
typedef typename Conditional<IsPointer<D>::value, PI, D>::type AddendType;
typedef typename ConditionalPrime<IsSigned<I>::value, intptr_t, uintptr_t>::type PI;
typedef typename ConditionalPrime<IsPointer<D>::value, PI, D>::type AddendType;
// Only allow conversions that can't change the value.
STATIC_ASSERT(IsSigned<I>::value == IsSigned<AddendType>::value);
STATIC_ASSERT(sizeof(I) <= sizeof(AddendType));
Expand Down Expand Up @@ -690,9 +690,9 @@ struct Atomic::AddImpl<
{
STATIC_ASSERT(sizeof(intptr_t) == sizeof(P*));
STATIC_ASSERT(sizeof(uintptr_t) == sizeof(P*));
typedef typename Conditional<IsSigned<I>::value,
intptr_t,
uintptr_t>::type CI;
typedef typename ConditionalPrime<IsSigned<I>::value,
intptr_t,
uintptr_t>::type CI;

static CI scale_addend(CI add_value) {
return add_value * sizeof(P);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/population_count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline unsigned population_count(T x) {
// We need to take care with implicit integer promotion when dealing with
// integers < 32-bit. We chose to do this by explicitly widening constants
// to unsigned
typedef typename Conditional<(sizeof(T) < sizeof(unsigned)), unsigned, T>::type P;
typedef typename ConditionalPrime<(sizeof(T) < sizeof(unsigned)), unsigned, T>::type P;
const T all = ~T(0); // 0xFF..FF
const P fives = all/3; // 0x55..55
const P threes = (all/15) * 3; // 0x33..33
Expand Down
18 changes: 9 additions & 9 deletions test/hotspot/gtest/gc/shared/test_oopStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ class OopStorageTest::CountingIterateClosure {
template<bool is_const>
class OopStorageTest::VM_CountAtSafepoint : public VM_GTestExecuteAtSafepoint {
public:
typedef typename Conditional<is_const,
const OopStorage,
OopStorage>::type Storage;
typedef typename ConditionalPrime<is_const,
const OopStorage,
OopStorage>::type Storage;

VM_CountAtSafepoint(Storage* storage, CountingIterateClosure* cl) :
_storage(storage), _cl(cl)
Expand Down Expand Up @@ -792,9 +792,9 @@ const size_t OopStorageTestIteration::_max_workers;
template<bool is_const>
class OopStorageTestIteration::VM_Verify : public VM_GTestExecuteAtSafepoint {
public:
typedef typename Conditional<is_const,
const OopStorage,
OopStorage>::type Storage;
typedef typename ConditionalPrime<is_const,
const OopStorage,
OopStorage>::type Storage;

VM_Verify(Storage* storage, VerifyState* vstate) :
_storage(storage), _vstate(vstate), _result(false)
Expand Down Expand Up @@ -892,9 +892,9 @@ template<bool concurrent, bool is_const>
class OopStorageTestParIteration::Task : public AbstractGangTask {
typedef OopStorage::ParState<concurrent, is_const> StateType;

typedef typename Conditional<is_const,
const OopStorage,
OopStorage>::type Storage;
typedef typename ConditionalPrime<is_const,
const OopStorage,
OopStorage>::type Storage;

public:
Task(const char* name, Storage* storage, VerifyState* vstate) :
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/gtest/metaprogramming/test_conditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class ConditionalTest {
class A: AllStatic {};
class B: AllStatic {};

typedef Conditional<true, A, B>::type A_B_if_true;
typedef ConditionalPrime<true, A, B>::type A_B_if_true;
static const bool A_B_if_true_is_A = IsSame<A_B_if_true, A>::value;
static const bool A_B_if_true_is_B = IsSame<A_B_if_true, B>::value;
STATIC_ASSERT(A_B_if_true_is_A);
STATIC_ASSERT(!A_B_if_true_is_B);

typedef Conditional<false, A, B>::type A_B_if_false;
typedef ConditionalPrime<false, A, B>::type A_B_if_false;
static const bool A_B_if_false_is_A = IsSame<A_B_if_false, A>::value;
static const bool A_B_if_false_is_B = IsSame<A_B_if_false, B>::value;
STATIC_ASSERT(!A_B_if_false_is_A);
Expand Down

0 comments on commit 11b9608

Please sign in to comment.