Skip to content

Commit

Permalink
Fix configure and build errors on OS X Yosemite: Substitute preadv an…
Browse files Browse the repository at this point in the history
…d pwritev with lseek+readv/writev if not available. Redundant check for clock_gettime removed, which was already checked in the platform case statement and failed on darwin systems.

Signed-off-by: Clemens Gruber <clemensgru@gmail.com>
  • Loading branch information
clemensg committed Oct 26, 2014
1 parent 5be06de commit 06dae2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 0 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,6 @@ AC_DEFINE_UNQUOTED([DBUS_CLIENT_GROUP], ["${DBUS_CLIENT_GROUP}"], [DBus client g
AC_MSG_RESULT(${DBUS_CLIENT_GROUP})
AC_SUBST([DBUS_CLIENT_GROUP])

dnl Check for clock_gettime. Some systems put it into -lc, while
dnl others use -lrt. Try the first and fallback to the latter.
RT_LIB=
AC_CHECK_FUNC([clock_gettime], [:],
[AC_CHECK_LIB([rt], [clock_gettime], [RT_LIB="-lrt"],
[AC_MSG_ERROR([Your system lacks clock_gettime])])])
AC_SUBST(RT_LIB)

PKG_CHECK_MODULES([LIBEVENT], [libevent >= 2.0])

have_dbus=false
Expand Down
10 changes: 10 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ int file_write(int fd, void *buf, size_t sz)
ssize_t ret;
iov[0].iov_base = buf;
iov[0].iov_len = sz;
#ifdef HAVE_PWRITEV
ret = IGNORE_EINTR (pwritev (fd, iov, 1, 0));
#else
lseek (fd, 0, SEEK_SET);
ret = IGNORE_EINTR (writev (fd, iov, 1));
#endif
if (ret != sz)
{
return -1;
Expand Down Expand Up @@ -332,7 +337,12 @@ int file_read(int fd, void *buf, size_t sz)
struct iovec iov[1];
iov[0].iov_base = buf;
iov[0].iov_len = sz;
#ifdef HAVE_PREADV
if (preadv (fd, iov, 1, 0) != sz)
#else
lseek (fd, 0, SEEK_SET);
if (readv (fd, iov, 1) != sz)
#endif
{
/* Returns -1 on read failure */
return -1;
Expand Down

0 comments on commit 06dae2c

Please sign in to comment.