dnl YAZ Toolkit, Index Data 1994-2001
dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.45 2001-05-16 07:37:39 adam Exp $
+dnl $Id: configure.in,v 1.46 2001-10-03 23:55:18 adam Exp $
AC_INIT(include/yaz/yaz-version.h)
AM_INIT_AUTOMAKE(yaz, 1.7)
dnl
AC_MSG_WARN(Your system doesn't seem to support ANSI C)
fi
dnl
-dnl ------ Threads
-AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
AC_SUBST(LIBTHREAD)
-if test "$enable_threads" = "yes"; then
+HAVETHREADS=0
+LIBTHREAD=""
+dnl
+AC_ARG_ENABLE(pth, [ --disable-pth disable GNU threads],[enable_pth=$enableval],[enable_pth=yes])
+AC_SUBST(LIBPTH)
+if test "$enable_pth" = "yes"; then
+ OLIBS=$LIBS
+ AC_CHECK_LIB(pth,main)
+ if test "$ac_cv_lib_pth_main" = "yes"; then
+ AC_CHECK_HEADERS(pth.h)
+ if test "$ac_cv_header_pth_h" = "yes"; then
+ LIBTHREAD="-lpth"
+ HAVETHREADS=1
+ fi
+ fi
+ LIBS=$OLIBS
+fi
+dnl
+dnl ------ POSIX Threads
+AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
+if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
OLIBS=$LIBS
AC_CHECK_LIB(pthread,main)
AC_MSG_CHECKING(for working POSIX Threads)
if test "$thread_ok" = "yes"; then
LIBTHREAD=-lpthread
AC_MSG_RESULT(yes)
+ AC_CHECK_HEADERS(pthread.h)
HAVETHREADS=1
else
- LIBTHREAD=""
AC_MSG_RESULT(no)
- HAVETHREADS=0
fi
LIBS=$OLIBS
fi
-## $Id: Makefile.am,v 1.12 2001-05-07 12:01:00 adam Exp $
+## $Id: Makefile.am,v 1.13 2001-10-03 23:55:18 adam Exp $
if ISTHR
extra=libyazthread.la
LDFLAGS=-version-info 1:0:0
-INCLUDES =-I$(top_srcdir)/include -I$(top_srcdir)/server -D_REENTRANT=1 -DHAVE_PTHREAD_H=1
+INCLUDES =-I$(top_srcdir)/include -I$(top_srcdir)/server -D_REENTRANT=1
bin_SCRIPTS = yaz-config
* Chas Woodfield, Fretwell Downing Informatics.
*
* $Log: statserv.c,v $
- * Revision 1.73 2001-06-28 09:27:06 adam
+ * Revision 1.74 2001-10-03 23:55:18 adam
+ * GNU threads support.
+ *
+ * Revision 1.73 2001/06/28 09:27:06 adam
* Number of started sessions logged.
*
* Revision 1.72 2001/03/25 21:55:13 adam
#include <direct.h>
#include "service.h"
#else
+
+#ifdef _REENTRANT
#if HAVE_PTHREAD_H
#include <pthread.h>
+#elif HAVE_PTH_H
+#include <pth.h>
+#endif
#endif
+
#include <unistd.h>
#include <pwd.h>
#endif
iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
++no_sessions;
}
+#ifdef _REENTRANT
#if HAVE_PTHREAD_H
if (control_block.threads)
{
}
else
new_session(new_line);
+#elif HAVE_PTH_H
+ if (control_block.threads)
+ {
+ pth_attr_t attr;
+ pth_t child_thread;
+
+ pth_attr_init (attr);
+ pth_attr_set (attr, PTH_ATTR_JOINABLE, FALSE);
+ child_thread = pth_spawn (attr, new_session, new_line);
+ pth_attr_destroy (attr);
+ }
+ else
+ new_session(new_line);
+#endif
+
#else
new_session(new_line);
#endif
/*
- * Copyright (c) 1995-2000, Index Data.
+ * Copyright (c) 1995-2001, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: nmem.c,v $
- * Revision 1.27 2001-09-27 12:09:18 adam
+ * Revision 1.28 2001-10-03 23:55:18 adam
+ * GNU threads support.
+ *
+ * Revision 1.27 2001/09/27 12:09:18 adam
* Function nmem_exit calls oid_exit (when reference is 0).
*
* Revision 1.26 2001/07/19 19:51:42 adam
#include <yaz/nmem.h>
#include <yaz/log.h>
#include <yaz/oid.h>
+
#ifdef WIN32
#include <windows.h>
-#elif _REENTRANT
+#endif
+#ifdef _REENTRANT
#if HAVE_PTHREAD_H
#include <pthread.h>
-#elif HAVE_THREAD_H
-#include <thread.h>
+#elif HAVE_PTH_H
+#include <pth.h>
#endif
#endif
static CRITICAL_SECTION critical_section;
#define NMEM_ENTER EnterCriticalSection(&critical_section)
#define NMEM_LEAVE LeaveCriticalSection(&critical_section)
-#elif _REENTRANT
+#endif
+
+#ifdef _REENTRANT
+#if HAVE_PTHREAD_H
static pthread_mutex_t nmem_mutex = PTHREAD_MUTEX_INITIALIZER;
#define NMEM_ENTER pthread_mutex_lock(&nmem_mutex);
#define NMEM_LEAVE pthread_mutex_unlock(&nmem_mutex);
+#elif HAVE_PTH_H
+static pth_mutex_t nmem_mutex;
+#define NMEM_ENTER pth_mutex_acquire(&nmem_mutex, 0, 0)
+#define NMEM_LEAVE pth_mutex_release(&nmem_mutex)
+#else
+#error x
+#endif
#else
#define NMEM_ENTER
#define NMEM_LEAVE
#endif
-
struct nmem_mutex {
#ifdef WIN32
CRITICAL_SECTION m_handle;
-#elif _REENTRANT
+#endif
+#if _REENTRANT
+
+#if HAVE_PTHREAD_H
pthread_mutex_t m_handle;
+#elif HAVE_PTH_H
+ pth_mutex_t m_handle;
+#endif
+
#else
int m_handle;
#endif
{
#ifdef WIN32
InitializeCriticalSection(&critical_section);
+#elif HAVE_PTH_H
+#ifdef __REENTRANT
+ pth_mutex_init (&nmem_mutex);
+#endif
#endif
nmem_active_no = 0;
freelist = NULL;