copy_types.c match_glob.c poll.c daemon.c \
iconv_encode_marc8.c iconv_encode_iso_8859_1.c iconv_encode_wchar.c \
iconv_decode_marc8.c iconv_decode_iso5426.c iconv_decode_danmarc.c sc.c \
- json.c xml_include.c file_glob.c dirent.c mutex.c thread_id.c gettimeofday.c
+ json.c xml_include.c file_glob.c dirent.c mutex-p.h mutex.c condvar.c \
+ thread_id.c gettimeofday.c
libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO)
--- /dev/null
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
+ * See the file LICENSE for details.
+ */
+
+/**
+ * \file condvar.c
+ * \brief Wraps condition variables
+ *
+ */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stddef.h>
+#include <yaz/xmalloc.h>
+#include <yaz/nmem.h>
+#include <yaz/log.h>
+#include <yaz/mutex.h>
+#include <yaz/gettimeofday.h>
+#ifdef WIN32
+#include <windows.h>
+#include <sys/timeb.h>
+#endif
+#include <time.h>
+
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#if YAZ_POSIX_THREADS
+#include <pthread.h>
+#endif
+
+#include "mutex-p.h"
+
+struct yaz_cond {
+#ifdef WIN32
+ CONDITION_VARIABLE cond;
+#elif YAZ_POSIX_THREADS
+ pthread_cond_t cond;
+#endif
+};
+
+void yaz_cond_create(YAZ_COND *p)
+{
+ *p = (YAZ_COND) malloc(sizeof(**p));
+#ifdef WIN32
+ InitializeConditionVariable(&(*p)->cond);
+#elif YAZ_POSIX_THREADS
+ pthread_cond_init(&(*p)->cond, 0);
+#endif
+}
+
+void yaz_cond_destroy(YAZ_COND *p)
+{
+ if (*p)
+ {
+#ifdef WIN32
+#elif YAZ_POSIX_THREADS
+ pthread_cond_destroy(&(*p)->cond);
+#endif
+ free(*p);
+ *p = 0;
+ }
+}
+
+int yaz_cond_wait(YAZ_COND p, YAZ_MUTEX m, const struct timeval *abstime)
+{
+#ifdef WIN32
+ if (abstime)
+ {
+ struct timeval tval_now;
+ int sec, msec;
+
+ yaz_gettimeofday(&tval_now);
+
+ sec = abstime->tv_sec - tval_now.tv_sec;
+ msec = (abstime->tv_usec - tval_now.tv_usec) / 1000;
+ return SleepConditionVariableCS(&p->cond, &m->handle, sec*1000 + msec);
+ }
+ else
+ return SleepConditionVariableCS(&p->cond, &m->handle, INFINITE);
+#elif YAZ_POSIX_THREADS
+ if (abstime)
+ {
+ struct timespec s;
+ s.tv_sec = abstime->tv_sec;
+ s.tv_nsec = abstime->tv_usec * 1000;
+ return pthread_cond_timedwait(&p->cond, &m->handle, &s);
+ }
+ else
+ return pthread_cond_wait(&p->cond, &m->handle);
+#else
+ return -1;
+#endif
+}
+
+int yaz_cond_signal(YAZ_COND p)
+{
+#ifdef WIN32
+ WakeConditionVariable(&p->cond);
+ return 0;
+#elif YAZ_POSIX_THREADS
+ return pthread_cond_signal(&p->cond);
+#else
+ return -1;
+#endif
+}
+
+int yaz_cond_broadcast(YAZ_COND p)
+{
+#ifdef WIN32
+ WakeAllConditionVariable(&p->cond);
+ return 0;
+#elif YAZ_POSIX_THREADS
+ return pthread_cond_broadcast(&p->cond);
+#else
+ return -1;
+#endif
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
+ * See the file LICENSE for details.
+ */
+
+struct yaz_mutex {
+#ifdef WIN32
+ CRITICAL_SECTION handle;
+#elif YAZ_POSIX_THREADS
+ pthread_mutex_t handle;
+#endif
+ char *name;
+ int log_level;
+};
+
#include <pthread.h>
#endif
-struct yaz_mutex {
-#ifdef WIN32
- CRITICAL_SECTION handle;
-#elif YAZ_POSIX_THREADS
- pthread_mutex_t handle;
-#endif
- char *name;
- int log_level;
-};
-
-struct yaz_cond {
-#ifdef WIN32
- CONDITION_VARIABLE cond;
-#elif YAZ_POSIX_THREADS
- pthread_cond_t cond;
-#endif
-};
+#include "mutex-p.h"
void yaz_mutex_create(YAZ_MUTEX *p)
{
}
}
-
-void yaz_cond_create(YAZ_COND *p)
-{
- *p = (YAZ_COND) malloc(sizeof(**p));
-#ifdef WIN32
- InitializeConditionVariable(&(*p)->cond);
-#elif YAZ_POSIX_THREADS
- pthread_cond_init(&(*p)->cond, 0);
-#endif
-}
-
-void yaz_cond_destroy(YAZ_COND *p)
-{
- if (*p)
- {
-#ifdef WIN32
-#elif YAZ_POSIX_THREADS
- pthread_cond_destroy(&(*p)->cond);
-#endif
- free(*p);
- *p = 0;
- }
-}
-
-int yaz_cond_wait(YAZ_COND p, YAZ_MUTEX m, const struct timeval *abstime)
-{
-#ifdef WIN32
- if (abstime)
- {
- struct timeval tval_now;
- int sec, msec;
-
- yaz_gettimeofday(&tval_now);
-
- sec = abstime->tv_sec - tval_now.tv_sec;
- msec = (abstime->tv_usec - tval_now.tv_usec) / 1000;
- return SleepConditionVariableCS(&p->cond, &m->handle, sec*1000 + msec);
- }
- else
- return SleepConditionVariableCS(&p->cond, &m->handle, INFINITE);
-#elif YAZ_POSIX_THREADS
- if (abstime)
- {
- struct timespec s;
- s.tv_sec = abstime->tv_sec;
- s.tv_nsec = abstime->tv_usec * 1000;
- return pthread_cond_timedwait(&p->cond, &m->handle, &s);
- }
- else
- return pthread_cond_wait(&p->cond, &m->handle);
-#else
- return -1;
-#endif
-}
-
-int yaz_cond_signal(YAZ_COND p)
-{
-#ifdef WIN32
- WakeConditionVariable(&p->cond);
- return 0;
-#elif YAZ_POSIX_THREADS
- return pthread_cond_signal(&p->cond);
-#else
- return -1;
-#endif
-}
-
-int yaz_cond_broadcast(YAZ_COND p)
-{
-#ifdef WIN32
- WakeAllConditionVariable(&p->cond);
- return 0;
-#elif YAZ_POSIX_THREADS
- return pthread_cond_broadcast(&p->cond);
-#else
- return -1;
-#endif
-}
-
/*
* Local variables:
* c-basic-offset: 4
YAZ_IMPLIB=$(LIBDIR)\yaz4d.lib
YAZ_ICU_DLL=$(BINDIR)\yaz_icu4d.dll
YAZ_ICU_IMPLIB=$(LIBDIR)\yaz_icu4d.lib
+YAZ_COND_DLL=$(BINDIR)\yaz_cond4d.dll
+YAZ_COND_IMPLIB=$(LIBDIR)\yaz_cond4d.lib
!else
YAZ_DLL=$(BINDIR)\yaz4.dll
YAZ_IMPLIB=$(LIBDIR)\yaz4.lib
YAZ_ICU_DLL=$(BINDIR)\yaz_icu4.dll
YAZ_ICU_IMPLIB=$(LIBDIR)\yaz_icu4.lib
+YAZ_COND_DLL=$(BINDIR)\yaz_cond4.dll
+YAZ_COND_IMPLIB=$(LIBDIR)\yaz_cond4.lib
!endif
CLIENT=$(BINDIR)\yaz-client.exe
TEST_MUTEX=$(BINDIR)\test_mutex.exe
# shortcut names defined here
-dll: dirs generate $(YAZ_DLL)
+dll: dirs generate $(YAZ_DLL) $(YAZ_COND_DLL)
client: dirs generate $(CLIENT)
ztest: dirs generate $(ZTEST)
$(OBJDIR)\fhistory.obj
YAZ_ICU_OBJS= $(OBJDIR)\yaz-icu.obj
+COND_DLL_OBJS= $(OBJDIR)\condvar.obj
ZTEST_OBJS= \
$(OBJDIR)\dummy-opac.obj \
/implib:"$(YAZ_ICU_IMPLIB)"
$(MT) -manifest $@.manifest -outputresource:$@;2
+$(YAZ_COND_DLL) $(YAZ_COND_IMPLIB): "$(BINDIR)" $(COND_DLL_OBJS) $(YAZ_COND_RES)
+ $(LINK_DLL) $(COND_LIB) $(YAZ_IMPLIB)\
+ $(COND_DLL_OBJS) \
+ $(YAZ_COND_RES) \
+ /out:$@ \
+ /implib:"$(YAZ_COND_IMPLIB)"
+ $(MT) -manifest $@.manifest -outputresource:$@;2
+
$(CLIENT) : "$(BINDIR)" $(YAZ_CLIENT_OBJS) $(YAZ_DLL)
$(LINK_PROGRAM) $(YAZ_CLIENT_OBJS) /out:$@
$(MT) -manifest $@.manifest -outputresource:$@;1
$(LINK_PROGRAM) $(TST_TIMING_OBJS) /out:$@
$(MT) -manifest $@.manifest -outputresource:$@;1
-$(TEST_MUTEX) : "$(BINDIR)" $(TEST_MUTEX_OBJS) $(YAZ_DLL)
- $(LINK_PROGRAM) $(TEST_MUTEX_OBJS) /out:$@
+$(TEST_MUTEX) : "$(BINDIR)" $(TEST_MUTEX_OBJS) $(YAZ_COND_DLL)
+ $(LINK_PROGRAM) $(YAZ_COND_IMPLIB) $(TEST_MUTEX_OBJS) /out:$@
$(MT) -manifest $@.manifest -outputresource:$@;1
# Other rules