[PATCH] fix building with newer libaio

Mike Frysinger vapier at gentoo.org
Sat Apr 19 20:28:08 UTC 2008


Newer versions of libaio changed struct members.  This adds a configure
check to see what members are available, and allow the user to control
whether to even build against libaio.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 configure.ac |   20 ++++++++++++++++++++
 desc.c       |    8 ++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index bb2b354..554b8b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,6 +170,26 @@ AC_CHECK_MEMBERS([struct stat.st_blksize,
 		  struct stat.st_rdev])
 AC_STAT64
 
+AC_ARG_ENABLE(libaio,
+	AC_HELP_STRING([--enable-libaio],[enable support for libaio @<:@default=auto@:>@]),
+	[enable_libaio=$enableval],
+	[enable_libaio=auto]
+)
+if test "x$enable_libaio" != "xno" ; then
+	AC_CHECK_HEADER([libaio.h],[have_libaio=yes],[have_libaio=no])
+	if test "x$enable_libaio$have_libaio" = "xyesno" ; then
+		AC_MSG_ERROR(Could not detect libaio.h)
+	elif test "x$have_libaio" = "xyes" ; then
+		AC_DEFINE(HAVE_LIBAIO_H, 1, [System has libaio.h])
+		AC_CHECK_MEMBERS([
+			struct iocb.data,
+			struct iocb.aio_data,
+			struct iocb.key,
+			struct iocb.aio_key],
+		[], [], [#include <libaio.h>])
+	fi
+fi
+
 AC_TYPE_SIGNAL
 AC_TYPE_UID_T
 AC_TYPE_MODE_T
diff --git a/desc.c b/desc.c
index b1b11db..4badaa7 100644
--- a/desc.c
+++ b/desc.c
@@ -765,7 +765,11 @@ struct tcb *tcp;
 					continue;
 				}
 				tprintf("{%p, %u, %hu, %hu, %d}",
+#ifdef HAVE_STRUCT_IOCB_AIO_DATA
+					iocb.aio_data, iocb.aio_data,
+#else
 					iocb.data, iocb.key,
+#endif
 					iocb.aio_lio_opcode,
 					iocb.aio_reqprio, iocb.aio_fildes);
 			}
@@ -791,7 +795,11 @@ struct tcb *tcp;
 #ifdef HAVE_LIBAIO_H
 		if (umove(tcp, tcp->u_arg[1], &iocb) == 0) {
 			tprintf("{%p, %u, %hu, %hu, %d}, ",
+#ifdef HAVE_STRUCT_IOCB_AIO_DATA
+				iocb.aio_data, iocb.aio_data,
+#else
 				iocb.data, iocb.key,
+#endif
 				iocb.aio_lio_opcode,
 				iocb.aio_reqprio, iocb.aio_fildes);
 		} else
-- 
1.5.5





More information about the Strace-devel mailing list