8299482: Remove metaprogramming/isIntegral.hpp

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Justin King 2023-01-11 05:33:29 +00:00 committed by Kim Barrett
parent 10a747c70b
commit f312c99977
5 changed files with 17 additions and 138 deletions

View File

@ -1,59 +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_ISINTEGRAL_HPP
#define SHARE_METAPROGRAMMING_ISINTEGRAL_HPP
#include "metaprogramming/integralConstant.hpp"
#include "metaprogramming/isSigned.hpp"
#include <limits>
#include <type_traits>
// This metafunction returns true iff the type T (irrespective of CV qualifiers)
// is an integral type. Note that this is false for enums.
template<typename T>
struct IsIntegral
: public IntegralConstant<bool, std::numeric_limits<typename std::remove_cv<T>::type>::is_integer>
{};
// This metafunction returns true iff the type T (irrespective of CV qualifiers)
// is a signed integral type. Note that this is false for enums.
template<typename T>
struct IsSignedIntegral
: public IntegralConstant<bool, IsIntegral<T>::value && IsSigned<T>::value>
{};
// This metafunction returns true iff the type T (irrespective of CV qualifiers)
// is an unsigned integral type. Note that this is false for enums.
template<typename T>
struct IsUnsignedIntegral
: public IntegralConstant<bool, IsIntegral<T>::value && !IsSigned<T>::value>
{};
#endif // SHARE_METAPROGRAMMING_ISINTEGRAL_HPP

View File

