Mercurial > hg > octave-lojdl
changeset 7872:1b63f8da772d
fix unloading of mex files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 05 Jun 2008 14:41:52 -0400 |
parents | ab9fc4e3cdca |
children | 02b590f46a29 |
files | liboctave/ChangeLog liboctave/oct-shlib.cc src/ChangeLog src/dynamic-ld.cc src/dynamic-ld.h src/ov-dld-fcn.cc src/ov-mex-fcn.cc |
diffstat | 7 files changed, 83 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2008-06-05 John W. Eaton <jwe@octave.org> + + * oct-shlib.cc (octave_base_shlib::remove): Only dereference + counter if iterator is valid. + 2008-06-02 David Bateman <dbateman@free.fr> * fCmplxDET.cc (FloatComplexDET::value_will_overflow,
--- a/liboctave/oct-shlib.cc +++ b/liboctave/oct-shlib.cc @@ -136,7 +136,7 @@ fcn_names_iterator p = fcn_names.find (fcn_name); - if (--(p->second) == 0) + if (p != fcn_names.end () && --(p->second) == 0) { fcn_names.erase (fcn_name); retval = true;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2008-06-05 John W. Eaton <jwe@octave.org> + * dynamic-ld.cc (octave_dynamic_loader::mex_mangler, + octave_dynamic_loader::mex_uscore_mangler, + octave_dynamic_loader::mex_f77_mangler): New functions. + (octave_dynamic_loader::do_load_mex): Use them. + (octave_dynamic_loader::do_remove_oct): Rename from + octave_dynamic_loader::do_remove. + (octave_dynamic_loader::do_remove_mex): New function. + * dynamic-ld.h: Provide/fix decls. + * graphics.cc (properties::update_normals): Style fixes. * graphics.h.in: Style fixes.
--- a/src/dynamic-ld.cc +++ b/src/dynamic-ld.cc @@ -420,18 +420,19 @@ { octave_mex_file_list::append (mex_file); - function = mex_file.search ("mexFunction"); + 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 ("_mexFunction"); + function = mex_file.search (fcn_name, mex_uscore_mangler); if (! function) { - function = mex_file.search (STRINGIFY (F77_FUNC (mexfunction, MEXFUNCTION))); + function = mex_file.search (fcn_name, mex_f77_mangler); + if (function) have_fmex = true; } @@ -454,7 +455,8 @@ } bool -octave_dynamic_loader::do_remove (const std::string& fcn_name, octave_shlib& shl) +octave_dynamic_loader::do_remove_oct (const std::string& fcn_name, + octave_shlib& shl) { bool retval = false; @@ -472,6 +474,26 @@ return retval; } +bool +octave_dynamic_loader::do_remove_mex (const std::string& fcn_name, + octave_shlib& shl) +{ + bool retval = false; + + // We don't need to do anything if this is called because we are in + // the process of reloading a .oct file that has changed. + + if (! doing_load) + { + retval = shl.remove (fcn_name); + + if (shl.number_of_functions_loaded () == 0) + octave_mex_file_list::remove (shl); + } + + return retval; +} + octave_function * octave_dynamic_loader::load_oct (const std::string& fcn_name, const std::string& file_name, @@ -491,9 +513,17 @@ } bool -octave_dynamic_loader::remove (const std::string& fcn_name, octave_shlib& shl) +octave_dynamic_loader::remove_oct (const std::string& fcn_name, + octave_shlib& shl) { - return (instance_ok ()) ? instance->do_remove (fcn_name, shl) : false; + return (instance_ok ()) ? instance->do_remove_oct (fcn_name, shl) : false; +} + +bool +octave_dynamic_loader::remove_mex (const std::string& fcn_name, + octave_shlib& shl) +{ + return (instance_ok ()) ? instance->do_remove_mex (fcn_name, shl) : false; } std::string @@ -524,6 +554,24 @@ return retval; } +std::string +octave_dynamic_loader::mex_mangler (const std::string&) +{ + return "mexFunction"; +} + +std::string +octave_dynamic_loader::mex_uscore_mangler (const std::string&) +{ + return "_mexFunction"; +} + +std::string +octave_dynamic_loader::mex_f77_mangler (const std::string&) +{ + return STRINGIFY (F77_FUNC (mexfunction, MEXFUNCTION)); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/src/dynamic-ld.h +++ b/src/dynamic-ld.h @@ -51,7 +51,9 @@ const std::string& file_name = std::string (), bool relative = false); - static bool remove (const std::string& fcn_name, octave_shlib& shl); + static bool remove_oct (const std::string& fcn_name, octave_shlib& shl); + + static bool remove_mex (const std::string& fcn_name, octave_shlib& shl); private: @@ -75,7 +77,9 @@ const std::string& file_name = std::string (), bool relative = false); - bool do_remove (const std::string& fcn_name, octave_shlib& shl); + bool do_remove_oct (const std::string& fcn_name, octave_shlib& shl); + + bool do_remove_mex (const std::string& fcn_name, octave_shlib& shl); static bool doing_load; @@ -84,6 +88,12 @@ static std::string mangle_name (const std::string& name); static std::string xmangle_name (const std::string& name); + + static std::string mex_mangler (const std::string& name); + + static std::string mex_uscore_mangler (const std::string& name); + + static std::string mex_f77_mangler (const std::string& name); }; #endif