* configure.ac (AC_CHECK_WITH_HPI_MD_H): Added.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 31 Mar 2008 10:16:10 +0000 (12:16 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 31 Mar 2008 10:16:10 +0000 (12:16 +0200)
(AC_CHECK_WITH_HPI_H): Likewise.
* m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed default
for OpenJDK.
(AC_CHECK_WITH_CLASSPATH_LIBDIR): Likewise.
(AC_CHECK_WITH_JNI_MD_H): Likewise.
(AC_CHECK_WITH_JNI_H): Likewise.

* m4/hpi.m4: New file.
* src/native/vm/nativevm.c (nativevm_preinit): Call hpi_initialize.
* src/native/vm/sun/Makefile.am (libnativevmcore_la_SOURCES): Added
hpi.[ch].
* src/native/vm/sun/hpi.c: New file.
* src/native/vm/sun/hpi.h: Likewise.

* src/native/vm/sun/jvm.c (JVM_GetLastErrorString): Use HPI function.
(JVM_NativePath): Likewise.
(JVM_Open): Likewise.
(JVM_Close): Likewise.
(JVM_Read): Likewise.
(JVM_Write): Likewise.
(JVM_Available): Likewise.
(JVM_Lseek): Likewise.
(JVM_SetLength): Likewise.
(JVM_Sync): Likewise.
(JVM_InitializeSocketLibrary): Call hpi_initialize_socket_library.

* src/vmcore/options.c (opt_TraceHPI): Added global variable.
(options_xx): Handle new option.
* src/vmcore/options.h: Likewise.

configure.ac
m4/classpath.m4
m4/hpi.m4 [new file with mode: 0644]
src/native/vm/nativevm.c
src/native/vm/sun/Makefile.am
src/native/vm/sun/hpi.c [new file with mode: 0644]
src/native/vm/sun/hpi.h [new file with mode: 0644]
src/native/vm/sun/jvm.c
src/vmcore/options.c
src/vmcore/options.h

index 8bafe9fe5b51fd4de588adfe082459067d3ce2e3..d0e368673d2d798156049ed4840c4dc3d6649a2e 100644 (file)
@@ -780,6 +780,15 @@ dnl The check for jni_md.h must be before jni.h.
 AC_CHECK_WITH_JNI_MD_H
 AC_CHECK_WITH_JNI_H
 
+dnl HPI is only required for OpenJDK
+case "${WITH_CLASSPATH}" in
+    sun)
+        AC_CHECK_WITH_HPI_MD_H
+        AC_CHECK_WITH_HPI_H
+        ;;
+    *)
+        ;;
+esac
 
 dnl check for some programs we need
 
index 5091d7e3d6b11e8ea268893992092ca66bf26aea..1a65af749b434d2b7c934b39e3d10fb043d2115e 100644 (file)
@@ -76,14 +76,14 @@ dnl where are Java core library classes installed
 AC_DEFUN([AC_CHECK_WITH_CLASSPATH_CLASSES],[
 AC_MSG_CHECKING(where Java core library classes are installed)
 AC_ARG_WITH([classpath-classes],
-            [AS_HELP_STRING(--with-classpath-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=CLASSPATH_PREFIX/{share/classpath/glibj.zip,classes}]])],
+            [AS_HELP_STRING(--with-classpath-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=(gnu:${CLASSPATH_PREFIX}/share/classpath/glibj.zip,sun:${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/classes,*:${CLASSPATH_PREFIX})]])],
             [CLASSPATH_CLASSES=${withval}],
             [case "${WITH_CLASSPATH}" in
                  gnu)
                      CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip
                      ;;
                  sun)
-                     CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/classes
+                     CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/classes
                      ;;
                  *)
                      CLASSPATH_CLASSES=${CLASSPATH_PREFIX}
