it.
Rather than failing at runtime, it is better to fail at compile or
link time.
svn:r1363
AC_DEFINE(HAVE_PTHREADS, 1,
[Define if we have pthreads on this system])
have_pthreads=yes])
-AM_CONDITIONAL(PTHREADS, [test "$have_pthreads" != "no"])
+AM_CONDITIONAL(PTHREADS, [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"])
# check if we should compile locking into the library
if test x$enable_thread_support = xno; then
}
#endif
+#ifndef _EVENT_DISABLE_THREAD_SUPPORT
/* support for threading */
void (*_evthread_locking_fn)(int mode, void *lock) = NULL;
unsigned long (*_evthread_id_fn)(void) = NULL;
void
evthread_set_locking_callback(void (*locking_fn)(int mode, void *lock))
{
-#ifdef _EVENT_DISABLE_THREAD_SUPPORT
- event_errx(1, "%s: not compiled with thread support", __func__);
-#else
_evthread_locking_fn = locking_fn;
-#endif
}
+#endif
#if defined(_EVENT_HAVE_EVENTFD) && defined(_EVENT_HAVE_SYS_EVENTFD_H)
static void
#endif
}
+#ifndef _EVENT_DISABLE_THREAD_SUPPORT
void
evthread_set_id_callback(unsigned long (*id_fn)(void))
{
-#ifdef _EVENT_DISABLE_THREAD_SUPPORT
- event_errx(1, "%s: not compiled with thread support", __func__);
-#else
_evthread_id_fn = id_fn;
-#endif
}
+#endif
int
evthread_make_base_notifiable(struct event_base *base)
return event_add(&base->th_notify, NULL);
}
+#ifndef _EVENT_DISABLE_THREAD_SUPPORT
void
evthread_set_lock_create_callbacks(void *(*alloc_fn)(void),
void (*free_fn)(void *))
{
-#ifdef _EVENT_DISABLE_THREAD_SUPPORT
- event_errx(1, "%s: not compiled with thread support", __func__);
-#else
_evthread_lock_alloc_fn = alloc_fn;
_evthread_lock_free_fn = free_fn;
-#endif
}
+#endif
void
event_base_dump_events(struct event_base *base, FILE *output)
#define EVTHREAD_WRITE 0x04
#define EVTHREAD_READ 0x08
+#ifndef _EVENT_DISABLE_THREAD_SUPPORT
+
/**
Sets the functions Libevent should use for allocating and freeing
locks. This needs to be called in addition to
void evthread_set_id_callback(
unsigned long (*id_fn)(void));
-/** Make sure it's safe to tell an event base to wake up from another thread.
-
- @return 0 on success, -1 on failure.
- */
-int evthread_make_base_notifiable(struct event_base *base);
-
-#ifdef WIN32
+#if defined(WIN32) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)
/** Sets up Libevent for use with Windows builtin locking and thread ID
functions. Unavailable if Libevent is not built for Windows.
#define EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 1
#endif
-#ifdef _EVENT_HAVE_PTHREADS
+#if defined(_EVENT_HAVE_PTHREADS)
/** Sets up Libevent for use with Pthreads locking and thread ID functions.
Unavailable if Libevent is not build for use with pthreads. Requires
libraries to link against Libevent_pthreads as well as Libevent.
#define EVTHREAD_USE_PTHREADS_IMPLEMENTED 1
#endif
+#endif /* _EVENT_DISABLE_THREAD_SUPPORT */
+
+/** Make sure it's safe to tell an event base to wake up from another thread.
+ or a signal handler.
+
+ @return 0 on success, -1 on failure.
+ */
+int evthread_make_base_notifiable(struct event_base *base);
+
#ifdef __cplusplus
}
#endif