From b193bca2bd5c28b1aad894e66d9ff199decbf491 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 15 Sep 2008 05:54:44 +0000 Subject: [PATCH] fix a bug in the windows gdb stub caused by passing a fastcall callback to createthread --- desmume/src/gdbstub.h | 23 ++++++++++------------- desmume/src/gdbstub/gdbstub.cpp | 2 +- desmume/src/types.h | 2 ++ desmume/src/windows/DeSmuME_2005.vcproj | 4 ++-- desmume/src/windows/main.cpp | 6 +++--- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/desmume/src/gdbstub.h b/desmume/src/gdbstub.h index 697937c32..06544d6e7 100644 --- a/desmume/src/gdbstub.h +++ b/desmume/src/gdbstub.h @@ -1,5 +1,3 @@ -#ifndef _GDBSTUB_H_ -#define _GDBSTUB_H_ 1 /* $Id: gdbstub.h,v 1.1 2007-06-07 09:43:25 masscat Exp $ */ /* Copyright (C) 2006 Ben Jaques @@ -22,11 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __cplusplus -#define EXTERNC extern "C" -#else -#define EXTERNC -#endif +#ifndef _GDBSTUB_H_ +#define _GDBSTUB_H_ 1 + +#include "types.h" typedef void *gdbstub_handle_t; @@ -34,15 +31,15 @@ typedef void *gdbstub_handle_t; * The function interface */ -EXTERNC gdbstub_handle_t +gdbstub_handle_t createStub_gdb( u16 port, struct armcpu_memory_iface **cpu_memio, struct armcpu_memory_iface *direct_memio); -EXTERNC void +void destroyStub_gdb( gdbstub_handle_t stub); -EXTERNC void +void activateStub_gdb( gdbstub_handle_t stub, struct armcpu_ctrl_iface *cpu_ctrl); @@ -50,11 +47,11 @@ activateStub_gdb( gdbstub_handle_t stub, * An implementation of the following functions is required * for the GDB stub to function. */ -EXTERNC void * -createThread_gdb( void (*thread_function)( void *data), +void * +createThread_gdb( void (WINAPI *thread_function)( void *data), void *thread_data); -EXTERNC void +void joinThread_gdb( void *thread_handle); #endif /* End of _GDBSTUB_H_ */ diff --git a/desmume/src/gdbstub/gdbstub.cpp b/desmume/src/gdbstub/gdbstub.cpp index 62e1b28be..570363c3f 100644 --- a/desmume/src/gdbstub/gdbstub.cpp +++ b/desmume/src/gdbstub/gdbstub.cpp @@ -1041,7 +1041,7 @@ execute_gdb( void *data, uint32_t instr_addr, int thumb) { } static void -listenerThread_gdb( void *data) { +WINAPI listenerThread_gdb( void *data) { struct gdb_stub_state *state = (struct gdb_stub_state *)data; fd_set read_sock_set; fd_set main_set; diff --git a/desmume/src/types.h b/desmume/src/types.h index 291b116ad..2eb31ffd9 100644 --- a/desmume/src/types.h +++ b/desmume/src/types.h @@ -22,6 +22,8 @@ #ifdef _WIN32 #define strcasecmp(x,y) stricmp(x,y) +#else +#define WINAPI #endif #ifdef _MSC_VER diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 5a8415f6d..d77f9abc3 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -55,7 +55,7 @@ WholeProgramOptimization="false" AdditionalIncludeDirectories="..;.\zlib123;.\zziplib" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\"0.8.0b2 DEBUG\";WIN32;BETA_VERSION;SPU_INTERPOLATE;HAVE_LIBZ;GDB_STUB" - ExceptionHandling="0" + ExceptionHandling="1" BufferSecurityCheck="false" EnableEnhancedInstructionSet="0" DebugInformationFormat="4" @@ -142,7 +142,7 @@ AdditionalIncludeDirectories="..;.\zlib123;.\zziplib" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\"0.8.0b2\";WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;GDB_STUB;SPU_INTERPOLATE" StringPooling="true" - ExceptionHandling="0" + ExceptionHandling="1" BufferSecurityCheck="false" EnableEnhancedInstructionSet="0" FloatingPointModel="2" diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index be6dd057f..bde8a0a0b 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -681,8 +681,8 @@ BOOL LoadROM(char * filename, const char *cflash_disk_image) /* * The thread handling functions needed by the GDB stub code. */ -extern "C" void * -createThread_gdb( void (*thread_function)( void *data), +void * +createThread_gdb( void (APIENTRY *thread_function)( void *data), void *thread_data) { void *new_thread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)thread_function, thread_data, @@ -691,7 +691,7 @@ createThread_gdb( void (*thread_function)( void *data), return new_thread; } -extern "C" void +void joinThread_gdb( void *thread_handle) { }