mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
sync with r2397
This commit is contained in:
parent
77de71ae5e
commit
b73297e799
1 changed files with 7 additions and 55 deletions
|
@ -85,73 +85,25 @@ uint64_t tr_date( void );
|
||||||
void tr_wait( uint64_t delay_milliseconds );
|
void tr_wait( uint64_t delay_milliseconds );
|
||||||
|
|
||||||
#define tr_blockPiece(a) _tr_blockPiece(tor,a)
|
#define tr_blockPiece(a) _tr_blockPiece(tor,a)
|
||||||
static inline int _tr_blockPiece( const tr_torrent_t * tor, int block )
|
int _tr_blockPiece( const tr_torrent_t * tor, int block );
|
||||||
{
|
|
||||||
const tr_info_t * inf = &tor->info;
|
|
||||||
return block / ( inf->pieceSize / tor->blockSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tr_blockSize(a) _tr_blockSize(tor,a)
|
#define tr_blockSize(a) _tr_blockSize(tor,a)
|
||||||
static inline int _tr_blockSize( const tr_torrent_t * tor, int block )
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tr_blockPosInPiece(a) _tr_blockPosInPiece(tor,a)
|
#define tr_blockPosInPiece(a) _tr_blockPosInPiece(tor,a)
|
||||||
static inline int _tr_blockPosInPiece( const tr_torrent_t * tor, int block )
|
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 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tr_pieceCountBlocks(a) _tr_pieceCountBlocks(tor,a)
|
#define tr_pieceCountBlocks(a) _tr_pieceCountBlocks(tor,a)
|
||||||
static inline int _tr_pieceCountBlocks( const tr_torrent_t * tor, int piece )
|
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tr_pieceStartBlock(a) _tr_pieceStartBlock(tor,a)
|
#define tr_pieceStartBlock(a) _tr_pieceStartBlock(tor,a)
|
||||||
static inline int _tr_pieceStartBlock( const tr_torrent_t * tor, int piece )
|
int _tr_pieceStartBlock( const tr_torrent_t * tor, int piece );
|
||||||
{
|
|
||||||
const tr_info_t * inf = &tor->info;
|
|
||||||
return piece * ( inf->pieceSize / tor->blockSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tr_pieceSize(a) _tr_pieceSize(tor,a)
|
#define tr_pieceSize(a) _tr_pieceSize(tor,a)
|
||||||
static inline int _tr_pieceSize( const tr_torrent_t * tor, int piece )
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tr_block(a,b) _tr_block(tor,a,b)
|
#define tr_block(a,b) _tr_block(tor,a,b)
|
||||||
static inline int _tr_block( const tr_torrent_t * tor, int index, int begin )
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
****
|
****
|
||||||
|
|
Loading…
Reference in a new issue