From dac482f71679f2175c9379e442d69e3993ec7730 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Jan 2009 13:23:40 +0100 Subject: Add support for aligned buffers without alignment macros If we don't have alignment macros, we do what we can: overcommit 64 bytes and find the proper 64-byte-aligned position in the buffer. --- src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h index 7cba4e4..bff770c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h @@ -45,7 +45,7 @@ namespace WTF { #define WTF_ALIGN_OF(type) __alignof(type) #define WTF_ALIGNED(variable_type, variable, n) __declspec(align(n)) variable_type variable #else - #error WTF_ALIGN macros need alignment control. + #define WTF_ALIGN_OF(type) 0 #endif #if COMPILER(GCC) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 303) @@ -54,6 +54,7 @@ namespace WTF { typedef char AlignedBufferChar; #endif + #ifdef WTF_ALIGNED template struct AlignedBuffer; template struct AlignedBuffer { AlignedBufferChar buffer[size]; }; template struct AlignedBuffer { WTF_ALIGNED(AlignedBufferChar, buffer[size], 2); }; @@ -62,6 +63,17 @@ namespace WTF { template struct AlignedBuffer { WTF_ALIGNED(AlignedBufferChar, buffer[size], 16); }; template struct AlignedBuffer { WTF_ALIGNED(AlignedBufferChar, buffer[size], 32); }; template struct AlignedBuffer { WTF_ALIGNED(AlignedBufferChar, buffer[size], 64); }; + #else + template struct AlignedBuffer + { + AlignedBufferChar oversizebuffer[size + 64]; + AlignedBufferChar *buffer; + inline AlignedBuffer() : buffer(oversizebuffer) + { + buffer += 64 - (reinterpret_cast(buffer) & 0x3f); + } + }; + #endif template class VectorDestructor; -- cgit v0.12