Changeset 2552


Ignore:
Timestamp:
07/16/08 23:24:09 (5 years ago)
Author:
sam
Message:
  • Implement freopen64, fsetpos64 and fseeko64 for OpenSolaris?.
Location:
zzuf/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r2542 r2552  
    3939 
    4040AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe) 
    41 AC_CHECK_FUNCS(open64 __open64 lseek64 __lseek64 mmap64 fopen64 __fopen64 __freopen64 dup dup2 fseeko __fseeko64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf 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 __lseek64 mmap64 fopen64 __fopen64 freopen64 __freopen64 dup dup2 fseeko fseeko64 __fseeko64 fsetpos64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf 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

    r2533 r2552  
    109109\fB__open64\fR(), \fB__lseek64\fR(), \fB__filbuf\fR() 
    110110.TP 
     111Required on OpenSolaris: 
     112\fBfreopen64\fR(), \fBfseeko64\fR(), \fBfsetpos64\fR() 
     113.TP 
    111114Signal handling: 
    112115\fBsignal\fR(), \fBsigaction\fR() 
  • zzuf/trunk/src/lib-stream.c

    r2542 r2552  
    6363static FILE *  (*ORIG(freopen))  (const char *path, const char *mode, 
    6464                                  FILE *stream); 
     65#if defined HAVE_FREOPEN64 
     66static FILE *  (*ORIG(freopen64))(const char *path, const char *mode, 
     67                                  FILE *stream); 
     68#endif 
    6569#if defined HAVE___FREOPEN64 
    6670static FILE *  (*ORIG(__freopen64)) (const char *path, const char *mode, 
     
    7175static int     (*ORIG(fseeko))   (FILE *stream, off_t offset, int whence); 
    7276#endif 
     77#if defined HAVE_FSEEKO64 
     78static int     (*ORIG(fseeko64)) (FILE *stream, off_t offset, int whence); 
     79#endif 
    7380#if defined HAVE___FSEEKO64 
    7481static int     (*ORIG(__fseeko64)) (FILE *stream, off_t offset, int whence); 
     82#endif 
     83#if defined HAVE_FSETPOS64 
     84static int     (*ORIG(fsetpos64))(FILE *stream, const fpos64_t *pos); 
    7585#endif 
    7686#if defined HAVE___FSETPOS64 
     
    206216} 
    207217 
     218#if defined HAVE_FREOPEN64 
     219FILE *NEW(freopen64)(const char *path, const char *mode, FILE *stream) 
     220{ 
     221    FILE *ret; FREOPEN(freopen64); return ret; 
     222} 
     223#endif 
     224 
    208225#if defined HAVE___FREOPEN64 
    209226FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream) 
     
    263280#endif 
    264281 
     282#if defined HAVE_FSEEKO64 
     283int NEW(fseeko64)(FILE *stream, off64_t offset, int whence) 
     284{ 
     285    int ret; FSEEK(fseeko64, ftello); return ret; 
     286} 
     287#endif 
     288 
    265289#if defined HAVE___FSEEKO64 
    266290int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence) 
     
    270294#endif 
    271295 
     296#define FSETPOS(fn) \ 
     297    do \ 
     298    { \ 
     299        int fd; \ 
     300        LOADSYM(fn); \ 
     301        fd = fileno(stream); \ 
     302        if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 
     303            return ORIG(fn)(stream, pos); \ 
     304        _zz_lock(fd); \ 
     305        ret = ORIG(fn)(stream, pos); \ 
     306        _zz_unlock(fd); \ 
     307        debug("%s([%i], %lli) = %i", __func__, \ 
     308              fd, (long long int)*pos, ret); \ 
     309        /* On HP-UX at least, fpos64_t == int64_t */ \ 
     310        _zz_setpos(fd, (int64_t)*pos); \ 
     311    } \ 
     312    while(0) 
     313 
     314#if defined HAVE_FSETPOS64 
     315int NEW(fsetpos64)(FILE *stream, const fpos64_t *pos) 
     316{ 
     317    int ret; FSETPOS(fsetpos64); return ret; 
     318} 
     319#endif 
     320 
    272321#if defined HAVE___FSETPOS64 
    273322int NEW(__fsetpos64)(FILE *stream, const fpos64_t *pos) 
    274323{ 
    275     int ret, fd; 
    276  
    277     LOADSYM(__fsetpos64); 
    278     fd = fileno(stream); 
    279     if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) 
    280         return ORIG(__fsetpos64)(stream, pos); 
    281     _zz_lock(fd); 
    282     ret = ORIG(__fsetpos64)(stream, pos); 
    283     _zz_unlock(fd); 
    284     debug("%s([%i], %lli) = %i", __func__, 
    285           fd, (long long int)*pos, ret); 
    286     /* On HP-UX at least, fpos64_t == int64_t */ 
    287     _zz_setpos(fd, (int64_t)*pos); 
    288  
    289     return ret; 
     324    int ret; FSETPOS(__fsetpos64); return ret; 
    290325} 
    291326#endif 
Note: See TracChangeset for help on using the changeset viewer.