Changeset 8175


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

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

Location:
trunk/libtransmission
Files:
3 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.
  • trunk/libtransmission/fdlimit.h

    r7720 r8175  
    3232void tr_fdInit( size_t openFileLimit,
    3333                size_t globalPeerLimit );
     34
     35FILE* tr_open_file_for_reading( const char * filename, tr_bool sequential );
    3436
    3537/**
  • trunk/libtransmission/verify.c

    r8171 r8175  
    2323#include "transmission.h"
    2424#include "completion.h"
     25#include "fdlimit.h"
    2526#include "resume.h" /* tr_torrentSaveResume() */
    2627#include "inout.h"
     
    7576        {
    7677            char * filename = tr_buildPath( tor->downloadDir, file->name, NULL );
    77             fp = fopen( filename, "rb" );
    78 #ifdef HAVE_POSIX_FADVISE
    79             if( fp != NULL )
    80                 posix_fadvise( fileno( fp ), 0, 0, POSIX_FADV_SEQUENTIAL );
    81 #endif
     78            fp = tr_open_file_for_reading( filename, TRUE );
    8279            /* fprintf( stderr, "opening file #%d (%s) -- %p\n", fileIndex, filename, fp ); */
    8380            tr_free( filename );
Note: See TracChangeset for help on using the changeset viewer.