aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-03-17 00:45:37 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-03-17 00:45:37 +0000
commit2b7f1f8f41666dc1d921e759ca80a24846f745fe (patch)
tree9c8375299ef6ce318b2eb397da5d0658a1f7d5e7 /libjava
parent01cca2d84d09910e5033d1151f4bceb0d1bb5c82 (diff)
downloadgcc-2b7f1f8f41666dc1d921e759ca80a24846f745fe.zip
gcc-2b7f1f8f41666dc1d921e759ca80a24846f745fe.tar.gz
gcc-2b7f1f8f41666dc1d921e759ca80a24846f745fe.tar.bz2
resolve.cc (ncode): Use _Jv_platform_ffi_abi.
* resolve.cc (ncode): Use _Jv_platform_ffi_abi. Include platform.h. * java/lang/natRuntime.cc (insertSystemProperties): Use _Jv_platform_path_separator. (nativeGetLibname): Use _Jv_platform_file_separator. (_load): Use _Jv_platform_onload_names. (onload_names): New global. * include/win32.h (_Jv_platform_file_separator): New define. (_Jv_platform_path_separator): Likewise. (_Jv_platform_onload_names): Likewise. (_Jv_platform_ffi_abi): Likewise. * include/posix.h (_Jv_platform_file_separator): New define. (_Jv_platform_path_separator): Likewise. (_Jv_platform_onload_names): Likewise. (_Jv_platform_ffi_abi): Likewise. From-SVN: r64461
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog18
-rw-r--r--libjava/include/posix.h12
-rw-r--r--libjava/include/win32.h16
-rw-r--r--libjava/java/lang/natRuntime.cc39
-rw-r--r--libjava/resolve.cc10
5 files changed, 63 insertions, 32 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index afa56a7..3aadf49 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,21 @@
+2003-03-16 Tom Tromey <tromey@redhat.com>
+
+ * resolve.cc (ncode): Use _Jv_platform_ffi_abi.
+ Include platform.h.
+ * java/lang/natRuntime.cc (insertSystemProperties): Use
+ _Jv_platform_path_separator.
+ (nativeGetLibname): Use _Jv_platform_file_separator.
+ (_load): Use _Jv_platform_onload_names.
+ (onload_names): New global.
+ * include/win32.h (_Jv_platform_file_separator): New define.
+ (_Jv_platform_path_separator): Likewise.
+ (_Jv_platform_onload_names): Likewise.
+ (_Jv_platform_ffi_abi): Likewise.
+ * include/posix.h (_Jv_platform_file_separator): New define.
+ (_Jv_platform_path_separator): Likewise.
+ (_Jv_platform_onload_names): Likewise.
+ (_Jv_platform_ffi_abi): Likewise.
+
2003-03-14 Hans Boehm <Hans.Boehm@hp.com>
* java/lang/natObject.cc (JV_SYNC_HASH): replace signed % by &.
diff --git a/libjava/include/posix.h b/libjava/include/posix.h
index 0aadd47..bbec6d1 100644
--- a/libjava/include/posix.h
+++ b/libjava/include/posix.h
@@ -44,6 +44,18 @@ details. */
#define _Jv_platform_solib_prefix "lib"
#define _Jv_platform_solib_suffix ".so"
+// Separator for file name components.
+#define _Jv_platform_file_separator ((jchar) '/')
+// Separator for path components.
+#define _Jv_platform_path_separator ((jchar) ':')
+
+// List of names for `JNI_OnLoad'.
+#define _Jv_platform_onload_names { "JNI_OnLoad", NULL }
+
+// Type of libffi ABI used by JNICALL methods. NOTE: This must agree
+// with the JNICALL definition in jni.h
+#define _Jv_platform_ffi_abi FFI_DEFAULT_ABI
+
#ifndef DISABLE_JAVA_NET
#include <java/net/InetAddress.h>
#endif
diff --git a/libjava/include/win32.h b/libjava/include/win32.h
index 4330c79..320273a 100644
--- a/libjava/include/win32.h
+++ b/libjava/include/win32.h
@@ -24,6 +24,22 @@ details. */
#define _Jv_platform_solib_prefix ""
#define _Jv_platform_solib_suffix ".dll"
+// Separator for file name components.
+#define _Jv_platform_file_separator ((jchar) '\\')
+// Separator for path components.
+#define _Jv_platform_path_separator ((jchar) ';')
+
+// List of names for `JNI_OnLoad'. On Win32, JNI_OnLoad is an
+// "stdcall" function taking two pointers (8 bytes) as arguments. It
+// could also have been exported as "JNI_OnLoad@8" (MinGW) or
+// "_JNI_OnLoad@8" (MSVC).
+#define _Jv_platform_onload_names \
+ { "JNI_OnLoad", "JNI_OnLoad@8", "_JNI_OnLoad@8", NULL }
+
+// Type of libffi ABI used by JNICALL methods. NOTE: This must agree
+// with the JNICALL definition in jni.h
+#define _Jv_platform_ffi_abi FFI_STDCALL
+
#ifndef DISABLE_JAVA_NET
// these errors cannot occur on Win32
diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc
index 237b0d1..b4c1510 100644
--- a/libjava/java/lang/natRuntime.cc
+++ b/libjava/java/lang/natRuntime.cc
@@ -140,6 +140,11 @@ java::lang::Runtime::gc (void)
_Jv_RunGC ();
}
+#ifdef USE_LTDL
+// List of names for JNI_OnLoad.
+static const char *onload_names[] = _Jv_platform_onload_names;
+#endif
+
void
java::lang::Runtime::_load (jstring path, jboolean do_search)
{
@@ -221,19 +226,16 @@ java::lang::Runtime::_load (jstring path, jboolean do_search)
throw new UnsatisfiedLinkError (str);
}
- void *onload = lt_dlsym (h, "JNI_OnLoad");
-
-#ifdef WIN32
- // On Win32, JNI_OnLoad is an "stdcall" function taking two pointers
- // (8 bytes) as arguments. It could also have been exported as
- // "JNI_OnLoad@8" (MinGW) or "_JNI_OnLoad@8" (MSVC).
- if (onload == NULL)
+ // Search for JNI_OnLoad function.
+ void *onload = NULL;
+ const char **name = onload_names;
+ while (*name != NULL)
{
- onload = lt_dlsym (h, "JNI_OnLoad@8");
- if (onload == NULL)
- onload = lt_dlsym (h, "_JNI_OnLoad@8");
+ onload = lt_dlsym (h, *name);
+ if (onload != NULL)
+ break;
+ ++name;
}
-#endif /* WIN32 */
if (onload != NULL)
{
@@ -570,11 +572,7 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
if (classpath)
{
sb->append (JvNewStringLatin1 (classpath));
-#ifdef WIN32
- sb->append ((jchar) ';');
-#else
- sb->append ((jchar) ':');
-#endif
+ sb->append (_Jv_platform_path_separator);
}
if (cp != NULL)
sb->append (cp);
@@ -632,14 +630,7 @@ java::lang::Runtime::nativeGetLibname (jstring pathname, jstring libname)
java::lang::StringBuffer *sb = new java::lang::StringBuffer ();
sb->append(pathname);
if (pathname->length() > 0)
- {
- // FIXME: use platform function here.
-#ifdef WIN32
- sb->append ((jchar) '\\');
-#else
- sb->append ((jchar) '/');
-#endif
- }
+ sb->append (_Jv_platform_file_separator);
sb->append (JvNewStringLatin1 (_Jv_platform_solib_prefix));
sb->append(libname);
diff --git a/libjava/resolve.cc b/libjava/resolve.cc
index aa17ea9..ea50645 100644
--- a/libjava/resolve.cc
+++ b/libjava/resolve.cc
@@ -11,6 +11,7 @@ details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
#include <config.h>
+#include <platform.h>
#include <java-interp.h>
@@ -1003,14 +1004,7 @@ _Jv_JNIMethod::ncode ()
memcpy (&jni_arg_types[offset], &closure->arg_types[0],
arg_count * sizeof (ffi_type *));
- // NOTE: This must agree with the JNICALL definition in jni.h
-#ifdef WIN32
-#define FFI_JNI_ABI FFI_STDCALL
-#else
-#define FFI_JNI_ABI FFI_DEFAULT_ABI
-#endif
-
- if (ffi_prep_cif (&jni_cif, FFI_JNI_ABI,
+ if (ffi_prep_cif (&jni_cif, _Jv_platform_ffi_abi,
extra_args + arg_count, rtype,
jni_arg_types) != FFI_OK)
throw_internal_error ("ffi_prep_cif failed for JNI function");