@ -30,7 +30,6 @@
#include "metaprogramming/conditional.hpp"
#include "metaprogramming/enableIf.hpp"
#include "metaprogramming/integralConstant.hpp"
#include "metaprogramming/isIntegral.hpp"
#include "metaprogramming/isPointer.hpp"
#include "metaprogramming/isSame.hpp"
#include "oops/accessDecorators.hpp"
@ -1094,7 +1093,7 @@ namespace AccessInternal {
// If this fails to compile, then you have sent in something that is
// not recognized as a valid primitive type to a primitive Access function.
STATIC_ASSERT((HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value || // oops have already been validated
(IsPointer<T>::value || IsIntegral<T>::value) ||
(IsPointer<T>::value || std::is_integral<T>::value) ||
std::is_floating_point<T>::value)); // not allowed primitive type
}
@ -1214,7 +1213,7 @@ namespace AccessInternal {
arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
size_t length) {
STATIC_ASSERT((HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ||
(IsSame<T, void>::value || IsIntegral<T>::value) ||
(IsSame<T, void>::value || std::is_integral<T>::value) ||
std::is_floating_point<T>::value)); // arraycopy allows type erased void elements
using DecayedT = std::decay_t<T>;
const DecoratorSet expanded_decorators = DecoratorFixup<decorators | IS_ARRAY | IN_HEAP>::value;

View File

@ -28,9 +28,9 @@
#include "memory/allocation.hpp"
#include "metaprogramming/conditional.hpp"
#include "metaprogramming/enableIf.hpp"
#include "metaprogramming/isIntegral.hpp"
#include "metaprogramming/isPointer.hpp"
#include "metaprogramming/isSame.hpp"
#include "metaprogramming/isSigned.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include "runtime/orderAccess.hpp"
#include "utilities/align.hpp"
@ -392,7 +392,7 @@ template<typename T, typename PlatformOp>
struct Atomic::LoadImpl<
T,
PlatformOp,
typename EnableIf<IsIntegral<T>::value || IsPointer<T>::value>::type>
typename EnableIf<std::is_integral<T>::value || IsPointer<T>::value>::type>
{
T operator()(T const volatile* dest) const {
// Forward to the platform handler for the size of T.
@ -444,7 +444,7 @@ template<typename T, typename PlatformOp>
struct Atomic::StoreImpl<
T, T,
PlatformOp,
typename EnableIf<IsIntegral<T>::value>::type>
typename EnableIf<std::is_integral<T>::value>::type>
{
void operator()(T volatile* dest, T new_value) const {
// Forward to the platform handler for the size of T.
@ -509,14 +509,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);
STATIC_ASSERT(IsPointer<D>::value || std::is_integral<D>::value);
typedef typename Conditional<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);
STATIC_ASSERT(IsPointer<D>::value || std::is_integral<D>::value);
typedef typename Conditional<IsPointer<D>::value, ptrdiff_t, D>::type I;
// Assumes two's complement integer representation.
#pragma warning(suppress: 4146)
@ -525,8 +525,8 @@ inline void Atomic::dec(D volatile* dest, atomic_memory_order order) {
template<typename D, typename I>
inline D Atomic::sub(D volatile* dest, I sub_value, atomic_memory_order order) {
STATIC_ASSERT(IsPointer<D>::value || IsIntegral<D>::value);
STATIC_ASSERT(IsIntegral<I>::value);
STATIC_ASSERT(IsPointer<D>::value || std::is_integral<D>::value);
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.
typedef typename Conditional<IsSigned<I>::value, intptr_t, uintptr_t>::type PI;
@ -675,8 +675,8 @@ inline D Atomic::fetch_and_add(D volatile* dest, I add_value,
template<typename D, typename I>
struct Atomic::AddImpl<
D, I,
typename EnableIf<IsIntegral<I>::value &&
IsIntegral<D>::value &&
typename EnableIf<std::is_integral<I>::value &&
std::is_integral<D>::value &&
(sizeof(I) <= sizeof(D)) &&
(IsSigned<I>::value == IsSigned<D>::value)>::type>
{
@ -693,7 +693,7 @@ struct Atomic::AddImpl<
template<typename P, typename I>
struct Atomic::AddImpl<
P*, I,
typename EnableIf<IsIntegral<I>::value && (sizeof(I) <= sizeof(P*))>::type>
typename EnableIf<std::is_integral<I>::value && (sizeof(I) <= sizeof(P*))>::type>
{
STATIC_ASSERT(sizeof(intptr_t) == sizeof(P*));
STATIC_ASSERT(sizeof(uintptr_t) == sizeof(P*));
@ -768,7 +768,7 @@ inline bool Atomic::replace_if_null(D* volatile* dest, T* value,
template<typename T>
struct Atomic::CmpxchgImpl<
T, T, T,
typename EnableIf<IsIntegral<T>::value>::type>
typename EnableIf<std::is_integral<T>::value>::type>
{
T operator()(T volatile* dest, T compare_value, T exchange_value,
atomic_memory_order order) const {
@ -903,7 +903,7 @@ inline T Atomic::CmpxchgByteUsingInt::operator()(T volatile* dest,
template<typename T>
struct Atomic::XchgImpl<
T, T,
typename EnableIf<IsIntegral<T>::value>::type>
typename EnableIf<std::is_integral<T>::value>::type>
{
T operator()(T volatile* dest, T exchange_value, atomic_memory_order order) const {
// Forward to the platform handler for the size of T.

View File

@ -27,11 +27,12 @@
#include "metaprogramming/conditional.hpp"
#include "metaprogramming/enableIf.hpp"
#include "metaprogramming/isIntegral.hpp"
#include "metaprogramming/isSigned.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// Returns the population count of x, i.e., the number of bits set in x.
//
// Adapted from Hacker's Delight, 2nd Edition, Figure 5-2 and the text that
@ -47,7 +48,7 @@ template <typename T>
inline unsigned population_count(T x) {
STATIC_ASSERT(BitsPerWord <= 128);
STATIC_ASSERT(BitsPerByte == 8);
STATIC_ASSERT(IsIntegral<T>::value);
STATIC_ASSERT(std::is_integral<T>::value);
STATIC_ASSERT(!IsSigned<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

View File

@ -1,62 +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/isIntegral.hpp"
#include "utilities/debug.hpp"
class IsIntegralTest: AllStatic {
class A: AllStatic {};
static const bool ii_voidptr = IsIntegral<void*>::value;
STATIC_ASSERT(!ii_voidptr);
static const bool ii_Aptr = IsIntegral<A*>::value;
STATIC_ASSERT(!ii_Aptr);
static const bool ii_cAptr = IsIntegral<const A*>::value;
STATIC_ASSERT(!ii_cAptr);
static const bool ii_vAptr = IsIntegral<volatile A*>::value;
STATIC_ASSERT(!ii_vAptr);
static const bool ii_Avptr = IsIntegral<A* volatile>::value;
STATIC_ASSERT(!ii_Avptr);
static const bool ii_intptrt = IsIntegral<intptr_t>::value;
STATIC_ASSERT(ii_intptrt);
static const bool ii_char = IsIntegral<char>::value;
STATIC_ASSERT(ii_char);
static const bool ii_cintptrt = IsIntegral<const intptr_t>::value;
STATIC_ASSERT(ii_cintptrt);
static const bool ii_vintptrt = IsIntegral<volatile intptr_t>::value;
STATIC_ASSERT(ii_vintptrt);
static const bool ii_cvintptrt = IsIntegral<const volatile intptr_t>::value;
STATIC_ASSERT(ii_cvintptrt);
};