Cleanup and fixing of Code/Framework

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-08-16 15:54:35 -07:00
parent 230e0c6976
commit 06e6f83907
18 changed files with 40 additions and 149 deletions
@@ -13,11 +13,6 @@
#include <AzCore/std/parallel/spin_mutex.h>
#ifdef AZ_COMPILER_MSVC
# pragma warning(push)
# pragma warning(disable: 4355) // 'this' : used in base member initializer list
#endif
// A reasonable define for a stack allocator size for the high level jobs.
#define AZ_JOBS_DEFAULT_STACK_ALLOCATOR_SIZE AZStd::GetMax<unsigned>(2048,512 * AZStd::thread::hardware_concurrency())
@@ -769,9 +764,5 @@ namespace AZ
}
}
#ifdef AZ_COMPILER_MSVC
# pragma warning(pop)
#endif
#endif
#pragma once
@@ -10,12 +10,9 @@
#include <AzCore/Math/Internal/SimdMathCommon_scalar.inl>
#ifdef _MSC_VER
// Unity builds on windows using the scalar backend are tripping some really strange warning behavior..
// Disable the warning so we can test the scalar implementation with unity on windows
# pragma warning (push)
# pragma warning (disable: 4723) // Potential divide by zero
#endif
AZ_PUSH_DISABLE_WARNING(4723, "-Wunknown-warning-option") // Potential divide by zero
namespace AZ
{
@@ -1049,6 +1046,4 @@ namespace AZ
}
}
#ifdef _MSC_VER
# pragma warning (pop)
#endif
AZ_POP_DISABLE_WARNING
@@ -246,10 +246,6 @@ namespace AZ
//! Takes the absolute value of each component of the quaternion.
Quaternion GetAbs() const;
#ifdef AZ_COMPILER_MSVC
# pragma warning(push)
# pragma warning(disable:4201) // anonymous union
#endif
union
{
Simd::Vec4::FloatType m_value;
@@ -263,9 +259,6 @@ namespace AZ
float m_w;
};
};
#ifdef AZ_COMPILER_MSVC
# pragma warning(pop)
#endif
};
//! Non-member functionality belonging to the AZ namespace
@@ -281,10 +281,6 @@ namespace AZ
private:
#ifdef AZ_COMPILER_MSVC
# pragma warning(push)
# pragma warning(disable:4201) // anonymous union
#endif
union
{
Simd::Vec2::FloatType m_value;
@@ -296,9 +292,6 @@ namespace AZ
float m_y;
};
};
#ifdef AZ_COMPILER_MSVC
# pragma warning(pop)
#endif
};
//! Allows pre-multiplying by a float.
@@ -312,10 +312,6 @@ namespace AZ
private:
#ifdef AZ_COMPILER_MSVC
# pragma warning(push)
# pragma warning(disable:4201) // anonymous union
#endif
union
{
Simd::Vec3::FloatType m_value;
@@ -328,9 +324,6 @@ namespace AZ
float m_z;
};
};
#ifdef AZ_COMPILER_MSVC
# pragma warning(pop)
#endif
};
//! Non member functionality belonging to the AZ namespace.
@@ -283,11 +283,6 @@ namespace AZ
Simd::Vec4::FloatType GetSimdValue() const;
protected:
#ifdef AZ_COMPILER_MSVC
# pragma warning(push)
# pragma warning(disable:4201) // anonymous union
#endif
union
{
Simd::Vec4::FloatType m_value;
@@ -301,9 +296,6 @@ namespace AZ
float m_w;
};
};
#ifdef AZ_COMPILER_MSVC
# pragma warning(pop)
#endif
};
}
@@ -1294,14 +1294,6 @@ int mspace_mallopt(int, int);
/*------------------------------ internal #includes ---------------------- */
#ifdef WIN32
#pragma warning(push)
#pragma warning( disable : 4146 ) /* no "unsigned" warnings */
# ifdef AZ_PLATFORM_WINDOWS
# pragma warning( disable : 4267 )
# endif
#endif /* WIN32 */
#include <stdio.h> /* for printing in malloc_stats */
#ifndef LACKS_ERRNO_H
@@ -2170,7 +2162,7 @@ typedef unsigned int flag_t; /* The type of various bit flag sets */
#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A)))
/* Bounds on request (not chunk) sizes. */
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2)
#define MAX_REQUEST ((~MIN_CHUNK_SIZE + 1) << 2)
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
/* pad request bytes into a usable size */
@@ -2881,10 +2873,10 @@ static size_t traverse_and_check(mstate m);
#define treemap_is_marked(M, i) ((M)->treemap & idx2bit(i))
/* isolate the least set bit of a bitmap */
#define least_bit(x) ((x) & - (x))
#define least_bit(x) ((x) & (~(x)+1))
/* mask with all bits to left of least bit of x on */
#define left_bits(x) ((x << 1) | -(x << 1))
#define left_bits(x) ((x << 1) | (~(x << 1)+1))
/* mask with all bits to left of or equal to least bit of x on */
#define same_or_left_bits(x) ((x) | -(x))
@@ -4528,7 +4520,7 @@ static int sys_trim(mstate m, size_t pad)
static void* tmalloc_large(mstate m, size_t nb)
{
tchunkptr v = 0;
size_t rsize = -nb; /* Unsigned negation */
size_t rsize = ~nb+1; /* Unsigned negation */
tchunkptr t;
bindex_t idx;
compute_tree_index(nb, idx);
@@ -4807,7 +4799,7 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes)
char* br = (char*)mem2chunk((size_t)(((size_t)(mem +
alignment -
SIZE_T_ONE)) &
- alignment));
(~alignment+1)));
char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE) ?
br : br + alignment;
mchunkptr newp = (mchunkptr)pos;
@@ -5489,7 +5481,7 @@ postaction:
size_t msize;
ensure_initialization();
msize = pad_request(sizeof(struct malloc_state));
if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size))
if (capacity < (~(msize + TOP_FOOT_SIZE + mparams.page_size)+1))
{
size_t rs = ((capacity == 0) ? mparams.granularity :
(capacity + TOP_FOOT_SIZE + msize));
@@ -5512,7 +5504,7 @@ postaction:
ensure_initialization();
msize = pad_request(sizeof(struct malloc_state));
if (capacity > msize + TOP_FOOT_SIZE &&
capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size))
capacity < (~(msize + TOP_FOOT_SIZE + mparams.page_size)+1))
{
m = init_user_mstate((char*)base, capacity);
m->seg.sflags = EXTERN_BIT;
@@ -6367,6 +6359,3 @@ postaction:
*/
#ifdef WIN32
#pragma warning(pop)
#endif /* WIN32 */
@@ -87,9 +87,6 @@
#define AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING AZ_POP_DISABLE_WARNING
# define AZ_FORCE_INLINE __forceinline
#if !defined(_DEBUG)
# pragma warning(disable:4714) //warning C4714 marked as __forceinline not inlined. Sadly this happens when LTCG during linking. We tried to NOT use force inline but VC 2012 is bad at inlining.
#endif
/// Aligns a declaration.
# define AZ_ALIGN(_decl, _alignment) \
@@ -24,11 +24,6 @@
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/Script/ScriptContextAttributes.h>
#if defined(AZ_COMPILER_MSVC)
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
namespace AZStd
{
template <typename T>
@@ -4507,7 +4502,7 @@ namespace AZ
params.resize(sizeof...(Args) + eBehaviorBusForwarderEventIndices::ParameterFirst);
SetParameters<R>(&params[eBehaviorBusForwarderEventIndices::Result], nullptr);
SetParameters<void*>(&params[eBehaviorBusForwarderEventIndices::UserData], nullptr);
if (sizeof...(Args) > 0)
if constexpr (sizeof...(Args) > 0)
{
SetParameters<Args...>(&params[eBehaviorBusForwarderEventIndices::ParameterFirst], nullptr);
}
@@ -4872,10 +4867,6 @@ namespace AZ
} // namespace Internal
} // namespace AZ
#if defined(AZ_COMPILER_MSVC)
# pragma warning(pop)
#endif
// pull AzStd on demand reflection
#include <AzCore/RTTI/AzStdOnDemandPrettyName.inl>
#include <AzCore/RTTI/AzStdOnDemandReflection.inl>
@@ -656,26 +656,25 @@ namespace AZ
using ElementType = typename AZStd::Utils::if_c<AZStd::is_enum<typename ElementTypeInfo::Type>::value, typename ElementTypeInfo::Type, typename ElementTypeInfo::ElementType>::type;
AZ_Assert(m_classData->m_typeId == AzTypeInfo<typename ElementTypeInfo::ClassType>::Uuid(), "Data element (%s) belongs to a different class!", AzTypeInfo<typename ElementTypeInfo::ValueType>::Name());
#if defined(AZ_COMPILER_MSVC)
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
const SerializeContext::ClassData* classData = m_context->m_serializeContext.FindClassData(AzTypeInfo<typename ElementTypeInfo::ValueType>::Uuid());
if (classData && classData->m_editData)
{
return DataElement<T>(uiId, memberVariable, classData->m_editData->m_name, classData->m_editData->m_description);
}
else if (AZStd::is_enum<ElementType>::value && AzTypeInfo<ElementType>::Name() != nullptr)
else
{
auto enumIter = m_context->m_enumData.find(AzTypeInfo<ElementType>::Uuid());
if (enumIter != m_context->m_enumData.end())
if constexpr (AZStd::is_enum<ElementType>::value)
{
return DataElement<T>(uiId, memberVariable, enumIter->second.m_name, enumIter->second.m_description);
if (AzTypeInfo<ElementType>::Name() != nullptr)
{
auto enumIter = m_context->m_enumData.find(AzTypeInfo<ElementType>::Uuid());
if (enumIter != m_context->m_enumData.end())
{
return DataElement<T>(uiId, memberVariable, enumIter->second.m_name, enumIter->second.m_description);
}
}
}
}
#if defined(AZ_COMPILER_MSVC)
# pragma warning(pop)
#endif
const char* typeName = AzTypeInfo<typename ElementTypeInfo::ValueType>::Name();
return DataElement<T>(uiId, memberVariable, typeName, typeName);
@@ -291,9 +291,7 @@ namespace AZStd
template <>
struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 2* sizeof(int) >
{
#if defined(AZ_COMPILER_MSVC)
# pragma warning(push)
# pragma warning(disable: 4121) // alignment of a member was sensitive to packing
AZ_PUSH_DISABLE_WARNING(4121, "-Wunknown-warning-option") // alignment of a member was sensitive to packing
// GenericClass* (X::*ProbeFunc) changes it's size. From Microsoft:
// Jason Shirk [MSFT]
// This is a known bug/issue. Unfortunately, we can't fix it in X86 product
@@ -302,7 +300,6 @@ namespace AZStd
// We have addressed the issue for all future platforms (including IA64) where
// binary compatibility isn't yet an issue.
// We can fix this warning by adding forward decl class __single_inheritance CLASS; if the XFuncType is member function.
#endif
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass* Convert(X* pthis, XFuncType function_to_bind, GenericMemFuncType& bound_func)
{
@@ -330,11 +327,7 @@ namespace AZStd
u.s.codeptr = u2.s.codeptr;
return (pthis->*u.ProbeFunc)();
}
#if defined(AZ_COMPILER_MSVC)
# pragma warning(default: 4121) // alignment of a member was sensitive to packing
# pragma warning(pop)
#endif
AZ_POP_DISABLE_WARNING
};
// Nasty hack for Microsoft and Intel (IA32 and Itanium)
@@ -20,13 +20,6 @@
#include <AzCore/std/typetraits/remove_cvref.h>
#include <AzCore/std/createdestroy.h>
#if defined(AZ_COMPILER_MSVC)
# pragma warning( push )
# pragma warning( disable : 4793 ) // complaint about native code generation
# pragma warning( disable : 4127 ) // "conditional expression is constant"
# pragma warning( disable : 4275 ) // non dll-interface class 'stdext::exception' used as base for dll-interface class 'std::bad_cast'
#endif
#define AZSTD_FUNCTION_TARGET_FIX(x)
#define AZSTD_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, Type) AZStd::enable_if_t<!std::is_integral_v<Functor>, Type>
@@ -796,12 +789,5 @@ namespace AZStd
//#undef aztypeid
//#undef aztypeid_cmp
#if defined(AZ_COMPILER_MSVC)
# pragma warning( default : 4793 ) // complaint about native code generation
# pragma warning( default : 4127 ) // "conditional expression is constant"
# pragma warning( default : 4275 ) // non dll-interface class 'stdext::exception' used as base for dll-interface class 'std::bad_cast'
# pragma warning( pop )
#endif
#endif // AZSTD_FUNCTION_BASE_HEADER
#pragma once
@@ -13,11 +13,6 @@
#include <AzCore/std/typetraits/remove_cvref.h>
#include <AzCore/std/allocator.h>
#if defined(AZ_COMPILER_MSVC)
# pragma warning( push )
# pragma warning( disable : 4127 ) // "conditional expression is constant"
#endif
namespace AZStd
{
namespace Internal
@@ -689,7 +684,3 @@ namespace AZStd
}
};
} // end namespace AZStd
#if defined(AZ_COMPILER_MSVC)
# pragma warning( pop )
#endif
@@ -489,24 +489,26 @@ namespace AZStd
{
return;
}
float loadFactor = (float)m_numElements.load(memory_order_acquire) / (float)m_storage.get_num_buckets();
if (loadFactor > max_load_factor())
else
{
acquire_all();
//check the load factor again, as another thread may have beaten us to the rehash
size_type numElements = m_numElements.load(memory_order_acquire);
float maxLoadFactor = max_load_factor();
size_type numBuckets = m_storage.get_num_buckets();
loadFactor = (float)numElements / (float)numBuckets;
if (loadFactor > maxLoadFactor)
float loadFactor = (float)m_numElements.load(memory_order_acquire) / (float)m_storage.get_num_buckets();
if (loadFactor > max_load_factor())
{
size_type minNumBuckets = (size_type)((float)numElements / maxLoadFactor);
m_storage.rehash(this, minNumBuckets);
}
acquire_all();
release_all();
// check the load factor again, as another thread may have beaten us to the rehash
size_type numElements = m_numElements.load(memory_order_acquire);
float maxLoadFactor = max_load_factor();
size_type numBuckets = m_storage.get_num_buckets();
loadFactor = (float)numElements / (float)numBuckets;
if (loadFactor > maxLoadFactor)
{
size_type minNumBuckets = (size_type)((float)numElements / maxLoadFactor);
m_storage.rehash(this, minNumBuckets);
}
release_all();
}
}
}
@@ -192,9 +192,5 @@ namespace AZStd
}
} // namespace AZStd
/*#ifdef AZ_COMPILER_MSVC
# pragma warning(pop)
#endif */
#endif // #ifndef AZSTD_SMART_PTR_WEAK_PTR_H
#pragma once
@@ -22,11 +22,6 @@
// used for std::pointer_traits \note do an AZStd version
#include <memory>
#if defined(AZ_COMPILER_MSVC)
# pragma warning(push)
# pragma warning(disable: 6011 28198)
#endif // AZ_COMPILER_MSVC
#ifndef AZ_REGEX_MAX_COMPLEXITY_COUNT
#define AZ_REGEX_MAX_COMPLEXITY_COUNT 10000000L /* set to 0 to disable */
#endif /* AZ_REGEX_MAX_COMPLEXITY_COUNT */
@@ -4766,7 +4761,3 @@ namespace AZStd
Trans();
}
} // namespace AZStd
#if defined(AZ_COMPILER_MSVC)
# pragma warning(pop)
#endif // AZ_COMPILER_MSVC
+1 -1
View File
@@ -1736,7 +1736,7 @@ namespace Benchmark
std::numeric_limits<AZ::s8>::max());
std::generate(m_randomPriorities.begin(), m_randomPriorities.end(), [&randomPriorityDistribution, &randomPriorityGenerator]()
{
return randomPriorityDistribution(randomPriorityGenerator);
return static_cast<AZ::s8>(randomPriorityDistribution(randomPriorityGenerator));
});
// Generate some random depths
@@ -225,7 +225,6 @@ namespace JsonSerializationTests
static_assert((RowCount >= 3 && RowCount <= 4) && (ColumnCount >= 3 && ColumnCount <= 4),
"Only matrix 3x3, 3x4 or 4x4 are supported by this test.");
}
return "{}";
}
void ConfigureFeatures(JsonSerializerConformityTestDescriptorFeatures& features) override