@@ -111,14 +111,14 @@ dnl where are Java core library native libraries installed
 AC_DEFUN([AC_CHECK_WITH_CLASSPATH_LIBDIR],[
 AC_MSG_CHECKING(where Java core library native libraries are installed)
 AC_ARG_WITH([classpath-libdir],
-            [AS_HELP_STRING(--with-classpath-libdir=<dir>,installation directory of Java core library native libraries [[default=CLASSPATH_PREFIX/{lib,lib/${JAVA_ARCH}]])],
+            [AS_HELP_STRING(--with-classpath-libdir=<dir>,installation directory of Java core library native libraries [[default=(gnu:${CLASSPATH_PREFIX}/lib,sun:${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/lib/${JAVA_ARCH},*:${CLASSPATH_PREFIX})]])],
             [CLASSPATH_LIBDIR=${withval}],
             [case "${WITH_CLASSPATH}" in
                  gnu)
                      CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib
                      ;;
                  sun)
-                     CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib/${JAVA_ARCH}
+                     CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/lib/${JAVA_ARCH}
                      ;;
                  *)
                      CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}
@@ -138,11 +138,11 @@ dnl where jni_md.h is installed
 AC_DEFUN([AC_CHECK_WITH_JNI_MD_H],[
 AC_MSG_CHECKING(where jni_md.h is installed)
 AC_ARG_WITH([jni_md_h],
-            [AS_HELP_STRING(--with-jni_md_h=<dir>,path to jni_md.h [[default=(sun:CLASSPATH_PREFIX/include/linux,*:CLASSPATH_PREFIX/include)]])],
+            [AS_HELP_STRING(--with-jni_md_h=<dir>,path to jni_md.h [[default=(sun:${CLASSPATH_PREFIX}/jdk/src/solaris/javavm/export,*:${CLASSPATH_PREFIX}/include)]])],
             [WITH_JNI_MD_H=${withval}],
             [case "${WITH_CLASSPATH}" in
                  sun)
-                     WITH_JNI_MD_H=${CLASSPATH_PREFIX}/include/linux
+                     WITH_JNI_MD_H=${CLASSPATH_PREFIX}/jdk/src/solaris/javavm/export
                      ;;
                  *)
                      WITH_JNI_MD_H=${CLASSPATH_PREFIX}/include
@@ -164,9 +164,16 @@ dnl where jni.h is installed
 AC_DEFUN([AC_CHECK_WITH_JNI_H],[
 AC_MSG_CHECKING(where jni.h is installed)
 AC_ARG_WITH([jni_h],
-            [AS_HELP_STRING(--with-jni_h=<dir>,path to jni.h [[default=CLASSPATH_PREFIX/include]])],
+            [AS_HELP_STRING(--with-jni_h=<dir>,path to jni.h [[default=(sun:${CLASSPATH_PREFIX}/jdk/src/share/javavm/export,*:${CLASSPATH_PREFIX}/include)]])],
             [WITH_JNI_H=${withval}],
-            [WITH_JNI_H=${CLASSPATH_PREFIX}/include])
+            [case "${WITH_CLASSPATH}" in
+                 sun)
+                     WITH_JNI_H=${CLASSPATH_PREFIX}/jdk/src/share/javavm/export
+                     ;;
+                 *)
+                     WITH_JNI_H=${CLASSPATH_PREFIX}/include
+                     ;;
+            esac])
 AC_MSG_RESULT(${WITH_JNI_H})
 
 dnl We use CPPFLAGS so jni.h can find jni_md.h
diff --git a/m4/hpi.m4 b/m4/hpi.m4
new file mode 100644 (file)
index 0000000..9166e56
--- /dev/null
+++ b/m4/hpi.m4
@@ -0,0 +1,66 @@
+dnl m4/hpi.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl
+dnl This file is part of CACAO.
+dnl
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl where hpi_md.h is installed
+
+AC_DEFUN([AC_CHECK_WITH_HPI_MD_H],[
+AC_MSG_CHECKING(where hpi_md.h is installed)
+AC_ARG_WITH([hpi_md_h],
+            [AS_HELP_STRING(--with-hpi_md_h=<dir>,path to hpi_md.h (only with --with-classpath=sun) [[default=${CLASSPATH_PREFIX}/jdk/src/solaris/hpi/export]])],
+            [WITH_HPI_MD_H=${withval}],
+            [case "${WITH_CLASSPATH}" in
+                 sun)
+                     WITH_HPI_MD_H=${CLASSPATH_PREFIX}/jdk/src/solaris/hpi/export
+                     ;;
+                 *)
+                     ;;
+            esac])
+AC_MSG_RESULT(${WITH_HPI_MD_H})
+
+dnl We use CPPFLAGS so hpi.h can find hpi_md.h
+CPPFLAGS="${CPPFLAGS} -I${WITH_HPI_MD_H}"
+
+AC_CHECK_HEADER([${WITH_HPI_MD_H}/hpi_md.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_HPI_MD_H], "${WITH_HPI_MD_H}/hpi_md.h", [Java core library hpi_md.h header])],
+                [AC_MSG_ERROR(cannot find hpi_md.h)])
+])
+
+
+dnl where hpi.h is installed
+
+AC_DEFUN([AC_CHECK_WITH_HPI_H],[
+AC_MSG_CHECKING(where hpi.h is installed)
+AC_ARG_WITH([hpi_h],
+            [AS_HELP_STRING(--with-hpi_h=<dir>,path to hpi.h (only with --with-classpath=sun) [[default=${CLASSPATH_PREFIX}/jdk/src/share/hpi/export]])],
+            [WITH_HPI_H=${withval}],
+            [WITH_HPI_H=${CLASSPATH_PREFIX}/jdk/src/share/hpi/export])
+AC_MSG_RESULT(${WITH_HPI_H})
+
+dnl We use CPPFLAGS so hpi.h can find hpi_md.h
+CPPFLAGS="${CPPFLAGS} -I${WITH_HPI_H}"
+
+AC_CHECK_HEADER([${WITH_HPI_H}/hpi.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_HPI_H], "${WITH_HPI_H}/hpi.h", [Java core library hpi.h header])],
+                [AC_MSG_ERROR(cannot find hpi.h)],
+                [#include INCLUDE_HPI_MD_H])
+])
index 6ca352f21a58d0ccc287bfd244936126149b4f22..1b20720c28965cf11fac4cef497274850bfef92b 100644 (file)
@@ -41,6 +41,8 @@
 
 # include "native/native.h"
 
