cinvoke-svn
[Top][All Lists]
Advanced

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

[cinvoke-svn] r106 - in trunk/cinvoke/lib: . arch


From: will
Subject: [cinvoke-svn] r106 - in trunk/cinvoke/lib: . arch
Date: 14 Aug 2006 18:14:38 -0400

Author: will
Date: 2006-08-14 18:14:37 -0400 (Mon, 14 Aug 2006)
New Revision: 106

Modified:
   trunk/cinvoke/lib/arch/cl_x86_win.h
   trunk/cinvoke/lib/arch/empty_empty_empty.h
   trunk/cinvoke/lib/arch/gcc_ppc_osx.h
   trunk/cinvoke/lib/arch/gcc_sparc_unix.h
   trunk/cinvoke/lib/arch/gcc_x64_unix.h
   trunk/cinvoke/lib/arch/gcc_x86_unix.h
   trunk/cinvoke/lib/cinvoke.c
Log:
fixed floating point stack exception


Modified: trunk/cinvoke/lib/arch/cl_x86_win.h
===================================================================
--- trunk/cinvoke/lib/arch/cl_x86_win.h 2006-08-11 19:51:43 UTC (rev 105)
+++ trunk/cinvoke/lib/arch/cl_x86_win.h 2006-08-14 22:14:37 UTC (rev 106)
@@ -76,15 +76,15 @@
        __asm mov edx, [(regparms).second] \
        __asm call dword ptr [ep]
 
-#define ARCH_SAVE_RETURN(archvalue) \
-       __asm mov [(archvalue).ivallow], eax \
-       __asm mov [(archvalue).ivalhigh], edx \
-       __asm fstp [(archvalue).dval]
+#define ARCH_SAVE_RETURN(archvalue, type) \
+       __asm { mov [(archvalue).ivallow], eax \
+               __asm mov [(archvalue).ivalhigh], edx } \
+       if (type == CINV_T_FLOAT || type == CINV_T_DOUBLE) { __asm fstp 
[(archvalue).dval] }
 
-#define ARCH_SET_RETURN(archvalue) \
+#define ARCH_SET_RETURN(archvalue, type) \
+       if (type == CINV_T_FLOAT || type == CINV_T_DOUBLE) { __asm fld 
[(archvalue).dval] } \
        __asm mov eax, [(archvalue).ivallow] \
-       __asm mov edx, [(archvalue).ivalhigh] \
-       __asm fld [(archvalue).dval]
+       __asm mov edx, [(archvalue).ivalhigh]
 
 #define ARCH_PUT_STACK_BYTES(bcount) \
        __asm sub esp, bcount;

Modified: trunk/cinvoke/lib/arch/empty_empty_empty.h
===================================================================
--- trunk/cinvoke/lib/arch/empty_empty_empty.h  2006-08-11 19:51:43 UTC (rev 
105)
+++ trunk/cinvoke/lib/arch/empty_empty_empty.h  2006-08-14 22:14:37 UTC (rev 
106)
@@ -121,14 +121,14 @@
 
 // saves any possible return values in the ArchRetValue
 // structure given by archvalue.
-#define ARCH_SAVE_RETURN(archvalue) \
+#define ARCH_SAVE_RETURN(archvalue, type) \
        __asm mov [(archvalue).ivallow], eax \
        __asm mov [(archvalue).ivalhigh], edx \
        __asm fstp [(archvalue).dval] // TODO: fix this for your arch
 
 // stores the return values in the ArchRetValue structure
 // into any place where a caller might expect to find them
-#define ARCH_SET_RETURN(archvalue) \
+#define ARCH_SET_RETURN(archvalue, type) \
        __asm mov eax, [(archvalue).ivallow] \
        __asm mov edx, [(archvalue).ivalhigh] \
        __asm fld [(archvalue).dval] // TODO: fix this for your arch

Modified: trunk/cinvoke/lib/arch/gcc_ppc_osx.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_ppc_osx.h        2006-08-11 19:51:43 UTC (rev 
105)
+++ trunk/cinvoke/lib/arch/gcc_ppc_osx.h        2006-08-14 22:14:37 UTC (rev 
106)
@@ -180,7 +180,7 @@
                        "f11", "f12", "f13", \
                        "r0", "ctr");
 
-#define ARCH_SAVE_RETURN(archvalue) \
+#define ARCH_SAVE_RETURN(archvalue, type) \
        __asm__("stw r3, %0\n \
                stw r4, %1\n \
                stfd f1, %2\n" : \
@@ -188,7 +188,7 @@
                        "=m" ((archvalue).ivallo), \
                        "=m" ((archvalue).dval));
 
-#define ARCH_SET_RETURN(archvalue) \
+#define ARCH_SET_RETURN(archvalue, type) \
        __asm__("lwz r3, %0\n \
                lwz r4, %1\n \
                lfd f1, %2\n" :: \

Modified: trunk/cinvoke/lib/arch/gcc_sparc_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_sparc_unix.h     2006-08-11 19:51:43 UTC (rev 
105)
+++ trunk/cinvoke/lib/arch/gcc_sparc_unix.h     2006-08-14 22:14:37 UTC (rev 
106)
@@ -102,7 +102,7 @@
                        "%o4", "%o5", \
                        "%g1");
 
