Skip to content

Commit b7e95f8

Browse files
cursoragenttimfox
andcommitted
fix: keep native VM helper header lightweight
Co-authored-by: Tim Fox <timfox@outlook.com>
1 parent 5b2219b commit b7e95f8

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/qcommon/vm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,8 @@ intptr_t QDECL VM_Call( vm_t *vm, int nargs, int callnum, ... )
20332033
if ( vm->entryPoint )
20342034
{
20352035
va_list ap;
2036+
_Static_assert( VM_NATIVE_MODULE_ARG_COUNT == MAX_VMMAIN_CALL_ARGS - 1,
2037+
"native vmMain helper must pass every native arg slot" );
20362038
va_start( ap, callnum );
20372039
r = VM_CallNativeModuleEntryPoint( vm->entryPoint, nargs, callnum, ap );
20382040
va_end( ap );

src/qcommon/vm_native_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int VM_BuildNativeModuleLoadOrder( const char *moduleName, char out[][MAX_QPATH]
7676
}
7777

7878
intptr_t VM_CallNativeModuleEntryPoint( vmNativeModuleEntryPoint_t entryPoint, int nargs, int callnum, va_list ap ) {
79-
int32_t args[MAX_VMMAIN_CALL_ARGS - 1];
79+
int32_t args[VM_NATIVE_MODULE_ARG_COUNT];
8080
int i;
8181

8282
Com_Memset( args, 0, sizeof( args ) );

src/qcommon/vm_native_module.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef VM_NATIVE_MODULE_H
22
#define VM_NATIVE_MODULE_H
33

4-
#include "qcommon.h"
4+
#include "q_shared.h"
5+
6+
#define VM_NATIVE_MODULE_ARG_COUNT 3
57

68
typedef intptr_t (QDECL *vmNativeModuleEntryPoint_t)( int command, int arg0, int arg1, int arg2 );
79

0 commit comments

Comments
 (0)