From c4944e433419f330f2d6897daaae34a3c4d82b7c Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Mon, 17 Feb 2014 14:33:32 +1030 Subject: [PATCH] Deal with missing lseek64(2) sys call On OSX, off_t is 64 bits, so can use lseek(2) instead --- configure.in | 9 ++++++++- os.h | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index b045e58e..5623368d 100644 --- a/configure.in +++ b/configure.in @@ -69,7 +69,14 @@ AC_CHECK_LIB(c,srandomdev) dnl Solaris hides nanosleep here AC_CHECK_LIB(rt,nanosleep) -AC_CHECK_FUNCS([getpeereid bcopy bzero bcmp]) +AC_CHECK_FUNCS([getpeereid bcopy bzero bcmp lseek64]) +AC_CHECK_TYPES([off64_t], [have_off64_t=1], [have_off64_t=0]) +AC_CHECK_SIZEOF([off_t]) + +dnl There must be a 64-bit seek(2) system call of some kind +AS_IF([test \( "x$have_lseek64_t" = "xno" -a "x$ac_cv_sizeof_off_t" != x8 ], [ + AC_MSG_ERROR([Missing lseek64(2) system call]) +]) AC_CHECK_HEADERS( stdio.h \ diff --git a/os.h b/os.h index f69c04af..b8bbf26c 100644 --- a/os.h +++ b/os.h @@ -85,6 +85,21 @@ __SERVAL_DNA__OS_INLINE int bcmp(const void *s1, const void *s2, size_t n) { } #endif +/* If there is no lseek64(2) system call but off_t is 64 bits, then we can use + * lseek(2) instead. + */ +#ifndef HAVE_LSEEK64 +# if SIZEOF_OFF_T != 8 +# error "lseek64(2) system call is not available and `sizeof(off_t) is not 8" +# endif +# ifndef HAVE_OFF64_T +typedef off64_t off_t +__SERVAL_DNA__OS_INLINE off64_t lseek64(int fd, off64_t offset, int whence) { + return lseek(fd, offset, whence); +} +# endif +#endif + /* The "e" variants log the error before returning -1. */ int mkdirs(const char *path, mode_t mode);