What is the required alignment of long double in 64-bit linux, mac, and others?

此生再无相见时 提交于 2020-08-05 06:30:46

问题


I have been trying to find out exactly what is the required alignment of long double in x86-64 mac and linux. I have found various different things that hint at different requirements, but can't find an authorative source.

I am finding on Mac OS X, gcc will generate code sometimes which copy long doubles using movaps, which requires 16-byte alignment. But clang does not and gcc is very old, so maybe this is just an old bug which is not going to get fixed?


回答1:


The Linux x86_64 ABI specifies that long double shall be 16 byte aligned. This is different from the 32-bit x86 Linux ABI, which specifies that long double is only 4 byte aligned (suboptimal on current CPU's but an historical artifact).

I'm not sure about the Mac OSX x86 ABI, but it would surprise me if they'd retain such historical baggage. Hence my guess would be 16-byte alignment.



来源:https://stackoverflow.com/questions/12938828/what-is-the-required-alignment-of-long-double-in-64-bit-linux-mac-and-others

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!