+# include "native/vm/sun/hpi.h"
+
 # include "vm/properties.h"
 # include "vm/vm.h"
 
@@ -125,6 +127,10 @@ void nativevm_preinit(void)
 
        native_library_add(u, NULL, handle);
 
+       /* Initialize the HPI. */
+
+       hpi_initialize();
+
        _Jv_sun_misc_Unsafe_init();
 
 # else
index e1f7372a694df3fe1fc6e733c9e6e9e042e8aea0..1f1753140d188af5bfe7fe41af157071becfe6c4 100644 (file)
@@ -1,9 +1,7 @@
 ## src/native/vm/sun/Makefile.am
 ##
-## Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
-## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-## J. Wenninger, Institut f. Computersprachen - TU Wien
+## Copyright (C) 2007, 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 ##
 ## This file is part of CACAO.
 ##
@@ -31,6 +29,8 @@ noinst_LTLIBRARIES = \
        libnativevmcore.la
 
 libnativevmcore_la_SOURCES = \
+       hpi.c \
+       hpi.h \
        jvm.c
 
 
diff --git a/src/native/vm/sun/hpi.c b/src/native/vm/sun/hpi.c
new file mode 100644 (file)
index 0000000..d2395ad
--- /dev/null
@@ -0,0 +1,196 @@
+/* src/native/vm/sun/hpi.c - HotSpot HPI interface functions
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+/* We include hpi_md.h before hpi.h as the latter includes the
+   former. */
+
+#include INCLUDE_HPI_MD_H
+#include INCLUDE_HPI_H
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "vm/properties.h"
+#include "vm/vm.h"
+
+#include "vmcore/options.h"
+#include "vmcore/system.h"
+#include "vmcore/utf8.h"
+
+
+/* VM callback functions ******************************************************/
+
+static vm_calls_t callbacks = {
+       /* TODO What should we use here? */
+/*   jio_fprintf, */
+/*   unimplemented_panic, */
+/*   unimplemented_monitorRegister, */
+       NULL,
+       NULL,
+       NULL,
+       
+       NULL, /* unused */
+       NULL, /* unused */
+       NULL  /* unused */
+};
+
+
+/* HPI interfaces *************************************************************/
+
+GetInterfaceFunc      hpi_get_interface = NULL;
+HPI_FileInterface    *hpi_file          = NULL;
+HPI_SocketInterface  *hpi_socket        = NULL;
+HPI_LibraryInterface *hpi_library       = NULL;
+HPI_SystemInterface  *hpi_system        = NULL;
+
+
+/* hpi_initialize **************************************************************
+
+   Initialize the Host Porting Interface (HPI).
+
+*******************************************************************************/
+
+void hpi_initialize(void)
+{
+       char        *boot_library_path;
+       int          len;
+       char        *p;
+       utf         *u;
+       lt_dlhandle  handle;
+       lt_ptr       dll_initialize;
+       int          result;
+    jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *);
+
+       TRACESUBSYSTEMINITIALIZATION("hpi_init");
+
+       /* Load libhpi.so */
+
+       boot_library_path = properties_get("sun.boot.library.path");
+
+       len =
+               system_strlen(boot_library_path) +
+               system_strlen("/native_threads/libhpi.so") +
+               system_strlen("0");
+
+       p = MNEW(char, len);
+
+       system_strcpy(p, boot_library_path);
+       system_strcat(p, "/native_threads/libhpi.so");
+
+       u = utf_new_char(p);
+
+    if (opt_TraceHPI)
+               log_println("hpi_init: Loading HPI %s ", p);
+
+       MFREE(p, char, len);
+
+       handle = native_library_open(u);
+
+       if (handle == NULL)
+               if (opt_TraceHPI)
+                       vm_abort("hpi_init: HPI open failed");
+
+       /* Resolve the DLL_Initialize function from the library. */
+
+       dll_initialize = lt_dlsym(handle, "DLL_Initialize");
+
+    DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc *, void *)) (intptr_t) dll_initialize;
+
+    if (opt_TraceHPI && DLL_Initialize == NULL)
+               log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", lt_dlerror());
+
+    if (DLL_Initialize == NULL ||
+        (*DLL_Initialize)(&hpi_get_interface, &callbacks) < 0) {
+
+        if (opt_TraceHPI)
+                       vm_abort("hpi_init: HPI DLL_Initialize failed");
+    }
+
+       native_library_add(u, NULL, handle);
+
+    if (opt_TraceHPI)
+               log_println("hpi_init: HPI loaded successfully");
+
+       /* Resolve the interfaces. */
+
+       result = (*hpi_get_interface)((void **) &hpi_file, "File", 1);
+
+       if (result != 0)
+               vm_abort("hpi_init: Can't find HPI_FileInterface");
+
+       result = (*hpi_get_interface)((void **) &hpi_library, "Library", 1);
+
+       if (result != 0)
+               vm_abort("hpi_init: Can't find HPI_LibraryInterface");
+
+       result = (*hpi_get_interface)((void **) &hpi_system, "System", 1);
+
+       if (result != 0)
+               vm_abort("hpi_init: Can't find HPI_SystemInterface");
+}
+
+
+/* hpi_initialize_socket_library ***********************************************
+
+   Initialize the library Host Porting Interface (HPI).
+
+*******************************************************************************/
+
+int hpi_initialize_socket_library(void)
+{
+       int result;
+
+       /* Resolve the socket library interface. */
+
+       result = (*hpi_get_interface)((void **) &hpi_socket, "Socket", 1);
+
+       if (result != 0) {
+               if (opt_TraceHPI)
+                       log_println("hpi_initialize_socket_library: Can't find HPI_SocketInterface");
+
+               return JNI_ERR;
+       }
+
+       return JNI_OK;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/sun/hpi.h b/src/native/vm/sun/hpi.h
new file mode 100644 (file)
index 0000000..9b0b19f
--- /dev/null
@@ -0,0 +1,74 @@
+/* src/native/vm/sun/hpi.h - HotSpot HPI interface functions
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _HPI_H
+#define _HPI_H
+
+#include "config.h"
+
+/* HPI headers *****************************************************************
+
+   We include hpi_md.h before hpi.h as the latter includes the former.
+
+   These includes define:
+
+   #define _JAVASOFT_HPI_MD_H_
+   #define _JAVASOFT_HPI_H_
+
+*******************************************************************************/
+
+#include INCLUDE_HPI_MD_H
+#include INCLUDE_HPI_H
+
+
+/* HPI interfaces *************************************************************/
+
+extern HPI_FileInterface    *hpi_file;
+extern HPI_SocketInterface  *hpi_socket;
+extern HPI_LibraryInterface *hpi_library;
+extern HPI_SystemInterface  *hpi_system;
+
+
+/* functions ******************************************************************/
+
+void hpi_initialize(void);
+int  hpi_initialize_socket_library(void);
+
+#endif /* _HPI_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 46d359dce5670660d3a8a9b05efcf6911332a184..1b562b1b0335f9c68b28b2141794a02cc8a0876b 100644 (file)
@@ -67,6 +67,8 @@
 #include "native/vm/java_lang_reflect_Method.h"
 #include "native/vm/reflect.h"
 
+#include "native/vm/sun/hpi.h"
+
 #include "threads/lock-common.h"
 #include "threads/threads-common.h"
 
@@ -704,25 +706,9 @@ void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
 
 jint JVM_GetLastErrorString(char *buf, int len)
 {
-       const char *s;
-       int n;
-
-    if (errno == 0) {
-               return 0;
-    }
-       else {
-               s = strerror(errno);
-               n = strlen(s);
-
-               if (n >= len)
-                       n = len - 1;
-
-               strncpy(buf, s, n);
-
-               buf[n] = '\0';
+       TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len));
 
-               return n;
-    }
+       return hpi_system->GetLastErrorString(buf, len);
 }
 
 
