Changeset 36740 in webkit for trunk/JavaScriptCore/wtf/Vector.h
- Timestamp:
- Sep 21, 2008, 1:17:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/Vector.h
r35900 r36740 36 36 using std::min; 37 37 using std::max; 38 38 39 // WTF_ALIGN_OF / WTF_ALIGNED 40 #if COMPILER(GCC) || COMPILER(MINGW) 41 #define WTF_ALIGN_OF(type) __alignof__(type) 42 #define WTF_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((__aligned__(n))) 43 #elif COMPILER(MSVC) 44 #define WTF_ALIGN_OF(type) __alignof(type) 45 #define WTF_ALIGNED(variable_type, variable, n) __declspec(align(n)) variable_type variable 46 #else 47 #error WTF_ALIGN macros need alignment control. 48 #endif 49 50 #if COMPILER(GCC) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 303) 51 typedef char __attribute__((__may_alias__)) AlignedBufferChar; 52 #else 53 typedef char AlignedBufferChar; 54 #endif 55 56 template <size_t size, size_t alignment> struct AlignedBuffer; 57 template <size_t size> struct AlignedBuffer<size, 1> { AlignedBufferChar buffer[size]; }; 58 template <size_t size> struct AlignedBuffer<size, 2> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 2); }; 59 template <size_t size> struct AlignedBuffer<size, 4> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 4); }; 60 template <size_t size> struct AlignedBuffer<size, 8> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 8); }; 61 template <size_t size> struct AlignedBuffer<size, 16> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 16); }; 62 template <size_t size> struct AlignedBuffer<size, 32> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 32); }; 63 template <size_t size> struct AlignedBuffer<size, 64> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 64); }; 64 39 65 template <bool needsDestruction, typename T> 40 66 class VectorDestructor; … … 385 411 386 412 static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T); 387 T* inlineBuffer() { return reinterpret_cast<T*>(&m_inlineBuffer); } 388 389 // FIXME: Nothing guarantees this buffer is appropriately aligned to hold objects of type T. 390 char m_inlineBuffer[m_inlineBufferSize]; 413 T* inlineBuffer() { return reinterpret_cast<T*>(m_inlineBuffer.buffer); } 414 415 AlignedBuffer<m_inlineBufferSize, WTF_ALIGN_OF(T)> m_inlineBuffer; 391 416 }; 392 417
Note:
See TracChangeset
for help on using the changeset viewer.