From d268e8794a446a69ddf0b04cc4e9399f3518a618 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 30 Mar 2021 19:46:24 +0200 Subject: [PATCH] Declare callback delegates as using Cdecl calling convention, so it's consistent with the rest of the code and also consistent across all platforms. --- Assets/Scripts/SysCalls.cs | 4 ++++ engine/projects/uniquake/uniquake.h | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/SysCalls.cs b/Assets/Scripts/SysCalls.cs index e97de9c..2eea816 100644 --- a/Assets/Scripts/SysCalls.cs +++ b/Assets/Scripts/SysCalls.cs @@ -35,6 +35,7 @@ public class SysCalls: CallbackHandler public IntPtr SysFloatTime; } + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void SysPrintCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string message); [AOT.MonoPInvokeCallback(typeof(SysPrintCallback))] @@ -48,6 +49,7 @@ public class SysCalls: CallbackHandler Debug.Log(message); } + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void SysErrorCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string message); [AOT.MonoPInvokeCallback(typeof(SysErrorCallback))] @@ -63,6 +65,7 @@ public class SysCalls: CallbackHandler Application.Quit(1); } + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void SysQuitCallback(IntPtr target); [AOT.MonoPInvokeCallback(typeof(SysQuitCallback))] @@ -77,6 +80,7 @@ public class SysCalls: CallbackHandler Application.Quit(0); } + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate double SysFloatTimeCallback(IntPtr target); [AOT.MonoPInvokeCallback(typeof(SysFloatTimeCallback))] diff --git a/engine/projects/uniquake/uniquake.h b/engine/projects/uniquake/uniquake.h index 75b3462..a11ba31 100644 --- a/engine/projects/uniquake/uniquake.h +++ b/engine/projects/uniquake/uniquake.h @@ -13,10 +13,10 @@ typedef struct unity_syscalls_s { void *target; - void(__stdcall *SysPrint)(void *target, const char *msg); - void(__stdcall *SysError)(void *target, const char *msg); - void(__stdcall *SysQuit)(void *target); - double(__stdcall *SysFloatTime)(void *target); + void(*SysPrint)(void *target, const char *msg); + void(*SysError)(void *target, const char *msg); + void(*SysQuit)(void *target); + double(*SysFloatTime)(void *target); } unity_syscalls_t; extern const unity_syscalls_t *unity_syscalls;