Use fseeko64() everywhere when possible, instead of potential 32-bit versions.
This commit is contained in:
parent
7026052971
commit
c9150f4458
@ -48,7 +48,7 @@ AC_SUBST(DLL_LDFLAGS)
|
||||
AC_CHECK_HEADERS(windows.h winsock2.h io.h process.h unistd.h inttypes.h stdint.h getopt.h libc.h malloc.h dlfcn.h regex.h sys/cdefs.h sys/socket.h netinet/in.h arpa/inet.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h sys/time.h endian.h)
|
||||
|
||||
AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
|
||||
AC_CHECK_FUNCS(open64 __open64 lseek64 __lseek64 mmap64 fopen64 __fopen64 freopen64 __freopen64 dup dup2 fseeko fseeko64 __fseeko64 fsetpos64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf __srget __uflow map_fd memalign posix_memalign aio_read accept bind connect socket readv pread recv recvfrom recvmsg mmap valloc sigaction getpagesize getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked)
|
||||
AC_CHECK_FUNCS(open64 __open64 lseek64 __lseek64 mmap64 fopen64 __fopen64 freopen64 __freopen64 dup dup2 ftello ftello64 __ftello64 fseeko fseeko64 __fseeko64 fsetpos64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf __srget __uflow map_fd memalign posix_memalign aio_read accept bind connect socket readv pread recv recvfrom recvmsg mmap valloc sigaction getpagesize getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked)
|
||||
|
||||
AC_CHECK_TYPES(sighandler_t, [], [],
|
||||
[#define _GNU_SOURCE
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
/* #undef HAVE_FSEEKO */
|
||||
#define HAVE_FSEEKO64 1
|
||||
/* #undef HAVE_FSETPOS64 */
|
||||
/* #undef HAVE_FTELLO */
|
||||
#define HAVE_FTELLO64 1
|
||||
/* #undef HAVE_GETCHAR_UNLOCKED */
|
||||
/* #undef HAVE_GETC_UNLOCKED */
|
||||
/* #undef HAVE_GETDELIM */
|
||||
@ -106,6 +108,7 @@
|
||||
/* #undef HAVE___FREOPEN64 */
|
||||
/* #undef HAVE___FSEEKO64 */
|
||||
/* #undef HAVE___FSETPOS64 */
|
||||
/* #undef HAVE___FTELLO64 */
|
||||
/* #undef HAVE___GETDELIM */
|
||||
/* #undef HAVE___LSEEK64 */
|
||||
/* #undef HAVE___OPEN64 */
|
||||
|
||||
@ -30,6 +30,17 @@
|
||||
# define HAVE_BSD_STDIO
|
||||
#endif
|
||||
|
||||
/* Define the best ftell() clone */
|
||||
#if defined HAVE_FTELLO64
|
||||
# define MYFTELL ftello64
|
||||
#elif defined HAVE___FTELLO64
|
||||
# define MYFTELL __ftello64
|
||||
#elif defined HAVE_FTELLO
|
||||
# define MYFTELL ftello
|
||||
#else
|
||||
# define MYFTELL ftell
|
||||
#endif
|
||||
|
||||
#if defined HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#elif defined HAVE_INTTYPES_H
|
||||
@ -295,16 +306,16 @@ FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream)
|
||||
*/
|
||||
|
||||
#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
|
||||
# define FSEEK_FUZZ(myftell)
|
||||
# define FSEEK_FUZZ()
|
||||
#else
|
||||
# define FSEEK_FUZZ(myftell) \
|
||||
# define FSEEK_FUZZ() \
|
||||
if(ret == 0) \
|
||||
{ \
|
||||
/* FIXME: check what happens when fseek()ing a pipe */ \
|
||||
switch(whence) \
|
||||
{ \
|
||||
case SEEK_END: \
|
||||
offset = myftell(stream); \
|
||||
offset = MYFTELL(stream); \
|
||||
/* fall through */ \
|
||||
case SEEK_SET: \
|
||||
_zz_setpos(fd, offset); \
|
||||
@ -316,7 +327,7 @@ FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FSEEK(myfseek, myftell) \
|
||||
#define FSEEK(myfseek) \
|
||||
do \
|
||||
{ \
|
||||
int fd; \
|
||||
@ -330,33 +341,33 @@ FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream)
|
||||
_zz_unlock(fd); \
|
||||
debug("%s([%i], %lli, %i) = %i", __func__, \
|
||||
fd, (long long int)offset, whence, ret); \
|
||||
FSEEK_FUZZ(myftell) \
|
||||
FSEEK_FUZZ() \
|
||||
DEBUG_STREAM("new", stream); \
|
||||
} while(0)
|
||||
|
||||
int NEW(fseek)(FILE *stream, long offset, int whence)
|
||||
{
|
||||
int ret; FSEEK(fseek, ftell); return ret;
|
||||
int ret; FSEEK(fseek); return ret;
|
||||
}
|
||||
|
||||
#if defined HAVE_FSEEKO
|
||||
int NEW(fseeko)(FILE *stream, off_t offset, int whence)
|
||||
{
|
||||
int ret; FSEEK(fseeko, ftello); return ret;
|
||||
int ret; FSEEK(fseeko); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE_FSEEKO64
|
||||
int NEW(fseeko64)(FILE *stream, off64_t offset, int whence)
|
||||
{
|
||||
int ret; FSEEK(fseeko64, ftello64); return ret;
|
||||
int ret; FSEEK(fseeko64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___FSEEKO64
|
||||
int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence)
|
||||
{
|
||||
int ret; FSEEK(__fseeko64, ftello); return ret;
|
||||
int ret; FSEEK(__fseeko64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -461,7 +472,7 @@ void NEW(rewind)(FILE *stream)
|
||||
# define FREAD_FUZZ(fd, oldpos) \
|
||||
do \
|
||||
{ \
|
||||
int64_t newpos = ftell(stream); \
|
||||
int64_t newpos = MYFTELL(stream); \
|
||||
/* XXX: the number of bytes read is not ret * size, because \
|
||||
* a partial read may have advanced the stream pointer. However, \
|
||||
* when reading from a pipe ftell() will return 0, and ret * size \
|
||||
@ -514,7 +525,7 @@ void NEW(rewind)(FILE *stream)
|
||||
if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \
|
||||
return ORIG(myfread)(ptr, size, nmemb, stream); \
|
||||
DEBUG_STREAM("old", stream); \
|
||||
oldpos = ftell(stream); \
|
||||
oldpos = MYFTELL(stream); \
|
||||
_zz_lock(fd); \
|
||||
ret = ORIG(myfread)(ptr, size, nmemb, stream); \
|
||||
_zz_unlock(fd); \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user