dnl YAZ Toolkit, Index Data 1994-2001
dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.47 2001-10-04 00:37:58 adam Exp $
+dnl $Id: configure.in,v 1.48 2001-10-05 13:55:17 adam Exp $
AC_INIT(include/yaz/yaz-version.h)
AM_INIT_AUTOMAKE(yaz, 1.7)
dnl
fi
dnl
AC_SUBST(LIBTHREAD)
+AC_SUBST(CFLAGSTHREADS)
HAVETHREADS=0
+CFLAGSTHREADS=""
LIBTHREAD=""
dnl
AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
AC_CHECK_HEADERS(pth.h)
if test "$ac_cv_header_pth_h" = "yes"; then
LIBTHREAD="-lpth"
+ CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
HAVETHREADS=1
fi
fi
if test "$thread_ok" = "yes"; then
LIBTHREAD=-lpthread
AC_MSG_RESULT(yes)
- AC_CHECK_HEADERS(pthread.h)
+ CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
HAVETHREADS=1
else
AC_MSG_RESULT(no)
-## $Id: Makefile.am,v 1.13 2001-10-03 23:55:18 adam Exp $
+## $Id: Makefile.am,v 1.14 2001-10-05 13:55:17 adam Exp $
if ISTHR
extra=libyazthread.la
# No real sources
libyaz_la_SOURCES=
-libyazthread_la_SOURCES=nmem.c statserv.c
+libyazthread_la_SOURCES=nmem.c statserv.c eventl.c
$(srcdir)/nmem.c: $(top_srcdir)/util/nmem.c
cp $(top_srcdir)/util/nmem.c $(srcdir)
$(srcdir)/statserv.c: $(top_srcdir)/server/statserv.c
cp $(top_srcdir)/server/statserv.c $(srcdir)
+$(srcdir)/eventl.c: $(top_srcdir)/server/eventl.c
+ cp $(top_srcdir)/server/eventl.c $(srcdir)
+
LDFLAGS=-version-info 1:0:0
-INCLUDES =-I$(top_srcdir)/include -I$(top_srcdir)/server -D_REENTRANT=1
+INCLUDES =-I$(top_srcdir)/include -I$(top_srcdir)/server @CFLAGSTHREADS@
bin_SCRIPTS = yaz-config
/*
- * Copyright (c) 1995-1999, Index Data
+ * Copyright (c) 1995-2001, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: eventl.c,v $
- * Revision 1.29 1999-11-30 13:47:12 adam
+ * Revision 1.30 2001-10-05 13:55:17 adam
+ * Added defines YAZ_GNU_THREADS, YAZ_POSIX_THREADS in code and yaz-config
+ *
+ * Revision 1.29 1999/11/30 13:47:12 adam
* Improved installation. Moved header files to include/yaz.
*
* Revision 1.28 1999/08/27 09:40:32 adam
#include "session.h"
#include <yaz/statserv.h>
+#if YAZ_GNU_THREADS
+#include <pth.h>
+#define YAZ_EV_SELECT pth_select
+#endif
+
+#ifndef YAZ_EV_SELECT
+#define YAZ_EV_SELECT select
+#endif
+
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
{
IOCHAN new_iochan;
if (p->fd > max)
max = p->fd;
}
- if ((res = select(max + 1, &in, &out, &except, timeout)) < 0)
+ res = YAZ_EV_SELECT(max + 1, &in, &out, &except, timeout);
+ if (res < 0)
{
if (errno == EINTR)
continue;
* Chas Woodfield, Fretwell Downing Informatics.
*
* $Log: statserv.c,v $
- * Revision 1.75 2001-10-04 00:37:58 adam
+ * Revision 1.76 2001-10-05 13:55:17 adam
+ * Added defines YAZ_GNU_THREADS, YAZ_POSIX_THREADS in code and yaz-config
+ *
+ * Revision 1.75 2001/10/04 00:37:58 adam
* Fixes for GNU threads (not working yet).
*
* Revision 1.74 2001/10/03 23:55:18 adam
#include <direct.h>
#include "service.h"
#else
+#include <unistd.h>
+#include <pwd.h>
+#endif
-#ifdef _REENTRANT
-#if HAVE_PTHREAD_H
+#if YAZ_POSIX_THREADS
#include <pthread.h>
-#elif HAVE_PTH_H
+#elif YAZ_GNU_THREADS
#include <pth.h>
#endif
-#endif
-#include <unistd.h>
-#include <pwd.h>
-#endif
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
++no_sessions;
}
-#ifdef _REENTRANT
-#if HAVE_PTHREAD_H
+#if YAZ_POSIX_THREADS
if (control_block.threads)
{
pthread_t child_thread;
}
else
new_session(new_line);
-#elif HAVE_PTH_H
+#elif YAZ_GNU_THREADS
if (control_block.threads)
{
pth_attr_t attr;
pth_attr_set (attr, PTH_ATTR_JOINABLE, FALSE);
pth_attr_set (attr, PTH_ATTR_STACK_SIZE, 32*1024);
pth_attr_set (attr, PTH_ATTR_NAME, "session");
- yaz_log (LOG_LOG, "pth_spawn");
+ yaz_log (LOG_LOG, "pth_spawn begin");
child_thread = pth_spawn (attr, new_session, new_line);
-#if 0
+ yaz_log (LOG_LOG, "pth_spawn finish");
pth_attr_destroy (attr);
-#endif
}
else
new_session(new_line);
-#endif
-
#else
new_session(new_line);
#endif
control_block.dynamic = 0;
break;
case 'T':
-#if _REENTRANT
+#if YAZ_POSIX_THREADS
+ control_block.dynamic = 0;
+ control_block.threads = 1;
+#elif YAZ_GNU_THREADS
control_block.dynamic = 0;
control_block.threads = 1;
#else
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: nmem.c,v $
- * Revision 1.29 2001-10-04 00:37:58 adam
+ * Revision 1.30 2001-10-05 13:55:17 adam
+ * Added defines YAZ_GNU_THREADS, YAZ_POSIX_THREADS in code and yaz-config
+ *
+ * Revision 1.29 2001/10/04 00:37:58 adam
* Fixes for GNU threads (not working yet).
*
* Revision 1.28 2001/10/03 23:55:18 adam
#include <windows.h>
#endif
-#ifdef _REENTRANT
-#if HAVE_PTHREAD_H
+#if YAZ_POSIX_THREADS
#include <pthread.h>
-#elif HAVE_PTH_H
-#include <pth.h>
#endif
+#if YAZ_GNU_THREADS
+#include <pth.h>
#endif
#define NMEM_CHUNK (4*1024)
static CRITICAL_SECTION critical_section;
#define NMEM_ENTER EnterCriticalSection(&critical_section)
#define NMEM_LEAVE LeaveCriticalSection(&critical_section)
-#endif
-
-#ifdef _REENTRANT
-#if HAVE_PTHREAD_H
+struct nmem_mutex {
+ CRITICAL_SECTION m_handle;
+};
+#elif YAZ_POSIX_THREADS
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;
+struct nmem_mutex {
+ pthread_mutex_t m_handle;
+};
+#elif YAZ_GNU_THREADS
+static pth_mutex_t nmem_mutex = PTH_MUTEX_INIT;
#define NMEM_ENTER pth_mutex_acquire(&nmem_mutex, 0, 0)
#define NMEM_LEAVE pth_mutex_release(&nmem_mutex)
-#else
-#error x
-#endif
+struct nmem_mutex {
+ pth_mutex_t m_handle;
+};
#else
#define NMEM_ENTER
#define NMEM_LEAVE
-#endif
-
struct nmem_mutex {
-#ifdef WIN32
- CRITICAL_SECTION m_handle;
-#elif _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
+ int dummy;
};
+#endif
YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p)
{
*p = (NMEM_MUTEX) malloc (sizeof(**p));
#ifdef WIN32
InitializeCriticalSection(&(*p)->m_handle);
-#elif _REENTRANT
+#elif YAZ_POSIX_THREADS
pthread_mutex_init (&(*p)->m_handle, 0);
+#elif YAZ_GNU_THREADS
+ pth_mutex_init (&(*p)->m_handle);
#endif
}
NMEM_LEAVE;
{
#ifdef WIN32
EnterCriticalSection(&p->m_handle);
-#elif _REENTRANT
+#elif YAZ_POSIX_THREADS
pthread_mutex_lock(&p->m_handle);
#endif
}
{
#ifdef WIN32
LeaveCriticalSection(&p->m_handle);
-#elif _REENTRANT
+#elif YAZ_POSIX_THREADS
pthread_mutex_unlock(&p->m_handle);
#endif
}
{
#ifdef WIN32
InitializeCriticalSection(&critical_section);
-#endif
-
-#ifdef _REENTRANT
-#if HAVE_PTH_H
+#elif YAZ_GNU_THREADS
yaz_log (LOG_LOG, "pth_init");
pth_init ();
- pth_mutex_init (&nmem_mutex);
-#endif
#endif
nmem_active_no = 0;
freelist = NULL;
#!/bin/sh
-# $Id: yaz-config.in,v 1.8 2001-09-28 10:42:28 adam Exp $
+# $Id: yaz-config.in,v 1.9 2001-10-05 13:55:17 adam Exp $
yazprefix=@prefix@
yaz_echo_cflags=no
yaz_echo_libs=no
fi
if test "$lib_thread" = "yes"; then
- YAZINC="$YAZINC -D_REENTRANT"
+ YAZINC="$YAZINC @CFLAGSTHREADS@"
fi
if test "$yaz_echo_help" = "yes"; then
-## $Id: Makefile.am,v 1.5 2001-03-21 15:02:39 adam Exp $
+## $Id: Makefile.am,v 1.6 2001-10-05 13:55:17 adam Exp $
bin_PROGRAMS=yaz-ztest
endif
yaz_ztest_LDADD=$(extra) ../lib/libyaz.la $(LIBTHREAD)
-INCLUDES=-I$(top_srcdir)/include
+INCLUDES=-I$(top_srcdir)/include @CFLAGSTHREADS@