[kaffe] CVS kaffe (guilhem): Fixlets + VMSelector merged back.

Kaffe CVS cvs-commits at kaffe.org
Sun Apr 10 09:50:33 PDT 2005


PatchSet 5669 
Date: 2005/04/10 16:46:02
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fixlets + VMSelector merged back.

        * configure.ac: Reset to 1.1.x-cvs

        * configure: Regenerated.

        * libraries/clib/nio/gnu_java_nio_VMSelector.c: Merged back from GNU
        Classpath with the right indentation.

Members: 
	ChangeLog:1.3835->1.3836 
	configure:1.443->1.444 
	configure.ac:1.133->1.134 
	libraries/clib/nio/gnu_java_nio_VMSelector.c:INITIAL->1.10 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3835 kaffe/ChangeLog:1.3836
--- kaffe/ChangeLog:1.3835	Fri Apr  8 06:12:05 2005
+++ kaffe/ChangeLog	Sun Apr 10 16:46:02 2005
@@ -1,3 +1,12 @@
+2005-04-10  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* configure.ac: Reset to 1.1.x-cvs
+	
+	* configure: Regenerated.
+
+	* libraries/clib/nio/gnu_java_nio_VMSelector.c: Merged back from GNU
+	Classpath with the right indentation.
+
 2005-04-06  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* Makefile.am
Index: kaffe/configure
diff -u kaffe/configure:1.443 kaffe/configure:1.444
--- kaffe/configure:1.443	Tue Apr  5 03:32:32 2005
+++ kaffe/configure	Sun Apr 10 16:46:04 2005
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for Kaffe Virtual Machine 1.1.5.
+# Generated by GNU Autoconf 2.59 for Kaffe Virtual Machine 1.1.x-cvs.
 #
 # Report bugs to <kaffe at kaffe.org>.
 #
@@ -446,8 +446,8 @@
 # Identity of this package.
 PACKAGE_NAME='Kaffe Virtual Machine'
 PACKAGE_TARNAME='kaffe'
-PACKAGE_VERSION='1.1.5'
-PACKAGE_STRING='Kaffe Virtual Machine 1.1.5'
+PACKAGE_VERSION='1.1.x-cvs'
+PACKAGE_STRING='Kaffe Virtual Machine 1.1.x-cvs'
 PACKAGE_BUGREPORT='kaffe at kaffe.org'
 
 ac_unique_file="kaffe"
