configure.ac: Make pthreads library check work on HP-UX.

On HP-UX, libpthread uses mangled symbol names like on Tru64, but
what's worse, the HP-UX C library provides stub versions of almost
all libpthread functions that return errors instead of doing what
they are supposed to -- and there's no way to detect this at compile
time.

However, there are a number of symbols in libpthread that the C
library doesn't define stubs for, and so we can run AC_SEARCH_LIBS
for one of those functions in libpthread, and if that returns
success, force libpthread to be linked in.  pthread_trace_notify_np
is one such symbol, and we will arbitrarily pick it for this purpose.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
configure.ac: Define _XOPEN_SOURCE to 500 on HP-UX.

On HP-UX, we need -D_XOPEN_SOURCE=500 so that Berkeley socket API
functions use 'socklen_t's for sockaddr struct lengths instead of
ints.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
configure.ac: Detect __sync_lock_test_and_set().

If pthreads spinlocks aren't available, we use hand-coded spinlocks
based on __sync_lock_test_and_set(), but not all platforms have that
latter function available (HP-UX without a sufficiently new version
of gcc is one such platform).  On such platforms, we'll have to stub
out our spinlocks entirely -- this isn't generally safe, but there's
nothing better we can do in that case (apart from refusing to build
at all).

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
configure.ac: Add checks for CLOCK_{MONOTONIC,REALTIME}.

On HP-UX, CLOCK_{MONOTONIC,REALTIME} are enum values, and not
defines, so we can't check for them using #ifdef, like we were doing
in iv_timer.  Detect these constants at configure time, and define
appropriate HAVE_* symbols in config.h for iv_timer to use.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_getaddrinfo: Don't assume existence of struct sockaddr_in6 on HP-UX.

On HP-UX, we need to define _XOPEN_SOURCE to 500 to make the
Berkeley socket API use socklen_t instead of int for sockaddr struct
lengths, but a side effect of this is that netinet/in6.h stops defining
struct sockaddr_in6.  There's not much we can do about that, though, so
just concede defeat and stop referencing struct sockaddr_in6 on HP-UX.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Include arpa/inet.h in sources that use hton[sl]().

As this is necessary on HP-UX when _XOPEN_SOURCE is defined to 500.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
lib/test/server: Don't open too many sockets on HP-UX.

As the default resource limits are set rather low.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
lib/test/timer_rat: Don't register too many timers on HP-UX.

As the default value causes the assembler/linker to run out of memory.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_thread: Print pthread_create() return code in case of failure.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
iv_wait: Avoid using PTHREAD_MUTEX_INITIALIZER.

As it is broken on HP-UX.  Initialize the global mutex from
iv_wait's module constructor function instead.

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