changeset 28130:0a88a4743096

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.
author John W. Eaton <jwe@octave.org>
date Tue, 18 Feb 2020 12:50:18 -0500
parents 5b37e5e03bb5
children 4c21f99b4ad5
files libinterp/corefcn/dynamic-ld.cc libinterp/corefcn/dynamic-ld.h libinterp/octave-value/ov-mex-fcn.cc libinterp/octave-value/ov-mex-fcn.h
diffstat 4 files changed, 53 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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);
   };
 }
 
--- 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 ());
 
--- 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.