From 63fccea4ea6857534ebb5e1e197c4b99bd89e9cf Mon Sep 17 00:00:00 2001 From: ljrittle Date: Wed, 17 Oct 2001 04:55:30 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46307 138bc75d-0d04-0410-961f-82ee72b054a4 --- ChangeLog | 12 ++++++++++++ include/gc_pthread_redirects.h | 4 +--- include/private/gcconfig.h | 6 +++++- linux_threads.c | 11 +++++++++++ tests/test.c | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff94d2b7..58c5f390 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-10-16 Loren J. Rittle + + * 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. + 2001-10-16 Loren J. Rittle * Makefile.am (test.o): Find tests/test.c in $(srcdir). diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index ac254a86..47284fbc 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -44,9 +44,7 @@ #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)) +#if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS) && !defined(GC_SOLARIS_PTHREADS) /* We treat these similarly. */ # include # include diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index e92f2a4e..4334dbd2 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -1017,7 +1017,11 @@ # endif # ifdef FREEBSD # define OS_TYPE "FREEBSD" -# define MPROTECT_VDB +# 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 diff --git a/linux_threads.c b/linux_threads.c index f52eab8c..ccd7dc65 100644 --- a/linux_threads.c +++ b/linux_threads.c @@ -1272,6 +1272,17 @@ int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) /* 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. */ diff --git a/tests/test.c b/tests/test.c index 35cb1357..e8cc9763 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1624,7 +1624,7 @@ main() } # endif /* GC_HPUX_THREADS */ pthread_attr_init(&attr); -# if defined(GC_IRIX_THREADS) +# if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) pthread_attr_setstacksize(&attr, 1000000); # endif n_tests = 0; -- 2.40.0