Commit 72f56af8 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Symbian: work-around the absence of pread/pwrite

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent d273f722
...@@ -547,7 +547,7 @@ dnl Check for system libs needed ...@@ -547,7 +547,7 @@ dnl Check for system libs needed
need_libc=false need_libc=false
dnl Check for usual libc functions dnl Check for usual libc functions
AC_CHECK_FUNCS([daemon fcntl fdopendir fstatvfs fork getenv getpwuid_r gettimeofday isatty lstat memalign mmap openat posix_fadvise posix_madvise posix_memalign setenv setlocale stricmp strnicmp uselocale]) AC_CHECK_FUNCS([daemon fcntl fdopendir fstatvfs fork getenv getpwuid_r gettimeofday isatty lstat memalign mmap openat pread posix_fadvise posix_madvise posix_memalign setenv setlocale stricmp strnicmp uselocale])
AC_REPLACE_FUNCS([asprintf atof atoll getcwd getdelim getpid gmtime_r lldiv localtime_r nrand48 rewind strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy vasprintf]) AC_REPLACE_FUNCS([asprintf atof atoll getcwd getdelim getpid gmtime_r lldiv localtime_r nrand48 rewind strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy vasprintf])
AC_CHECK_FUNCS(fdatasync,, AC_CHECK_FUNCS(fdatasync,,
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.]) [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
......
...@@ -385,6 +385,30 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset) ...@@ -385,6 +385,30 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset)
} }
#endif #endif
#ifndef HAVE_PREAD
static
ssize_t pread(int fd, const void * buf, size_t size, off_t offset) {
off_t offs0;
ssize_t rd;
if ((offs0 = lseek(fd, 0, SEEK_CUR)) == (off_t)-1) return -1;
if (lseek(fd, offset, SEEK_SET) == (off_t)-1) return -1;
rd = read(fd, (void *)buf, size);
if (lseek(fd, offs0, SEEK_SET) == (off_t)-1) return -1;
return rd;
}
static
ssize_t pwrite(int fd, const void * buf, size_t size, off_t offset) {
off_t offs0;
ssize_t wr;
if ((offs0 = lseek(fd, 0, SEEK_CUR)) == (off_t)-1) return -1;
if (lseek(fd, offset, SEEK_SET) == (off_t)-1) return -1;
wr = write(fd, (void *)buf, size);
if (lseek(fd, offs0, SEEK_SET) == (off_t)-1) return -1;
return wr;
}
#endif
/** /**
* Loads a file into a block of memory. If possible a private file mapping is * Loads a file into a block of memory. If possible a private file mapping is
* created. Otherwise, the file is read normally. On 32-bits platforms, this * created. Otherwise, the file is read normally. On 32-bits platforms, this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment