}
#endif
{
- ev_off_t start_pos = lseek(fd, 0, SEEK_CUR), pos;
ev_off_t read_so_far = 0;
+ ev_ssize_t n = 0;
char *mem;
+#ifndef EVENT__HAVE_PREAD
+ ev_off_t start_pos = lseek(fd, 0, SEEK_CUR);
+ ev_off_t pos;
int e;
- ev_ssize_t n = 0;
+#endif /* no pread() */
if (!(mem = mm_malloc(length)))
goto err;
+#ifdef EVENT__HAVE_PREAD
+ while (read_so_far < length) {
+ n = pread(fd, mem + read_so_far, length - read_so_far,
+ offset + read_so_far);
+ if (n <= 0)
+ break;
+ read_so_far += n;
+ }
+ if (n < 0 || (n == 0 && length > read_so_far)) {
+ mm_free(mem);
+ goto err;
+ }
+#else /* fallback to seek() and read() */
if (start_pos < 0) {
mm_free(mem);
goto err;
mm_free(mem);
goto err;
}
+#endif /* pread */
seg->contents = mem;
}
AC_C_INLINE
dnl Checks for library functions.
-AC_CHECK_FUNCS([accept4 arc4random arc4random_buf arc4random_addrandom eventfd epoll_create1 epoll_pwait2 fcntl getegid geteuid getifaddrs gettimeofday issetugid mach_absolute_time mmap nanosleep pipe pipe2 putenv sendfile setenv setrlimit sigaction signal strsignal strlcpy strsep strtok_r strtoll sysctl timerfd_create umask unsetenv usleep getrandom mmap64])
+AC_CHECK_FUNCS([accept4 arc4random arc4random_buf arc4random_addrandom eventfd epoll_create1 epoll_pwait2 fcntl getegid geteuid getifaddrs gettimeofday issetugid mach_absolute_time mmap nanosleep pipe pipe2 pread putenv sendfile setenv setrlimit sigaction signal strsignal strlcpy strsep strtok_r strtoll sysctl timerfd_create umask unsetenv usleep getrandom mmap64])
AS_IF([test "$bwin32" = "true"],
AC_CHECK_FUNCS(_gmtime64_s, , [AC_CHECK_FUNCS(_gmtime64)])