@@ -732,9 +718,7 @@ char *JVM_NativePath(char *path)
 {
        TRACEJVMCALLS(("JVM_NativePath(path=%s)", path));
 
-       /* XXX is this correct? */
-
-       return path;
+       return hpi_file->NativePath(path);
 }
 
 
@@ -2145,7 +2129,7 @@ jint JVM_Open(const char *fname, jint flags, jint mode)
 
        TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode));
 
-       result = system_open(fname, flags, mode);
+       result = hpi_file->Open(fname, flags, mode);
 
        if (result >= 0) {
                return result;
@@ -2167,7 +2151,7 @@ jint JVM_Close(jint fd)
 {
        TRACEJVMCALLS(("JVM_Close(fd=%d)", fd));
 
-       return system_close(fd);
+       return hpi_file->Close(fd);
 }
 
 
@@ -2177,7 +2161,7 @@ jint JVM_Read(jint fd, char *buf, jint nbytes)
 {
        TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes));
 
-       return system_read(fd, buf, nbytes);
+       return (jint) hpi_file->Read(fd, buf, nbytes);
 }
 
 
@@ -2187,7 +2171,7 @@ jint JVM_Write(jint fd, char *buf, jint nbytes)
 {
        TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes));
 
-       return system_write(fd, buf, nbytes);
+       return (jint) hpi_file->Write(fd, buf, nbytes);
 }
 
 
@@ -2195,25 +2179,9 @@ jint JVM_Write(jint fd, char *buf, jint nbytes)
 
 jint JVM_Available(jint fd, jlong *pbytes)
 {
-#if defined(FIONREAD)
-       int bytes;
-       int result;
-
        TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes));
 
-       *pbytes = 0;
-
-       result = ioctl(fd, FIONREAD, &bytes);
-
-       if (result < 0)
-               return 0;
-
-       *pbytes = bytes;
-
-       return 1;
-#else
-# error FIONREAD not defined
-#endif
+       return hpi_file->Available(fd, pbytes);
 }
 
 
@@ -2223,7 +2191,7 @@ jlong JVM_Lseek(jint fd, jlong offset, jint whence)
 {
        TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence));
 
-       return (jlong) system_lseek(fd, (off_t) offset, whence);
+       return hpi_file->Seek(fd, (off_t) offset, whence);
 }
 
 
@@ -2233,7 +2201,7 @@ jint JVM_SetLength(jint fd, jlong length)
 {
        TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length));
 
-       return system_ftruncate(fd, length);
+       return hpi_file->SetLength(fd, length);
 }
 
 
@@ -2243,7 +2211,7 @@ jint JVM_Sync(jint fd)
 {
        TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd));
 
-       return system_fsync(fd);
+       return hpi_file->Sync(fd);
 }
 
 