@@ -988,7 +988,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Kaffe Virtual Machine 1.1.5 to adapt to many kinds of systems.
+\`configure' configures Kaffe Virtual Machine 1.1.x-cvs to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1058,7 +1058,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Kaffe Virtual Machine 1.1.5:";;
+     short | recursive ) echo "Configuration of Kaffe Virtual Machine 1.1.x-cvs:";;
    esac
   cat <<\_ACEOF
 
@@ -1298,7 +1298,7 @@
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-Kaffe Virtual Machine configure 1.1.5
+Kaffe Virtual Machine configure 1.1.x-cvs
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1335,7 +1335,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Kaffe Virtual Machine $as_me 1.1.5, which was
+It was created by Kaffe Virtual Machine $as_me 1.1.x-cvs, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -2000,7 +2000,7 @@
 
 # Define the identity of the package.
  PACKAGE='kaffe'
- VERSION='1.1.5'
+ VERSION='1.1.x-cvs'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -49606,7 +49606,7 @@
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by Kaffe Virtual Machine $as_me 1.1.5, which was
+This file was extended by Kaffe Virtual Machine $as_me 1.1.x-cvs, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -49669,7 +49669,7 @@
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-Kaffe Virtual Machine config.status 1.1.5
+Kaffe Virtual Machine config.status 1.1.x-cvs
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
Index: kaffe/configure.ac
diff -u kaffe/configure.ac:1.133 kaffe/configure.ac:1.134
--- kaffe/configure.ac:1.133	Tue Apr  5 03:32:41 2005
+++ kaffe/configure.ac	Sun Apr 10 16:46:10 2005
@@ -1,4 +1,4 @@
-AC_INIT([Kaffe Virtual Machine],[1.1.5],[kaffe at kaffe.org],[kaffe])
+AC_INIT([Kaffe Virtual Machine],[1.1.x-cvs],[kaffe at kaffe.org],[kaffe])
 
 AC_PREREQ(2.59)
 
===================================================================
Checking out kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c
RCS:  /home/cvs/kaffe/kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c,v
VERS: 1.10
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c	Sun Apr 10 16:50:33 2005
@@ -0,0 +1,296 @@
+/* gnu_java_nio_VMSelector.c - Native methods for SelectorImpl class
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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.
+ 
+GNU Classpath 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 GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include "config.h"
+
+/* <sys/types.h> needs to be included on OSX before <sys/select.h> */
+#if defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+#include <sys/select.h>
+#include <sys/time.h>
+
+#include <string.h>
+
+#include <errno.h>
+
+#include <jni.h>
+#include <jcl.h>
+
+#include "gnu_java_nio_VMSelector.h"
+
+/* Amount of characters in the error message buffer for strerror_r. */
+#define BUF_SIZE 250
+
+void helper_put_filedescriptors (JNIEnv *, jintArray, fd_set *, int *);
+
+void helper_get_filedescriptors (JNIEnv *, jintArray *, fd_set *);
+
+void helper_reset (JNIEnv *, jintArray *);
+
+int
+helper_select (JNIEnv *, jclass, jmethodID,
+	       int, fd_set *, fd_set *, fd_set *, struct timeval *);
+
+void
+helper_put_filedescriptors (JNIEnv * env, jintArray fdArray, fd_set * fds,
+			    int *max_fd)
+{
+  jint *tmpFDArray = (*env)->GetIntArrayElements (env, fdArray, 0);
+  int size = (*env)->GetArrayLength (env, fdArray);
+  int index, fd;
+
+  for (index = 0; index < size; index++)
+    {
+      fd = tmpFDArray[index];
+
+      if (fd > 0)
+	{
+	  FD_SET (tmpFDArray[index], fds);
+
+	  if (tmpFDArray[index] > (*max_fd))
+	    (*max_fd) = tmpFDArray[index];
+	}
+    }
+}
+
+void
+helper_get_filedescriptors (JNIEnv * env, jintArray * fdArray, fd_set * fds)
+{
+  jint *tmpFDArray = (*env)->GetIntArrayElements (env, fdArray, 0);
+  int size = (*env)->GetArrayLength (env, fdArray);
+  int index, fd;
+
+  for (index = 0; index < size; index++)
+    {
+      fd = tmpFDArray[index];
+      if (fd < 0 || !FD_ISSET (fd, fds))
+	tmpFDArray[index] = 0;
+    }
+}
+
+void
+helper_reset (JNIEnv * env, jintArray * fdArray)
+{
+  jint *tmpFDArray = (*env)->GetIntArrayElements (env, fdArray, 0);
+  int size = (*env)->GetArrayLength (env, fdArray);
+  int index;
+
+  for (index = 0; index < size; index++)
+    tmpFDArray[index] = 0;
+}
+
+/* A wrapper for select() which ignores EINTR.
+ * Taken from gclib's posix.cc
+ */
+int
+helper_select (JNIEnv * env, jclass thread_class,
+	       jmethodID thread_interrupted, int n, fd_set * readfds,
+	       fd_set * writefds, fd_set * exceptfds, struct timeval *timeout)
+{
+#ifdef HAVE_SYS_SELECT_H
+  /* If we have a timeout, compute the absolute ending time. */
+  struct timeval end, delay, after;
+  int r;
+
+  if (timeout)
+    {
+      gettimeofday (&end, NULL);
+
+      end.tv_usec += timeout->tv_usec;
+
+      if (end.tv_usec >= 1000000)
+	{
+	  ++end.tv_sec;
+	  end.tv_usec -= 1000000;
+	}
+
+      end.tv_sec += timeout->tv_sec;
+      delay = *timeout;
+    }
+  else
+    {
+      /* Placate compiler. */
+      delay.tv_sec = delay.tv_usec = 0;
+    }
+
+  while (1)
+    {
+      r = select (n, readfds, writefds, exceptfds, timeout ? &delay : NULL);
+
+      if (r < 0 && errno != EINTR)
+	return -errno;
+      else if (r >= 0)
+	return r;
+
+      /* Here we know we got EINTR. */
+      if ((*env)->
+	  CallStaticBooleanMethod (env, thread_class, thread_interrupted))
+	{
+	  return -EINTR;
+	}
+
+      if (timeout)
+	{
+	  gettimeofday (&after, NULL);
+
+	  /* Now compute new timeout argument. */
+	  delay.tv_usec = end.tv_usec - after.tv_usec;
+	  delay.tv_sec = end.tv_sec - after.tv_sec;
+
+	  if (delay.tv_usec < 0)
+	    {
+	      --delay.tv_sec;
+	      delay.tv_usec += 1000000;
+	    }
+
+	  if (delay.tv_sec < 0)
+	    {
+	      /* We assume that the user wants a valid select() call
+	       * more than precise timing.  So if we get a series of
+	       * EINTR we just keep trying with delay 0 until we get a
+	       * valid result.
+	       */
+	      delay.tv_sec = 0;
+	    }
+	}
+    }
+#else /* HAVE_SYS_SELECT_H */
+  return 0;
+#endif
+
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMSelector_select (JNIEnv * env,
+				     jclass obj __attribute__ ((__unused__)),
+				     jintArray read,
+				     jintArray write,
+				     jintArray except, jlong timeout)
+{
+  jint result;
+  jclass thread_class = (*env)->FindClass (env, "java/lang/Thread");
+  jmethodID thread_current_thread =
+    (*env)->GetStaticMethodID (env, thread_class, "currentThread",
+			       "()Ljava/lang/Thread;");
+  jmethodID thread_interrupt =
+    (*env)->GetMethodID (env, thread_class, "interrupt", "()V");
+  jmethodID thread_interrupted =
+    (*env)->GetStaticMethodID (env, thread_class, "interrupted", "()Z");
+  jobject current_thread;
+  int max_fd = 0;
+  fd_set read_fds;
+  fd_set write_fds;
+  fd_set except_fds;
+  struct timeval real_time_data;
+  struct timeval *time_data = NULL;
+  char message_buf[BUF_SIZE + 1];
+
+  /* If a legal timeout value isn't given, use NULL.
+   * This means an infinite timeout. The specification
+   * also says that a zero timeout should be treated
+   * as infinite. Otherwise (if the timeout value is legal),
+   * fill our timeval struct and use it for the select.
+   */
+  if (timeout > 0)
+    {
+      real_time_data.tv_sec = timeout / 1000;
+      real_time_data.tv_usec = (timeout % 1000) * 1000;
+      time_data = &real_time_data;
+    }
+
+  /* Reset all fd_set structures */
+  FD_ZERO (&read_fds);
+  FD_ZERO (&write_fds);
+  FD_ZERO (&except_fds);
+
+  /* Fill the fd_set data structures for the _Jv_select() call. */
+  helper_put_filedescriptors (env, read, &read_fds, &max_fd);
+  helper_put_filedescriptors (env, write, &write_fds, &max_fd);
+  helper_put_filedescriptors (env, except, &except_fds, &max_fd);
+
+  /* Actually do the select */
+  result =
+    helper_select (env, thread_class, thread_interrupted, max_fd + 1,
+		   &read_fds, &write_fds, &except_fds, time_data);
+
+  if (result == -EINTR)
+    {
+      /* The behavior of JRE 1.4.1 is that no exception is thrown
+       * when the thread is interrupted, but the thread's interrupt
+       * status is set. Clear all of our select sets and return 0,
+       * indicating that nothing was selected.
+       */
+      current_thread =
+	(*env)->CallStaticObjectMethod (env, thread_class,
+					thread_current_thread);
+      (*env)->CallVoidMethod (env, current_thread, thread_interrupt);
+
+      helper_reset (env, read);
+      helper_reset (env, write);
+      helper_reset (env, except);
+
+      return 0;
+    }
+
+  if (result < 0)
+    {
+
+      int errorcode = -result;
+
+      if (strerror_r (errorcode, message_buf, BUF_SIZE))
+	{
+	  /* This would mean that message_buf was to small
+	   * to hold the error message.
+	   */
+	  JCL_ThrowException (env, "java/lang/InternalError",
+			      "Not enough space in message buffer.");
+	  return 0;
+	}
+
+      JCL_ThrowException (env, "java/io/IOException", message_buf);
+      return 0;
+    }
+
+  /* Set the file descriptors according to the values returned from select(). */
+  helper_get_filedescriptors (env, read, &read_fds);
+  helper_get_filedescriptors (env, write, &write_fds);
+  helper_get_filedescriptors (env, except, &except_fds);
+
+  return result;
+}



More information about the kaffe mailing list