Attached is a patchlet that makes libeio fall back to futimesat() if
the platform doesn't support futimes(), like e.g. SunOS.
From df0ea8653f3b5a62ab8f465d0f1f9ef55f74718f Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <[email protected]>
Date: Wed, 12 Oct 2011 21:57:24 +0200
Subject: [PATCH] Use futimesat() if futimes() is not available.
---
eio.c | 11 +++++++----
libeio.m4 | 15 +++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/eio.c b/eio.c
index ec7ac54..13afa68 100644
--- a/eio.c
+++ b/eio.c
@@ -1008,9 +1008,11 @@ eio__utimes (const char *filename, const struct timeval times[2])
#endif
#ifndef HAVE_FUTIMES
-
-# undef futimes
-# define futimes(fd,times) eio__futimes (fd, times)
+# if HAVE_FUTIMESAT
+# define futimes(fd,times) futimesat (fd, 0, times)
+# else /* !HAVE_FUTIMESAT */
+# undef futimes
+# define futimes(fd,times) eio__futimes (fd, times)
static int
eio__futimes (int fd, const struct timeval tv[2])
@@ -1019,7 +1021,8 @@ eio__futimes (int fd, const struct timeval tv[2])
return -1;
}
-#endif
+# endif /* HAVE_FUTIMESAT */
+#endif /* HAVE_FUTIMES */
#if !HAVE_FDATASYNC
# undef fdatasync
diff --git a/libeio.m4 b/libeio.m4
index 59151f5..2abe298 100644
--- a/libeio.m4
+++ b/libeio.m4
@@ -38,6 +38,21 @@ int main (void)
]],ac_cv_futimes=yes,ac_cv_futimes=no)])
test $ac_cv_futimes = yes && AC_DEFINE(HAVE_FUTIMES, 1, futimes(2) is available)
+AC_CACHE_CHECK(for futimesat, ac_cv_futimesat, [AC_LINK_IFELSE([[
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/time.h>
+struct timeval tv[2];
+int res;
+int fd;
+int main (void)
+{
+ res = futimesat (fd, 0, tv);
+ return 0;
+}
+]],ac_cv_futimesat=yes,ac_cv_futimesat=no)])
+test $ac_cv_futimesat = yes && AC_DEFINE(HAVE_FUTIMESAT, 1, futimesat(2) is available)
+
AC_CACHE_CHECK(for readahead, ac_cv_readahead, [AC_LINK_IFELSE([
#include <fcntl.h>
int main (void)
--
1.7.3.4
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev