[Xcb-commit] libxcb: Branch 'xcb-1.9' - 4 commits - configure.ac src
Alan Coopersmith
alanc at kemper.freedesktop.org
Fri Nov 8 05:43:04 CET 2013
configure.ac | 54 +++++++++++++++++++++++++++++++++++++++++++++---------
src/xcb_conn.c | 15 ++++++++++-----
src/xcb_in.c | 24 +++++++++---------------
src/xcbint.h | 5 -----
4 files changed, 64 insertions(+), 34 deletions(-)
New commits:
commit 7dae7ba3f97c29ae55c72f02eccc59fd77390677
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date: Thu Nov 7 20:27:32 2013 -0800
libxcb 1.9.3
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
diff --git a/configure.ac b/configure.ac
index 406aca2..94da4f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
# Initialize Autoconf
AC_PREREQ(2.57)
AC_INIT([libxcb],
- 1.9.2,
+ 1.9.3,
[xcb at lists.freedesktop.org])
AC_CONFIG_SRCDIR([xcb.pc.in])
commit 33d2404d0b84ee30a51d7a9bdcc748cc82dea884
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date: Thu Nov 7 20:23:27 2013 -0800
Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
Required to expose the structure members in Solaris headers, since it
was an XPG4/UNIX95 addition to the Solaris ABI.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
(cherry picked from commit e8663a935890ff366f49e356211049dfd0d9756a)
diff --git a/configure.ac b/configure.ac
index a3468e1..406aca2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,40 @@ xauto)
;;
esac
+# XPG4v2/UNIX95 added msg_control - check to see if we need to define
+# _XOPEN_SOURCE to get it (such as on Solaris)
+AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
+ [
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+ ])
+# First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
+if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
+ unset ac_cv_member_struct_msghdr_msg_control
+ AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
+ AC_CHECK_MEMBER([struct msghdr.msg_control],
+ [AC_DEFINE([_XOPEN_SOURCE], [600],
+ [Defined if needed to expose struct msghdr.msg_control])
+ ], [], [
+#define _XOPEN_SOURCE 600
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+ ])
+fi
+# If that didn't work, fall back to XPG5/UNIX98 with C89
+if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
+ unset ac_cv_member_struct_msghdr_msg_control
+ AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
+ AC_CHECK_MEMBER([struct msghdr.msg_control],
+ [AC_DEFINE([_XOPEN_SOURCE], [500],
+ [Defined if needed to expose struct msghdr.msg_control])
+ ], [sendfds="no"], [
+#define _XOPEN_SOURCE 500
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+ ])
+fi
+
case x$sendfds in
xyes)
AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg])
commit a2322e3cdccab552e143c33c75369216edfcb418
Author: Keith Packard <keithp at keithp.com>
Date: Thu Nov 7 17:36:01 2013 -0800
Add configure option to enable or disable fd passing with sendmsg
--disable-sendfds or --enable-sendfds
By default, configure auto-detects based on whether your system
supports sendmsg at all.
Signed-off-by: Keith Packard <keithp at keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
(cherry picked from commit af8067cbf48561f1e2d43e153292e68e0376a8f9)
diff --git a/configure.ac b/configure.ac
index 09bb496..a3468e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,14 +82,16 @@ AC_HEADER_STDC
AC_SEARCH_LIBS(getaddrinfo, socket)
AC_SEARCH_LIBS(connect, socket)
-have_sendmsg="no"
-case $host_os in
-linux*)
- AC_SEARCH_LIBS(sendmsg, socket, [have_sendmsg="yes"], [have_sendmsg="no"])
- ;;
+AC_ARG_ENABLE(sendfds, AS_HELP_STRING([--disable-sendfds], [Support FD passing (default: auto)]),
+ [sendfds=$enableval], [sendfds=auto])
+
+case x$sendfds in
+xauto)
+ AC_SEARCH_LIBS(sendmsg, socket, [sendfds="yes"], [sendfds="no"])
+ ;;
esac
-case x$have_sendmsg in
+case x$sendfds in
xyes)
AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg])
;;
@@ -192,7 +194,7 @@ XCB_EXTENSION(Composite, "yes")
XCB_EXTENSION(Damage, "yes")
XCB_EXTENSION(DPMS, "yes")
XCB_EXTENSION(DRI2, "yes")
-XCB_EXTENSION(DRI3, "$have_sendmsg")
+XCB_EXTENSION(DRI3, "$sendfds")
XCB_EXTENSION(GLX, "yes")
XCB_EXTENSION(Present, "yes")
XCB_EXTENSION(RandR, "yes")
@@ -275,7 +277,7 @@ echo " Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
echo ""
echo " Configuration"
echo " XDM support.........: ${have_xdmcp}"
-echo " sendmsg fd passing..: ${have_sendmsg}"
+echo " sendmsg fd passing..: ${sendfds}"
echo " Build unit tests....: ${HAVE_CHECK}"
echo " XCB buffer size.....: ${xcb_queue_buffer_size}"
echo ""
commit e7aa524bcb5ffe1e09051afd324941b8980ba77b
Author: Keith Packard <keithp at keithp.com>
Date: Thu Nov 7 17:28:45 2013 -0800
Switch to using the CMSG_* macros for FD passing
Use these instead of computing the values directly so that it might
work on BSD or other non-Linux systems
Signed-off-by: Keith Packard <keithp at keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
(cherry picked from commit 83f28ef8655acff746eab64eabe2e31f8cf0c892)
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index d5d3c46..85f5b94 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -216,18 +216,23 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
#if HAVE_SENDMSG
if (c->out.out_fd.nfd) {
+ char cmsgbuf[CMSG_SPACE(sizeof(int) * XCB_MAX_PASS_FD)];
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_iov = *vector,
.msg_iovlen = n,
- .msg_control = &c->out.out_fd,
- .msg_controllen = sizeof (struct cmsghdr) + c->out.out_fd.nfd * sizeof (int),
+ .msg_control = cmsgbuf,
+ .msg_controllen = CMSG_LEN(c->out.out_fd.nfd * sizeof (int)),
};
int i;
- c->out.out_fd.cmsghdr.cmsg_len = msg.msg_controllen;
- c->out.out_fd.cmsghdr.cmsg_level = SOL_SOCKET;
- c->out.out_fd.cmsghdr.cmsg_type = SCM_RIGHTS;
+ struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
+
+ hdr->cmsg_len = msg.msg_controllen;
+ hdr->cmsg_level = SOL_SOCKET;
+ hdr->cmsg_type = SCM_RIGHTS;
+ memcpy(CMSG_DATA(hdr), c->out.out_fd.fd, c->out.out_fd.nfd * sizeof (int));
+
n = sendmsg(c->fd, &msg, 0);
if(n < 0 && errno == EAGAIN)
return 1;
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 839f615..8c3a58c 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -888,17 +888,14 @@ int _xcb_in_read(xcb_connection_t *c)
.iov_base = c->in.queue + c->in.queue_len,
.iov_len = sizeof(c->in.queue) - c->in.queue_len,
};
- struct {
- struct cmsghdr cmsghdr;
- int fd[XCB_MAX_PASS_FD];
- } fds;
+ char cmsgbuf[CMSG_SPACE(sizeof(int) * XCB_MAX_PASS_FD)];
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_iov = &iov,
.msg_iovlen = 1,
- .msg_control = &fds,
- .msg_controllen = sizeof (struct cmsghdr) + sizeof(int) * (XCB_MAX_PASS_FD - c->in.in_fd.nfd),
+ .msg_control = cmsgbuf,
+ .msg_controllen = CMSG_SPACE(sizeof(int) * (XCB_MAX_PASS_FD - c->in.in_fd.nfd)),
};
n = recvmsg(c->fd, &msg, 0);
@@ -916,15 +913,12 @@ int _xcb_in_read(xcb_connection_t *c)
#endif
if(n > 0) {
#if HAVE_SENDMSG
- if (msg.msg_controllen > sizeof (struct cmsghdr))
- {
- if (fds.cmsghdr.cmsg_level == SOL_SOCKET &&
- fds.cmsghdr.cmsg_type == SCM_RIGHTS)
- {
- int nfd = (msg.msg_controllen - sizeof (struct cmsghdr)) / sizeof (int);
- memmove(&c->in.in_fd.fd[c->in.in_fd.nfd],
- fds.fd,
- nfd);
+ struct cmsghdr *hdr;
+
+ for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) {
+ if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) {
+ int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int);
+ memcpy(&c->in.in_fd.fd[c->in.in_fd.nfd], CMSG_DATA(hdr), nfd * sizeof (int));
c->in.in_fd.nfd += nfd;
}
}
diff --git a/src/xcbint.h b/src/xcbint.h
index 45dc044..ff97f5d 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -34,10 +34,6 @@
#include "config.h"
#endif
-#if HAVE_SENDMSG
-#include <sys/socket.h>
-#endif
-
#ifdef GCC_HAS_VISIBILITY
#pragma GCC visibility push(hidden)
#endif
@@ -89,7 +85,6 @@ typedef void (*xcb_return_socket_func_t)(void *closure);
#define XCB_MAX_PASS_FD 16
typedef struct _xcb_fd {
- struct cmsghdr cmsghdr;
int fd[XCB_MAX_PASS_FD];
int nfd;
int ifd;
More information about the xcb-commit
mailing list