From 2482796098748a4aa1c684ff34d622564d3d1bff Mon Sep 17 00:00:00 2001 From: twisti Date: Fri, 1 Jun 2007 00:29:51 +0000 Subject: [PATCH] * m4/ac_pthreads_implementation.m4: Reverted rev7996. * m4/threads.m4: Likewise. * src/threads/threads-common.c [__LINUX__] (threads_pthreads_implementation_nptl): Added. (threads_preinit) [__LINUX__]: Check which thread-implementation we are using. * src/threads/threads-common.h [__LINUX__] (threads_pthreads_implementation_nptl): Added. * src/vm/signal.c (signal_init) [__LINUX__]: Check for threads_pthreads_implementation_nptl. * src/vm/vm.c (vm_create) [__LINUX__]: Likewise. --- m4/ac_pthreads_implementation.m4 | 68 -------------------------------- m4/threads.m4 | 7 ---- src/threads/threads-common.c | 37 ++++++++++++++++- src/threads/threads-common.h | 8 +++- src/vm/signal.c | 12 ++++-- src/vm/vm.c | 10 ++--- 6 files changed, 57 insertions(+), 85 deletions(-) delete mode 100644 m4/ac_pthreads_implementation.m4 diff --git a/m4/ac_pthreads_implementation.m4 b/m4/ac_pthreads_implementation.m4 deleted file mode 100644 index c8cf76d62..000000000 --- a/m4/ac_pthreads_implementation.m4 +++ /dev/null @@ -1,68 +0,0 @@ -dnl m4/ac_pthreads_implementation.m4 -dnl -dnl Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, -dnl C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -dnl E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -dnl J. Wenninger, Institut f. Computersprachen - TU Wien -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 -dnl $Id: configure.ac 7228 2007-01-19 01:13:48Z edwin $ - - -dnl checks if the pthreads implementation is NPTL or LinuxThreads - -AC_DEFUN([AC_CHECK_PTHREADS_IMPLEMENTATION], -[ - AC_MSG_CHECKING(pthread implementation) - AC_TRY_RUN( -[ -#include -#include -#include - -int main(void) -{ - char *pathbuf; - size_t n; - - /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */ - /* If the glibc is a pre-2.3.2 version, the compilation fails and we - fall back to linuxthreads. */ - - n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0); - - pathbuf = malloc(n); - if ((pathbuf = malloc(n)) == NULL) abort(); - (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, n); - - if (strstr(pathbuf, "linuxthreads") != NULL) - return 1; - - return 0; -} -], -[ - AC_MSG_RESULT(NPTL) - AC_DEFINE(PTHREADS_IS_NPTL, 1, [NPTL pthreads implementation]) -], -[ - AC_MSG_RESULT(linuxthreads) - AC_DEFINE(PTHREADS_IS_LINUXTHREADS, 1, [LinuxThreads pthread implementation]) -]) -]) diff --git a/m4/threads.m4 b/m4/threads.m4 index 9dcdf44c6..9b2e404a0 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -59,13 +59,6 @@ case "${ENABLE_THREADS}" in AC_DEFINE([ENABLE_THREADS], 1, [enable threads]) AC_CHECK_LIB(pthread, main) - dnl check for pthread implementation - case "${OS_DIR}" in - linux ) - AC_CHECK_PTHREADS_IMPLEMENTATION - ;; - esac - ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT" dnl we changed ARCH_CFLAGS, set CFLAGS again diff --git a/src/threads/threads-common.c b/src/threads/threads-common.c index 83c69e88e..b07331505 100644 --- a/src/threads/threads-common.c +++ b/src/threads/threads-common.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: threads-common.c 7970 2007-05-25 15:23:56Z twisti $ + $Id: threads-common.c 7998 2007-06-01 00:29:51Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -75,6 +76,11 @@ static list_t *list_threads; /* global threads free-list */ static list_t *list_threads_free; +#if defined(__LINUX__) +/* XXX Remove for exact-GC. */ +bool threads_pthreads_implementation_nptl; +#endif + /* threads_preinit ************************************************************* @@ -88,6 +94,35 @@ static list_t *list_threads_free; void threads_preinit(void) { threadobject *mainthread; +#if defined(__LINUX__) + char *pathbuf; + size_t len; +#endif + +#if defined(__LINUX__) + /* XXX Remove for exact-GC. */ + + /* On Linux we need to check the pthread implementation. */ + + /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */ + /* If the glibc is a pre-2.3.2 version, we fall back to + linuxthreads. */ + +# if defined(_CS_GNU_LIBPTHREAD_VERSION) + len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0); + + pathbuf = MNEW(char, len); + + (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len); + + if (strstr(pathbuf, "NPTL") != NULL) + threads_pthreads_implementation_nptl = true; + else + threads_pthreads_implementation_nptl = false; +# else + threads_pthreads_implementation_nptl = false; +# endif +#endif /* initialize the threads lists */ diff --git a/src/threads/threads-common.h b/src/threads/threads-common.h index a440f12d5..39b1f2782 100644 --- a/src/threads/threads-common.h +++ b/src/threads/threads-common.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: threads-common.h 7984 2007-05-30 20:30:00Z twisti $ + $Id: threads-common.h 7998 2007-06-01 00:29:51Z twisti $ */ @@ -67,6 +67,12 @@ #define MAX_PRIORITY 10 +#if defined(__LINUX__) +/* XXX Remove for exact-GC. */ +extern bool threads_pthreads_implementation_nptl; +#endif + + /* function prototypes ********************************************************/ void threads_preinit(void); diff --git a/src/vm/signal.c b/src/vm/signal.c index 7f9dcbaf0..5c6a82cf7 100644 --- a/src/vm/signal.c +++ b/src/vm/signal.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: signal.c 7996 2007-05-31 23:05:51Z twisti $ + $Id: signal.c 7998 2007-06-01 00:29:51Z twisti $ */ @@ -92,8 +92,10 @@ bool signal_init(void) assert(OFFSET(java_bytearray, data) > EXCEPTION_HARDWARE_PATCHER); -#if !defined(PTHREADS_IS_LINUXTHREADS) - /* XXX Remove this #ifdef with exact-GC. */ +#if defined(__LINUX__) + /* XXX Remove for exact-GC. */ + if (threads_pthreads_implementation_nptl) { +#endif /* Block the following signals (SIGINT for -c, SIGQUIT for -\). We enable them later in signal_thread, but only for @@ -112,6 +114,10 @@ bool signal_init(void) if (sigprocmask(SIG_BLOCK, &mask, NULL) != 0) vm_abort("signal_init: sigprocmask failed: %s", strerror(errno)); + +#if defined(__LINUX__) + /* XXX Remove for exact-GC. */ + } #endif #if defined(ENABLE_GC_BOEHM) diff --git a/src/vm/vm.c b/src/vm/vm.c index c4284a054..36bcd39de 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -1638,14 +1638,14 @@ bool vm_create(JavaVMInitArgs *vm_args) if (!recompile_init()) vm_abort("vm_create: recompile_init failed"); -#if !defined(PTHREADS_IS_LINUXTHREADS) - /* XXX Remove this #ifdef with exact-GC. */ - /* start the signal handler thread */ - if (!signal_start_thread()) - vm_abort("vm_create: signal_start_thread failed"); +#if defined(__LINUX__) + /* XXX Remove for exact-GC. */ + if (threads_pthreads_implementation_nptl) #endif + if (!signal_start_thread()) + vm_abort("vm_create: signal_start_thread failed"); /* finally, start the finalizer thread */ -- 2.25.1