Changeset 4041 for zzuf


Ignore:
Timestamp:
Nov 26, 2009, 2:13:58 AM (10 years ago)
Author:
Sam Hocevar
Message:

Use fseeko64() everywhere when possible, instead of potential 32-bit versions.

Location:
zzuf/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r4029 r4041  
    4949
    5050AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
    51 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)
     51AC_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)
    5252
    5353AC_CHECK_TYPES(sighandler_t, [], [],
  • zzuf/trunk/msvc/config.h

    r4031 r4041  
    4343#define HAVE_FSEEKO64 1
    4444/* #undef HAVE_FSETPOS64 */
     45/* #undef HAVE_FTELLO */
     46#define HAVE_FTELLO64 1
    4547/* #undef HAVE_GETCHAR_UNLOCKED */
    4648/* #undef HAVE_GETC_UNLOCKED */
     
    107109/* #undef HAVE___FSEEKO64 */
    108110/* #undef HAVE___FSETPOS64 */
     111/* #undef HAVE___FTELLO64 */
    109112/* #undef HAVE___GETDELIM */
    110113/* #undef HAVE___LSEEK64 */
  • zzuf/trunk/src/lib-stream.c

    r4032 r4041  
    2929#elif defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
    3030#   define HAVE_BSD_STDIO
     31#endif
     32
     33/* Define the best ftell() clone */
     34#if defined HAVE_FTELLO64
     35#   define MYFTELL ftello64
     36#elif defined HAVE___FTELLO64
     37#   define MYFTELL __ftello64
     38#elif defined HAVE_FTELLO
     39#   define MYFTELL ftello
     40#else
     41#   define MYFTELL ftell
    3142#endif
    3243
     
    296307
    297308#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    298 #   define FSEEK_FUZZ(myftell)
    299 #else
    300 #   define FSEEK_FUZZ(myftell) \
     309#   define FSEEK_FUZZ()
     310#else
     311#   define FSEEK_FUZZ() \
    301312        if(ret == 0) \
    302313        { \
     
    305316            { \
    306317                case SEEK_END: \
    307                     offset = myftell(stream); \
     318                    offset = MYFTELL(stream); \
    308319                    /* fall through */ \
    309320                case SEEK_SET: \
     
    317328#endif
    318329
    319 #define FSEEK(myfseek, myftell) \
     330#define FSEEK(myfseek) \
    320331    do \
    321332    { \
     
    331342        debug("%s([%i], %lli, %i) = %i", __func__, \
    332343              fd, (long long int)offset, whence, ret); \
    333         FSEEK_FUZZ(myftell) \
     344        FSEEK_FUZZ() \
    334345        DEBUG_STREAM("new", stream); \
    335346    } while(0)
     
    337348int NEW(fseek)(FILE *stream, long offset, int whence)
    338349{
    339     int ret; FSEEK(fseek, ftell); return ret;
     350    int ret; FSEEK(fseek); return ret;
    340351}
    341352
     
    343354int NEW(fseeko)(FILE *stream, off_t offset, int whence)
    344355{
    345     int ret; FSEEK(fseeko, ftello); return ret;
     356    int ret; FSEEK(fseeko); return ret;
    346357}
    347358#endif
     
    350361int NEW(fseeko64)(FILE *stream, off64_t offset, int whence)
    351362{
    352     int ret; FSEEK(fseeko64, ftello64); return ret;
     363    int ret; FSEEK(fseeko64); return ret;
    353364}
    354365#endif
     
    357368int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence)
    358369{
    359     int ret; FSEEK(__fseeko64, ftello); return ret;
     370    int ret; FSEEK(__fseeko64); return ret;
    360371}
    361372#endif
     
    462473    do \
    463474    { \
    464         int64_t newpos = ftell(stream); \
     475        int64_t newpos = MYFTELL(stream); \
    465476        /* XXX: the number of bytes read is not ret * size, because \
    466477         * a partial read may have advanced the stream pointer. However, \
     
    515526            return ORIG(myfread)(ptr, size, nmemb, stream); \
    516527        DEBUG_STREAM("old", stream); \
    517         oldpos = ftell(stream); \
     528        oldpos = MYFTELL(stream); \
    518529        _zz_lock(fd); \
    519530        ret = ORIG(myfread)(ptr, size, nmemb, stream); \
Note: See TracChangeset for help on using the changeset viewer.