Commit 804b2c48 by Tom Tromey Committed by Tom Tromey

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
parent 6ecc7b8f
2003-02-23 Tom Tromey <tromey@redhat.com>
* 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.
2002-02-21 Anthony Green <green@redhat.com> 2002-02-21 Anthony Green <green@redhat.com>
* java/lang/Thread.java (Thread): New constructor taking stack * java/lang/Thread.java (Thread): New constructor taking stack
......
...@@ -60,48 +60,28 @@ details. */ ...@@ -60,48 +60,28 @@ details. */
AC_LTDL_PREOPEN to see if we do. */ AC_LTDL_PREOPEN to see if we do. */
extern const lt_dlsymlist lt_preloaded_symbols[1] = { { 0, 0 } }; extern const lt_dlsymlist lt_preloaded_symbols[1] = { { 0, 0 } };
// We keep track of all the libraries loaded by this application. For struct lookup_data
// 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)
{ {
if (libraries_count == libraries_size) const char *symname;
{ void *result;
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;
}
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 * void *
_Jv_FindSymbolInExecutable (const char *symname) _Jv_FindSymbolInExecutable (const char *symname)
{ {
for (int i = 0; i < libraries_count; ++i) lookup_data data;
{ data.symname = symname;
void *r = lt_dlsym (libraries[i], symname); data.result = NULL;
if (r) lt_dlforeach (find_symbol, (lt_ptr_t) &data);
return r; return data.result;
}
return NULL;
} }
void void
...@@ -237,8 +217,6 @@ java::lang::Runtime::_load (jstring path, jboolean do_search) ...@@ -237,8 +217,6 @@ java::lang::Runtime::_load (jstring path, jboolean do_search)
throw new UnsatisfiedLinkError (str); throw new UnsatisfiedLinkError (str);
} }
add_library (h);
void *onload = lt_dlsym (h, "JNI_OnLoad"); void *onload = lt_dlsym (h, "JNI_OnLoad");
#ifdef WIN32 #ifdef WIN32
...@@ -289,8 +267,6 @@ java::lang::Runtime::loadLibraryInternal (jstring lib) ...@@ -289,8 +267,6 @@ java::lang::Runtime::loadLibraryInternal (jstring lib)
buf[total] = '\0'; buf[total] = '\0';
// FIXME: make sure path is absolute. // FIXME: make sure path is absolute.
lt_dlhandle h = lt_dlopenext (buf); lt_dlhandle h = lt_dlopenext (buf);
if (h != NULL)
add_library (h);
return h != NULL; return h != NULL;
#else #else
return false; return false;
...@@ -302,9 +278,8 @@ java::lang::Runtime::init (void) ...@@ -302,9 +278,8 @@ java::lang::Runtime::init (void)
{ {
#ifdef USE_LTDL #ifdef USE_LTDL
lt_dlinit (); lt_dlinit ();
lt_dlhandle self = lt_dlopen (NULL); // Make sure self is opened.
if (self != NULL) lt_dlopen (NULL);
add_library (self);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment