summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-01-18 22:56:54 +0000
committerMichael Smith <mikesmiffy128@gmail.com>2022-01-18 22:56:54 +0000
commit98378138a521fa52758f1ed3501900e6c323c474 (patch)
tree2671a6cc1ba80d9790995b33205536c4184f55b2
parente388efa5eba02ce6909193f700f11fe1385230e9 (diff)
Very slightly tidy RTTI stuff
More handwavey Linux prep, nothing too significant.
-rw-r--r--src/abi.h24
-rw-r--r--src/con_.c16
-rw-r--r--src/con_.h17
3 files changed, 44 insertions, 13 deletions
diff --git a/src/abi.h b/src/abi.h
index 54c504a..5c9ae52 100644
--- a/src/abi.h
+++ b/src/abi.h
@@ -74,7 +74,7 @@ struct msvc_rtti_locator {
// I mean seriously look at this crap!
#define DEF_MSVC_BASIC_RTTI(mod, name, vtab, typestr) \
mod struct msvc_rtti_locator name; \
-static struct msvc_rtti_descriptor _desc_##name = {(vtab) + 1, 0, typestr}; \
+static struct msvc_rtti_descriptor _desc_##name = {(vtab), 0, typestr}; \
static struct msvc_basedesc _basedesc_##name = {&_desc_##name, 0, {0, 0, 0}, 0}; \
mod struct msvc_rtti_locator name = { \
0, 0, 0, \
@@ -84,6 +84,28 @@ mod struct msvc_rtti_locator name = { \
} \
};
+#else
+
+#warning FIXME! More stuff needs to be implemented/fixed here!
+
+struct itanium_type_info {
+ struct itanium_type_info_vtable {
+ void *dtor1, *dtor2; // ???
+ // there's some more functions here in libstdc++: is_pointer,
+ // is_function, do_catch, etc. however they're not specified in itanium
+ // abi doc. hoping to do without them, but we'll see I guess
+ } *vtable;
+ const char *name;
+};
+
+#define DEF_ITANIUM_BASIC_RTTI(mod, name, typestr) \
+ mod struct itanium_type_info name = { \
+ &(struct itanium_type_info_vtable){ \
+ 0, 0 /* FIXME/TEMP: definitely need real functions here! */ \
+ }, \
+ typestr \
+ };
+
#endif
#endif
diff --git a/src/con_.c b/src/con_.c
index 357430b..7525229 100644
--- a/src/con_.c
+++ b/src/con_.c
@@ -96,7 +96,7 @@ static inline void initval(struct con_var *v) {
// right next to each other.
static int vtidx_InternalSetValue;
-// implementatiosn of virtual functions for our vars and commands below...
+// implementation of virtual functions for our vars and commands below...
static void VCALLCONV dtor(void *_) {} // we don't use constructors/destructors
@@ -305,16 +305,16 @@ void *_con_vtab_cmd[14 + NVDTOR] = {
// the engine does dynamic_casts on ConVar at some points so we have to fill out
// bare minimum rtti to prevent crashes. oh goody.
#ifdef _WIN32
-DEF_MSVC_BASIC_RTTI(static, varrtti, _con_realvtab_var, "sst_ConVar")
+DEF_MSVC_BASIC_RTTI(static, varrtti, _con_vtab_var, "sst_ConVar")
+#else
+DEF_ITANIUM_BASIC_RTTI(static, varrtti, "sst_ConVar")
#endif
-void *_con_realvtab_var[20] = {
-#ifdef _WIN32
- &varrtti,
-#else
- // this, among many other things, will be totally different on linux
-#warning FIX THIS TOO!
+struct _con_vtab_var_wrap _con_vtab_var_wrap = {
+#ifndef _WIN32
+ 0, // this *is* the top, no offset needed :)
#endif
+ &varrtti,
(void *)&dtor,
#ifndef _WIN32
(void *)&dtor,
diff --git a/src/con_.h b/src/con_.h
index 653bdad..58a8d63 100644
--- a/src/con_.h
+++ b/src/con_.h
@@ -211,10 +211,19 @@ extern int con_cmdclient;
// internal detail, used by DEF_* macros below
extern void *_con_vtab_cmd[];
-// msvc rtti tables are offset negatively from the vtable pointer. to make this
-// a constant expression we have to use a macro
-#define _con_vtab_var (_con_realvtab_var + 1)
-extern void *_con_realvtab_var[];
+// rtti pointers are offset negatively from the vtable pointer. to make this
+// a constant expression we have to use a macro.
+extern struct _con_vtab_var_wrap {
+#ifdef _WIN32
+ struct msvc_rtti_locator *rtti;
+#else
+ // itanium ABI also has the top offset/"whole object" offset in libstdc++
+ ssize topoffset;
+ struct itanium_type_info *rtti;
+#endif
+ void *vtable[19];
+} _con_vtab_var_wrap;
+#define _con_vtab_var (_con_vtab_var_wrap.vtable)
extern void *_con_vtab_iconvar[];
#define _DEF_CVAR(name_, desc, value, hasmin_, min, hasmax_, max, flags_) \