+CAPTIVE_STDCALL calling by hand to workaround broken GCC.
authorshort <>
Tue, 23 Sep 2003 07:08:58 +0000 (07:08 +0000)
committershort <>
Tue, 23 Sep 2003 07:08:58 +0000 (07:08 +0000)
src/libcaptive/cc/sharedcachemap.c
src/libcaptive/client/init.c
src/libcaptive/ex/work.c
src/libcaptive/include/captive/calltype_reactos.h
src/libcaptive/ldr/loader.c
src/libcaptive/po/shutdownwork.c
src/libcaptive/ps/Makefile.am
src/libcaptive/ps/calltype.S [new file with mode: 0644]

index 8b68ac7..6dec135 100644 (file)
@@ -591,14 +591,14 @@ CaptiveSharedCacheMapObject_page *page;
        g_return_if_fail(page->dirty);
 
        if (page->lsn_newest) {
-LARGE_INTEGER lsn_newest_LargeInteger;
-
                /* sanity check */
                g_assert(!lsn_last || lsn_last<=page->lsn_newest);
                lsn_last=page->lsn_newest;
 
-               lsn_newest_LargeInteger.QuadPart=page->lsn_newest;
-               (*captive_FlushToLsnRoutine)(captive_LogHandle,lsn_newest_LargeInteger);
+               captive_stdcall_call_12((CaptiveStdCallFunc12)captive_FlushToLsnRoutine,
+                               captive_LogHandle,
+                               (gpointer)(guint32)(page->lsn_newest>> 0U),     /* 'LARGE_INTEGER' argument */
+                               (gpointer)(guint32)(page->lsn_newest>>32U));
                }
 
        offset_LargeInteger.QuadPart=offset;
index 85dfdbd..9b7469e 100644 (file)
@@ -204,10 +204,10 @@ NTSTATUS err;
                        captive_utf8_to_UnicodeString_alloca("\\captive\\filesystem")); /* DriverEntry_RegistryPath */
        g_return_val_if_fail(NT_SUCCESS(err),FALSE);
        if (captive_DriverObject_ReinitRoutine) {
-               (*captive_DriverObject_ReinitRoutine)(
+               captive_stdcall_call_12((CaptiveStdCallFunc12)captive_DriverObject_ReinitRoutine,
                                &captive_DriverObject,  /* DriverObject */
                                captive_DriverObject_ReinitRoutine_Context,     /* Context */
-                               1);     /* Count: # of calls of ReinitRoutine incl. the current one */
+                               (gpointer)1);   /* Count: # of calls of ReinitRoutine incl. the current one */
                }
 
        return TRUE;
