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>
* java/lang/natClass.cc: Fixed notification of threads
......
......@@ -106,3 +106,9 @@
/* Define if you want a bytecode 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,
AC_DEFINE(INTERPRETER)
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 I/O routines.
dnl FIXME: this should not be a local option but a global target
......@@ -306,8 +302,6 @@ if test -n "${with_cross_host}"; then
GCJ=
fi
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(ctime_r ctime, break)
AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
......@@ -377,23 +371,37 @@ else
AC_EGREP_HEADER(gethostname, unistd.h, [
AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
# Look for these functions in the thread library.
save_LIBS="$LIBS"
LIBS="$LIBS $THREADLIBS"
AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
# Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since
# Solaris 7 the name librt is preferred.
AC_CHECK_FUNCS(sched_yield, , [
AC_CHECK_LIB(rt, sched_yield, [
AC_DEFINE(HAVE_SCHED_YIELD)
THREADLIBS="$THREADLIBS -lrt"
THREADSPECS="$THREADSPECS -lrt"], [
AC_CHECK_LIB(posix4, sched_yield, [
AC_DEFINE(HAVE_SCHED_YIELD)
THREADLIBS="$THREADLIBS -lposix4"
THREADSPECS="$THREADSPECS -lposix4"])])])
LIBS="$save_LIBS"
# Look for these functions in the thread library, but only bother
# if using POSIX threads.
if test "$THREADS" = posix; then
save_LIBS="$LIBS"
LIBS="$LIBS $THREADLIBS"
# Some POSIX thread systems don't have pthread_mutexattr_settype.
# E.g., Solaris.
AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
# Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since
# Solaris 7 the name librt is preferred.
AC_CHECK_FUNCS(sched_yield, , [
AC_CHECK_LIB(rt, sched_yield, [
AC_DEFINE(HAVE_SCHED_YIELD)
THREADLIBS="$THREADLIBS -lrt"
THREADSPECS="$THREADSPECS -lrt"], [
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.
time_found=no
......@@ -461,10 +469,6 @@ else
])
SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
if test "$enable_interpreter" = yes; then
INTERPSPEC=
fi
if test "$with_system_zlib" = yes; then
AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj)
else
......
......@@ -122,6 +122,12 @@
/* Define if you want a bytecode 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. */
#undef HAVE_ACCESS
......
......@@ -31,9 +31,7 @@ details. */
typedef pthread_cond_t _Jv_ConditionVariable_t;
// FIXME: it is ugly to use LINUX_THREADS as the define. Instead
// think of a better scheme.
#ifdef LINUX_THREADS
#if defined (PTHREAD_MUTEX_HAVE_M_COUNT) || defined (PTHREAD_MUTEX_HAVE___M_COUNT)
// On Linux we use implementation details of mutexes in order to get
// faster results.
......@@ -41,6 +39,8 @@ typedef pthread_mutex_t _Jv_Mutex_t;
#else /* LINUX_THREADS */
#define PTHREAD_MUTEX_IS_STRUCT
typedef struct
{
// Mutex used when locking this structure transiently.
......@@ -67,7 +67,7 @@ typedef struct
int count;
} _Jv_Mutex_t;
#endif /* LINUX_THREADS */
#endif
typedef struct
{
......@@ -88,7 +88,7 @@ typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
inline pthread_mutex_t *
_Jv_PthreadGetMutex (_Jv_Mutex_t *mu)
{
#if defined (LINUX_THREADS)
#if ! defined (PTHREAD_MUTEX_IS_STRUCT)
return mu;
#elif defined (HAVE_RECURSIVE_MUTEX)
return &mu->mutex;
......@@ -110,9 +110,11 @@ _Jv_PthreadCheckMonitor (_Jv_Mutex_t *mu)
// See if the mutex is locked by this thread.
if (pthread_mutex_trylock (pmu))
return 1;
#ifdef LINUX_THREADS
#if defined (PTHREAD_MUTEX_HAVE_M_COUNT)
// On Linux we exploit knowledge of the implementation.
int r = pmu->m_count == 1;
#elif defined (PTHREAD_MUTEX_HAVE___M_COUNT)
int r = pmu->__m_count == 1;
#else
int r = mu->count == 0;
#endif
......@@ -170,7 +172,7 @@ inline void
_Jv_MutexInit (_Jv_Mutex_t *mu)
{
pthread_mutex_init (_Jv_PthreadGetMutex (mu), NULL);
#ifndef LINUX_THREADS
#ifdef PTHREAD_MUTEX_IS_STRUCT
mu->count = 0;
#endif
}
......@@ -206,7 +208,7 @@ inline int
_Jv_MutexLock (_Jv_Mutex_t *mu)
{
int r = pthread_mutex_lock (mu);
#ifndef LINUX_THREADS
#ifdef PTHREAD_MUTEX_IS_STRUCT
if (! r)
++mu->count;
#endif
......@@ -217,7 +219,7 @@ inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu)
{
int r = pthread_mutex_unlock (mu);
#ifndef LINUX_THREADS
#ifdef PTHREAD_MUTEX_IS_STRUCT
if (! r)
--mu->count;
#endif
......
......@@ -4,7 +4,7 @@
# to link with libgcj.
#
%rename lib liborig
*lib: -lgcj -lm @INTERPSPEC@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(liborig)
*lib: -lgcj -lm @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(liborig)
%rename cc1 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.
# This Makefile.in is free software; the Free Software Foundation
......@@ -10,6 +10,7 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
......@@ -45,10 +46,9 @@ AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
......@@ -80,7 +80,6 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
INTERPSPEC = @INTERPSPEC@
LD = @LD@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
......@@ -90,7 +89,6 @@ LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
......@@ -100,6 +98,7 @@ THREADINCS = @THREADINCS@
THREADLIBS = @THREADLIBS@
THREADOBJS = @THREADOBJS@
THREADSPEC = @THREADSPEC@
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@
ZDEPS = @ZDEPS@
ZINCS = @ZINCS@
......@@ -108,7 +107,6 @@ ZLIBSPEC = @ZLIBSPEC@
here = @here@
libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign dejagnu no-installinfo
# Setup the testing framework, if you have one
......@@ -123,16 +121,15 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
RUNTESTFLAGS = @AM_RUNTESTFLAGS@
subdir = testsuite
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
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
all: all-redirect
.SUFFIXES:
......@@ -149,6 +146,8 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = testsuite
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
......@@ -158,7 +157,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
......@@ -222,7 +221,7 @@ uninstall: uninstall-am
all-am: Makefile
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
......@@ -257,8 +256,8 @@ maintainer-clean: maintainer-clean-am
.PHONY: tags distdir check-DEJAGNU info-am info dvi-am dvi check \
check-am installcheck-am installcheck install-info-am install-info \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all install-strip \
installdirs mostlyclean-generic distclean-generic clean-generic \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
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