Deal with missing lseek64(2) sys call

On OSX, off_t is 64 bits, so can use lseek(2) instead
This commit is contained in:
Andrew Bettison 2014-02-17 14:33:32 +10:30
parent a77b0702b1
commit c4944e4334
2 changed files with 23 additions and 1 deletions

View File

@ -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 \

15
os.h
View File

@ -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);