This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Support --enable-threads configuration with GC 6.1 Alpha 1


Hans informed me that this boehm-gc patch has already been applied to
his post-GC 6.1 Alpha 1 source tree.  It is an improved version of the
patch I floated some time ago to get threaded GC working on FreeBSD.
The patch was radically simplified due to Hans' generalization of
threading configuration.  Bootstrapped on i386-unknown-freebsd4.3.
There is still that one known threading deadlock bug (probably in our
pthread implementation or another interaction with the signal-handler
architecture) but it has only ever been seen to affect the GC test
code not real Java programs built against the library.  And that
remaining platform bug beats the core dump one used to receive.

Permission to apply to the gcc mainline?

2001-10-16  Loren J. Rittle  <ljrittle@acm.org>

	* include/gc_pthread_redirects.h: Generalize test to use GC_PTHREADS.
	* linux_threads.c (WRAP_FUNC(pthread_join)): Conditionalized on
	GC_FREEBSD_THREADS, handle strange interaction between system
	pthread implementation and boehm-gc signal-handler architecture.
	* tests/test.c (main): Conditionalized on GC_FREEBSD_THREADS,
	set stack.
	* include/private/gcconfig.h (configuration keyed off FREEBSD):
	Define SIG_SUSPEND, SIG_THR_RESTART.  Do not define
	MPROTECT_VDB when GC_FREEBSD_THREADS is defined.

Index: include/gc_pthread_redirects.h
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/include/gc_pthread_redirects.h,v
retrieving revision 1.2
diff -c -r1.2 gc_pthread_redirects.h
*** gc_pthread_redirects.h	2001/08/17 18:30:50	1.2
--- gc_pthread_redirects.h	2001/10/17 02:14:01
***************
*** 44,52 ****
  #endif /* SOLARIS_THREADS || SOLARIS_PTHREADS */
  
  
! #if !defined(GC_USE_LD_WRAP) && \
!     (defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \
!      || defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS))
  /* We treat these similarly. */
  # include <pthread.h>
  # include <signal.h>
--- 44,50 ----
  #endif /* SOLARIS_THREADS || SOLARIS_PTHREADS */
  
  
! #if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS) && !defined(GC_SOLARIS_PTHREADS)
  /* We treat these similarly. */
  # include <pthread.h>
  # include <signal.h>
Index: linux_threads.c
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/linux_threads.c,v
retrieving revision 1.14
diff -c -r1.14 linux_threads.c
*** linux_threads.c	2001/10/16 09:01:35	1.14
--- linux_threads.c	2001/10/17 02:14:01
***************
*** 1272,1277 ****
--- 1272,1288 ----
      /* cant have been recycled by pthreads.				*/
      UNLOCK();
      result = REAL_FUNC(pthread_join)(thread, retval);
+ # if defined (GC_FREEBSD_THREADS)
+     /* On FreeBSD, the wrapped pthread_join() sometimes returns (what
+        appears to be) a spurious EINTR which caused the test and real code
+        to gratuitously fail.  Having looked at system pthread library source
+        code, I see how this return code may be generated.  In one path of
+        code, pthread_join() just returns the errno setting of the thread
+        being joined.  This does not match the POSIX specification or the
+        local man pages thus I have taken the liberty to catch this one
+        spurious return value properly conditionalized on GC_FREEBSD_THREADS. */
+     if (result == EINTR) result = 0;
+ # endif
      if (result == 0) {
          LOCK();
          /* Here the pthread thread id may have been recycled. */
Index: tests/test.c
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/tests/test.c,v
retrieving revision 1.5
diff -c -r1.5 test.c
*** test.c	2001/10/16 09:01:40	1.5
--- test.c	2001/10/17 02:14:02
***************
*** 1624,1630 ****
  	}
  #   endif	/* GC_HPUX_THREADS */
      pthread_attr_init(&attr);
! #   if defined(GC_IRIX_THREADS)
      	pthread_attr_setstacksize(&attr, 1000000);
  #   endif
      n_tests = 0;
--- 1624,1630 ----
  	}
  #   endif	/* GC_HPUX_THREADS */
      pthread_attr_init(&attr);
! #   if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS)
      	pthread_attr_setstacksize(&attr, 1000000);
  #   endif
      n_tests = 0;
Index: include/private/gcconfig.h
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/include/private/gcconfig.h,v
retrieving revision 1.6
diff -c -r1.6 gcconfig.h
*** gcconfig.h	2001/10/16 09:01:39	1.6
--- gcconfig.h	2001/10/17 02:14:01
***************
*** 1017,1023 ****
  #   endif
  #   ifdef FREEBSD
  #	define OS_TYPE "FREEBSD"
! #	define MPROTECT_VDB
  #	define FREEBSD_STACKBOTTOM
  #	ifdef __ELF__
  #	    define DYNAMIC_LOADING
--- 1017,1027 ----
  #   endif
  #   ifdef FREEBSD
  #	define OS_TYPE "FREEBSD"
! #	ifndef GC_FREEBSD_THREADS
! #	    define MPROTECT_VDB
! #	endif
! #	define SIG_SUSPEND SIGUSR1
! #	define SIG_THR_RESTART SIGUSR2
  #	define FREEBSD_STACKBOTTOM
  #	ifdef __ELF__
  #	    define DYNAMIC_LOADING


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]