Changeset 7576


Ignore:
Timestamp:
Jan 2, 2009, 6:28:22 AM (12 years ago)
Author:
charles
Message:

(trunk libT) add "inline" hint to several one-liner functions

Location:
trunk/libtransmission
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r7573 r7576  
    107107***/
    108108
    109 static int
     109static inline int
    110110comparePointers( const void * a, const void * b )
    111111{
  • trunk/libtransmission/bandwidth.h

    r7534 r7576  
    7575
    7676/** @brief test to see if the pointer refers to a live bandwidth object */
    77 tr_bool  tr_isBandwidth               ( const tr_bandwidth  * bandwidth );
     77extern inline tr_bool
     78         tr_isBandwidth               ( const tr_bandwidth  * bandwidth );
    7879
    7980/******
     
    8687 * @see tr_bandwidthGetDesiredSpeed
    8788 */
    88 void    tr_bandwidthSetDesiredSpeed   ( tr_bandwidth        * bandwidth,
     89extern inline void
     90        tr_bandwidthSetDesiredSpeed   ( tr_bandwidth        * bandwidth,
    8991                                        tr_direction          direction,
    9092                                        double                desiredSpeed );
     
    9496 * @see tr_bandwidthSetDesiredSpeed
    9597 */
    96 double  tr_bandwidthGetDesiredSpeed   ( const tr_bandwidth  * bandwidth,
     98extern inline double
     99        tr_bandwidthGetDesiredSpeed   ( const tr_bandwidth  * bandwidth,
    97100                                        tr_direction          direction );
    98101
     
    100103 * @brief Set whether or not this bandwidth should throttle its peer-io's speeds
    101104 */
    102 void    tr_bandwidthSetLimited        ( tr_bandwidth        * bandwidth,
     105extern inline void
     106        tr_bandwidthSetLimited        ( tr_bandwidth        * bandwidth,
    103107                                        tr_direction          direction,
    104108                                        tr_bool               isLimited );
     
    107111 * @return nonzero if this bandwidth throttles its peer-ios speeds
    108112 */
    109 tr_bool tr_bandwidthIsLimited         ( const tr_bandwidth  * bandwidth,
     113extern inline tr_bool
     114        tr_bandwidthIsLimited         ( const tr_bandwidth  * bandwidth,
    110115                                        tr_direction          direction );
    111116
     
    131136 * @brief Get the raw total of bytes read or sent by this bandwidth subtree.
    132137 */
    133 double  tr_bandwidthGetRawSpeed       ( const tr_bandwidth  * bandwidth,
     138extern inline double
     139        tr_bandwidthGetRawSpeed       ( const tr_bandwidth  * bandwidth,
    134140                                        tr_direction          direction );
    135141
     
    137143 * @brief Get the number of piece data bytes read or sent by this bandwidth subtree.
    138144 */
    139 double  tr_bandwidthGetPieceSpeed     ( const tr_bandwidth  * bandwidth,
     145extern inline double
     146        tr_bandwidthGetPieceSpeed     ( const tr_bandwidth  * bandwidth,
    140147                                        tr_direction          direction );
    141148
     
    174181 * They will be notified when more bandwidth is made available for them to consume.
    175182 */
    176 void    tr_bandwidthAddPeer           ( tr_bandwidth        * bandwidth,
     183extern inline void
     184        tr_bandwidthAddPeer           ( tr_bandwidth        * bandwidth,
    177185                                        struct tr_peerIo    * peerIo );
    178186
     
    180188 * @brief remove a peer-io from this bandwidth's list.
    181189 */
    182 void    tr_bandwidthRemovePeer        ( tr_bandwidth        * bandwidth,
     190extern inline void
     191        tr_bandwidthRemovePeer        ( tr_bandwidth        * bandwidth,
    183192                                        struct tr_peerIo    * peerIo );
    184193
  • trunk/libtransmission/completion.c

    r7525 r7576  
    368368    }
    369369}
    370 
  • trunk/libtransmission/completion.h

    r7151 r7576  
    4343tr_completeness            tr_cpGetStatus( const tr_completion * );
    4444
    45 uint64_t                   tr_cpHaveTotal( const tr_completion * );
     45extern inline uint64_t     tr_cpHaveTotal( const tr_completion * );
    4646
    4747uint64_t                   tr_cpHaveValid( const tr_completion * );
    4848
    49 uint64_t                   tr_cpLeftUntilComplete( const tr_completion * );
     49extern inline uint64_t     tr_cpLeftUntilComplete( const tr_completion * );
    5050
    51 uint64_t                   tr_cpLeftUntilDone( const tr_completion * );
     51extern inline uint64_t     tr_cpLeftUntilDone( const tr_completion * );
    5252
    5353uint64_t                   tr_cpSizeWhenDone( const tr_completion * );
    5454
    55 float                      tr_cpPercentComplete( const tr_completion * );
     55extern inline float        tr_cpPercentComplete( const tr_completion * );
    5656
    57 float                      tr_cpPercentDone( const tr_completion * );
     57extern inline float        tr_cpPercentDone( const tr_completion * );
    5858
    5959void                       tr_cpInvalidateDND( tr_completion * );
     
    6464
    6565/* Pieces */
    66 int                        tr_cpPieceIsComplete( const tr_completion * completion,
     66extern inline int          tr_cpPieceIsComplete( const tr_completion * completion,
    6767                                                 tr_piece_index_t      piece );
    6868
     
    7474
    7575/* Blocks */
    76 int                        tr_cpBlockIsComplete( const tr_completion * completion,
     76extern inline int          tr_cpBlockIsComplete( const tr_completion * completion,
    7777                                                 tr_block_index_t block );
    7878
     
    8383                                                  struct tr_bitfield * blocks );
    8484
    85 int                        tr_cpMissingBlocksInPiece( const tr_completion  * completion,
     85extern inline int          tr_cpMissingBlocksInPiece( const tr_completion  * completion,
    8686                                                      tr_piece_index_t       piece );
    8787
    8888
    89 const struct tr_bitfield * tr_cpPieceBitfield( const tr_completion* );
     89extern inline const struct tr_bitfield *
     90                           tr_cpPieceBitfield( const tr_completion* );
    9091
    91 const struct tr_bitfield * tr_cpBlockBitfield( const tr_completion * );
     92extern inline const struct tr_bitfield *
     93                           tr_cpBlockBitfield( const tr_completion * );
    9294
    9395#endif
  • trunk/libtransmission/peer-io.c

    r7574 r7576  
    838838                    size_t            byteCount )
    839839{
     840    assert( tr_isPeerIo( io ) );
    840841    assert( EVBUFFER_LENGTH( inbuf ) >= byteCount );
    841842
     
    870871{
    871872    uint16_t tmp;
    872 
    873     assert( tr_isPeerIo( io ) );
    874 
    875873    tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );
    876874    *setme = ntohs( tmp );
     
    883881{
    884882    uint32_t tmp;
    885 
    886     assert( tr_isPeerIo( io ) );
    887 
    888883    tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );
    889884    *setme = ntohl( tmp );
     
    896891{
    897892    uint8_t tmp[MAX_STACK_ARRAY_SIZE];
    898 
    899     assert( tr_isPeerIo( io ) );
    900893
    901894    while( byteCount > 0 )
     
    1001994{
    1002995    assert( tr_isPeerIo( io ) );
    1003     assert( tr_isDirection( dir ) );
    1004996
    1005997    return tr_bandwidthClamp( io->bandwidth, dir, 1024 ) > 0;
  • trunk/libtransmission/peer-io.h

    r7446 r7576  
    8484tr_bool              tr_peerIoIsIncoming( const tr_peerIo * io );
    8585
    86 int                  tr_peerIoGetAge( const tr_peerIo * io );
     86extern inline int    tr_peerIoGetAge( const tr_peerIo * io );
    8787
    8888
     
    181181                              size_t            byteCount );
    182182
    183 void      tr_peerIoReadUint8( tr_peerIo *       io,
     183extern inline void
     184          tr_peerIoReadUint8( tr_peerIo *       io,
    184185                              struct evbuffer * inbuf,
    185186                              uint8_t *         setme );
    186187
    187 void      tr_peerIoReadUint16( tr_peerIo *       io,
     188extern inline void
     189          tr_peerIoReadUint16( tr_peerIo *       io,
    188190                               struct evbuffer * inbuf,
    189191                               uint16_t *        setme );
    190192
    191 void      tr_peerIoReadUint32( tr_peerIo *       io,
     193extern inline void
     194          tr_peerIoReadUint32( tr_peerIo *       io,
    192195                               struct evbuffer * inbuf,
    193196                               uint32_t *        setme );
     
    215218**/
    216219
    217 tr_bool   tr_peerIoHasBandwidthLeft( const tr_peerIo  * io,
     220extern inline tr_bool   tr_peerIoHasBandwidthLeft( const tr_peerIo  * io,
    218221                                     tr_direction       direction );
    219222
     
    226229                          size_t          byteLimit );
    227230
    228 struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io );
     231extern inline struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io );
    229232
    230233
  • trunk/libtransmission/peer-msgs.c

    r7565 r7576  
    369369}
    370370
    371 static void
     371static inline void
    372372dbgOutMessageLen( tr_peermsgs * msgs )
    373373{
     
    946946}
    947947
    948 static int
     948static inline int
    949949requestQueueIsFull( const tr_peermsgs * msgs )
    950950{
     
    15801580}
    15811581
    1582 static void
     1582static inline void
    15831583decrementDownloadedCount( tr_peermsgs * msgs, uint32_t byteCount )
    15841584{
     
    15881588}
    15891589
    1590 static void
     1590static inline void
    15911591clientGotUnwantedBlock( tr_peermsgs * msgs, const struct peer_request * req )
    15921592{
     
    19481948}
    19491949
    1950 static void
     1950static inline void
    19511951pexDroppedCb( void * vpex,
    19521952              void * userData )
     
    19611961}
    19621962
    1963 static void
     1963static inline void
    19641964pexElementCb( void * vpex,
    19651965              void * userData )
    19661966{
    19671967    PexDiffs * diffs = userData;
    1968     tr_pex *   pex = vpex;
     1968    tr_pex * pex = vpex;
    19691969
    19701970    diffs->elements[diffs->elementCount++] = *pex;
     
    21332133}
    21342134
    2135 static int
     2135static inline int
    21362136pexPulse( void * vpeer )
    21372137{
  • trunk/libtransmission/peer-msgs.h

    r7456 r7576  
    4141                              uint32_t      pieceIndex );
    4242
    43 void         tr_peerMsgsPulse( tr_peermsgs * msgs );
     43extern inline void
     44             tr_peerMsgsPulse( tr_peermsgs * msgs );
    4445
    4546void         tr_peerMsgsCancel( tr_peermsgs * msgs,
     
    5657                                    uint32_t      length );
    5758
    58 void         tr_peerMsgsUnsubscribe( tr_peermsgs      * peer,
     59extern inline void
     60             tr_peerMsgsUnsubscribe( tr_peermsgs      * peer,
    5961                                     tr_publisher_tag   tag );
    6062
  • trunk/libtransmission/torrent.c

    r7525 r7576  
    412412/* the tiers will be sorted from lowest to highest,
    413413 * and trackers are randomized within the tiers */
    414 static int
     414static inline int
    415415compareRandomTracker( const void * va,
    416416                      const void * vb )
     
    698698}
    699699
    700 static void
     700static inline void
    701701tr_torrentManualUpdateImpl( void * vtor )
    702702{
  • trunk/libtransmission/torrent.h

    r7525 r7576  
    6464                                   tr_bool          has );
    6565
    66 void        tr_torrentLock( const tr_torrent * session );
    67 
    68 void        tr_torrentUnlock( const tr_torrent * session );
     66extern inline void
     67            tr_torrentLock( const tr_torrent * session );
     68
     69extern inline void
     70            tr_torrentUnlock( const tr_torrent * session );
    6971
    7072tr_bool     tr_torrentIsSeed( const tr_torrent * session );
     
    7274void        tr_torrentChangeMyPort( tr_torrent * session );
    7375
    74 tr_bool     tr_torrentExists( const tr_session * session,
     76extern inline tr_bool
     77            tr_torrentExists( const tr_session * session,
    7578                              const uint8_t    * hash );
    7679
     
    9295                                              tr_direction       direction );
    9396
    94 /* get the index of this piece's first block */
    95 #define tr_torPieceFirstBlock( tor, piece ) ( ( piece ) *\
    96                                              ( tor )->blockCountInPiece )
    97 
    98 /* what piece index is this block in? */
    99 #define tr_torBlockPiece( tor, block ) ( ( block ) /\
    100                                         ( tor )->blockCountInPiece )
    101 
    102 /* how many blocks are in this piece? */
    103 #define tr_torPieceCountBlocks( tor, piece ) \
    104     ( ( ( piece ) ==\
    105        ( ( tor )->info.pieceCount - \
    106         1 ) ) ? ( tor )->blockCountInLastPiece : ( tor )->blockCountInPiece )
    107 
    108 /* how many bytes are in this piece? */
    109 #define tr_torPieceCountBytes( tor, piece ) \
    110     ( ( ( piece ) ==\
    111        ( ( tor )->info.pieceCount - \
    112         1 ) ) ? ( tor )->lastPieceSize : ( tor )->info.pieceSize )
    113 
    114 /* how many bytes are in this block? */
    115 #define tr_torBlockCountBytes( tor, block ) \
    116     ( ( ( block ) ==\
    117        ( ( tor )->blockCount - \
    118         1 ) ) ? ( tor )->lastBlockSize : ( tor )->blockSize )
    11997
    12098#define tr_block( a, b ) _tr_block( tor, a, b )
     
    246224};
    247225
     226/* get the index of this piece's first block */
     227static inline tr_block_index_t
     228tr_torPieceFirstBlock( const tr_torrent * tor, const tr_piece_index_t piece )
     229{
     230    return piece * tor->blockCountInPiece;
     231}
     232
     233/* what piece index is this block in? */
     234static inline tr_piece_index_t
     235tr_torBlockPiece( const tr_torrent * tor, const tr_block_index_t block )
     236{
     237    return block / tor->blockCountInPiece;
     238}
     239
     240/* how many blocks are in this piece? */
     241static inline uint32_t
     242tr_torPieceCountBlocks( const tr_torrent * tor, const tr_piece_index_t piece )
     243{
     244    return piece == tor->info.pieceCount - 1 ? tor->blockCountInLastPiece
     245                                             : tor->blockCountInPiece;
     246}
     247
     248/* how many bytes are in this piece? */
     249static inline uint32_t
     250tr_torPieceCountBytes( const tr_torrent * tor, const tr_piece_index_t piece )
     251{
     252    return piece == tor->info.pieceCount - 1 ? tor->lastPieceSize
     253                                             : tor->info.pieceSize;
     254}
     255
     256/* how many bytes are in this block? */
     257static inline uint32_t
     258tr_torBlockCountBytes( const tr_torrent * tor, const tr_block_index_t block )
     259{
     260    return block == tor->blockCount - 1 ? tor->lastBlockSize
     261                                        : tor->blockSize;
     262}
     263
    248264#endif
  • trunk/libtransmission/transmission.h

    r7575 r7576  
    827827 * tr_info.hashString.
    828828 */
    829 int tr_torrentId( const tr_torrent * torrent );
     829extern inline int tr_torrentId( const tr_torrent * torrent );
    830830
    831831/****
Note: See TracChangeset for help on using the changeset viewer.