mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
8f8924c3f4
* fixed #10929: Hash computation in native engine causes loss of precision. Force use 32 bits hash for all platforms. * More uint64_t -> ccstd:hash_t * Some uint64_t -> uint32_t in SkeletalAnimationUtils.h/.cpp * operator() return ccstd::hash_t now and add some comments. * size_t -> ccstd::hash_t in StringPool.h, Font.h/.cpp
63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
|
|
// Copyright 2005-2009 Daniel James.
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
// On some platforms std::limits gives incorrect values for long double.
|
|
// This tries to work around them.
|
|
|
|
#if !defined(CCSTD_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER)
|
|
#define CCSTD_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER
|
|
|
|
#include <boost/config.hpp>
|
|
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
|
#pragma once
|
|
#endif
|
|
|
|
#include <boost/limits.hpp>
|
|
|
|
// On OpenBSD, numeric_limits is not reliable for long doubles, but
|
|
// the macros defined in <float.h> are and support long double when STLport
|
|
// doesn't.
|
|
|
|
#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE)
|
|
#include <float.h>
|
|
#endif
|
|
|
|
namespace ccstd
|
|
{
|
|
namespace hash_detail
|
|
{
|
|
template <class T>
|
|
struct limits : std::numeric_limits<T> {};
|
|
|
|
#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE)
|
|
template <>
|
|
struct limits<long double>
|
|
: std::numeric_limits<long double>
|
|
{
|
|
static long double epsilon() {
|
|
return LDBL_EPSILON;
|
|
}
|
|
|
|
static long double (max)() {
|
|
return LDBL_MAX;
|
|
}
|
|
|
|
static long double (min)() {
|
|
return LDBL_MIN;
|
|
}
|
|
|
|
BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG);
|
|
BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP);
|
|
BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP);
|
|
#if defined(_STLP_NO_LONG_DOUBLE)
|
|
BOOST_STATIC_CONSTANT(int, radix = FLT_RADIX);
|
|
#endif
|
|
};
|
|
#endif // __OpenBSD__
|
|
}
|
|
}
|
|
|
|
#endif
|