From 272cd40139f2b0f05a12d021b2b090417a4e0817 Mon Sep 17 00:00:00 2001 From: short <> Date: Tue, 23 Sep 2003 07:08:58 +0000 Subject: [PATCH] +CAPTIVE_STDCALL calling by hand to workaround broken GCC. --- src/libcaptive/cc/sharedcachemap.c | 8 +-- src/libcaptive/client/init.c | 4 +- src/libcaptive/ex/work.c | 3 +- src/libcaptive/include/captive/calltype_reactos.h | 10 ++++ src/libcaptive/ldr/loader.c | 4 +- src/libcaptive/po/shutdownwork.c | 7 +-- src/libcaptive/ps/Makefile.am | 1 + src/libcaptive/ps/calltype.S | 66 +++++++++++++++++++++++ 8 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 src/libcaptive/ps/calltype.S diff --git a/src/libcaptive/cc/sharedcachemap.c b/src/libcaptive/cc/sharedcachemap.c index 8b68ac7..6dec135 100644 --- a/src/libcaptive/cc/sharedcachemap.c +++ b/src/libcaptive/cc/sharedcachemap.c @@ -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; diff --git a/src/libcaptive/client/init.c b/src/libcaptive/client/init.c index 85dfdbd..9b7469e 100644 --- a/src/libcaptive/client/init.c +++ b/src/libcaptive/client/init.c @@ -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; diff --git a/src/libcaptive/ex/work.c b/src/libcaptive/ex/work.c index 980960b..3094f61 100644 --- a/src/libcaptive/ex/work.c +++ b/src/libcaptive/ex/work.c @@ -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 */ diff --git a/src/libcaptive/include/captive/calltype_reactos.h b/src/libcaptive/include/captive/calltype_reactos.h index 44586e0..59b166d 100644 --- a/src/libcaptive/include/captive/calltype_reactos.h +++ b/src/libcaptive/include/captive/calltype_reactos.h @@ -22,6 +22,7 @@ #include +#include /* 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 diff --git a/src/libcaptive/ldr/loader.c b/src/libcaptive/ldr/loader.c index 9829310..8629e22 100644 --- a/src/libcaptive/ldr/loader.c +++ b/src/libcaptive/ldr/loader.c @@ -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; diff --git a/src/libcaptive/po/shutdownwork.c b/src/libcaptive/po/shutdownwork.c index 032a036..4f08ef8 100644 --- a/src/libcaptive/po/shutdownwork.c +++ b/src/libcaptive/po/shutdownwork.c @@ -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; diff --git a/src/libcaptive/ps/Makefile.am b/src/libcaptive/ps/Makefile.am index 2b1b3ac..12854b1 100644 --- a/src/libcaptive/ps/Makefile.am +++ b/src/libcaptive/ps/Makefile.am @@ -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 index 0000000..c03b630 --- /dev/null +++ b/src/libcaptive/ps/calltype.S @@ -0,0 +1,66 @@ +/* $Id$ + * CAPTIVE_STDCALL calling by hand as GCC has it broken + * Copyright (C) 2003 Jan Kratochvil + * + * 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 -- 1.8.3.1