mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-01-31 20:50:47 +00:00
64bit plugin fixes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4120 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
c39db1d7a4
commit
3a6f3fd66c
3 changed files with 59 additions and 38 deletions
|
@ -233,11 +233,11 @@ int IRC_CvarUpdate(void) // perhaps void instead?
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRC_Command(char *args);
|
void IRC_Command(char *args);
|
||||||
int IRC_ExecuteCommand(int *args);
|
qintptr_t IRC_ExecuteCommand(qintptr_t *args);
|
||||||
int IRC_ConExecuteCommand(int *args);
|
qintptr_t IRC_ConExecuteCommand(qintptr_t *args);
|
||||||
int IRC_Frame(int *args);
|
qintptr_t IRC_Frame(qintptr_t *args);
|
||||||
|
|
||||||
int Plug_Init(int *args)
|
qintptr_t Plug_Init(qintptr_t *args)
|
||||||
{
|
{
|
||||||
if ( Plug_Export("Tick", IRC_Frame) &&
|
if ( Plug_Export("Tick", IRC_Frame) &&
|
||||||
Plug_Export("ExecuteCommand", IRC_ExecuteCommand))
|
Plug_Export("ExecuteCommand", IRC_ExecuteCommand))
|
||||||
|
@ -279,7 +279,7 @@ int Plug_Init(int *args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int IRC_ExecuteCommand(int *args)
|
qintptr_t IRC_ExecuteCommand(qintptr_t *args)
|
||||||
{
|
{
|
||||||
char cmd[8];
|
char cmd[8];
|
||||||
Cmd_Argv(0, cmd, sizeof(cmd));
|
Cmd_Argv(0, cmd, sizeof(cmd));
|
||||||
|
@ -290,7 +290,7 @@ int IRC_ExecuteCommand(int *args)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int IRC_ConExecuteCommand(int *args)
|
qintptr_t IRC_ConExecuteCommand(qintptr_t *args)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int cmdlen;
|
int cmdlen;
|
||||||
|
@ -339,7 +339,7 @@ ircclient_t *IRC_Connect(char *server, int defport)
|
||||||
|
|
||||||
//not yet blocking. So no frequent attempts please...
|
//not yet blocking. So no frequent attempts please...
|
||||||
//non blocking prevents connect from returning worthwhile sensible value.
|
//non blocking prevents connect from returning worthwhile sensible value.
|
||||||
if ((int)irc->socket < 0)
|
if ((qintptr_t)irc->socket < 0)
|
||||||
{
|
{
|
||||||
Con_Printf("IRC_OpenSocket: couldn't connect\n");
|
Con_Printf("IRC_OpenSocket: couldn't connect\n");
|
||||||
IRC_Free(irc);
|
IRC_Free(irc);
|
||||||
|
@ -1324,7 +1324,7 @@ int IRC_ClientFrame(ircclient_t *irc)
|
||||||
//functions above this line allow connections to multiple servers.
|
//functions above this line allow connections to multiple servers.
|
||||||
//it is just the control functions that only allow one server.
|
//it is just the control functions that only allow one server.
|
||||||
|
|
||||||
int IRC_Frame(int *args)
|
qintptr_t IRC_Frame(qintptr_t *args)
|
||||||
{
|
{
|
||||||
int stat = IRC_CONTINUE;
|
int stat = IRC_CONTINUE;
|
||||||
if (ircclient)
|
if (ircclient)
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
const char *name;
|
||||||
export_t func;
|
export_t func;
|
||||||
} exports_t;
|
} exports_t;
|
||||||
extern exports_t exports[16];
|
extern exports_t exports[16];
|
||||||
|
|
||||||
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 )
|
qintptr_t NATIVEEXPORT vmMain( qintptr_t command, qintptr_t arg0, qintptr_t arg1, qintptr_t arg2, qintptr_t arg3, qintptr_t arg4, qintptr_t arg5, qintptr_t arg6, qintptr_t arg7, qintptr_t arg8, qintptr_t arg9, qintptr_t arg10, qintptr_t arg11 )
|
||||||
{
|
{
|
||||||
int ret;
|
qintptr_t ret;
|
||||||
int args[12];
|
qintptr_t args[12];
|
||||||
args[0] = arg0;
|
args[0] = arg0;
|
||||||
args[1] = arg1;
|
args[1] = arg1;
|
||||||
args[2] = arg2;
|
args[2] = arg2;
|
||||||
|
@ -31,27 +31,27 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a
|
||||||
|
|
||||||
|
|
||||||
#ifndef Q3_VM
|
#ifndef Q3_VM
|
||||||
int (QDECL *plugin_syscall)( int arg, ... );
|
qintptr_t (QDECL *plugin_syscall)( qintptr_t arg, ... );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PASSFLOAT(f) *(int*)&(f)
|
#define PASSFLOAT(f) *(int*)&(f)
|
||||||
|
|
||||||
#define ARGNAMES ,funcname
|
#define ARGNAMES ,funcname
|
||||||
BUILTINR(funcptr_t, Plug_GetEngineFunction, (char *funcname));
|
BUILTINR(funcptr_t, Plug_GetEngineFunction, (const char *funcname));
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
|
||||||
#define ARGNAMES ,funcname,expnum
|
#define ARGNAMES ,funcname,expnum
|
||||||
BUILTINR(int, Plug_ExportToEngine, (char *funcname, int expnum));
|
BUILTINR(int, Plug_ExportToEngine, (const char *funcname, int expnum));
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
|
||||||
#ifndef Q3_VM
|
#ifndef Q3_VM
|
||||||
#define ARGNAMES ,funcname,func
|
#define ARGNAMES ,funcname,func
|
||||||
BUILTINR(qboolean, Plug_ExportNative, (char *funcname, void *func));
|
BUILTINR(qboolean, Plug_ExportNative, (const char *funcname, void *func));
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARGNAMES ,text
|
#define ARGNAMES ,text
|
||||||
BUILTIN(void, Con_Print, (char *text)); //on to main console.
|
BUILTIN(void, Con_Print, (const char *text)); //on to main console.
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
|
||||||
#define ARGNAMES ,conname,text
|
#define ARGNAMES ,conname,text
|
||||||
|
@ -254,7 +254,7 @@ char *va(char *format, ...) //Identical in function to the one in Quake, though
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Con_Printf(char *format, ...)
|
void Con_Printf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char string[1024];
|
static char string[1024];
|
||||||
|
@ -265,7 +265,7 @@ void Con_Printf(char *format, ...)
|
||||||
|
|
||||||
Con_Print(string);
|
Con_Print(string);
|
||||||
}
|
}
|
||||||
void Sys_Errorf(char *format, ...)
|
void Sys_Errorf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char string[1024];
|
static char string[1024];
|
||||||
|
@ -370,14 +370,14 @@ void Plug_InitStandardBuiltins(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q3_VM
|
#ifndef Q3_VM
|
||||||
void dllEntry(int (QDECL *funcptr)(int,...))
|
void NATIVEEXPORT dllEntry(qintptr_t (QDECL *funcptr)(qintptr_t,...))
|
||||||
{
|
{
|
||||||
plugin_syscall = funcptr;
|
plugin_syscall = funcptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vmvideo_t vid;
|
vmvideo_t vid;
|
||||||
int Plug_UpdateVideo(int *args)
|
qintptr_t Plug_UpdateVideo(qintptr_t *args)
|
||||||
{
|
{
|
||||||
vid.width = args[0];
|
vid.width = args[0];
|
||||||
vid.height = args[1];
|
vid.height = args[1];
|
||||||
|
@ -385,7 +385,7 @@ int Plug_UpdateVideo(int *args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Plug_InitAPI(int *args)
|
qintptr_t Plug_InitAPI(qintptr_t *args)
|
||||||
{
|
{
|
||||||
#ifdef Q3_VM
|
#ifdef Q3_VM
|
||||||
Plug_GetEngineFunction = (void*)args[0];
|
Plug_GetEngineFunction = (void*)args[0];
|
||||||
|
@ -399,7 +399,7 @@ int Plug_InitAPI(int *args)
|
||||||
return Plug_Init(args);
|
return Plug_Init(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean Plug_Export(char *name, export_t func)
|
qboolean Plug_Export(const char *name, export_t func)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < sizeof(exports)/sizeof(exports[0]); i++)
|
for (i = 0; i < sizeof(exports)/sizeof(exports[0]); i++)
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#ifdef Q3_VM
|
#ifdef Q3_VM
|
||||||
|
|
||||||
|
typedef int qintptr_t;
|
||||||
|
typedef unsigned int quintptr_t;
|
||||||
|
|
||||||
#define TESTBI 1
|
#define TESTBI 1
|
||||||
#ifdef TESTBI
|
#ifdef TESTBI
|
||||||
# define EBUILTIN(t, n, args) extern t (*n) args
|
# define EBUILTIN(t, n, args) extern t (*n) args
|
||||||
|
@ -51,28 +54,41 @@ void BadBuiltin(void);
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
typedef long long qintptr_t;
|
||||||
|
typedef unsigned long long quintptr_t;
|
||||||
|
#else
|
||||||
|
typedef long qintptr_t;
|
||||||
|
typedef unsigned long quintptr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#define NATIVEEXPORT __attribute__((visibility("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//DLLs need a wrapper to add the extra parameter and call a boring function.
|
//DLLs need a wrapper to add the extra parameter and call a boring function.
|
||||||
#define EBUILTIN(t, n, args) extern int BUILTIN_##n; t n args
|
#define EBUILTIN(t, n, args) extern qintptr_t BUILTIN_##n; t n args
|
||||||
#define TEST
|
#define TEST
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#define BUILTINR(t, n, args) int BUILTIN_##n; t n args {int res; if (!BUILTINISVALID(n))Sys_Error("Builtin "#n" is not valid\n");res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
|
#define BUILTINR(t, n, args) qintptr_t BUILTIN_##n; t n args {qintptr_t res; if (!BUILTINISVALID(n))Sys_Error("Builtin "#n" is not valid\n");res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
|
||||||
#define BUILTIN(t, n, args) int BUILTIN_##n; t n args {if (!BUILTINISVALID(n))Sys_Error("Builtin "#n" is not valid\n");plugin_syscall(BUILTIN_##n ARGNAMES);}
|
#define BUILTIN(t, n, args) qintptr_t BUILTIN_##n; t n args {if (!BUILTINISVALID(n))Sys_Error("Builtin "#n" is not valid\n");plugin_syscall(BUILTIN_##n ARGNAMES);}
|
||||||
#else
|
#else
|
||||||
#define BUILTINR(t, n, args) int BUILTIN_##n; t n args {int res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
|
#define BUILTINR(t, n, args) qintptr_t BUILTIN_##n; t n args {qintptr_t res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
|
||||||
#define BUILTIN(t, n, args) int BUILTIN_##n; t n args {plugin_syscall(BUILTIN_##n ARGNAMES);}
|
#define BUILTIN(t, n, args) qintptr_t BUILTIN_##n; t n args {plugin_syscall(BUILTIN_##n ARGNAMES);}
|
||||||
#endif
|
#endif
|
||||||
#define CHECKBUILTIN(n) BUILTIN_##n = (int)Plug_GetEngineFunction(#n);
|
#define CHECKBUILTIN(n) BUILTIN_##n = (qintptr_t)Plug_GetEngineFunction(#n);
|
||||||
#define BUILTINISVALID(n) (BUILTIN_##n != 0)
|
#define BUILTINISVALID(n) (BUILTIN_##n != 0)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define QDECL __cdecl
|
#define QDECL __cdecl
|
||||||
#else
|
#else
|
||||||
#define QDECL
|
#define QDECL
|
||||||
#endif
|
#endif
|
||||||
extern int (*plugin_syscall)( int arg, ... );
|
extern qintptr_t (*plugin_syscall)( qintptr_t arg, ... );
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void strlcpy(char *d, const char *s, int n);
|
void strlcpy(char *d, const char *s, int n);
|
||||||
|
@ -80,6 +96,11 @@ int snprintf(char *buffer, size_t maxlen, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NATIVEEXPORT
|
||||||
|
#define NATIVEEXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
typedef enum {qfalse, qtrue} qboolean;
|
typedef enum {qfalse, qtrue} qboolean;
|
||||||
#else
|
#else
|
||||||
|
@ -112,11 +133,11 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
//Basic builtins:
|
//Basic builtins:
|
||||||
EBUILTIN(funcptr_t, Plug_GetEngineFunction, (char *funcname)); //set up in vmMain, use this to get all other builtins
|
EBUILTIN(funcptr_t, Plug_GetEngineFunction, (const char *funcname)); //set up in vmMain, use this to get all other builtins
|
||||||
#ifndef Q3_VM
|
#ifndef Q3_VM
|
||||||
EBUILTIN(qboolean, Plug_ExportNative, (char *funcname, void *func)); //set up in vmMain, use this to get all other builtins
|
EBUILTIN(qboolean, Plug_ExportNative, (const char *funcname, void *func)); //set up in vmMain, use this to get all other builtins
|
||||||
#endif
|
#endif
|
||||||
EBUILTIN(void, Con_Print, (char *text)); //on to main console.
|
EBUILTIN(void, Con_Print, (const char *text)); //on to main console.
|
||||||
|
|
||||||
EBUILTIN(void, Con_SubPrint, (char *subname, char *text)); //on to sub console.
|
EBUILTIN(void, Con_SubPrint, (char *subname, char *text)); //on to sub console.
|
||||||
EBUILTIN(void, Con_RenameSub, (char *oldname, char *newname)); //rename a console.
|
EBUILTIN(void, Con_RenameSub, (char *oldname, char *newname)); //rename a console.
|
||||||
|
@ -199,12 +220,12 @@ EBUILTIN(float, cos, (float f));
|
||||||
EBUILTIN(float, sin, (float f));
|
EBUILTIN(float, sin, (float f));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*export_t) (int *args);
|
typedef qintptr_t (*export_t) (qintptr_t *args);
|
||||||
char *va(char *format, ...);
|
char *va(char *format, ...);
|
||||||
int Plug_Init(int *args);
|
qintptr_t Plug_Init(qintptr_t *args);
|
||||||
qboolean Plug_Export(char *name, export_t func);
|
qboolean Plug_Export(const char *name, export_t func);
|
||||||
void Con_Printf(char *format, ...);
|
void Con_Printf(const char *format, ...);
|
||||||
void Sys_Errorf(char *format, ...);
|
void Sys_Errorf(const char *format, ...);
|
||||||
typedef unsigned char qbyte;
|
typedef unsigned char qbyte;
|
||||||
void Q_strncpyz(char *d, const char *s, int n);
|
void Q_strncpyz(char *d, const char *s, int n);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue