Use __BIGGEST_ALIGNMENT__ only if its smaller than sizeof\(T\)
parent
db768200ab
commit
5790163abc
10
misc.h
10
misc.h
|
|
@ -875,7 +875,8 @@ inline T1 RoundUpToMultipleOf(const T1 &n, const T2 &m)
|
||||||
//! \details Internally the function calls C++11's <tt>alignof</tt> if available. If not available,
|
//! \details Internally the function calls C++11's <tt>alignof</tt> if available. If not available,
|
||||||
//! then the function uses compiler specific extensions such as <tt>__alignof</tt> and
|
//! then the function uses compiler specific extensions such as <tt>__alignof</tt> and
|
||||||
//! <tt>_alignof_</tt>. If an extension is not available, then the function uses
|
//! <tt>_alignof_</tt>. If an extension is not available, then the function uses
|
||||||
//! <tt>__BIGGEST_ALIGNMENT__</tt>. <tt>sizeof(T)</tt> is used if the others are not available.
|
//! <tt>__BIGGEST_ALIGNMENT__</tt> if <tt>__BIGGEST_ALIGNMENT__</tt> is smaller than <tt>sizeof(T)</tt>.
|
||||||
|
//! <tt>sizeof(T)</tt> is used if all others are not available.
|
||||||
//! In <em>all</em> cases, if <tt>CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS</tt> is defined, then the
|
//! In <em>all</em> cases, if <tt>CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS</tt> is defined, then the
|
||||||
//! function returns 1.
|
//! function returns 1.
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
@ -893,11 +894,14 @@ inline unsigned int GetAlignmentOf(T *dummy=NULL) // VC60 workaround
|
||||||
return __alignof(T);
|
return __alignof(T);
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
return __alignof__(T);
|
return __alignof__(T);
|
||||||
#elif __BIGGEST_ALIGNMENT__
|
|
||||||
return __BIGGEST_ALIGNMENT__;
|
|
||||||
#elif CRYPTOPP_BOOL_SLOW_WORD64
|
#elif CRYPTOPP_BOOL_SLOW_WORD64
|
||||||
return UnsignedMin(4U, sizeof(T));
|
return UnsignedMin(4U, sizeof(T));
|
||||||
#else
|
#else
|
||||||
|
# if __BIGGEST_ALIGNMENT__
|
||||||
|
if (__BIGGEST_ALIGNMENT__ < sizeof(T))
|
||||||
|
return __BIGGEST_ALIGNMENT__;
|
||||||
|
else
|
||||||
|
# endif
|
||||||
return sizeof(T);
|
return sizeof(T);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue