8300265: Remove metaprogramming/isSigned.hpp
Reviewed-by: kbarrett, tschatzl
This commit is contained in:
parent
5a4945c0d9
commit
03a9a88efb
@ -26,11 +26,12 @@
|
||||
#ifndef SHARE_MEMORY_METASPACE_COUNTERS_HPP
|
||||
#define SHARE_MEMORY_METASPACE_COUNTERS_HPP
|
||||
|
||||
#include "metaprogramming/isSigned.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace metaspace {
|
||||
|
||||
// We seem to be counting a lot of things which makes it worthwhile to
|
||||
@ -43,7 +44,7 @@ class AbstractCounter {
|
||||
T _c;
|
||||
|
||||
// Only allow unsigned values for now
|
||||
STATIC_ASSERT(IsSigned<T>::value == false);
|
||||
STATIC_ASSERT(std::is_signed<T>::value == false);
|
||||
|
||||
public:
|
||||
|
||||
@ -86,7 +87,7 @@ class AbstractAtomicCounter {
|
||||
volatile T _c;
|
||||
|
||||
// Only allow unsigned values for now
|
||||
STATIC_ASSERT(IsSigned<T>::value == false);
|
||||
STATIC_ASSERT(std::is_signed<T>::value == false);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_METAPROGRAMMING_ISSIGNED_HPP
|
||||
#define SHARE_METAPROGRAMMING_ISSIGNED_HPP
|
||||
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
struct IsSigned
|
||||
: public IntegralConstant<bool, std::numeric_limits<typename std::remove_cv<T>::type>::is_signed>
|
||||
{};
|
||||
|
||||
#endif // SHARE_METAPROGRAMMING_ISSIGNED_HPP
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "metaprogramming/isSigned.hpp"
|
||||
#include "metaprogramming/primitiveConversions.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
@ -526,10 +525,10 @@ inline D Atomic::sub(D volatile* dest, I sub_value, atomic_memory_order order) {
|
||||
STATIC_ASSERT(std::is_integral<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.
|
||||
using PI = std::conditional_t<IsSigned<I>::value, intptr_t, uintptr_t>;
|
||||
using PI = std::conditional_t<std::is_signed<I>::value, intptr_t, uintptr_t>;
|
||||
using AddendType = std::conditional_t<std::is_pointer<D>::value, PI, D>;
|
||||
// Only allow conversions that can't change the value.
|
||||
STATIC_ASSERT(IsSigned<I>::value == IsSigned<AddendType>::value);
|
||||
STATIC_ASSERT(std::is_signed<I>::value == std::is_signed<AddendType>::value);
|
||||
STATIC_ASSERT(sizeof(I) <= sizeof(AddendType));
|
||||
AddendType addend = sub_value;
|
||||
// Assumes two's complement integer representation.
|
||||
@ -675,7 +674,7 @@ struct Atomic::AddImpl<
|
||||
typename EnableIf<std::is_integral<I>::value &&
|
||||
std::is_integral<D>::value &&
|
||||
(sizeof(I) <= sizeof(D)) &&
|
||||
(IsSigned<I>::value == IsSigned<D>::value)>::type>
|
||||
(std::is_signed<I>::value == std::is_signed<D>::value)>::type>
|
||||
{
|
||||
static D add_and_fetch(D volatile* dest, I add_value, atomic_memory_order order) {
|
||||
D addend = add_value;
|
||||
@ -697,7 +696,7 @@ struct Atomic::AddImpl<
|
||||
|
||||
// Type of the scaled addend. An integral type of the same size as a
|
||||
// pointer, and the same signedness as I.
|
||||
using SI = std::conditional_t<IsSigned<I>::value, intptr_t, uintptr_t>;
|
||||
using SI = std::conditional_t<std::is_signed<I>::value, intptr_t, uintptr_t>;
|
||||
|
||||
// Type of the unscaled destination. A pointer type with pointee size == 1.
|
||||
using UP = const char*;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#define SHARE_UTILITIES_POPULATION_COUNT_HPP
|
||||
|
||||
#include "metaprogramming/enableIf.hpp"
|
||||
#include "metaprogramming/isSigned.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
@ -48,7 +47,7 @@ inline unsigned population_count(T x) {
|
||||
STATIC_ASSERT(BitsPerWord <= 128);
|
||||
STATIC_ASSERT(BitsPerByte == 8);
|
||||
STATIC_ASSERT(std::is_integral<T>::value);
|
||||
STATIC_ASSERT(!IsSigned<T>::value);
|
||||
STATIC_ASSERT(!std::is_signed<T>::value);
|
||||
// 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
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "metaprogramming/isSigned.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
|
||||
class IsSignedTest: AllStatic {
|
||||
template <typename SignedType, typename UnsignedType>
|
||||
class TestIntegers: AllStatic {
|
||||
static const bool _signed_type_is_signed = IsSigned<SignedType>::value;
|
||||
STATIC_ASSERT(_signed_type_is_signed);
|
||||
static const bool _unsigned_type_is_unsigned = !IsSigned<UnsignedType>::value;
|
||||
STATIC_ASSERT(_unsigned_type_is_unsigned);
|
||||
|
||||
static const bool _cvsigned_type_is_signed = IsSigned<const volatile SignedType>::value;
|
||||
STATIC_ASSERT(_signed_type_is_signed);
|
||||
static const bool _cvunsigned_type_is_unsigned = !IsSigned<const volatile UnsignedType>::value;
|
||||
STATIC_ASSERT(_unsigned_type_is_unsigned);
|
||||
};
|
||||
|
||||
const TestIntegers<int8_t, uint8_t> TestByte;
|
||||
const TestIntegers<int16_t, uint16_t> TestShort;
|
||||
const TestIntegers<int32_t, uint32_t> TestInt;
|
||||
const TestIntegers<int64_t, uint64_t> TestLong;
|
||||
};
|
@ -23,17 +23,17 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "metaprogramming/isSigned.hpp"
|
||||
#include "utilities/count_leading_zeros.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "unittest.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
template <typename T> void one_or_two_set_bits() {
|
||||
uint32_t bit1_pos = 0;
|
||||
uint32_t bits = sizeof(T) * BitsPerByte;
|
||||
uint32_t limit = bits - (IsSigned<T>::value ? 1 : 0);
|
||||
uint32_t limit = bits - (std::is_signed<T>::value ? 1 : 0);
|
||||
for (uint64_t ix = 1; bit1_pos < limit; ix = ix * 2, ++bit1_pos) {
|
||||
uint32_t bit2_pos = 0;
|
||||
for (uint64_t jx = 1; bit2_pos < limit; jx = jx * 2, ++bit2_pos) {
|
||||
@ -56,7 +56,7 @@ TEST(count_leading_zeros, one_or_two_set_bits) {
|
||||
}
|
||||
|
||||
template <typename T> void high_zeros_low_ones() {
|
||||
uint32_t number_of_leading_zeros = (IsSigned<T>::value ? 1 : 0);
|
||||
uint32_t number_of_leading_zeros = (std::is_signed<T>::value ? 1 : 0);
|
||||
T value = std::numeric_limits<T>::max();
|
||||
for ( ; value != 0; value >>= 1, ++number_of_leading_zeros) {
|
||||
EXPECT_EQ(number_of_leading_zeros, count_leading_zeros(value))
|
||||
@ -78,7 +78,7 @@ TEST(count_leading_zeros, high_zeros_low_ones) {
|
||||
template <typename T> void high_ones_low_zeros() {
|
||||
T value = std::numeric_limits<T>::max();
|
||||
|
||||
uint32_t number_of_leading_zeros = (IsSigned<T>::value ? 1 : 0);
|
||||
uint32_t number_of_leading_zeros = (std::is_signed<T>::value ? 1 : 0);
|
||||
for (uint64_t i = 1; value != 0; value -= i, i <<= 1) {
|
||||
EXPECT_EQ(number_of_leading_zeros, count_leading_zeros(value))
|
||||
<< "value = " << value;
|
||||
@ -97,4 +97,4 @@ TEST(count_leading_zeros, high_ones_low_zeros) {
|
||||
high_ones_low_zeros<uint16_t>();
|
||||
high_ones_low_zeros<uint32_t>();
|
||||
high_ones_low_zeros<uint64_t>();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user