$NetBSD: patch-ab,v 1.12 2008/06/19 01:56:44 bjs Exp $ --- dbus/dbus-sysdeps-unix.c.orig 2008-04-04 11:24:08.000000000 -0400 +++ dbus/dbus-sysdeps-unix.c @@ -35,6 +35,9 @@ #include "dbus-list.h" #include "dbus-credentials.h" +#ifdef HAVE_NETBSD_ATOMIC_OPS +#include +#endif #include #include #include @@ -786,7 +789,9 @@ _dbus_connect_tcp_socket (const char fprintf(stderr, "Family %s\n", family ? family : "none"); hints.ai_protocol = IPPROTO_TCP; hints.ai_socktype = SOCK_STREAM; +#ifdef AI_ADDRCONFIG hints.ai_flags = AI_ADDRCONFIG; +#endif if ((res = getaddrinfo(host, port, &hints, &ai)) != 0) { @@ -889,7 +894,11 @@ _dbus_listen_tcp_socket (const char hints.ai_protocol = IPPROTO_TCP; hints.ai_socktype = SOCK_STREAM; +#ifdef AI_ADDRCONFIG hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; +#else + hints.ai_flags = AI_PASSIVE; +#endif redo_lookup_with_port: if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai) @@ -1753,7 +1762,26 @@ _dbus_parse_uid (const DBusString * return TRUE; } +#ifdef HAVE_NETBSD_ATOMIC_OPS +dbus_int32_t +_dbus_atomic_inc (DBusAtomic *atomic) +{ + register dbus_int32_t old = atomic->value; + + atomic_inc_uint((unsigned *)&atomic->value); + return old; +} +dbus_int32_t +_dbus_atomic_dec (DBusAtomic *atomic) +{ + register dbus_int32_t old = atomic->value; + + atomic_dec_uint((unsigned *)&atomic->value); + return old; +} +_DBUS_DEFINE_GLOBAL_LOCK (atomic); +#else _DBUS_DEFINE_GLOBAL_LOCK (atomic); #if DBUS_USE_ATOMIC_INT_486_COND @@ -1818,6 +1846,7 @@ _dbus_atomic_dec (DBusAtomic *atomic) return res; #endif } +#endif /* HAVE_NETBSD_ATOMIC_OPS */ #ifdef DBUS_BUILD_TESTS /** Gets our GID @@ -2711,8 +2740,18 @@ int _dbus_printf_string_upper_bound (const char *format, va_list args) { +#if defined(__hpux) || defined(__sgi) +/* this code from libnbcompat's vsnprintf */ + static FILE *devnull = 0; + if (!devnull) { + devnull = fopen("/dev/null", "w"); + if (!devnull) return -1; + } + return vfprintf(devnull, format, args); +#else char c; return vsnprintf (&c, 1, format, args); +#endif } /**