index 980960b..3094f61 100644 (file)
@@ -33,7 +33,8 @@ static gboolean ExQueueWorkItem_idlefunc(WORK_QUEUE_ITEM *WorkItem_copy /* data
 
        /* typedef VOID STDCALL_FUNC (*PWORKER_THREAD_ROUTINE)(PVOID Parameter); */
 
-       (*WorkItem_copy->WorkerRoutine)(WorkItem_copy->Parameter);
+       captive_stdcall_call_4((CaptiveStdCallFunc4)WorkItem_copy->WorkerRoutine,
+                       WorkItem_copy->Parameter);      /* Parameter */
        g_free(WorkItem_copy);
 
        return FALSE;   /* remove-me */
index 44586e0..59b166d 100644 (file)
@@ -22,6 +22,7 @@
 
 
 #include <glib/gmacros.h>
+#include <glib/gtypes.h>
 /* captive/?*_reactos.h include files have forbidden any reactos/?* inclusions
  * as they are being included by reactos/compat.h.
  */
@@ -69,6 +70,15 @@ G_BEGIN_DECLS
  */
 #undef CAPTIVE_FASTCALL
 
+
+typedef gpointer CAPTIVE_STDCALL (*CaptiveStdCallFunc4 )(gpointer arg0);
+typedef gpointer CAPTIVE_STDCALL (*CaptiveStdCallFunc8 )(gpointer arg0,gpointer arg1);
+typedef gpointer CAPTIVE_STDCALL (*CaptiveStdCallFunc12)(gpointer arg0,gpointer arg1,gpointer arg2);
+
+gpointer captive_stdcall_call_4 (CaptiveStdCallFunc4  func,gpointer arg0);
+gpointer captive_stdcall_call_8 (CaptiveStdCallFunc8  func,gpointer arg0,gpointer arg1);
+gpointer captive_stdcall_call_12(CaptiveStdCallFunc12 func,gpointer arg0,gpointer arg1,gpointer arg2);
+
 G_END_DECLS
 
 
index 9829310..8629e22 100644 (file)
@@ -220,7 +220,9 @@ NTSTATUS err;
 
        /* initialize the module */
        DriverEntry=(PDRIVER_INITIALIZE)(*ModuleObjectp)->EntryPoint;
-       err=(*DriverEntry)(DriverEntry_DriverObject,DriverEntry_RegistryPath);
+       err=(NTSTATUS)captive_stdcall_call_8((CaptiveStdCallFunc8)DriverEntry,
+                       DriverEntry_DriverObject,
+                       DriverEntry_RegistryPath);
        if (!NT_SUCCESS(err))
                goto err_LdrUnloadModule;
 
index 032a036..4f08ef8 100644 (file)
@@ -58,7 +58,10 @@ static void PoQueueShutdownWorkItem_func(struct captive_work_queue_item *captive
 {
        g_return_if_fail(captive_work_queue_item!=NULL);
 
-       (*captive_work_queue_item->WorkerRoutine)(captive_work_queue_item->Parameter);
+       /* typedef VOID CAPTIVE_STDCALL (*PWORKER_THREAD_ROUTINE)(IN PVOID Context); */
+
+       captive_stdcall_call_4((CaptiveStdCallFunc4)captive_work_queue_item->WorkerRoutine,
+                       captive_work_queue_item->Parameter);    /* Context */
 
        g_free(captive_work_queue_item);
 }
@@ -79,8 +82,6 @@ struct captive_work_queue_item *captive_work_queue_item;
 
        /* FIXME: Should we check for func/data dupes? Are they permitted by W32? */
 
-       /* typedef VOID (*PWORKER_THREAD_ROUTINE)(IN PVOID Context); */
-
        ghook=g_hook_alloc(&captive_PoQueueShutdownWorkItem_hooklist);
        ghook->func=PoQueueShutdownWorkItem_func;
        ghook->data=captive_work_queue_item;
index 2b1b3ac..12854b1 100644 (file)
@@ -21,6 +21,7 @@ include $(top_srcdir)/src/libcaptive/Makefile-libcaptive.am
 
 noinst_LTLIBRARIES=libps.la
 libps_la_SOURCES= \
+               calltype.S \
                create.c \
                math.c \
                ps_reactos.c \
diff --git a/src/libcaptive/ps/calltype.S b/src/libcaptive/ps/calltype.S
new file mode 100644 (file)
index 0000000..c03b630
--- /dev/null
@@ -0,0 +1,66 @@
+/* $Id$
+ * CAPTIVE_STDCALL calling by hand as GCC has it broken
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+/*
+ * typedef gpointer CAPTIVE_STDCALL (*CaptiveStdCallFunc4 )(gpointer arg0);
+ * gpointer captive_stdcall_call_4 (CaptiveStdCallFunc4  func,gpointer arg0);
+ */
+       .globl captive_stdcall_call_4
+captive_stdcall_call_4:
+       pushl %ebp      /* std stack frame */
+       movl  %esp,%ebp /* std stack frame */
+       pushl 12(%ebp)  /* arg0 */
+       movl   8(%ebp),%eax     /* func */
+       call  *%eax
+       /* keep '%eax' return value */
+       leave
+       ret
+
+/*
+ * typedef gpointer CAPTIVE_STDCALL (*CaptiveStdCallFunc8 )(gpointer arg0,gpointer arg1);
+ * gpointer captive_stdcall_call_8 (CaptiveStdCallFunc8  func,gpointer arg0,gpointer arg1);
+ */
+       .globl captive_stdcall_call_8
+captive_stdcall_call_8:
+       pushl %ebp      /* std stack frame */
+       movl  %esp,%ebp /* std stack frame */
+       pushl 16(%ebp)  /* arg1 */
+       pushl 12(%ebp)  /* arg0 */
+       movl   8(%ebp),%eax     /* func */
+       call  *%eax
+       /* keep '%eax' return value */
+       leave
+       ret
+
+/*
+ * typedef gpointer CAPTIVE_STDCALL (*CaptiveStdCallFunc12)(gpointer arg0,gpointer arg1,gpointer arg2);
+ * gpointer captive_stdcall_call_12(CaptiveStdCallFunc12 func,gpointer arg0,gpointer arg1,gpointer arg2);
+ */
+       .globl captive_stdcall_call_12
+captive_stdcall_call_12:
+       pushl %ebp      /* std stack frame */
+       movl  %esp,%ebp /* std stack frame */
+       pushl 20(%ebp)  /* arg2 */
+       pushl 16(%ebp)  /* arg1 */
+       pushl 12(%ebp)  /* arg0 */
+       movl   8(%ebp),%eax     /* func */
+       call  *%eax
+       /* keep '%eax' return value */
+       leave
+       ret