Skip to content

Commit

Permalink
configure: Use AC_SYS_LARGEFILE
Browse files Browse the repository at this point in the history
With musl-1.2.4 LFS support is being disabled and will later be entirely
removed where it is expected to use off_t and lseek rather than off64_t
and lseek64.

With glibc these types are also obsolete where it is expected to use the
_FILE_OFFSET_BITS define where off_t and lseek will become 64-bit
compatible versions when needed. This is set by AC_SYS_LARGEFILE.
  • Loading branch information
orbea authored and Oleksiy-Yakovenko committed Jul 30, 2023
1 parent de440a8 commit 8fa263e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AC_PROG_CXX
AC_PROG_OBJC
AC_STDC_HEADERS
AC_PROG_INSTALL
AC_SYS_LARGEFILE
dnl AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
AC_C_BIGENDIAN
Expand Down
8 changes: 3 additions & 5 deletions src/vfs_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include <unistd.h>

#ifndef __linux__
#define off64_t off_t
#define lseek64 lseek
#define O_LARGEFILE 0
#endif

Expand Down Expand Up @@ -169,7 +167,7 @@ stdio_seek (DB_FILE *stream, int64_t offset, int whence) {
whence = SEEK_SET;
offset = ((STDIO_FILE*)stream)->offs + offset;
}
off64_t res = lseek64 (((STDIO_FILE *)stream)->stream, offset, whence);
off_t res = lseek (((STDIO_FILE *)stream)->stream, offset, whence);
if (res == -1) {
return -1;
}
Expand Down Expand Up @@ -214,8 +212,8 @@ stdio_getlength (DB_FILE *stream) {
return l;
#else
if (!f->have_size) {
int64_t size = lseek64 (f->stream, 0, SEEK_END);
lseek64 (f->stream, f->offs, SEEK_SET);
int64_t size = lseek (f->stream, 0, SEEK_END);
lseek (f->stream, f->offs, SEEK_SET);
#ifdef USE_BUFFERING
f->bufremaining = 0;
#endif
Expand Down

0 comments on commit 8fa263e

Please sign in to comment.