From 80d9efbd29b89571bb0defbdf2b68d85b9c7315e Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 16 Jul 2008 23:17:12 +0000 Subject: [PATCH] * Support fsetpos64 on Linux. --- configure.ac | 16 ++++++++++++++++ src/lib-stream.c | 5 ++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a5793a4..31c2447 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,22 @@ AC_MSG_RESULT($ac_v_fp_cnt/$ac_v_fp_ptr) AC_DEFINE_UNQUOTED(FILE_CNT, $ac_v_fp_cnt, [Define to the FILE::cnt member name]) AC_DEFINE_UNQUOTED(FILE_PTR, $ac_v_fp_ptr, [Define to the FILE::ptr member name]) +dnl On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object. +AC_MSG_CHECKING(how to access fpos64_t x) +ac_v_fpos64_t="unknown" +AC_TRY_COMPILE( + [#define _LARGEFILE64_SOURCE + #include ], + [fpos64_t x; long long int y = x.__pos;], + [ac_v_fpos64_t="(x).__pos"]) +AC_TRY_COMPILE( + [#define _LARGEFILE64_SOURCE + #include ], + [fpos64_t x; long long int y = (long long int)x;], + [ac_v_fpos64_t="(x)"]) +AC_MSG_RESULT($ac_v_fpos64_t) +AC_DEFINE_UNQUOTED(FPOS_CAST(x), $ac_v_fpos64_t, [Define to a macro for accessing an fpos64_t variable]) + AC_MSG_CHECKING(for pragma INIT/FINI) AC_TRY_COMPILE([], [#pragma INIT "my_init" diff --git a/src/lib-stream.c b/src/lib-stream.c index 4c29700..eb46f1b 100644 --- a/src/lib-stream.c +++ b/src/lib-stream.c @@ -307,9 +307,8 @@ int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence) ret = ORIG(fn)(stream, pos); \ _zz_unlock(fd); \ debug("%s([%i], %lli) = %i", __func__, \ - fd, (long long int)*pos, ret); \ - /* On HP-UX at least, fpos64_t == int64_t */ \ - _zz_setpos(fd, (int64_t)*pos); \ + fd, (long long int)FPOS_CAST(*pos), ret); \ + _zz_setpos(fd, (int64_t)FPOS_CAST(*pos)); \ } \ while(0)