Changeset 2528 for zzuf/trunk


Ignore:
Timestamp:
Jul 15, 2008, 10:16:11 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Implement additional functions required on HP-UX: fopen64, fseeko64, freopen64, open64, lseek64.
Location:
zzuf/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r2527 r2528  
    3939
    4040AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
    41 AC_CHECK_FUNCS(open64 lseek64 mmap64 fopen64 dup dup2 fseeko _IO_getc getline getdelim __getdelim fgetln __srefill 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)
     41AC_CHECK_FUNCS(open64 __open64 lseek64 mmap64 fopen64 __fopen64 __freopen64 dup dup2 fseeko __fseeko64 _IO_getc getline getdelim __getdelim fgetln __srefill 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)
    4242
    4343AC_CHECK_TYPES(sighandler_t, [], [],
  • zzuf/trunk/doc/libzzuf.3

    r2365 r2528  
    9494\fBfree\fR(), \fBmemalign\fR(), \fBposix_memalign\fR()
    9595.TP
    96 Linux-specific:
     96Required on Linux:
    9797\fBopen64\fR(), \fBlseek64\fR(), \fBmmap64\fR(), \fB_IO_getc\fR(),
    9898\fBgetline\fR(), \fBgetdelim\fR(), \fB__getdelim\fR(), \fBgetc_unlocked\fR(),
     
    100100\fBfread_unlocked\fR()
    101101.TP
    102 BSD-specific:
     102Required on BSD systems:
    103103\fBfgetln\fR(), \fB__srefill\fR()
    104104.TP
    105 Mac OS X-specific:
     105Required on Mac OS X:
    106106\fBmap_fd\fR()
     107.TP
     108Required on HP-UX:
     109\fB__fopen64\fR(), \fB__fseeko64\fR(), \fB__freopen64\fR(), \fB__open64\fR(),
     110\fB__lseek64\fR()
    107111.TP
    108112Signal handling:
  • zzuf/trunk/src/lib-fd.c

    r2527 r2528  
    8484static int     (*ORIG(open64))  (const char *file, int oflag, ...);
    8585#endif
     86#if defined HAVE___OPEN64
     87static int     (*ORIG(__open64))(const char *file, int oflag, ...);
     88#endif
    8689#if defined HAVE_DUP
    8790static int     (*ORIG(dup))     (int oldfd);
     
    133136#if defined HAVE_LSEEK64
    134137static off64_t (*ORIG(lseek64)) (int fd, off64_t offset, int whence);
     138#endif
     139#if defined HAVE___LSEEK64
     140static off64_t (*ORIG(__lseek64)) (int fd, off64_t offset, int whence);
    135141#endif
    136142static int     (*ORIG(close))   (int fd);
     
    177183{
    178184    int ret; OPEN(open64); return ret;
     185}
     186#endif
     187
     188#if defined HAVE___OPEN64
     189int NEW(__open64)(const char *file, int oflag, ...)
     190{
     191    int ret; OPEN(__open64); return ret;
    179192}
    180193#endif
     
    523536off64_t NEW(lseek64)(int fd, off64_t offset, int whence)
    524537{
    525     off64_t ret;
    526     LSEEK(lseek64, off64_t);
    527     return ret;
     538    off64_t ret; LSEEK(lseek64, off64_t); return ret;
     539}
     540#endif
     541
     542#if defined HAVE___LSEEK64
     543off64_t NEW(__lseek64)(int fd, off64_t offset, int whence)
     544{
     545    off64_t ret; LSEEK(__lseek64, off64_t); return ret;
    528546}
    529547#endif
  • zzuf/trunk/src/lib-stream.c

    r2524 r2528  
    4949static FILE *  (*ORIG(fopen64))  (const char *path, const char *mode);
    5050#endif
     51#if defined HAVE___FOPEN64
     52static FILE *  (*ORIG(__fopen64))(const char *path, const char *mode);
     53#endif
    5154static FILE *  (*ORIG(freopen))  (const char *path, const char *mode,
    5255                                  FILE *stream);
     56#if defined HAVE___FREOPEN64
     57static FILE *  (*ORIG(__freopen64)) (const char *path, const char *mode,
     58                                     FILE *stream);
     59#endif
    5360static int     (*ORIG(fseek))    (FILE *stream, long offset, int whence);
    5461#if defined HAVE_FSEEKO
    5562static int     (*ORIG(fseeko))   (FILE *stream, off_t offset, int whence);
     63#endif
     64#if defined HAVE___FSEEKO64
     65static int     (*ORIG(__fseeko64)) (FILE *stream, off_t offset, int whence);
    5666#endif
    5767static void    (*ORIG(rewind))   (FILE *stream);
     
    135145#endif
    136146
     147#if defined HAVE___FOPEN64
     148FILE *NEW(__fopen64)(const char *path, const char *mode)
     149{
     150    FILE *ret; FOPEN(__fopen64); return ret;
     151}
     152#endif
     153
     154#define FREOPEN(fn) \
     155    do \
     156    { \
     157        int fd0 = -1, fd1 = -1, disp = 0; \
     158        LOADSYM(fn); \
     159        if(_zz_ready && (fd0 = fileno(stream)) >= 0 && _zz_iswatched(fd0)) \
     160        { \
     161            _zz_unregister(fd0); \
     162            disp = 1; \
     163        } \
     164        _zz_lock(-1); \
     165        ret = ORIG(fn)(path, mode, stream); \
     166        _zz_unlock(-1); \
     167        if(ret && _zz_mustwatch(path)) \
     168        { \
     169            fd1 = fileno(ret); \
     170            _zz_register(fd1); \
     171            disp = 1; \
     172        } \
     173        if(disp) \
     174            debug("%s(\"%s\", \"%s\", [%i]) = [%i]", __func__, \
     175                  path, mode, fd0, fd1); \
     176    } while(0)
     177
    137178FILE *NEW(freopen)(const char *path, const char *mode, FILE *stream)
    138179{
    139     FILE *ret;
    140     int fd0 = -1, fd1 = -1, disp = 0;
    141 
    142     LOADSYM(freopen);
    143     if(_zz_ready && (fd0 = fileno(stream)) >= 0 && _zz_iswatched(fd0))
    144     {
    145         _zz_unregister(fd0);
    146         disp = 1;
    147     }
    148 
    149     _zz_lock(-1);
    150     ret = ORIG(freopen)(path, mode, stream);
    151     _zz_unlock(-1);
    152 
    153     if(ret && _zz_mustwatch(path))
    154     {
    155         fd1 = fileno(ret);
    156         _zz_register(fd1);
    157         disp = 1;
    158     }
    159 
    160     if(disp)
    161         debug("%s(\"%s\", \"%s\", [%i]) = [%i]", __func__,
    162               path, mode, fd0, fd1);
    163 
    164     return ret;
    165 }
     180    FILE *ret; FREOPEN(freopen); return ret;
     181}
     182
     183#if defined HAVE___FREOPEN64
     184FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream)
     185{
     186    FILE *ret; FREOPEN(__freopen64); return ret;
     187}
     188#endif
    166189
    167190#if defined HAVE___SREFILL /* Don't fuzz or seek if we have __srefill() */
     
    212235{
    213236    int ret; FSEEK(fseeko, ftello); return ret;
     237}
     238#endif
     239
     240#if defined HAVE___FSEEKO64
     241int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence)
     242{
     243    int ret; FSEEK(__fseeko64, ftello); return ret;
    214244}
    215245#endif
Note: See TracChangeset for help on using the changeset viewer.