Mercurial > octave
annotate libinterp/corefcn/dynamic-ld.h @ 23554:b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
* oct-shlib.h, oct-shlib.cc
(dynamic_library::dynlib_rep::function_names): New function.
(dynamic_library::dynlib_rep::clear_fcn_names)): New function.
(dynamic_library::dynlib_rep::do_close_hook): Delete.
(dynamic_library::close): Return list of function names instead of
calling close_hook function on each function name.
* dynamic-ld.h, dynamic-ld.cc (dynamic_loader::shlibs_list::remove):
Return list of removed functions instead of passing close_hook
function to the shared-library close function.
(dynamic_loader::do_clear): Clear functions removed from dynamically
loaded library here.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Jun 2017 09:16:02 -0400 |
parents | 092078913d54 |
children | 0a6e87804cab |
rev | line source |
---|---|
1 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_dynamic_ld_h) |
383 | 24 #define octave_dynamic_ld_h 1 |
1 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
27 |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
28 #include <list> |
2862 | 29 #include <string> |
30 | |
3325 | 31 #include "oct-shlib.h" |
2894 | 32 |
7336 | 33 class octave_function; |
34 | |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
35 namespace octave |
2894 | 36 { |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
37 class |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
38 dynamic_loader |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
39 { |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
40 private: |
2894 | 41 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
42 class |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
43 shlibs_list |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
44 { |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
45 public: |
2894 | 46 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
47 typedef std::list<octave::dynamic_library>::iterator iterator; |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
48 typedef std::list<octave::dynamic_library>::const_iterator const_iterator; |
2894 | 49 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
50 shlibs_list (void) : lib_list () { } |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
51 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
52 ~shlibs_list (void) = default; |
1 | 53 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
54 void append (const octave::dynamic_library& shl); |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
55 |
23554
b075b1629c26
don't use hook function in dynamic_library::dynlib_rep::close function
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
56 std::list<std::string> remove (octave::dynamic_library& shl); |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
57 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
58 octave::dynamic_library find_file (const std::string& file_name) const; |
5864 | 59 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
60 void display (void) const; |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
61 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
62 private: |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
63 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
64 // No copying! |
3325 | 65 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
66 shlibs_list (const shlibs_list&) = delete; |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
67 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
68 shlibs_list& operator = (const shlibs_list&) = delete; |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
69 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
70 // List of libraries we have loaded. |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
71 std::list<octave::dynamic_library> lib_list; |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
72 }; |
7872 | 73 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
74 protected: |
2894 | 75 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
76 dynamic_loader (void) : loaded_shlibs () { } |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
77 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
78 public: |
2894 | 79 |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
80 // No copying! |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
81 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
82 dynamic_loader (const dynamic_loader&) = delete; |
2894 | 83 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
84 dynamic_loader& operator = (const dynamic_loader&) = delete; |
2894 | 85 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
86 virtual ~dynamic_loader (void) = default; |
2926 | 87 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
88 static octave_function * |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
89 load_oct (const std::string& fcn_name, |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
90 const std::string& file_name = "", |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
91 bool relative = false); |
2926 | 92 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
93 static octave_function * |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
94 load_mex (const std::string& fcn_name, |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
95 const std::string& file_name = "", |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
96 bool relative = false); |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
97 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
98 static bool remove_oct (const std::string& fcn_name, |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
99 octave::dynamic_library& shl); |
2926 | 100 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
101 static bool remove_mex (const std::string& fcn_name, |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
102 octave::dynamic_library& shl); |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
103 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
104 private: |
5864 | 105 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
106 static dynamic_loader *instance; |
5864 | 107 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
108 static void cleanup_instance (void) { delete instance; instance = 0; } |
3325 | 109 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
110 static bool instance_ok (void); |
7872 | 111 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
112 static void do_clear_function (const std::string& fcn_name); |
2894 | 113 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
114 void do_clear (octave::dynamic_library& oct_file); |
3325 | 115 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
116 octave_function * |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
117 do_load_oct (const std::string& fcn_name, |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
118 const std::string& file_name = "", |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
119 bool relative = false); |
3325 | 120 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
121 octave_function * |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
122 do_load_mex (const std::string& fcn_name, |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
123 const std::string& file_name = "", |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
124 bool relative = false); |
2926 | 125 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
126 bool do_remove_oct (const std::string& fcn_name, octave::dynamic_library& shl); |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
127 |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
128 bool do_remove_mex (const std::string& fcn_name, octave::dynamic_library& shl); |
3325 | 129 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
130 static bool doing_load; |
2926 | 131 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
132 protected: |
3325 | 133 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
134 shlibs_list loaded_shlibs; |
7336 | 135 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
136 static std::string name_mangler (const std::string& name); |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
137 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
138 static std::string name_uscore_mangler (const std::string& name); |
7872 | 139 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
140 static std::string mex_mangler (const std::string& name); |
7872 | 141 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
142 static std::string mex_uscore_mangler (const std::string& name); |
7872 | 143 |
23000
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
144 static std::string mex_f77_mangler (const std::string& name); |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
145 }; |
f981282a3bd0
move octave_dynamic_loader into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22999
diff
changeset
|
146 } |
1 | 147 |
148 #endif |