summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Harris <git@peter.is-a-geek.org>2012-08-12 13:28:36 -0400
committerPeter Harris <pharris@opentext.com>2012-08-15 18:24:13 -0400
commitc22b5b2ae67b77f58821d4fe2fdf24f0825d2401 (patch)
tree60966a6856487978d4b7431765eb2817c8d47e14
parent5f8f2ba1c4f9ac74c8f301dcca8566e296e37995 (diff)
Allow xcb_send_request with >UIO_MAXIOV iovecsHEADmaster
This allows an application to do a scatter/gather operation on a large image buffer to avoid the extra memcpy. MacOSX 10.6 mentions UIO_MAXIOV in the man page for writev, but does not define it in any system header. Use autoconf to test for MAX_IOV from <limits.h> in that case. Signed-off-by: Peter Harris <pharris@opentext.com>
-rw-r--r--configure.ac7
-rw-r--r--src/xcb_conn.c7
2 files changed, 13 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index e94e32c..4e9eab2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,6 +110,13 @@ dnl check for support for Solaris Trusted Extensions
AC_CHECK_HEADERS([tsol/label.h])
AC_CHECK_FUNCS([is_system_labeled])
+dnl check for UIO_MAXIOV, or at least IOV_MAX
+AC_CHECK_DECL([UIO_MAXIOV], [],
+ [AC_CHECK_DECL([IOV_MAX], [AC_DEFINE([UIO_MAXIOV], [IOV_MAX])],
+ [AC_DEFINE([UIO_MAXIOV], [16], [Define if not provided by <sys/uio.h>])],
+ [[#include <limits.h>]])],
+ [[#include <sys/uio.h>]])
+
xcbincludedir='${includedir}/xcb'
AC_SUBST(xcbincludedir)
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 725502a..9abd640 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
+#include <limits.h>
#include "xcb.h"
#include "xcbint.h"
@@ -204,7 +205,11 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
i++;
}
#else
- n = writev(c->fd, *vector, *count);
+ n = *count;
+ if (n > UIO_MAXIOV)
+ n = UIO_MAXIOV;
+
+ n = writev(c->fd, *vector, n);
if(n < 0 && errno == EAGAIN)
return 1;
#endif /* _WIN32 */