Commit bc5afba4 by Tom Tromey Committed by Tom Tromey

posix-threads.h (PTHREAD_MUTEX_IS_STRUCT): New define.

	* include/posix-threads.h (PTHREAD_MUTEX_IS_STRUCT): New define.
	(_Jv_PthreadGetMutex): Use it.
	(_Jv_PthreadCheckMonitor): Use new M_COUNT macros.
	(_Jv_MutexInit): Use PTHREAD_MUTEX_IS_STRUCT.
	(_Jv_MutexLock): Likewise.
	(_Jv_MutexUnlock): Likewise.
	* include/config.h.in: Rebuilt.
	* acconfig.h (PTHREAD_MUTEX_HAVE_M_COUNT,
	PTHREAD_MUTEX_HAVE___M_COUNT): New undefs.
	* configure: Rebuilt.
	* libgcj.spec.in: Don't mention INTERPSPEC.
	* configure.in (INTERPSPEC): Removed.
	Only run pthreads-related checks when using POSIX threads.  Check
	for m_count and __m_count in mutex structure.

From-SVN: r29048
parent 2598e85a
1999-09-01 Tom Tromey <tromey@cygnus.com>
* include/posix-threads.h (PTHREAD_MUTEX_IS_STRUCT): New define.
(_Jv_PthreadGetMutex): Use it.
(_Jv_PthreadCheckMonitor): Use new M_COUNT macros.
(_Jv_MutexInit): Use PTHREAD_MUTEX_IS_STRUCT.
(_Jv_MutexLock): Likewise.
(_Jv_MutexUnlock): Likewise.
* include/config.h.in: Rebuilt.
* acconfig.h (PTHREAD_MUTEX_HAVE_M_COUNT,
PTHREAD_MUTEX_HAVE___M_COUNT): New undefs.
* configure: Rebuilt.
* libgcj.spec.in: Don't mention INTERPSPEC.
* configure.in (INTERPSPEC): Removed.
Only run pthreads-related checks when using POSIX threads. Check
for m_count and __m_count in mutex structure.
1999-09-01 Matt Welsh <mdw@cs.berkeley.edu> 1999-09-01 Matt Welsh <mdw@cs.berkeley.edu>
* java/lang/natClass.cc: Fixed notification of threads * java/lang/natClass.cc: Fixed notification of threads
......
...@@ -106,3 +106,9 @@ ...@@ -106,3 +106,9 @@
/* Define if you want a bytecode interpreter. */ /* Define if you want a bytecode interpreter. */
#undef INTERPRETER #undef INTERPRETER
/* Define if pthread_mutex_t has m_count member. */
#undef PTHREAD_MUTEX_HAVE_M_COUNT
/* Define if pthread_mutex_t has __m_count member. */
#undef PTHREAD_MUTEX_HAVE___M_COUNT
...@@ -50,10 +50,6 @@ AC_ARG_ENABLE(interpreter, ...@@ -50,10 +50,6 @@ AC_ARG_ENABLE(interpreter,
AC_DEFINE(INTERPRETER) AC_DEFINE(INTERPRETER)
fi) fi)
dnl This becomes -lffi if the interpreter is enabled.
INTERPSPEC=
AC_SUBST(INTERPSPEC)
dnl If the target is an eCos system, use the appropriate eCos dnl If the target is an eCos system, use the appropriate eCos
dnl I/O routines. dnl I/O routines.
dnl FIXME: this should not be a local option but a global target dnl FIXME: this should not be a local option but a global target
...@@ -306,8 +302,6 @@ if test -n "${with_cross_host}"; then ...@@ -306,8 +302,6 @@ if test -n "${with_cross_host}"; then
GCJ= GCJ=
fi fi
else else
# Some POSIX thread systems don't have pthread_mutexattr_settype.
# E.g., Solaris.
AC_CHECK_FUNCS(strerror ioctl select open fsync sleep) AC_CHECK_FUNCS(strerror ioctl select open fsync sleep)
AC_CHECK_FUNCS(ctime_r ctime, break) AC_CHECK_FUNCS(ctime_r ctime, break)
AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r) AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
...@@ -377,23 +371,37 @@ else ...@@ -377,23 +371,37 @@ else
AC_EGREP_HEADER(gethostname, unistd.h, [ AC_EGREP_HEADER(gethostname, unistd.h, [
AC_DEFINE(HAVE_GETHOSTNAME_DECL)])]) AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
# Look for these functions in the thread library. # Look for these functions in the thread library, but only bother
save_LIBS="$LIBS" # if using POSIX threads.
LIBS="$LIBS $THREADLIBS" if test "$THREADS" = posix; then
AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np) save_LIBS="$LIBS"
LIBS="$LIBS $THREADLIBS"
# Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since # Some POSIX thread systems don't have pthread_mutexattr_settype.
# Solaris 7 the name librt is preferred. # E.g., Solaris.
AC_CHECK_FUNCS(sched_yield, , [ AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
AC_CHECK_LIB(rt, sched_yield, [
AC_DEFINE(HAVE_SCHED_YIELD) # Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since
THREADLIBS="$THREADLIBS -lrt" # Solaris 7 the name librt is preferred.
THREADSPECS="$THREADSPECS -lrt"], [ AC_CHECK_FUNCS(sched_yield, , [
AC_CHECK_LIB(posix4, sched_yield, [ AC_CHECK_LIB(rt, sched_yield, [
AC_DEFINE(HAVE_SCHED_YIELD) AC_DEFINE(HAVE_SCHED_YIELD)
THREADLIBS="$THREADLIBS -lposix4" THREADLIBS="$THREADLIBS -lrt"
THREADSPECS="$THREADSPECS -lposix4"])])]) THREADSPECS="$THREADSPECS -lrt"], [
LIBS="$save_LIBS" AC_CHECK_LIB(posix4, sched_yield, [
AC_DEFINE(HAVE_SCHED_YIELD)
THREADLIBS="$THREADLIBS -lposix4"
THREADSPECS="$THREADSPECS -lposix4"])])])
LIBS="$save_LIBS"
# We can save a little space at runtime if the mutex has m_count
# or __m_count. This is a nice hack for Linux.
AC_TRY_COMPILE([#include <pthread.h>], [
extern pthread_mutex_t *mutex; int q = mutex->m_count;
], AC_DEFINE(PTHREAD_MUTEX_HAVE_M_COUNT), [
AC_TRY_COMPILE([#include <pthread.h>], [
extern pthread_mutex_t *mutex; int q = mutex->__m_count;
], AC_DEFINE(PTHREAD_MUTEX_HAVE___M_COUNT))])
fi
# We require a way to get the time. # We require a way to get the time.
time_found=no time_found=no
...@@ -461,10 +469,6 @@ else ...@@ -461,10 +469,6 @@ else
]) ])
SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets" SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
if test "$enable_interpreter" = yes; then
INTERPSPEC=
fi
if test "$with_system_zlib" = yes; then if test "$with_system_zlib" = yes; then
AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj) AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj)
else else
......
...@@ -122,6 +122,12 @@ ...@@ -122,6 +122,12 @@
/* Define if you want a bytecode interpreter. */ /* Define if you want a bytecode interpreter. */
#undef INTERPRETER #undef INTERPRETER
/* Define if pthread_mutex_t has m_count member. */
#undef PTHREAD_MUTEX_HAVE_M_COUNT
/* Define if pthread_mutex_t has __m_count member. */
#undef PTHREAD_MUTEX_HAVE___M_COUNT
/* Define if you have the access function. */ /* Define if you have the access function. */
#undef HAVE_ACCESS #undef HAVE_ACCESS
......
...@@ -31,9 +31,7 @@ details. */ ...@@ -31,9 +31,7 @@ details. */
typedef pthread_cond_t _Jv_ConditionVariable_t; typedef pthread_cond_t _Jv_ConditionVariable_t;
// FIXME: it is ugly to use LINUX_THREADS as the define. Instead #if defined (PTHREAD_MUTEX_HAVE_M_COUNT) || defined (PTHREAD_MUTEX_HAVE___M_COUNT)
// think of a better scheme.
#ifdef LINUX_THREADS
// On Linux we use implementation details of mutexes in order to get // On Linux we use implementation details of mutexes in order to get
// faster results. // faster results.
...@@ -41,6 +39,8 @@ typedef pthread_mutex_t _Jv_Mutex_t; ...@@ -41,6 +39,8 @@ typedef pthread_mutex_t _Jv_Mutex_t;
#else /* LINUX_THREADS */ #else /* LINUX_THREADS */
#define PTHREAD_MUTEX_IS_STRUCT
typedef struct typedef struct
{ {
// Mutex used when locking this structure transiently. // Mutex used when locking this structure transiently.
...@@ -67,7 +67,7 @@ typedef struct ...@@ -67,7 +67,7 @@ typedef struct
int count; int count;
} _Jv_Mutex_t; } _Jv_Mutex_t;
#endif /* LINUX_THREADS */ #endif
typedef struct typedef struct
{ {
...@@ -88,7 +88,7 @@ typedef void _Jv_ThreadStartFunc (java::lang::Thread *); ...@@ -88,7 +88,7 @@ typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
inline pthread_mutex_t * inline pthread_mutex_t *
_Jv_PthreadGetMutex (_Jv_Mutex_t *mu) _Jv_PthreadGetMutex (_Jv_Mutex_t *mu)
{ {
#if defined (LINUX_THREADS) #if ! defined (PTHREAD_MUTEX_IS_STRUCT)
return mu; return mu;
#elif defined (HAVE_RECURSIVE_MUTEX) #elif defined (HAVE_RECURSIVE_MUTEX)
return &mu->mutex; return &mu->mutex;
...@@ -110,9 +110,11 @@ _Jv_PthreadCheckMonitor (_Jv_Mutex_t *mu) ...@@ -110,9 +110,11 @@ _Jv_PthreadCheckMonitor (_Jv_Mutex_t *mu)
// See if the mutex is locked by this thread. // See if the mutex is locked by this thread.
if (pthread_mutex_trylock (pmu)) if (pthread_mutex_trylock (pmu))
return 1; return 1;
#ifdef LINUX_THREADS #if defined (PTHREAD_MUTEX_HAVE_M_COUNT)
// On Linux we exploit knowledge of the implementation. // On Linux we exploit knowledge of the implementation.
int r = pmu->m_count == 1; int r = pmu->m_count == 1;
#elif defined (PTHREAD_MUTEX_HAVE___M_COUNT)
int r = pmu->__m_count == 1;
#else #else
int r = mu->count == 0; int r = mu->count == 0;
#endif #endif
...@@ -170,7 +172,7 @@ inline void ...@@ -170,7 +172,7 @@ inline void
_Jv_MutexInit (_Jv_Mutex_t *mu) _Jv_MutexInit (_Jv_Mutex_t *mu)
{ {
pthread_mutex_init (_Jv_PthreadGetMutex (mu), NULL); pthread_mutex_init (_Jv_PthreadGetMutex (mu), NULL);
#ifndef LINUX_THREADS #ifdef PTHREAD_MUTEX_IS_STRUCT
mu->count = 0; mu->count = 0;
#endif #endif
} }
...@@ -206,7 +208,7 @@ inline int ...@@ -206,7 +208,7 @@ inline int
_Jv_MutexLock (_Jv_Mutex_t *mu) _Jv_MutexLock (_Jv_Mutex_t *mu)
{ {
int r = pthread_mutex_lock (mu); int r = pthread_mutex_lock (mu);
#ifndef LINUX_THREADS #ifdef PTHREAD_MUTEX_IS_STRUCT
if (! r) if (! r)
++mu->count; ++mu->count;
#endif #endif
...@@ -217,7 +219,7 @@ inline int ...@@ -217,7 +219,7 @@ inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu) _Jv_MutexUnlock (_Jv_Mutex_t *mu)
{ {
int r = pthread_mutex_unlock (mu); int r = pthread_mutex_unlock (mu);
#ifndef LINUX_THREADS #ifdef PTHREAD_MUTEX_IS_STRUCT
if (! r) if (! r)
--mu->count; --mu->count;
#endif #endif
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# to link with libgcj. # to link with libgcj.
# #
%rename lib liborig %rename lib liborig
*lib: -lgcj -lm @INTERPSPEC@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(liborig) *lib: -lgcj -lm @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(liborig)
%rename cc1 cc1orig %rename cc1 cc1orig
*cc1: @DIVIDESPEC@ %(cc1orig) *cc1: @DIVIDESPEC@ %(cc1orig)
# Makefile.in generated automatically by automake 1.4a from Makefile.am # Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. # PARTICULAR PURPOSE.
SHELL = @SHELL@ SHELL = @SHELL@
srcdir = @srcdir@ srcdir = @srcdir@
...@@ -45,10 +46,9 @@ AUTOMAKE = @AUTOMAKE@ ...@@ -45,10 +46,9 @@ AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@ AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@ transform = @program_transform_name@
NORMAL_INSTALL = : NORMAL_INSTALL = :
...@@ -80,7 +80,6 @@ GCINCS = @GCINCS@ ...@@ -80,7 +80,6 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@ GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@ GCSPEC = @GCSPEC@
INTERPSPEC = @INTERPSPEC@
LD = @LD@ LD = @LD@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@ LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@ LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
...@@ -90,7 +89,6 @@ LN_S = @LN_S@ ...@@ -90,7 +89,6 @@ LN_S = @LN_S@
MAINT = @MAINT@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
NM = @NM@ NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
PERL = @PERL@ PERL = @PERL@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
...@@ -100,6 +98,7 @@ THREADINCS = @THREADINCS@ ...@@ -100,6 +98,7 @@ THREADINCS = @THREADINCS@
THREADLIBS = @THREADLIBS@ THREADLIBS = @THREADLIBS@
THREADOBJS = @THREADOBJS@ THREADOBJS = @THREADOBJS@
THREADSPEC = @THREADSPEC@ THREADSPEC = @THREADSPEC@
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@ VERSION = @VERSION@
ZDEPS = @ZDEPS@ ZDEPS = @ZDEPS@
ZINCS = @ZINCS@ ZINCS = @ZINCS@
...@@ -108,7 +107,6 @@ ZLIBSPEC = @ZLIBSPEC@ ...@@ -108,7 +107,6 @@ ZLIBSPEC = @ZLIBSPEC@
here = @here@ here = @here@
libgcj_basedir = @libgcj_basedir@ libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign dejagnu no-installinfo AUTOMAKE_OPTIONS = foreign dejagnu no-installinfo
# Setup the testing framework, if you have one # Setup the testing framework, if you have one
...@@ -123,16 +121,15 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \ ...@@ -123,16 +121,15 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
RUNTESTFLAGS = @AM_RUNTESTFLAGS@ RUNTESTFLAGS = @AM_RUNTESTFLAGS@
subdir = testsuite
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = ../include/config.h CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = ChangeLog Makefile.am Makefile.in DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best GZIP_ENV = --best
all: all-redirect all: all-redirect
.SUFFIXES: .SUFFIXES:
...@@ -149,6 +146,8 @@ TAGS: ...@@ -149,6 +146,8 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = testsuite
distdir: $(DISTFILES) distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \ here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \ top_distdir=`cd $(top_distdir) && pwd`; \
...@@ -158,7 +157,7 @@ distdir: $(DISTFILES) ...@@ -158,7 +157,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \ @for file in $(DISTFILES); do \
d=$(srcdir); \ d=$(srcdir); \
if test -d $$d/$$file; then \ if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \ cp -pr $$/$$file $(distdir)/$$file; \
else \ else \
test -f $(distdir)/$$file \ test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
...@@ -222,7 +221,7 @@ uninstall: uninstall-am ...@@ -222,7 +221,7 @@ uninstall: uninstall-am
all-am: Makefile all-am: Makefile
all-redirect: all-am all-redirect: all-am
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs:
...@@ -257,8 +256,8 @@ maintainer-clean: maintainer-clean-am ...@@ -257,8 +256,8 @@ maintainer-clean: maintainer-clean-am
.PHONY: tags distdir check-DEJAGNU info-am info dvi-am dvi check \ .PHONY: tags distdir check-DEJAGNU info-am info dvi-am dvi check \
check-am installcheck-am installcheck install-info-am install-info \ check-am installcheck-am installcheck install-info-am install-info \
install-exec-am install-exec install-data-am install-data install-am \ install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all install-strip \ install uninstall-am uninstall all-redirect all-am all installdirs \
installdirs mostlyclean-generic distclean-generic clean-generic \ mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean maintainer-clean-generic clean mostlyclean distclean maintainer-clean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment