# HG changeset patch # User John W. Eaton # Date 1582048218 18000 # Node ID 0a88a4743096913c1f2b1382dac9dcb6e8557fab # Parent 5b37e5e03bb5996037e79b0ba18bbb7cf74b5130 tag mex function as supporting interleaved complex (or not) * dynamic-ld.cc (dynamic_loader::try_load_mex): New function. (dynamic_loader::load_mex): Call it. Check mex file for __mx_has_interleaved_complex__ symbol and pass flag to octave_mex_function constructor. * ov-mex-fcn.cc (octave_mex_function::m_interleaved): New data member. (octave_mex_function::octave_mex_function): New arg, interleaved. (octave_mex_function::use_interleaved_complex): New function. diff -r 5b37e5e03bb5 -r 0a88a4743096 libinterp/corefcn/dynamic-ld.cc --- a/libinterp/corefcn/dynamic-ld.cc Tue Feb 18 12:45:45 2020 -0500 +++ b/libinterp/corefcn/dynamic-ld.cc Tue Feb 18 12:50:18 2020 -0500 @@ -199,13 +199,41 @@ return retval; } + void * + dynamic_loader::try_load_mex (dynamic_library& mex_file, + const std::string& fcn_name, bool& have_fmex) + { + // FCN_NAME is not used here, the mangler functions always return + // some form of "mexFunction". + + have_fmex = false; + + void *function = mex_file.search (fcn_name, mex_mangler); + + if (! function) + { + // FIXME: Can we determine this C mangling scheme + // automatically at run time or configure time? + + function = mex_file.search (fcn_name, mex_uscore_mangler); + + if (! function) + { + function = mex_file.search (fcn_name, mex_f77_mangler); + + if (function) + have_fmex = true; + } + } + + return function; + } + octave_function * dynamic_loader::load_mex (const std::string& fcn_name, const std::string& file_name, bool /*relative*/) { - octave_function *retval = nullptr; - unwind_protect frame; frame.protect_var (m_doing_load); @@ -230,29 +258,17 @@ bool have_fmex = false; - void *function = mex_file.search (fcn_name, mex_mangler); - - if (! function) - { - // FIXME: Can we determine this C mangling scheme - // automatically at run time or configure time? - function = mex_file.search (fcn_name, mex_uscore_mangler); - - if (! function) - { - function = mex_file.search (fcn_name, mex_f77_mangler); - - if (function) - have_fmex = true; - } - } + void *function = try_load_mex (mex_file, fcn_name, have_fmex); if (! function) error ("failed to install .mex file function '%s'", fcn_name.c_str ()); - retval = new octave_mex_function (function, have_fmex, mex_file, fcn_name); + void *symbol = mex_file.search ("__mx_has_interleaved_complex__"); - return retval; + bool interleaved = symbol != nullptr; + + return new octave_mex_function (function, interleaved, have_fmex, + mex_file, fcn_name); } bool diff -r 5b37e5e03bb5 -r 0a88a4743096 libinterp/corefcn/dynamic-ld.h --- a/libinterp/corefcn/dynamic-ld.h Tue Feb 18 12:45:45 2020 -0500 +++ b/libinterp/corefcn/dynamic-ld.h Tue Feb 18 12:50:18 2020 -0500 @@ -128,6 +128,9 @@ static std::string mex_uscore_mangler (const std::string& name); static std::string mex_f77_mangler (const std::string& name); + + static void * try_load_mex (dynamic_library& mex_file, + const std::string& fcn_name, bool& have_fmex); }; } diff -r 5b37e5e03bb5 -r 0a88a4743096 libinterp/octave-value/ov-mex-fcn.cc --- a/libinterp/octave-value/ov-mex-fcn.cc Tue Feb 18 12:45:45 2020 -0500 +++ b/libinterp/octave-value/ov-mex-fcn.cc Tue Feb 18 12:50:18 2020 -0500 @@ -46,10 +46,11 @@ "mex function", "mex function"); octave_mex_function::octave_mex_function - (void *fptr, bool fmex, const octave::dynamic_library& shl, + (void *fptr, bool interleaved, bool fmex, const octave::dynamic_library& shl, const std::string& nm) : octave_function (nm), m_mex_fcn_ptr (fptr), m_exit_fcn_ptr (nullptr), - m_is_fmex (fmex), m_sh_lib (shl) + m_sh_lib (shl), m_interleaved (interleaved), m_is_fmex (fmex), + m_is_system_fcn_file (false) { mark_fcn_file_up_to_date (time_parsed ()); diff -r 5b37e5e03bb5 -r 0a88a4743096 libinterp/octave-value/ov-mex-fcn.h --- a/libinterp/octave-value/ov-mex-fcn.h Tue Feb 18 12:45:45 2020 -0500 +++ b/libinterp/octave-value/ov-mex-fcn.h Tue Feb 18 12:50:18 2020 -0500 @@ -52,10 +52,12 @@ public: octave_mex_function (void) - : m_mex_fcn_ptr (), m_exit_fcn_ptr (), m_is_fmex (), m_sh_lib (), - m_time_checked (), m_is_system_fcn_file () { } + : m_mex_fcn_ptr (nullptr), m_exit_fcn_ptr (nullptr), m_sh_lib (), + m_time_checked (), m_interleaved (false), m_is_fmex (false), + m_is_system_fcn_file (false) + { } - octave_mex_function (void *fptr, bool fmex, + octave_mex_function (void *fptr, bool interleaved, bool fmex, const octave::dynamic_library& shl, const std::string& nm = ""); @@ -88,6 +90,8 @@ bool is_mex_function (void) const { return true; } + bool use_interleaved_complex (void) const { return m_interleaved; } + // We don't need to override both forms of the call method. The using // declaration will avoid warnings about partially-overloaded virtual // functions. @@ -111,14 +115,16 @@ void (*m_exit_fcn_ptr) (void); - bool m_is_fmex; - octave::dynamic_library m_sh_lib; // The time the file was last checked to see if it needs to be // parsed again. mutable octave::sys::time m_time_checked; + bool m_interleaved; + + bool m_is_fmex; + // True if this function came from a file that is considered to be a // system function. This affects whether we check the time stamp // on the file to see if it has changed.