fi
- #### Atomic integers (checks by Sebastian Wilhelmi for GLib)
- AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers])
- have_atomic_inc_cond=0
- if test x"$GCC" = xyes; then
- if test "x$enable_ansi" = "xyes"; then
- AC_MSG_RESULT([no])
- else
- case $host_cpu in
- i386)
- AC_MSG_RESULT([no])
- ;;
- i?86)
- case $host_os in
- darwin*)
- AC_MSG_RESULT([darwin])
- # check at compile-time, so that it is possible to build universal
- # (with multiple architectures at once on the compile line)
- have_atomic_inc_cond="(defined(__i386__) || defined(__x86_64__))"
- ;;
- *)
- AC_MSG_RESULT([i486])
- have_atomic_inc_cond=1
- ;;
- esac
- ;;
- *)
- AC_MSG_RESULT([no])
- ;;
- esac
- fi
+ #### Atomic integers
+
+ AC_CACHE_CHECK([whether $CC knows __sync_sub_and_fetch()],
+ dbus_cv_sync_sub_and_fetch,
+ [AC_LINK_IFELSE(
+ AC_LANG_PROGRAM([], [[int a = 4; int b = __sync_sub_and_fetch(&a, 4);]]),
+ [dbus_cv_sync_sub_and_fetch=yes],
+ [dbus_cv_sync_sub_and_fetch=no])
+ ])
+
+ if test "x$dbus_cv_sync_sub_and_fetch" = "xyes" ; then
+ have_sync=1
+ else
+ have_sync=0
fi
- AC_DEFINE_UNQUOTED([DBUS_USE_ATOMIC_INT_486_COND], [$have_atomic_inc_cond],
- [Always defined; expands to 1 if we should use atomic integer implementation for 486, else 0])
- AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT_COND, [$have_atomic_inc_cond],
- [Always defined; expands to 1 if we have an atomic integer implementation, else 0])
+
+ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension])
#### Various functions
-AC_CHECK_LIB(socket,socket)
+AC_SEARCH_LIBS(socket,[socket network])
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll)
AC_CHECK_HEADERS(errno.h)
+ AC_CHECK_HEADERS(byteswap.h)
+
AC_CHECK_HEADERS(unistd.h)
+# Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris
+#
+case $host_os in
+ solaris*)
+ CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;;
+esac
+
# checking for a posix version of getpwnam_r
# if we are cross compiling and can not run the test
# assume getpwnam_r is the posix version
*
* If -1 is passed for the timeout, a sane default timeout is used. -1
* is typically the best value for the timeout for this reason, unless
- * you want a very short or very long timeout. There is no way to
- * avoid a timeout entirely, other than passing INT_MAX for the
- * timeout to mean "very long timeout." libdbus clamps an INT_MAX
- * timeout down to a few hours timeout though.
+ * you want a very short or very long timeout. If INT_MAX is passed for
+ * the timeout, no timeout will be set and the call will block forever.
*
- * @warning if the connection is disconnected, the #DBusPendingCall
- * will be set to #NULL, so be careful with this.
- *
+ * @warning if the connection is disconnected or you try to send Unix
+ * file descriptors on a connection that does not support them, the
+ * #DBusPendingCall will be set to #NULL, so be careful with this.
+ *
* @param connection the connection
* @param message the message to send
- * @param pending_return return location for a #DBusPendingCall object, or #NULL if connection is disconnected
+ * @param pending_return return location for a #DBusPendingCall
+ * object, or #NULL if connection is disconnected or when you try to
+ * send Unix file descriptors on a connection that does not support
+ * them.
- * @param timeout_milliseconds timeout in milliseconds or -1 for default
+ * @param timeout_milliseconds timeout in milliseconds, -1 for default or INT_MAX for no timeout
* @returns #FALSE if no memory, #TRUE otherwise.
*
*/
unsigned char v_BYTE;
unsigned char v2_BYTE;
dbus_bool_t v_BOOLEAN;
+ DBusMessageIter iter, array_iter, struct_iter;
+ #ifdef HAVE_UNIX_FD_PASSING
+ int v_UNIX_FD;
+ #endif
message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
"/org/freedesktop/TestPath",
_dbus_message_loader_unref (loader);
check_memleaks ();
+ _dbus_check_fdleaks();
+ /* Check that we can abandon a container */
+ message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
+ "/org/freedesktop/TestPath",
+ "Foo.TestInterface",
+ "Method");
+
+ dbus_message_iter_init_append (message, &iter);
+
+ _dbus_assert (dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
+ (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &array_iter));
+ _dbus_assert (dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT,
+ NULL, &struct_iter));
+
+ s = "peaches";
+ _dbus_assert (dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING,
+ &s));
+
+ /* uh-oh, error, try and unwind */
+
+ dbus_message_iter_abandon_container (&array_iter, &struct_iter);
+ dbus_message_iter_abandon_container (&array_iter, &iter);
+
+ dbus_message_unref (message);
+
/* Load all the sample messages from the message factory */
{
DBusMessageDataIter diter;
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+
+ #include <config.h>
+
#include "dbus-spawn.h"
#include "dbus-sysdeps-unix.h"
#include "dbus-internals.h"
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = &cmsg;
- msg.msg_controllen = sizeof (cmsg);
+ msg.msg_control = (caddr_t) &cmsg;
+ msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
- memset (&cmsg, 0, sizeof (cmsg));
+ _DBUS_ZERO(cmsg);
- cmsg.hdr.cmsg_len = sizeof (cmsg);
+ cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred));
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_CREDS;
#endif
msg.msg_iovlen = 1;
#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS)
- memset (&cmsg, 0, sizeof (cmsg));
+ _DBUS_ZERO(cmsg);
- msg.msg_control = &cmsg;
- msg.msg_controllen = sizeof (cmsg);
+ msg.msg_control = (caddr_t) &cmsg;
+ msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
#endif
again: