Ignore:
Timestamp:
Apr 7, 2009, 8:25:32 PM (14 years ago)
Author:
charles
Message:

(trunk libT) #1976: build problem with r8173: "erreur: ‘POSIX_FADV_SEQUENTIAL’ undeclared"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r8142 r8175  
    206206}
    207207
     208FILE*
     209tr_open_file_for_reading( const char * filename, tr_bool sequential )
     210{
     211    int fd;
     212    int flags;
     213
     214    /* build the flags */
     215    flags = O_RDONLY;
     216#ifdef O_SEQUENTIAL
     217    if( sequential ) flags |= O_SEQUENTIAL;
     218#endif
     219#ifdef O_RANDOM
     220    if( !sequential ) flags |= O_RANDOM
     221#endif
     222#ifdef O_BINARY
     223    flags |= O_BINARY;
     224#endif
     225#ifdef O_LARGEFILE
     226    flags |= O_LARGEFILE;
     227#endif
     228
     229    /* open the file */
     230    fd = open( filename, flags, 0666 );
     231    if( fd < 0 )
     232        return NULL;
     233
     234#if defined( SYS_DARWIN )
     235    fcntl( fd, F_NOCACHE, 1 );
     236    fcntl( fd, F_RDAHEAD, sequential );
     237#elif defined( HAVE_POSIX_FADVISE )
     238    posix_fadvise( fd, 0, 0, sequential ? POSIX_FADV_SEQUENTIAL : POSIX_FADV_RANDOM );
     239#endif
     240
     241    return fdopen( fd, "r" );
     242}
     243
    208244/**
    209245 * returns 0 on success, or an errno value on failure.
Note: See TracChangeset for help on using the changeset viewer.