fuzzball
fuzzball copied to clipboard
Improve abort_interp macro to avoid usage of globals
abort_interp uses the global variables oper1, oper2, oper3, and oper4 which are defined in the header of each primitive file (p_*.c). abort_interp passes these variables to do_abort_interp which is an actual function that, in turn, may use those variables in messaging and similar purposes.
This is completely not threadsafe and generally just not good modern coding practice. Wyld has put effort into removing the usage of other globals in the p_*.c files but this will be a more concentrated effort as it will probably require a lot of rewrites. There's a lot of macro infrastructure built around those oper variables, used all over the place; how this functions will need to be re-imagined.
This kind of strikes me as a use-case for C++. If each MUF prim was an implementation of a base class, the operation variables could be base-class properties, and abort_interp could be a base class method. Really, the MUF implementation gets much cleaner in general as a class-based structure and it promotes a lot of re-use. It would basically remove the need for any of those macros.