sync with r2397

This commit is contained in:
Charles Kerr 2007-07-18 22:59:29 +00:00
parent 77de71ae5e
commit b73297e799
1 changed files with 7 additions and 55 deletions

View File

@ -85,73 +85,25 @@ uint64_t tr_date( void );
void tr_wait( uint64_t delay_milliseconds );
#define tr_blockPiece(a) _tr_blockPiece(tor,a)
static inline int _tr_blockPiece( const tr_torrent_t * tor, int block )
{
const tr_info_t * inf = &tor->info;
return block / ( inf->pieceSize / tor->blockSize );
}
int _tr_blockPiece( const tr_torrent_t * tor, int block );
#define tr_blockSize(a) _tr_blockSize(tor,a)
static inline int _tr_blockSize( const tr_torrent_t * tor, int block )
{
const tr_info_t * inf = &tor->info;
int dummy;
if( block != tor->blockCount - 1 ||
!( dummy = inf->totalSize % tor->blockSize ) )
{
return tor->blockSize;
}
return dummy;
}
int _tr_blockSize( const tr_torrent_t * tor, int block );
#define tr_blockPosInPiece(a) _tr_blockPosInPiece(tor,a)
static inline int _tr_blockPosInPiece( const tr_torrent_t * tor, int block )
{
const tr_info_t * inf = &tor->info;
return tor->blockSize *
( block % ( inf->pieceSize / tor->blockSize ) );
}
int _tr_blockPosInPiece( const tr_torrent_t * tor, int block );
#define tr_pieceCountBlocks(a) _tr_pieceCountBlocks(tor,a)
static inline int _tr_pieceCountBlocks( const tr_torrent_t * tor, int piece )
{
const tr_info_t * inf = &tor->info;
if( piece < inf->pieceCount - 1 ||
!( tor->blockCount % ( inf->pieceSize / tor->blockSize ) ) )
{
return inf->pieceSize / tor->blockSize;
}
return tor->blockCount % ( inf->pieceSize / tor->blockSize );
}
int _tr_pieceCountBlocks( const tr_torrent_t * tor, int piece );
#define tr_pieceStartBlock(a) _tr_pieceStartBlock(tor,a)
static inline int _tr_pieceStartBlock( const tr_torrent_t * tor, int piece )
{
const tr_info_t * inf = &tor->info;
return piece * ( inf->pieceSize / tor->blockSize );
}
int _tr_pieceStartBlock( const tr_torrent_t * tor, int piece );
#define tr_pieceSize(a) _tr_pieceSize(tor,a)
static inline int _tr_pieceSize( const tr_torrent_t * tor, int piece )
{
const tr_info_t * inf = &tor->info;
if( piece < inf->pieceCount - 1 ||
!( inf->totalSize % inf->pieceSize ) )
{
return inf->pieceSize;
}
return inf->totalSize % inf->pieceSize;
}
int _tr_pieceSize( const tr_torrent_t * tor, int piece );
#define tr_block(a,b) _tr_block(tor,a,b)
static inline int _tr_block( const tr_torrent_t * tor, int index, int begin )
{
const tr_info_t * inf = &tor->info;
return index * ( inf->pieceSize / tor->blockSize ) +
begin / tor->blockSize;
}
int _tr_block( const tr_torrent_t * tor, int index, int begin );
/***
****