Fix passing arguments to VM dylib on Apple M1

The engine function pointer to vmMain used variadic arguments but
the vmMain function in the dylib has explicit arguments. Evidently
the arguments are stored on the stack and/or registers differently.

Found by fretn.
This commit is contained in:
Zack Middleton 2021-11-19 13:45:35 -05:00
parent 68ac81316d
commit 75ae9119e6
3 changed files with 5 additions and 3 deletions

View file

@ -355,6 +355,8 @@ typedef enum {
TRAP_TESTPRINTFLOAT TRAP_TESTPRINTFLOAT
} sharedTraps_t; } sharedTraps_t;
typedef intptr_t (QDECL *vmMainProc)(int callNum, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11);
void VM_Init( void ); void VM_Init( void );
vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *),
vmInterpret_t interpret ); vmInterpret_t interpret );
@ -1080,7 +1082,7 @@ NON-PORTABLE SYSTEM SERVICES
void Sys_Init (void); void Sys_Init (void);
// general development dll loading for virtual machine testing // general development dll loading for virtual machine testing
void * QDECL Sys_LoadGameDll( const char *name, intptr_t (QDECL **entryPoint)(int, ...), void * QDECL Sys_LoadGameDll( const char *name, vmMainProc *entryPoint,
intptr_t (QDECL *systemcalls)(intptr_t, ...) ); intptr_t (QDECL *systemcalls)(intptr_t, ...) );
void Sys_UnloadDll( void *dllHandle ); void Sys_UnloadDll( void *dllHandle );

View file

@ -154,7 +154,7 @@ struct vm_s {
// for dynamic linked modules // for dynamic linked modules
void *dllHandle; void *dllHandle;
intptr_t (QDECL *entryPoint)( int callNum, ... ); vmMainProc entryPoint;
void (*destroy)(vm_t* self); void (*destroy)(vm_t* self);
// for interpreted modules // for interpreted modules

View file

@ -579,7 +579,7 @@ Used to load a development dll instead of a virtual machine
================= =================
*/ */
void *Sys_LoadGameDll(const char *name, void *Sys_LoadGameDll(const char *name,
intptr_t (QDECL **entryPoint)(int, ...), vmMainProc *entryPoint,
intptr_t (*systemcalls)(intptr_t, ...)) intptr_t (*systemcalls)(intptr_t, ...))
{ {
void *libHandle; void *libHandle;