[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cinvoke-dev] OS X/Intel fixes

From: Will Weisser
Subject: RE: [cinvoke-dev] OS X/Intel fixes
Date: Wed, 6 Aug 2008 06:01:00 -0700

Congrats on your release! I'll review this patch ASAP.  Actually I'm not
sure OSX for x86 was ever officially supported because I've never had an
Intel Mac to test on.  Thanks for the help,


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Mooneer Salem
Sent: Saturday, August 02, 2008 5:58 AM
To: address@hidden
Subject: [cinvoke-dev] OS X/Intel fixes

Hi again,

I discovered a pretty nasty bug when using C/Invoke on an Intel Mac
running OSX. As it turns out, OSX on 32-bit Intel requires 16-byte
stack alignment, so attempting to use C/Invoke on that platform
results in weird crashes in __dyld_misaligned_stack_error() (64-bit
uses the standard ABI, so it worked correctly without modification
when I built the library and Kite for 64-bit). Below is a patch that
should fix this issue. I just went ahead and enforced 16-byte
alignment regardless of the OS, but this should not change the
behavior outside OSX.

--- cinvoke.old/lib/arch/gcc_x86_unix.h 2008-07-29 00:46:50.000000000
+++ cinvoke/lib/arch/gcc_x86_unix.h     2008-08-02 01:55:47.000000000
@@ -86,7 +86,9 @@
                        "m" ((archvalue).ivalhigh) : \
                        "%eax", "%edx");

+/* OSX requires 16-byte alignment on x86-32. Should not hurt on other
x86 OSes. */
 #define ARCH_PUT_STACK_BYTES(bcount) \
+    bcount += ((bcount % 16) ? (16 - (bcount % 16)) : 0); \
        __asm__("subl %0, %%esp" :: "m" (bcount) : "%esp");

 #define ARCH_REMOVE_STACK_BYTES(bcount) \

Let me know if you have any questions.



P.S.: Kite 1.0b4 was just released today, with the above change. :)

cinvoke-dev mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]