From 03d50fbd77481568bb2127d8b92e22d2cdc61ab8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2009 03:05:39 +0200 Subject: sysdeps-unix: if MSG_NOSIGNAL is available don't touch SIGPIPE by default If we can use MSG_NOSIGNAL we don't have to play games with SIGPIPE --- configure.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 9e047eae..88d2164c 100644 --- a/configure.in +++ b/configure.in @@ -769,6 +769,9 @@ AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)]) dnl needed on darwin for NAME_MAX AC_CHECK_HEADERS(sys/syslimits.h) +dnl Make it easy to check if we have MSG_NOSIGNAL without actually having to include sys/socket.h +AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [[ #include ]]) + dnl check for flavours of varargs macros (test from GLib) AC_MSG_CHECKING(for ISO C99 varargs macros in C) AC_TRY_COMPILE([],[ -- cgit From 4c4db7f9da1aa29c264a9f9d7d9fb1d774e28ee1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2009 03:20:27 +0200 Subject: sysdeps-unix: add basic IO primitives for unix fd passing This introduces three new functions: _dbus_read_socket_with_unix_fds _dbus_write_socket_with_unix_fds _dbus_read_socket_with_unix_fds_two These work exactly like their counterpart sans 'with_unix_fds' except that they also send/recieve file descriptors along with the actual payload data. --- configure.in | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 88d2164c..0732adcd 100644 --- a/configure.in +++ b/configure.in @@ -1094,6 +1094,16 @@ else AC_MSG_RESULT(no) fi +# Check for SCM_RIGHTS +AC_MSG_CHECKING([for SCM_RIGHTS]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +static int x = SCM_RIGHTS; +]], [[]])], +[ AC_MSG_RESULT([supported]) + AC_DEFINE([HAVE_UNIX_FD_PASSING], [1], [Supports sending UNIX file descriptors]) ], +[ AC_MSG_RESULT([not supported]) ]) #### Set up final flags DBUS_CLIENT_CFLAGS= -- cgit From 18b08180aa5a4417fa1d6d268a1aad894e8a4549 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2009 04:43:31 +0200 Subject: build-system: define _GNU_SOURCE centrally Instead of having everyone define _GNU_SOURCE and similar macros seperately, simply do so centrally by using AC_USE_SYSTEM_EXTENSIONS --- configure.in | 1 + 1 file changed, 1 insertion(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 0732adcd..62312eb0 100644 --- a/configure.in +++ b/configure.in @@ -57,6 +57,7 @@ AC_SUBST(DBUS_VERSION) AC_PROG_CC AM_PROG_CC_C_O AC_PROG_CXX +AC_USE_SYSTEM_EXTENSIONS AC_ISC_POSIX AC_HEADER_STDC AC_C_INLINE -- cgit From 3c319c71938ab06cf6f1750750927ffb5c200de4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2009 04:45:46 +0200 Subject: cloexec: make use of pipe2(O_CLOEXEC) when available This should fix another CLOEXEC race. --- configure.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 62312eb0..7e0c7d5a 100644 --- a/configure.in +++ b/configure.in @@ -816,6 +816,8 @@ fi AC_CHECK_FUNCS(getpeerucred getpeereid) +AC_CHECK_FUNCS(pipe2) + #### Abstract sockets if test x$enable_abstract_sockets = xauto; then -- cgit From 89318bbeb4076d8d9de9831d69621fc1411760d3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 May 2009 03:41:50 +0200 Subject: cloexec: set all sockets that are created with SOCK_CLOEXEC Since all socket users enable FD_CLOEXEC anyway we can just do that in _dbus_open_socket() and be done with it for all cases. By side effect this allows us to use SOCK_CLOEXEC and hence close the CLOEXEC race. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 7e0c7d5a..b087b003 100644 --- a/configure.in +++ b/configure.in @@ -816,7 +816,7 @@ fi AC_CHECK_FUNCS(getpeerucred getpeereid) -AC_CHECK_FUNCS(pipe2) +AC_CHECK_FUNCS(pipe2 accept4) #### Abstract sockets -- cgit From 9293e823767daee79386cc797510808f4eed01a3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 May 2009 22:30:14 +0200 Subject: atomic: implement atomic operations based on gcc's __sync extension Newer gccs and intel ccs support a __sync extension for making use of atomic operations. This patch replaces the handcrafted x86 atomic operation support with usage of __sync. __sync is supported by more processors and by more compilers than the old assembler code. Also, this extension has been available on gcc for quite a while now for x86, so replacing the old assembler code should only be a loss when very old compiilers are used. --- configure.in | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index b087b003..c2c6a8c9 100644 --- a/configure.in +++ b/configure.in @@ -590,41 +590,23 @@ if test "x$dbus_cv_va_val_copy" = "xno"; then 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; __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) -- cgit From ec901d786f6de6e6f870279e2d955f491619c559 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 May 2009 22:34:43 +0200 Subject: byteswap: make use of glibc specific bytswap primitives glibc knows three bswap_{16|32|64}() calls that internally make use of a gcc extension to implement faster byteswapping. We should make use of it if we can. --- configure.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index c2c6a8c9..036679ce 100644 --- a/configure.in +++ b/configure.in @@ -679,6 +679,8 @@ AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)]) AC_CHECK_HEADERS(errno.h) +AC_CHECK_HEADERS(byteswap.h) + AC_CHECK_HEADERS(unistd.h) # checking for a posix version of getpwnam_r -- cgit From 9f06daccce3f4e75cfac7c97bfb1743affb55cb2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2009 15:17:25 +0200 Subject: Fix detection of the GCC __sync intrinsics. We have to use the return value, otherwise GCC optimises the code by using instructions that don't return anything. That won't match what we actually use in dbus-sysdeps-unix.c --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 036679ce..2a0e64e2 100644 --- a/configure.in +++ b/configure.in @@ -595,7 +595,7 @@ fi 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; __sync_sub_and_fetch(&a, 4);]]), + 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]) ]) -- cgit