(trunk libT) add "inline" hint to several one-liner functions
This commit is contained in:
parent
5e806dc816
commit
d6b4db4a78
|
@ -106,7 +106,7 @@ struct tr_bandwidth
|
|||
****
|
||||
***/
|
||||
|
||||
static int
|
||||
static inline int
|
||||
comparePointers( const void * a, const void * b )
|
||||
{
|
||||
if( a != b )
|
||||
|
|
|
@ -74,7 +74,8 @@ tr_bandwidth*
|
|||
void tr_bandwidthFree ( tr_bandwidth * bandwidth );
|
||||
|
||||
/** @brief test to see if the pointer refers to a live bandwidth object */
|
||||
tr_bool tr_isBandwidth ( const tr_bandwidth * bandwidth );
|
||||
extern inline tr_bool
|
||||
tr_isBandwidth ( const tr_bandwidth * bandwidth );
|
||||
|
||||
/******
|
||||
*******
|
||||
|
@ -85,7 +86,8 @@ tr_bool tr_isBandwidth ( const tr_bandwidth * bandwidth );
|
|||
* @see tr_bandwidthAllocate
|
||||
* @see tr_bandwidthGetDesiredSpeed
|
||||
*/
|
||||
void tr_bandwidthSetDesiredSpeed ( tr_bandwidth * bandwidth,
|
||||
extern inline void
|
||||
tr_bandwidthSetDesiredSpeed ( tr_bandwidth * bandwidth,
|
||||
tr_direction direction,
|
||||
double desiredSpeed );
|
||||
|
||||
|
@ -93,20 +95,23 @@ void tr_bandwidthSetDesiredSpeed ( tr_bandwidth * bandwidth,
|
|||
* @brief Get the desired speed (in KiB/s) for ths bandwidth subtree.
|
||||
* @see tr_bandwidthSetDesiredSpeed
|
||||
*/
|
||||
double tr_bandwidthGetDesiredSpeed ( const tr_bandwidth * bandwidth,
|
||||
extern inline double
|
||||
tr_bandwidthGetDesiredSpeed ( const tr_bandwidth * bandwidth,
|
||||
tr_direction direction );
|
||||
|
||||
/**
|
||||
* @brief Set whether or not this bandwidth should throttle its peer-io's speeds
|
||||
*/
|
||||
void tr_bandwidthSetLimited ( tr_bandwidth * bandwidth,
|
||||
extern inline void
|
||||
tr_bandwidthSetLimited ( tr_bandwidth * bandwidth,
|
||||
tr_direction direction,
|
||||
tr_bool isLimited );
|
||||
|
||||
/**
|
||||
* @return nonzero if this bandwidth throttles its peer-ios speeds
|
||||
*/
|
||||
tr_bool tr_bandwidthIsLimited ( const tr_bandwidth * bandwidth,
|
||||
extern inline tr_bool
|
||||
tr_bandwidthIsLimited ( const tr_bandwidth * bandwidth,
|
||||
tr_direction direction );
|
||||
|
||||
/**
|
||||
|
@ -130,13 +135,15 @@ size_t tr_bandwidthClamp ( const tr_bandwidth * bandwidth,
|
|||
/**
|
||||
* @brief Get the raw total of bytes read or sent by this bandwidth subtree.
|
||||
*/
|
||||
double tr_bandwidthGetRawSpeed ( const tr_bandwidth * bandwidth,
|
||||
extern inline double
|
||||
tr_bandwidthGetRawSpeed ( const tr_bandwidth * bandwidth,
|
||||
tr_direction direction );
|
||||
|
||||
/**
|
||||
* @brief Get the number of piece data bytes read or sent by this bandwidth subtree.
|
||||
*/
|
||||
double tr_bandwidthGetPieceSpeed ( const tr_bandwidth * bandwidth,
|
||||
extern inline double
|
||||
tr_bandwidthGetPieceSpeed ( const tr_bandwidth * bandwidth,
|
||||
tr_direction direction );
|
||||
|
||||
/**
|
||||
|
@ -173,13 +180,15 @@ void tr_bandwidthHonorParentLimits ( tr_bandwidth * bandwidth,
|
|||
* @brief add a tr_peerIo to this bandwidth's list.
|
||||
* They will be notified when more bandwidth is made available for them to consume.
|
||||
*/
|
||||
void tr_bandwidthAddPeer ( tr_bandwidth * bandwidth,
|
||||
extern inline void
|
||||
tr_bandwidthAddPeer ( tr_bandwidth * bandwidth,
|
||||
struct tr_peerIo * peerIo );
|
||||
|
||||
/**
|
||||
* @brief remove a peer-io from this bandwidth's list.
|
||||
*/
|
||||
void tr_bandwidthRemovePeer ( tr_bandwidth * bandwidth,
|
||||
extern inline void
|
||||
tr_bandwidthRemovePeer ( tr_bandwidth * bandwidth,
|
||||
struct tr_peerIo * peerIo );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -367,4 +367,3 @@ tr_cpGetAmountDone( const tr_completion * cp,
|
|||
tr_torPieceCountBlocks( tor, piece );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,19 +42,19 @@ void tr_cpClose( tr_completion * );
|
|||
|
||||
tr_completeness tr_cpGetStatus( const tr_completion * );
|
||||
|
||||
uint64_t tr_cpHaveTotal( const tr_completion * );
|
||||
extern inline uint64_t tr_cpHaveTotal( const tr_completion * );
|
||||
|
||||
uint64_t tr_cpHaveValid( const tr_completion * );
|
||||
|
||||
uint64_t tr_cpLeftUntilComplete( const tr_completion * );
|
||||
extern inline uint64_t tr_cpLeftUntilComplete( const tr_completion * );
|
||||
|
||||
uint64_t tr_cpLeftUntilDone( const tr_completion * );
|
||||
extern inline uint64_t tr_cpLeftUntilDone( const tr_completion * );
|
||||
|
||||
uint64_t tr_cpSizeWhenDone( const tr_completion * );
|
||||
|
||||
float tr_cpPercentComplete( const tr_completion * );
|
||||
extern inline float tr_cpPercentComplete( const tr_completion * );
|
||||
|
||||
float tr_cpPercentDone( const tr_completion * );
|
||||
extern inline float tr_cpPercentDone( const tr_completion * );
|
||||
|
||||
void tr_cpInvalidateDND( tr_completion * );
|
||||
|
||||
|
@ -63,7 +63,7 @@ void tr_cpGetAmountDone( const tr_completion * completio
|
|||
int tabCount );
|
||||
|
||||
/* Pieces */
|
||||
int tr_cpPieceIsComplete( const tr_completion * completion,
|
||||
extern inline int tr_cpPieceIsComplete( const tr_completion * completion,
|
||||
tr_piece_index_t piece );
|
||||
|
||||
void tr_cpPieceAdd( tr_completion * completion,
|
||||
|
@ -73,7 +73,7 @@ void tr_cpPieceRem( tr_completion * completion,
|
|||
tr_piece_index_t piece );
|
||||
|
||||
/* Blocks */
|
||||
int tr_cpBlockIsComplete( const tr_completion * completion,
|
||||
extern inline int tr_cpBlockIsComplete( const tr_completion * completion,
|
||||
tr_block_index_t block );
|
||||
|
||||
void tr_cpBlockAdd( tr_completion * completion,
|
||||
|
@ -82,12 +82,14 @@ void tr_cpBlockAdd( tr_completion * completion,
|
|||
int tr_cpBlockBitfieldSet( tr_completion * completion,
|
||||
struct tr_bitfield * blocks );
|
||||
|
||||
int tr_cpMissingBlocksInPiece( const tr_completion * completion,
|
||||
extern inline int tr_cpMissingBlocksInPiece( const tr_completion * completion,
|
||||
tr_piece_index_t piece );
|
||||
|
||||
|
||||
const struct tr_bitfield * tr_cpPieceBitfield( const tr_completion* );
|
||||
extern inline const struct tr_bitfield *
|
||||
tr_cpPieceBitfield( const tr_completion* );
|
||||
|
||||
const struct tr_bitfield * tr_cpBlockBitfield( const tr_completion * );
|
||||
extern inline const struct tr_bitfield *
|
||||
tr_cpBlockBitfield( const tr_completion * );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -837,6 +837,7 @@ tr_peerIoReadBytes( tr_peerIo * io,
|
|||
void * bytes,
|
||||
size_t byteCount )
|
||||
{
|
||||
assert( tr_isPeerIo( io ) );
|
||||
assert( EVBUFFER_LENGTH( inbuf ) >= byteCount );
|
||||
|
||||
switch( io->encryptionMode )
|
||||
|
@ -869,9 +870,6 @@ tr_peerIoReadUint16( tr_peerIo * io,
|
|||
uint16_t * setme )
|
||||
{
|
||||
uint16_t tmp;
|
||||
|
||||
assert( tr_isPeerIo( io ) );
|
||||
|
||||
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );
|
||||
*setme = ntohs( tmp );
|
||||
}
|
||||
|
@ -882,9 +880,6 @@ tr_peerIoReadUint32( tr_peerIo * io,
|
|||
uint32_t * setme )
|
||||
{
|
||||
uint32_t tmp;
|
||||
|
||||
assert( tr_isPeerIo( io ) );
|
||||
|
||||
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );
|
||||
*setme = ntohl( tmp );
|
||||
}
|
||||
|
@ -896,8 +891,6 @@ tr_peerIoDrain( tr_peerIo * io,
|
|||
{
|
||||
uint8_t tmp[MAX_STACK_ARRAY_SIZE];
|
||||
|
||||
assert( tr_isPeerIo( io ) );
|
||||
|
||||
while( byteCount > 0 )
|
||||
{
|
||||
const size_t thisPass = MIN( byteCount, sizeof( tmp ) );
|
||||
|
@ -1000,7 +993,6 @@ tr_bool
|
|||
tr_peerIoHasBandwidthLeft( const tr_peerIo * io, tr_direction dir )
|
||||
{
|
||||
assert( tr_isPeerIo( io ) );
|
||||
assert( tr_isDirection( dir ) );
|
||||
|
||||
return tr_bandwidthClamp( io->bandwidth, dir, 1024 ) > 0;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ int tr_peerIoReconnect( tr_peerIo * io );
|
|||
|
||||
tr_bool tr_peerIoIsIncoming( const tr_peerIo * io );
|
||||
|
||||
int tr_peerIoGetAge( const tr_peerIo * io );
|
||||
extern inline int tr_peerIoGetAge( const tr_peerIo * io );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -180,15 +180,18 @@ void tr_peerIoReadBytes( tr_peerIo * io,
|
|||
void * bytes,
|
||||
size_t byteCount );
|
||||
|
||||
void tr_peerIoReadUint8( tr_peerIo * io,
|
||||
extern inline void
|
||||
tr_peerIoReadUint8( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint8_t * setme );
|
||||
|
||||
void tr_peerIoReadUint16( tr_peerIo * io,
|
||||
extern inline void
|
||||
tr_peerIoReadUint16( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint16_t * setme );
|
||||
|
||||
void tr_peerIoReadUint32( tr_peerIo * io,
|
||||
extern inline void
|
||||
tr_peerIoReadUint32( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint32_t * setme );
|
||||
|
||||
|
@ -214,7 +217,7 @@ void tr_peerIoBandwidthUsed( tr_peerIo * io,
|
|||
***
|
||||
**/
|
||||
|
||||
tr_bool tr_peerIoHasBandwidthLeft( const tr_peerIo * io,
|
||||
extern inline tr_bool tr_peerIoHasBandwidthLeft( const tr_peerIo * io,
|
||||
tr_direction direction );
|
||||
|
||||
void tr_peerIoSetEnabled( tr_peerIo * io,
|
||||
|
@ -225,7 +228,7 @@ int tr_peerIoFlush( tr_peerIo * io,
|
|||
tr_direction dir,
|
||||
size_t byteLimit );
|
||||
|
||||
struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io );
|
||||
extern inline struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io );
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ pokeBatchPeriod( tr_peermsgs * msgs,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
dbgOutMessageLen( tr_peermsgs * msgs )
|
||||
{
|
||||
dbgmsg( msgs, "outMessage size is now %zu", EVBUFFER_LENGTH( msgs->outMessages ) );
|
||||
|
@ -945,7 +945,7 @@ pumpRequestQueue( tr_peermsgs * msgs, const time_t now )
|
|||
fireNeedReq( msgs );
|
||||
}
|
||||
|
||||
static int
|
||||
static inline int
|
||||
requestQueueIsFull( const tr_peermsgs * msgs )
|
||||
{
|
||||
const int req_max = msgs->maxActiveRequests;
|
||||
|
@ -1579,7 +1579,7 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen, size_t
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
decrementDownloadedCount( tr_peermsgs * msgs, uint32_t byteCount )
|
||||
{
|
||||
tr_torrent * tor = msgs->torrent;
|
||||
|
@ -1587,7 +1587,7 @@ decrementDownloadedCount( tr_peermsgs * msgs, uint32_t byteCount )
|
|||
tor->downloadedCur -= MIN( tor->downloadedCur, byteCount );
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
clientGotUnwantedBlock( tr_peermsgs * msgs, const struct peer_request * req )
|
||||
{
|
||||
decrementDownloadedCount( msgs, req->length );
|
||||
|
@ -1947,7 +1947,7 @@ pexAddedCb( void * vpex,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
pexDroppedCb( void * vpex,
|
||||
void * userData )
|
||||
{
|
||||
|
@ -1960,12 +1960,12 @@ pexDroppedCb( void * vpex,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
pexElementCb( void * vpex,
|
||||
void * userData )
|
||||
{
|
||||
PexDiffs * diffs = userData;
|
||||
tr_pex * pex = vpex;
|
||||
tr_pex * pex = vpex;
|
||||
|
||||
diffs->elements[diffs->elementCount++] = *pex;
|
||||
}
|
||||
|
@ -2132,7 +2132,7 @@ sendPex( tr_peermsgs * msgs )
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static inline int
|
||||
pexPulse( void * vpeer )
|
||||
{
|
||||
sendPex( vpeer );
|
||||
|
|
|
@ -40,7 +40,8 @@ void tr_peerMsgsSetChoke( tr_peermsgs *,
|
|||
void tr_peerMsgsHave( tr_peermsgs * msgs,
|
||||
uint32_t pieceIndex );
|
||||
|
||||
void tr_peerMsgsPulse( tr_peermsgs * msgs );
|
||||
extern inline void
|
||||
tr_peerMsgsPulse( tr_peermsgs * msgs );
|
||||
|
||||
void tr_peerMsgsCancel( tr_peermsgs * msgs,
|
||||
uint32_t pieceIndex,
|
||||
|
@ -55,7 +56,8 @@ tr_addreq_t tr_peerMsgsAddRequest( tr_peermsgs * peer,
|
|||
uint32_t offset,
|
||||
uint32_t length );
|
||||
|
||||
void tr_peerMsgsUnsubscribe( tr_peermsgs * peer,
|
||||
extern inline void
|
||||
tr_peerMsgsUnsubscribe( tr_peermsgs * peer,
|
||||
tr_publisher_tag tag );
|
||||
|
||||
size_t tr_generateAllowedSet( tr_piece_index_t * setmePieces,
|
||||
|
|
|
@ -411,7 +411,7 @@ struct RandomTracker
|
|||
|
||||
/* the tiers will be sorted from lowest to highest,
|
||||
* and trackers are randomized within the tiers */
|
||||
static int
|
||||
static inline int
|
||||
compareRandomTracker( const void * va,
|
||||
const void * vb )
|
||||
{
|
||||
|
@ -697,7 +697,7 @@ tr_torrentAllowsPex( const tr_torrent * tor )
|
|||
&& !tr_torrentIsPrivate( tor );
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
tr_torrentManualUpdateImpl( void * vtor )
|
||||
{
|
||||
tr_torrent * tor = vtor;
|
||||
|
|
|
@ -63,15 +63,18 @@ void tr_torrentSetHasPiece( tr_torrent * tor,
|
|||
tr_piece_index_t pieceIndex,
|
||||
tr_bool has );
|
||||
|
||||
void tr_torrentLock( const tr_torrent * session );
|
||||
extern inline void
|
||||
tr_torrentLock( const tr_torrent * session );
|
||||
|
||||
void tr_torrentUnlock( const tr_torrent * session );
|
||||
extern inline void
|
||||
tr_torrentUnlock( const tr_torrent * session );
|
||||
|
||||
tr_bool tr_torrentIsSeed( const tr_torrent * session );
|
||||
|
||||
void tr_torrentChangeMyPort( tr_torrent * session );
|
||||
|
||||
tr_bool tr_torrentExists( const tr_session * session,
|
||||
extern inline tr_bool
|
||||
tr_torrentExists( const tr_session * session,
|
||||
const uint8_t * hash );
|
||||
|
||||
tr_torrent* tr_torrentFindFromId( tr_session * session,
|
||||
|
@ -91,31 +94,6 @@ tr_bool tr_torrentAllowsPex( const tr_torrent * );
|
|||
tr_bool tr_torrentIsPieceTransferAllowed( const tr_torrent * torrent,
|
||||
tr_direction direction );
|
||||
|
||||
/* get the index of this piece's first block */
|
||||
#define tr_torPieceFirstBlock( tor, piece ) ( ( piece ) *\
|
||||
( tor )->blockCountInPiece )
|
||||
|
||||
/* what piece index is this block in? */
|
||||
#define tr_torBlockPiece( tor, block ) ( ( block ) /\
|
||||
( tor )->blockCountInPiece )
|
||||
|
||||
/* how many blocks are in this piece? */
|
||||
#define tr_torPieceCountBlocks( tor, piece ) \
|
||||
( ( ( piece ) ==\
|
||||
( ( tor )->info.pieceCount - \
|
||||
1 ) ) ? ( tor )->blockCountInLastPiece : ( tor )->blockCountInPiece )
|
||||
|
||||
/* how many bytes are in this piece? */
|
||||
#define tr_torPieceCountBytes( tor, piece ) \
|
||||
( ( ( piece ) ==\
|
||||
( ( tor )->info.pieceCount - \
|
||||
1 ) ) ? ( tor )->lastPieceSize : ( tor )->info.pieceSize )
|
||||
|
||||
/* how many bytes are in this block? */
|
||||
#define tr_torBlockCountBytes( tor, block ) \
|
||||
( ( ( block ) ==\
|
||||
( ( tor )->blockCount - \
|
||||
1 ) ) ? ( tor )->lastBlockSize : ( tor )->blockSize )
|
||||
|
||||
#define tr_block( a, b ) _tr_block( tor, a, b )
|
||||
tr_block_index_t _tr_block( const tr_torrent * tor,
|
||||
|
@ -245,4 +223,42 @@ struct tr_torrent
|
|||
struct tr_bandwidth * bandwidth;
|
||||
};
|
||||
|
||||
/* get the index of this piece's first block */
|
||||
static inline tr_block_index_t
|
||||
tr_torPieceFirstBlock( const tr_torrent * tor, const tr_piece_index_t piece )
|
||||
{
|
||||
return piece * tor->blockCountInPiece;
|
||||
}
|
||||
|
||||
/* what piece index is this block in? */
|
||||
static inline tr_piece_index_t
|
||||
tr_torBlockPiece( const tr_torrent * tor, const tr_block_index_t block )
|
||||
{
|
||||
return block / tor->blockCountInPiece;
|
||||
}
|
||||
|
||||
/* how many blocks are in this piece? */
|
||||
static inline uint32_t
|
||||
tr_torPieceCountBlocks( const tr_torrent * tor, const tr_piece_index_t piece )
|
||||
{
|
||||
return piece == tor->info.pieceCount - 1 ? tor->blockCountInLastPiece
|
||||
: tor->blockCountInPiece;
|
||||
}
|
||||
|
||||
/* how many bytes are in this piece? */
|
||||
static inline uint32_t
|
||||
tr_torPieceCountBytes( const tr_torrent * tor, const tr_piece_index_t piece )
|
||||
{
|
||||
return piece == tor->info.pieceCount - 1 ? tor->lastPieceSize
|
||||
: tor->info.pieceSize;
|
||||
}
|
||||
|
||||
/* how many bytes are in this block? */
|
||||
static inline uint32_t
|
||||
tr_torBlockCountBytes( const tr_torrent * tor, const tr_block_index_t block )
|
||||
{
|
||||
return block == tor->blockCount - 1 ? tor->lastBlockSize
|
||||
: tor->blockSize;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -826,7 +826,7 @@ uint64_t tr_torrentGetBytesLeftToAllocate( const tr_torrent * torrent );
|
|||
* between sessions. If you need that, use tr_info.hash or
|
||||
* tr_info.hashString.
|
||||
*/
|
||||
int tr_torrentId( const tr_torrent * torrent );
|
||||
extern inline int tr_torrentId( const tr_torrent * torrent );
|
||||
|
||||
/****
|
||||
***** Speed Limits
|
||||
|
|
Loading…
Reference in New Issue