我在尝试做一个程序编制与海湾合作委员会和使用建和SSE内部函数。看来当我的一个功能是所谓的脱,堆叠的取向不是保留。这里有一个简短的例子来说明我的意思是:

#include <cstdio>
#include <emmintrin.h>
#include <QtGui/QApplication.h>
#include <QtGui/QWidget.h>


class Widget: public QWidget {
public:
    void paintEvent(QPaintEvent *) {
        __m128 a;
        printf("a: 0x%08x\n", ((void *) &a));
    }
};


int main(int argc, char** argv)
{
    QApplication application(argc, argv);
    Widget w;
    w.paintEvent(NULL); // Called from here, my function behaves correctly
    w.show();
    w.update();
    // Qt will call Widget::paintEvent and my __m128 will not be
    // aligned on 16 bytes as it should
    application.processEvents();

    return 0;
}

这里的输出:

a: 0x0023ff40 // OK, that's aligned on 16 bytes
a: 0x0023d14c // Not aligned!

配置:

  • 英特尔的酷睿2
  • WinXP,SP3
  • 海湾合作委员会4.4(Mingw包括在脱SDK2010.01)

我试图汇编的例的程序有相同的选项,因为那些我看到在建makefile:

-O2 -Wall -frtti -fexceptions -mthreads

链接选项:

-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads

现在我不知道在哪个方向进行搜索。任何暗示将非常感激。谢谢!

法比安

有帮助吗?

解决方案

你可以使用选项 -mstackrealign 要做到,无需添加的属性源代码:

-mstackrealign 重新堆叠在入境。在英特尔x86,-mstackrealign选项会产生的一个备选序幕和尾声,重新调整的运行时堆叠,如果有必要的。这支混合码的遗产,保持4个字节对准堆与现代码,保持一个16字节堆对上证兼容性。另见的属性force_align_arg_pointer,适用于个人职能。

(从 海湾合作委员会的文档)

其他提示

__attribute__((force_align_arg_pointer)) void paintEvent(QPaintEvent *);

它的工作!没有任何人有一个更好的解决办法?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top