iv_handle: Add missing iv_handle_registered().

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_signal: Don't call sigaction() with SA_RESTART on QNX.

QNX does define a value for SA_RESTART, but any attempts to register
a signal handler with SA_RESTART set result in -ENOTSUP.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Fix iv_wait on QNX 6.5.0.

By not using wait4(2), which doesn't return events for some reason
(and since there are no man pages on the QNX machine I have access
to, I can't figure out why).

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_inited: Don't call pthread_getspecific() on an uninitialized key.

If __thread isn't available, and iv_init() has not been called yet
in this process, we will not have allocated a thread local storage
key yet, and calls to iv_get_state() will call pthread_getspecific()
on an uninitialized key.

This is not a problem for most users of iv_get_state(), except for
iv_inited(), since it is allowed to call iv_inited() without having
initialized ivykis in this process or thread.  Therefore, add a
check to iv_inited() to catch this case, and return 0 as expected.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Refrain from using __thread on win32 platforms.

At least under wine 1.5.8 as shipped with Fedora 17, accesses from
DllMain() during process/thread detach to __thread variables return
garbage, which would prevent us from calling __iv_deinit() on behalf
of threads that failed to do so before exiting from DllMain().

Work around this by switching from keeping the pointer to our struct
iv_state in a __thread variable to a thread local storage location
allocated by TlsAlloc().

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_main: Split into POSIX and win32 versions.

As the ifdef spaghetti in iv_main.c was getting out of hand, split
it up into separate iv_main_posix.c and iv_main_win32.c modules.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
configure.ac: Include sys/ucontext.h in the test for sys/thr.h.

On older FreeBSD versions, at least on 6.1, sys/thr.h can't be
compiled by itself, as it uses definitions from sys/ucontext.h
without including sys/ucontext.h.  This makes the autoconf test
for sys/thr.h fail with:

| checking sys/thr.h usability... no
| checking sys/thr.h presence... yes
| configure: WARNING: sys/thr.h: present but cannot be compiled
| configure: WARNING: sys/thr.h:     check for missing prerequisite headers?
| configure: WARNING: sys/thr.h: see the Autoconf documentation
| configure: WARNING: sys/thr.h:     section "Present But Cannot Be Compiled"
| configure: WARNING: sys/thr.h: proceeding with the compiler's result

We don't use sys/ucontext.h for anything else, so just delete the test
for it, and make [#include <sys/ucontext.h>] the fourth argument of
the AC_CHECK_HEADERS() statement checking for sys/thr.h, so that
sys/ucontext.h will be included in the test program for sys/thr.h (as
recommended by the autoconf documentation).

Caught by the BalaBit autobuilder.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_tls: Switch thread state block offsets from off_t to int.

So that we don't have to bother trying to find out which header
file defines off_t.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
test/avl: Turn into a pass/fail test, and run at make check time.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_event_raw_test: Turn into a pass/fail test, and run at make check time.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_signal_test: Turn into a pass/fail test, and run at make check time.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
test/struct_sizes: Turn into a pass/fail test, and run at make check time.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
test/timer: Turn into a pass/fail test, and run at make check time.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
test/timer_rat: Turn into a pass/fail test, and run at make check time.

And rename it to timer_order in the process.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>