diff options
author | Tom Tromey <tromey@redhat.com> | 2003-02-24 00:53:21 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-02-24 00:53:21 +0000 |
commit | 804b2c48eab2cb65fb0ae268c8a40e91c24777ff (patch) | |
tree | 5ff41a5e7e8d4dc63e4c27b4f3c34ec1a78f122f /libjava/java | |
parent | 6ecc7b8ffdbcc107a93eec87bd6c4c4fd48945a9 (diff) | |
download | gcc-804b2c48eab2cb65fb0ae268c8a40e91c24777ff.zip gcc-804b2c48eab2cb65fb0ae268c8a40e91c24777ff.tar.gz gcc-804b2c48eab2cb65fb0ae268c8a40e91c24777ff.tar.bz2 |
natRuntime.cc (libraries_size, [...]): Removed.
* java/lang/natRuntime.cc (libraries_size, libraries_count,
libraries): Removed.
(add_library): Removed.
(_load): Don't call add_library.
(loadLibraryInternal): Likewise.
(init): Likewise.
(lookup_data): New struct.
(find_symbol): New function.
(_Jv_FindSymbolInExecutable): Use it.
From-SVN: r63348
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/natRuntime.cc | 59 |
1 files changed, 17 insertions, 42 deletions
diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc index 9879b25..dee9511 100644 --- a/libjava/java/lang/natRuntime.cc +++ b/libjava/java/lang/natRuntime.cc @@ -60,48 +60,28 @@ details. */ AC_LTDL_PREOPEN to see if we do. */ extern const lt_dlsymlist lt_preloaded_symbols[1] = { { 0, 0 } }; -// We keep track of all the libraries loaded by this application. For -// now we use them to look up symbols for JNI. `libraries_size' holds -// the total size of the buffer. `libraries_count' is the number of -// items which are in use. -static int libraries_size; -static int libraries_count; -static lt_dlhandle *libraries; - -static void -add_library (lt_dlhandle lib) +struct lookup_data { - if (libraries_count == libraries_size) - { - int ns = libraries_size * 2; - if (ns == 0) - ns = 10; - lt_dlhandle *n = (lt_dlhandle *) _Jv_Malloc (ns * sizeof (lt_dlhandle)); - if (libraries) - { - memcpy (n, libraries, libraries_size * sizeof (lt_dlhandle)); - _Jv_Free (libraries); - } - libraries = n; - libraries_size = ns; - for (int i = libraries_count; i < libraries_size; ++i) - libraries[i] = NULL; - } + const char *symname; + void *result; +}; - libraries[libraries_count++] = lib; +static int +find_symbol (lt_dlhandle handle, lt_ptr_t data) +{ + lookup_data *ld = (lookup_data *) data; + ld->result = lt_dlsym (handle, ld->symname); + return ld->result != NULL; } void * _Jv_FindSymbolInExecutable (const char *symname) { - for (int i = 0; i < libraries_count; ++i) - { - void *r = lt_dlsym (libraries[i], symname); - if (r) - return r; - } - - return NULL; + lookup_data data; + data.symname = symname; + data.result = NULL; + lt_dlforeach (find_symbol, (lt_ptr_t) &data); + return data.result; } void @@ -237,8 +217,6 @@ java::lang::Runtime::_load (jstring path, jboolean do_search) throw new UnsatisfiedLinkError (str); } - add_library (h); - void *onload = lt_dlsym (h, "JNI_OnLoad"); #ifdef WIN32 @@ -289,8 +267,6 @@ java::lang::Runtime::loadLibraryInternal (jstring lib) buf[total] = '\0'; // FIXME: make sure path is absolute. lt_dlhandle h = lt_dlopenext (buf); - if (h != NULL) - add_library (h); return h != NULL; #else return false; @@ -302,9 +278,8 @@ java::lang::Runtime::init (void) { #ifdef USE_LTDL lt_dlinit (); - lt_dlhandle self = lt_dlopen (NULL); - if (self != NULL) - add_library (self); + // Make sure self is opened. + lt_dlopen (NULL); #endif } |