cinvoke-svn
[Top][All Lists]
Advanced

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

[cinvoke-svn] r58 - in trunk/cinvoke: lib/arch test


From: will
Subject: [cinvoke-svn] r58 - in trunk/cinvoke: lib/arch test
Date: 30 Jun 2006 01:20:42 -0400

Author: will
Date: 2006-06-30 01:20:42 -0400 (Fri, 30 Jun 2006)
New Revision: 58

Modified:
   trunk/cinvoke/lib/arch/gcc_x64_unix.h
   trunk/cinvoke/test/lib.c
   trunk/cinvoke/test/runtests.c
Log:
fixed callback stack offset


Modified: trunk/cinvoke/lib/arch/gcc_x64_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x64_unix.h       2006-06-30 04:39:43 UTC (rev 57)
+++ trunk/cinvoke/lib/arch/gcc_x64_unix.h       2006-06-30 05:20:42 UTC (rev 58)
@@ -171,7 +171,7 @@
 #define ARCH_GET_FRAME_PTR(fp) \
        __asm__("movq %%rbp, %0" : "=m" (fp));
 
-#define ARCH_CALLBACK_ARG_OFFSET (4*10) // XXX
+#define ARCH_CALLBACK_ARG_OFFSET (32)
 
 #define ARCH_STACK_GROWS_DOWN 1
 

Modified: trunk/cinvoke/test/lib.c
===================================================================
--- trunk/cinvoke/test/lib.c    2006-06-30 04:39:43 UTC (rev 57)
+++ trunk/cinvoke/test/lib.c    2006-06-30 05:20:42 UTC (rev 58)
@@ -78,3 +78,7 @@
        printf("test10: %d %d %c %ld %ld %d %d %ld %d (want 111 222 3 444 555 
666 777 888 999\n", i1, i2, i3, i4, i5, i6, i7, i8, i9);
        return 0.7f;
 }
+DLLEXPORT void test11(int (CDECL *f)(int, int, long, long, int, int,
+int, long)) {
+       printf("test9: %d (want 1)\n", f(1, 2, 3, 4, 5, 6, 0x77777777, 
0x8888888888888888));
+}

Modified: trunk/cinvoke/test/runtests.c
===================================================================
--- trunk/cinvoke/test/runtests.c       2006-06-30 04:39:43 UTC (rev 57)
+++ trunk/cinvoke/test/runtests.c       2006-06-30 05:20:42 UTC (rev 58)
@@ -318,7 +318,42 @@
        return 1;
 }
 
+void cbfunc2(CInvFunction *f, void *parameters[], void *returnout,
+       void *userdata) {
+       printf("userdata=%p (want 0xBB)\n", userdata);
+       printf("args=%d %d %ld %ld %d %d %x %lx"
+       " (want 1 2 3 4 5 6 77777777 8888888888888888)\n",
+               *(int *)parameters[0],
+               *(int *)parameters[1],
+               *(long *)parameters[2],
+               *(long *)parameters[3],
+               *(int *)parameters[4],
+               *(int *)parameters[5],
+               *(int *)parameters[6],
+               *(long *)parameters[7]);
 
+       *(int *)returnout = 1;
+}
+
+int test11(CInvContext *ctx, CInvLibrary *lib, void *ep,
+       CInvFunction *f) {
+       CInvFunction *proto = cinv_function_create(ctx, CINV_CC_DEFAULT, "i",
+               "iilliiil");
+       CInvCallback *cb = cinv_callback_create(ctx, proto, (void *)0xBB, 
cbfunc2);
+
+       void *e = cinv_callback_getentrypoint(ctx, cb);
+
+       void *args[1] = { &e };
+
+       if (!cinv_function_invoke(ctx, f, ep, NULL, args)) {
+               fprintf(stderr, "invoke failed: %s\n", 
cinv_context_geterrormsg(ctx));
+               return 0;
+       }
+
+       cinv_callback_delete(ctx, cb);
+       return 1;
+}
+
 #define UPDATE0(test) \
        if (test(ctx)) \
                succeeded++; \
@@ -378,6 +413,7 @@
        UPDATE0(test8);
        UPDATE(test9, "", "p");
        UPDATE(test10, "f", "isclliils");
+       UPDATE(test11, "", "p");
        
        if (!cinv_library_delete(ctx, lib)) {
                fprintf(stderr, "Error deleting library: %s\n",





reply via email to

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