Ignore:
Timestamp:
Aug 13, 2010, 3:14:36 AM (15 years ago)
Author:
[email protected]
Message:

Avoid increasing required alignment of target type warning on ARM
https://bugs.webkit.org/show_bug.cgi?id=38045

Reviewed by Gavin Barraclough.

The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM:
increases required alignment of target type warnings.
Casting the type of [pointer to Type2] object to void* bypasses the
warning.

(JSC::ARMAssembler::executableCopy):

(JSC::AssemblerBuffer::putShortUnchecked):
(JSC::AssemblerBuffer::putIntUnchecked):
(JSC::AssemblerBuffer::putInt64Unchecked):

(JSC::RegisterFile::RegisterFile):
(JSC::RegisterFile::grow):

(jsRegExpCompile):

(JSC::JSArray::putSlowCase):
(JSC::JSArray::increaseVectorLength):
(JSC::JSArray::increaseVectorPrefixLength):
(JSC::JSArray::shiftCount):
(JSC::JSArray::unshiftCount):

(WTF::PageHeapAllocator::New):
(WTF::TCMalloc_Central_FreeList::Populate):

  • wtf/MD5.cpp:

(WTF::reverseBytes):
(WTF::MD5::addBytes):
(WTF::MD5::checksum):

(isPointerTypeAlignmentOkay):
(reinterpret_cast_ptr):

(WTF::VectorBuffer::inlineBuffer):

(WTF::String::String):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/StdLibExtras.h

    r64327 r65311  
    5252#define STRINGIZE_VALUE_OF(exp) STRINGIZE(exp)
    5353
     54/*
     55 * The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
     56 * sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM with GCC:
     57 * increases required alignment of target type.
     58 *
     59 * An implicit or an extra static_cast<void*> bypasses the warning.
     60 * For more info see the following bugzilla entries:
     61 * - https://bugs.webkit.org/show_bug.cgi?id=38045
     62 * - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976
     63 */
     64#if CPU(ARM) && COMPILER(GCC)
     65template<typename Type>
     66bool isPointerTypeAlignmentOkay(Type* ptr)
     67{
     68    return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type));
     69}
     70
     71template<typename TypePtr>
     72TypePtr reinterpret_cast_ptr(void* ptr)
     73{
     74    ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
     75    return reinterpret_cast<TypePtr>(ptr);
     76}
     77
     78template<typename TypePtr>
     79TypePtr reinterpret_cast_ptr(const void* ptr)
     80{
     81    ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
     82    return reinterpret_cast<TypePtr>(ptr);
     83}
     84#else
     85#define reinterpret_cast_ptr reinterpret_cast
     86#endif
     87
    5488namespace WTF {
    5589
Note: See TracChangeset for help on using the changeset viewer.