@@ -2757,9 +2725,9 @@ jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
 
 jint JVM_InitializeSocketLibrary()
 {
-       log_println("JVM_InitializeSocketLibrary: IMPLEMENT ME!");
+       TRACEJVMCALLS(("JVM_InitializeSocketLibrary()"));
 
-       return 0;
+       return hpi_initialize_socket_library();
 }
 
 
index b74d3d6fca01735dc1b5186d9b6b5bf7a5123084..e9ae46fbcd763f25f93db60501fea452229bb28d 100644 (file)
@@ -197,6 +197,7 @@ int      opt_TestReplacement              = 0;
 #endif
 int      opt_TraceCompilerCalls           = 0;
 int      opt_TraceExceptions              = 0;
+int      opt_TraceHPI                     = 0;
 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
 int      opt_TraceInlining                = 0;
 #endif
@@ -253,6 +254,7 @@ enum {
        OPT_TestReplacement,
        OPT_TraceCompilerCalls,
        OPT_TraceExceptions,
+       OPT_TraceHPI,
        OPT_TraceInlining,
        OPT_TraceJavaCalls,
        OPT_TraceJNICalls,
@@ -314,6 +316,7 @@ option_t options_XX[] = {
 #endif
        { "TraceCompilerCalls",           OPT_TraceCompilerCalls,           OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
        { "TraceExceptions",              OPT_TraceExceptions,              OPT_TYPE_BOOLEAN, "trace Exception throwing" },
+       { "TraceHPI",                     OPT_TraceHPI,                     OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
        { "TraceInlining",                OPT_TraceInlining,                OPT_TYPE_VALUE,   "trace method inlining with the given verbosity level (default: 1)" },
 #endif
@@ -741,6 +744,10 @@ void options_xx(JavaVMInitArgs *vm_args)
                        opt_TraceExceptions = enable;
                        break;
 
+               case OPT_TraceHPI:
+                       opt_TraceHPI = enable;
+                       break;
+
 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
                case OPT_TraceInlining:
                        if (value == NULL)
index 9815f233126162bb3c41584b9f2a5bb955d20533..ca4e09666c6ab77c0eab2078ee93a508260f1a72 100644 (file)
@@ -216,6 +216,7 @@ extern int      opt_TestReplacement;
 #endif
 extern int      opt_TraceCompilerCalls;
 extern int      opt_TraceExceptions;
+extern int      opt_TraceHPI;
 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
 extern int      opt_TraceInlining;
 #endif