-#define ARCH_SAVE_RETURN(archvalue) \
+#define ARCH_SAVE_RETURN(archvalue, type) \
        __asm__("st %%o0, %0\n \
                        st %%o1, %1\n \
                        std %%f0, %2\n" : \
@@ -110,7 +110,7 @@
                        "=m" ((archvalue).ivallo), \
                        "=m" ((archvalue).dval));
 
-#define ARCH_SET_RETURN(archvalue) \
+#define ARCH_SET_RETURN(archvalue, type) \
        __asm__("ld %0, %%i0\n \
                        ld %1, %%i1\n \
                        ld %2, %%f0\n \

Modified: trunk/cinvoke/lib/arch/gcc_x64_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x64_unix.h       2006-08-11 19:51:43 UTC (rev 
105)
+++ trunk/cinvoke/lib/arch/gcc_x64_unix.h       2006-08-14 22:14:37 UTC (rev 
106)
@@ -142,13 +142,13 @@
                        "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
                        "%xmm6", "%xmm7");
 
-#define ARCH_SAVE_RETURN(archvalue) \
+#define ARCH_SAVE_RETURN(archvalue, type) \
        __asm__("movq %%rax, %0; \
                movsd %%xmm0, %1" : \
                        "=m" ((archvalue).ival), \
                        "=m" ((archvalue).dval));
 
-#define ARCH_SET_RETURN(archvalue) \
+#define ARCH_SET_RETURN(archvalue, type) \
        __asm__("movq %0, %%rax; \
                movsd %1, %%xmm0" :: \
                        "m" ((archvalue).ival), \

Modified: trunk/cinvoke/lib/arch/gcc_x86_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_unix.h       2006-08-11 19:51:43 UTC (rev 
105)
+++ trunk/cinvoke/lib/arch/gcc_x86_unix.h       2006-08-14 22:14:37 UTC (rev 
106)
@@ -64,22 +64,27 @@
 
 #define ARCH_CALL(regparms, ep) ((void (*)())ep)();
 
-#define ARCH_SAVE_RETURN(archvalue) \
+#define ARCH_SAVE_RETURN(archvalue, type) \
        __asm__("movl %%eax, %0; \
-                       movl %%edx, %1; \
-                       fstpl %2" : \
+                       movl %%edx, %1" : \
                        "=m" ((archvalue).ivallow), \
-                       "=m" ((archvalue).ivalhigh), \
-                       "=m" ((archvalue).dval));
+                       "=m" ((archvalue).ivalhigh)); \
+       if (type == CINV_T_FLOAT || type == CINV_T_DOUBLE) { \
+               __asm__("fstpl %0" : \
+                               "=m" ((archvalue).dval)); \
+       }
 
-#define ARCH_SET_RETURN(archvalue) \
+#define ARCH_SET_RETURN(archvalue, type) \
+       if (type == CINV_T_FLOAT || type == CINV_T_DOUBLE) { \
+               __asm__("fldl %0" :: \
+                               "m" ((archvalue).dval) : \
+                               "%st");
+       } \
        __asm__("movl %0, %%eax; \
-                       movl %1, %%edx; \
-                       fldl %2" :: \
+                       movl %1, %%edx" :: \
                        "m" ((archvalue).ivallow), \
-                       "m" ((archvalue).ivalhigh), \
-                       "m" ((archvalue).dval) : \
-                       "%eax", "%edx", "%st");
+                       "m" ((archvalue).ivalhigh) : \
+                       "%eax", "%edx");
 
 #define ARCH_PUT_STACK_BYTES(bcount) \
        __asm__("subl %0, %%esp" :: "m" (bcount) : "%esp");

Modified: trunk/cinvoke/lib/cinvoke.c
===================================================================
--- trunk/cinvoke/lib/cinvoke.c 2006-08-11 19:51:43 UTC (rev 105)
+++ trunk/cinvoke/lib/cinvoke.c 2006-08-14 22:14:37 UTC (rev 106)
@@ -227,9 +227,10 @@
        function->callconv = callingconvention;
        function->stacksize = 0;
        
-       if (!(*returnformat))
+       if (!(*returnformat)) {
                function->hasreturn = 0;
-       else {
+               function->rettype = -1; // invalid value
+       } else {
                function->hasreturn = 1;
                if (!parse_type(*returnformat, &function->rettype)) {
                        free(function);
@@ -410,7 +411,7 @@
        }
 
        ARCH_CALL(regparms, entrypoint)
-       ARCH_SAVE_RETURN(retval)
+       ARCH_SAVE_RETURN(retval, function->rettype)
 
        if (function->callconv != CINV_CC_STDCALL && stacksize != 0) {
                ARCH_REMOVE_STACK_BYTES(stacksize)
@@ -505,7 +506,7 @@
        
        if (cb->prototype->hasreturn) {
                set_value(&retval, cb->prototype->rettype, &returnptr);
-               ARCH_SET_RETURN(retval)
+               ARCH_SET_RETURN(retval, cb->prototype->rettype)
        }
 }
 





reply via email to

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