[kaffe] CVS kaffe (dalibor): Fixed sparc-solaris build failure

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Mon May 31 13:35:06 2004


PatchSet 4799 
Date: 2004/05/31 19:37:49
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Fixed sparc-solaris build failure

2004-05-31  Dalibor Topic  <robilad@kaffe.org>

        * kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
        Include errno.h. Moved system includes to top.
        (MAX_SYS_THREADS) Removed, since Solaris 9 is only limited by
        system ressources, so compilation breaks there.
        (MAX_CACHED_THREADS) Disable caching for now to make debugging
        and fixing pthreads simpler.
        (jthread_create) Check pthreat_create for failure, and clean up
        accordingly.

Members: 
	ChangeLog:1.2368->1.2369 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.25->1.26 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2368 kaffe/ChangeLog:1.2369
--- kaffe/ChangeLog:1.2368	Mon May 31 17:15:08 2004
+++ kaffe/ChangeLog	Mon May 31 19:37:49 2004
@@ -1,5 +1,16 @@
 2004-05-31  Dalibor Topic  <robilad@kaffe.org>
 
+	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
+	Include errno.h. Moved system includes to top.
+	(MAX_SYS_THREADS) Removed, since Solaris 9 is only limited by
+	system ressources, so compilation breaks there.
+	(MAX_CACHED_THREADS) Disable caching for now to make debugging
+	and fixing pthreads simpler.
+	(jthread_create) Check pthreat_create for failure, and clean up
+	accordingly.
+
+2004-05-31  Dalibor Topic  <robilad@kaffe.org>
+
 	* config/m68k/jit3-m68k.def:
 	fixed WOUT and LOUT calls to use jit3 syntax.
 
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.25 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.26
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.25	Wed May 26 22:13:19 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	Mon May 31 19:37:51 2004
@@ -8,6 +8,9 @@
  * of this file.
  */
 
+#include <errno.h>
+#include <limits.h>
+
 #include "config.h"
 #include "config-std.h"
 #include "config-signal.h"
@@ -47,8 +50,6 @@
  * typedefs & defines
  */
 
-#include <limits.h>
-
 /*
  * This is the configurable section. Note that SCHED_FIFO is the only
  * schedule policy which conforms to the "old" Java thread model (with
@@ -57,11 +58,8 @@
  */
 #define SCHEDULE_POLICY     SCHED_OTHER
 
-/* our upper create limit, to ensure we don't blow the system */
-#define MAX_SYS_THREADS     PTHREAD_THREADS_MAX - 1
-
 /* our upper limit for cached threads (0 = no caching at all) */
-#define MAX_CACHED_THREADS  MAX_SYS_THREADS - 3
+#define MAX_CACHED_THREADS 0
 
 /*
  * Now it starts to get hackish - we have to pick some signals
@@ -699,11 +697,7 @@
 	TUNLOCK( cur); /* ---------------------------------------------------- tLock */
   }
   else {
-	if ( nSysThreads++ > MAX_SYS_THREADS ){
-	  // bail out, we exceeded our physical thread limit
-	  DBG( JTHREAD, dprintf( "too many threads (%d)\n", nSysThreads))
-	  return (0);
-	}
+	int creation_succeeded;
 
 	nt = thread_malloc( sizeof(struct _jthread) );
 
@@ -740,7 +734,29 @@
 	 * we otherwise might have a invalid tid in the activeList. The new thread
 	 * in turn doesn't need the lock until it exits
 	 */
-	pthread_create( &nt->tid, &nt->attr, tRun, nt);
+	creation_succeeded = pthread_create( &nt->tid, &nt->attr, tRun, nt);
+
+	/* If the creation of the new thread failed for some reason,
+	 * print the reason, clean up and bail out.
+	 */
+	if (creation_succeeded != 0) {
+	  switch(creation_succeeded) {
+	  case EAGAIN: 
+	    DBG( JTHREAD, dprintf( "too many threads (%d)\n", nSysThreads));
+	    break;
+	  case EINVAL:
+	    DBG( JTHREAD, dprintf( "invalid value for nt.attr\n"));
+	    break;
+	  case EPERM:
+	    DBG( JTHREAD, dprintf( "no permission to set scheduling\n"));
+	    break;
+	  }
+
+	  sem_destroy( &nt->sem);
+	  TUNLOCK( cur);
+	  thread_free(nt);
+	  return 0;
+	}
 
 	/* wait until the thread specific data has been set, and the new thread
 	 * is in a suspendable state */