Changeset 7663


Ignore:
Timestamp:
Jan 11, 2009, 5:02:04 PM (12 years ago)
Author:
charles
Message:

(trunk libT) win32 portability patch from Alexey

Location:
trunk/libtransmission
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r7658 r7663  
    7272******/
    7373
    74 static inline int
     74static TR_INLINE int
    7575comparePointers( const void * a, const void * b )
    7676{
  • trunk/libtransmission/bandwidth.h

    r7658 r7663  
    118118
    119119/** @brief create a new tr_bandwidth object */
    120 static inline tr_bandwidth* tr_bandwidthNew( tr_session * session, tr_bandwidth * parent )
     120static TR_INLINE tr_bandwidth* tr_bandwidthNew( tr_session * session, tr_bandwidth * parent )
    121121{
    122122    return tr_bandwidthConstruct( tr_new0( tr_bandwidth, 1 ), session, parent );
     
    126126
    127127/** @brief free a tr_bandwidth object */
    128 static inline void tr_bandwidthFree( tr_bandwidth * bandwidth )
     128static TR_INLINE void tr_bandwidthFree( tr_bandwidth * bandwidth )
    129129{
    130130    tr_free( tr_bandwidthDestruct( bandwidth ) );
     
    132132
    133133/** @brief test to see if the pointer refers to a live bandwidth object */
    134 static inline tr_bool tr_isBandwidth( const tr_bandwidth  * b )
     134static TR_INLINE tr_bool tr_isBandwidth( const tr_bandwidth  * b )
    135135{
    136136    return ( b != NULL ) && ( b->magicNumber == MAGIC_NUMBER );
     
    146146 * @see tr_bandwidthGetDesiredSpeed
    147147 */
    148 static inline void tr_bandwidthSetDesiredSpeed( tr_bandwidth        * bandwidth,
     148static TR_INLINE void tr_bandwidthSetDesiredSpeed( tr_bandwidth        * bandwidth,
    149149                                                tr_direction          dir,
    150150                                                double                desiredSpeed )
     
    157157 * @see tr_bandwidthSetDesiredSpeed
    158158 */
    159 static inline double
     159static TR_INLINE double
    160160tr_bandwidthGetDesiredSpeed( const tr_bandwidth  * bandwidth,
    161161                             tr_direction          dir )
     
    167167 * @brief Set whether or not this bandwidth should throttle its peer-io's speeds
    168168 */
    169 static inline void tr_bandwidthSetLimited( tr_bandwidth        * bandwidth,
     169static TR_INLINE void tr_bandwidthSetLimited( tr_bandwidth        * bandwidth,
    170170                                           tr_direction          dir,
    171171                                           tr_bool               isLimited )
     
    177177 * @return nonzero if this bandwidth throttles its peer-ios speeds
    178178 */
    179 static inline tr_bool tr_bandwidthIsLimited( const tr_bandwidth  * bandwidth,
     179static TR_INLINE tr_bool tr_bandwidthIsLimited( const tr_bandwidth  * bandwidth,
    180180                                             tr_direction          dir )
    181181{
     
    233233 * in that particular case we want to ignore the global speed limit...
    234234 */
    235 static inline void tr_bandwidthHonorParentLimits ( tr_bandwidth        * bandwidth,
     235static TR_INLINE void tr_bandwidthHonorParentLimits ( tr_bandwidth        * bandwidth,
    236236                                                   tr_direction          direction,
    237237                                                   tr_bool               isEnabled )
  • trunk/libtransmission/bencode.h

    r7658 r7663  
    4545    } val;
    4646} tr_benc;
     47
     48#ifdef __cplusplus
     49extern "C" {
     50#endif
    4751
    4852/***
     
    157161tr_bool   tr_bencGetStr( const tr_benc * val, const char ** setme );
    158162
    159 static inline tr_bool tr_bencIsType  ( const tr_benc * b, int type ) { return ( b != NULL ) && ( b->type == type ); }
    160 static inline tr_bool tr_bencIsInt   ( const tr_benc * b ) { return tr_bencIsType( b, TYPE_INT ); }
    161 static inline tr_bool tr_bencIsDict  ( const tr_benc * b ) { return tr_bencIsType( b, TYPE_DICT ); }
    162 static inline tr_bool tr_bencIsList  ( const tr_benc * b ) { return tr_bencIsType( b, TYPE_LIST ); }
    163 static inline tr_bool tr_bencIsString( const tr_benc * b ) { return tr_bencIsType( b, TYPE_STR ); }
     163static TR_INLINE tr_bool tr_bencIsType  ( const tr_benc * b, int type ) { return ( b != NULL ) && ( b->type == type ); }
     164static TR_INLINE tr_bool tr_bencIsInt   ( const tr_benc * b ) { return tr_bencIsType( b, TYPE_INT ); }
     165static TR_INLINE tr_bool tr_bencIsDict  ( const tr_benc * b ) { return tr_bencIsType( b, TYPE_DICT ); }
     166static TR_INLINE tr_bool tr_bencIsList  ( const tr_benc * b ) { return tr_bencIsType( b, TYPE_LIST ); }
     167static TR_INLINE tr_bool tr_bencIsString( const tr_benc * b ) { return tr_bencIsType( b, TYPE_STR ); }
    164168
    165169/**
     
    185189void  tr_bencMergeDicts( tr_benc * target, const tr_benc * source );
    186190
     191#ifdef __cplusplus
     192}
    187193#endif
     194
     195#endif
  • trunk/libtransmission/completion.h

    r7632 r7663  
    6262tr_completion * tr_cpDestruct( tr_completion * );
    6363
    64 static inline tr_completion* tr_cpNew( tr_torrent * tor )
     64static TR_INLINE tr_completion* tr_cpNew( tr_torrent * tor )
    6565{
    6666    return tr_cpConstruct( tr_new0( tr_completion, 1 ), tor );
    6767}
    6868
    69 static inline void tr_cpFree( tr_completion * cp )
     69static TR_INLINE void tr_cpFree( tr_completion * cp )
    7070{
    7171    tr_free( tr_cpDestruct( cp ) );
     
    8888                                               int                     tabCount );
    8989
    90 static inline uint64_t tr_cpHaveTotal( const tr_completion * cp )
     90static TR_INLINE uint64_t tr_cpHaveTotal( const tr_completion * cp )
    9191{
    9292    return cp->sizeNow;
    9393}
    9494
    95 static inline uint64_t tr_cpLeftUntilComplete( const tr_completion * cp )
     95static TR_INLINE uint64_t tr_cpLeftUntilComplete( const tr_completion * cp )
    9696{
    9797    return tr_torrentInfo(cp->tor)->totalSize - cp->sizeNow;
    9898}
    9999
    100 static inline uint64_t tr_cpLeftUntilDone( const tr_completion * cp )
     100static TR_INLINE uint64_t tr_cpLeftUntilDone( const tr_completion * cp )
    101101{
    102102    return tr_cpSizeWhenDone( cp ) - cp->sizeNow;
    103103}
    104104
    105 static inline float tr_cpPercentComplete( const tr_completion * cp )
     105static TR_INLINE float tr_cpPercentComplete( const tr_completion * cp )
    106106{
    107107    return tr_getRatio( cp->sizeNow, tr_torrentInfo(cp->tor)->totalSize );
    108108}
    109109
    110 static inline float tr_cpPercentDone( const tr_completion * cp )
     110static TR_INLINE float tr_cpPercentDone( const tr_completion * cp )
    111111{
    112112    return tr_getRatio( cp->sizeNow, tr_cpSizeWhenDone( cp ) );
     
    133133**/
    134134
    135 static inline int tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) {
     135static TR_INLINE int tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) {
    136136    return tr_bitfieldHas( &cp->blockBitfield, block );
    137137}
     
    147147***/
    148148
    149 static inline const struct tr_bitfield * tr_cpPieceBitfield( const tr_completion * cp ) {
     149static TR_INLINE const struct tr_bitfield * tr_cpPieceBitfield( const tr_completion * cp ) {
    150150    return &cp->pieceBitfield;
    151151}
    152152
    153 static inline const struct tr_bitfield * tr_cpBlockBitfield( const tr_completion * cp ) {
     153static TR_INLINE const struct tr_bitfield * tr_cpBlockBitfield( const tr_completion * cp ) {
    154154    assert( cp );
    155155    assert( cp->blockBitfield.bits );
  • trunk/libtransmission/net.c

    r7652 r7663  
    5959
    6060
     61#ifdef WIN32
     62static const char *
     63inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
     64{
     65    if (af == AF_INET)
     66    {
     67        struct sockaddr_in in;
     68        memset(&in, 0, sizeof(in));
     69        in.sin_family = AF_INET;
     70        memcpy(&in.sin_addr, src, sizeof(struct in_addr));
     71        getnameinfo((struct sockaddr *)&in, sizeof(struct
     72            sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST);
     73        return dst;
     74    }
     75    else if (af == AF_INET6)
     76    {
     77        struct sockaddr_in6 in;
     78        memset(&in, 0, sizeof(in));
     79        in.sin6_family = AF_INET6;
     80        memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
     81        getnameinfo((struct sockaddr *)&in, sizeof(struct
     82            sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST);
     83        return dst;
     84    }
     85    return NULL;
     86}
     87
     88static int
     89inet_pton(int af, const char *src, void *dst)
     90{
     91    struct addrinfo hints;
     92    struct addrinfo *res;
     93    struct addrinfo *ressave;
     94
     95    memset(&hints, 0, sizeof(struct addrinfo));
     96    hints.ai_family = af;
     97
     98    if (getaddrinfo(src, NULL, &hints, &res) != 0)
     99        return -1;
     100
     101    ressave = res;
     102
     103    while (res)
     104    {
     105        memcpy(dst, res->ai_addr, res->ai_addrlen);
     106        res = res->ai_next;
     107    }
     108
     109    freeaddrinfo(ressave);
     110    return 0;
     111}
     112
     113#endif
     114
     115
    61116void
    62117tr_netInit( void )
  • trunk/libtransmission/net.h

    r7652 r7663  
    4343
    4444#ifdef WIN32
    45  #define ECONNREFUSED WSAECONNREFUSED
    46  #define ECONNRESET   WSAECONNRESET
    47  #define EHOSTUNREACH WSAEHOSTUNREACH
    48  #define EINPROGRESS  WSAEINPROGRESS
    49  #define ENOTCONN     WSAENOTCONN
    50  #define EWOULDBLOCK  WSAEWOULDBLOCK
    51  #define sockerrno WSAGetLastError( )
     45 #define ECONNREFUSED            WSAECONNREFUSED
     46 #define ECONNRESET              WSAECONNRESET
     47 #define EHOSTUNREACH            WSAEHOSTUNREACH
     48 #define EINPROGRESS             WSAEINPROGRESS
     49 #define ENOTCONN                WSAENOTCONN
     50 #define EWOULDBLOCK             WSAEWOULDBLOCK
     51 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
     52 #define ENETUNREACH             WSAENETUNREACH
     53 #define sockerrno               WSAGetLastError( )
    5254#else
    5355 #include <errno.h>
     
    8991void tr_suspectAddress( const tr_address * a, const char * source );
    9092
    91 static inline tr_bool tr_isAddress( const tr_address * a ) { return ( a != NULL ) && ( a->type==TR_AF_INET || a->type==TR_AF_INET6 ); }
     93static TR_INLINE tr_bool tr_isAddress( const tr_address * a ) { return ( a != NULL ) && ( a->type==TR_AF_INET || a->type==TR_AF_INET6 ); }
    9294
    9395typedef struct tr_net_af_support
  • trunk/libtransmission/peer-io.h

    r7658 r7663  
    127127void        tr_peerIoEnableLTEP( tr_peerIo * io, tr_bool flag );
    128128
    129 static inline tr_bool tr_peerIoSupportsLTEP( const tr_peerIo * io )
     129static TR_INLINE tr_bool tr_peerIoSupportsLTEP( const tr_peerIo * io )
    130130{
    131131    assert( tr_isPeerIo( io ) );
     
    136136void        tr_peerIoEnableFEXT( tr_peerIo * io, tr_bool flag );
    137137
    138 static inline tr_bool tr_peerIoSupportsFEXT( const tr_peerIo * io )
     138static TR_INLINE tr_bool tr_peerIoSupportsFEXT( const tr_peerIo * io )
    139139{
    140140    assert( tr_isPeerIo( io ) );
     
    147147**/
    148148
    149 static inline tr_session* tr_peerIoGetSession ( tr_peerIo * io )
     149static TR_INLINE tr_session* tr_peerIoGetSession ( tr_peerIo * io )
    150150{
    151151    assert( tr_isPeerIo( io ) );
     
    158158                              tr_port                   port );
    159159
    160 static inline const char* tr_peerIoGetAddrStr( const tr_peerIo * io )
     160static TR_INLINE const char* tr_peerIoGetAddrStr( const tr_peerIo * io )
    161161{
    162162    return tr_peerIoAddrStr( &io->addr, io->port );
     
    175175int                  tr_peerIoReconnect( tr_peerIo * io );
    176176
    177 static inline tr_bool tr_peerIoIsIncoming( const tr_peerIo * io )
     177static TR_INLINE tr_bool tr_peerIoIsIncoming( const tr_peerIo * io )
    178178{
    179179    return io->isIncoming;
    180180}
    181181
    182 static inline int    tr_peerIoGetAge( const tr_peerIo * io )
     182static TR_INLINE int    tr_peerIoGetAge( const tr_peerIo * io )
    183183{
    184184    return time( NULL ) - io->timeCreated;
     
    193193                                          const uint8_t * peer_id );
    194194
    195 static inline const uint8_t* tr_peerIoGetPeersId( const tr_peerIo * io )
     195static TR_INLINE const uint8_t* tr_peerIoGetPeersId( const tr_peerIo * io )
    196196{
    197197    assert( tr_isPeerIo( io ) );
     
    230230**/
    231231
    232 static inline struct tr_crypto * tr_peerIoGetCrypto( tr_peerIo * io )
     232static TR_INLINE struct tr_crypto * tr_peerIoGetCrypto( tr_peerIo * io )
    233233{
    234234    return io->crypto;
     
    246246                                  int         encryptionMode );
    247247
    248 static inline tr_bool tr_peerIoIsEncrypted( const tr_peerIo * io )
     248static TR_INLINE tr_bool tr_peerIoIsEncrypted( const tr_peerIo * io )
    249249{
    250250    return ( io != NULL ) && ( io->encryptionMode == PEER_ENCRYPTION_RC4 );
     
    256256                               size_t            byteCount );
    257257
    258 static inline void  tr_peerIoWriteUint8( tr_peerIo *       io,
     258static TR_INLINE void  tr_peerIoWriteUint8( tr_peerIo *       io,
    259259                                         struct evbuffer * outbuf,
    260260                                         uint8_t           writeme )
     
    263263}
    264264
    265 static inline void tr_peerIoWriteUint16( tr_peerIo *       io,
     265static TR_INLINE void tr_peerIoWriteUint16( tr_peerIo *       io,
    266266                                         struct evbuffer * outbuf,
    267267                                         uint16_t          writeme )
     
    271271}
    272272
    273 static inline void tr_peerIoWriteUint32( tr_peerIo *       io,
     273static TR_INLINE void tr_peerIoWriteUint32( tr_peerIo *       io,
    274274                                         struct evbuffer * outbuf,
    275275                                         uint32_t          writeme )
     
    284284                              size_t            byteCount );
    285285
    286 static inline void tr_peerIoReadUint8( tr_peerIo *       io,
     286static TR_INLINE void tr_peerIoReadUint8( tr_peerIo *       io,
    287287                                       struct evbuffer * inbuf,
    288288                                       uint8_t *         setme )
     
    291291}
    292292
    293 static inline void tr_peerIoReadUint16( tr_peerIo *       io,
     293static TR_INLINE void tr_peerIoReadUint16( tr_peerIo *       io,
    294294                                        struct evbuffer * inbuf,
    295295                                        uint16_t *        setme )
     
    300300}
    301301
    302 static inline void tr_peerIoReadUint32( tr_peerIo *       io,
     302static TR_INLINE void tr_peerIoReadUint32( tr_peerIo *       io,
    303303                                        struct evbuffer * inbuf,
    304304                                        uint32_t *        setme )
     
    319319size_t    tr_peerIoGetWriteBufferSpace( const tr_peerIo * io, uint64_t now );
    320320
    321 static inline void tr_peerIoSetParent( tr_peerIo            * io,
     321static TR_INLINE void tr_peerIoSetParent( tr_peerIo            * io,
    322322                                       struct tr_bandwidth  * parent )
    323323{
     
    332332                                  int                   isPieceData );
    333333
    334 static inline tr_bool tr_peerIoHasBandwidthLeft( const tr_peerIo  * io,
     334static TR_INLINE tr_bool tr_peerIoHasBandwidthLeft( const tr_peerIo  * io,
    335335                                                 tr_direction       dir )
    336336{
     
    340340}
    341341
    342 static inline double tr_peerIoGetPieceSpeed( const tr_peerIo * io, uint64_t now, tr_direction dir )
     342static TR_INLINE double tr_peerIoGetPieceSpeed( const tr_peerIo * io, uint64_t now, tr_direction dir )
    343343{
    344344    assert( tr_isPeerIo( io ) );
     
    364364**/
    365365
    366 static inline struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io )
     366static TR_INLINE struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io )
    367367{
    368368    return io->inbuf;
  • trunk/libtransmission/peer-mgr.c

    r7658 r7663  
    160160**/
    161161
    162 static inline void
     162static TR_INLINE void
    163163managerLock( const struct tr_peerMgr * manager )
    164164{
     
    166166}
    167167
    168 static inline void
     168static TR_INLINE void
    169169managerUnlock( const struct tr_peerMgr * manager )
    170170{
     
    172172}
    173173
    174 static inline void
     174static TR_INLINE void
    175175torrentLock( Torrent * torrent )
    176176{
     
    178178}
    179179
    180 static inline void
     180static TR_INLINE void
    181181torrentUnlock( Torrent * torrent )
    182182{
     
    184184}
    185185
    186 static inline int
     186static TR_INLINE int
    187187torrentIsLocked( const Torrent * t )
    188188{
  • trunk/libtransmission/peer-msgs.c

    r7658 r7663  
    247247}
    248248
    249 static inline void
     249static TR_INLINE void
    250250dbgOutMessageLen( tr_peermsgs * msgs )
    251251{
     
    820820}
    821821
    822 static inline int
     822static TR_INLINE int
    823823requestQueueIsFull( const tr_peermsgs * msgs )
    824824{
     
    15071507}
    15081508
    1509 static inline void
     1509static TR_INLINE void
    15101510decrementDownloadedCount( tr_peermsgs * msgs, uint32_t byteCount )
    15111511{
     
    15151515}
    15161516
    1517 static inline void
     1517static TR_INLINE void
    15181518clientGotUnwantedBlock( tr_peermsgs * msgs, const struct peer_request * req )
    15191519{
     
    18831883}
    18841884
    1885 static inline void
     1885static TR_INLINE void
    18861886pexDroppedCb( void * vpex,
    18871887              void * userData )
     
    18961896}
    18971897
    1898 static inline void
     1898static TR_INLINE void
    18991899pexElementCb( void * vpex,
    19001900              void * userData )
     
    20682068}
    20692069
    2070 static inline int
     2070static TR_INLINE int
    20712071pexPulse( void * vpeer )
    20722072{
  • trunk/libtransmission/platform.c

    r7658 r7663  
    240240            char appdata[MAX_PATH]; /* SHGetFolderPath() requires MAX_PATH */
    241241            *appdata = '\0';
    242             SHGetFolderPath( NULL, CSIDL_MYDOCUMENTS, NULL, 0, appdata );
     242            SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, 0, appdata );
    243243            home = tr_strdup( appdata );
    244244#else
  • trunk/libtransmission/ptrarray.h

    r7658 r7663  
    6767                               int          * size );
    6868
    69 static inline void  tr_ptrArrayClear( tr_ptrArray * a ) { a->n_items = 0; }
     69static TR_INLINE void  tr_ptrArrayClear( tr_ptrArray * a ) { a->n_items = 0; }
    7070
    7171int           tr_ptrArrayInsert( tr_ptrArray * array,
     
    7373                                 int           pos );
    7474
    75 static inline int tr_ptrArrayAppend( tr_ptrArray * array, void * appendMe )
     75static TR_INLINE int tr_ptrArrayAppend( tr_ptrArray * array, void * appendMe )
    7676{
    7777    return tr_ptrArrayInsert( array, appendMe, -1 );
     
    8484                                int            end );
    8585
    86 static inline void** tr_ptrArrayBase( const tr_ptrArray * a )
     86static TR_INLINE void** tr_ptrArrayBase( const tr_ptrArray * a )
    8787{
    8888    return a->items;
    8989}
    9090
    91 static inline int tr_ptrArraySize( const tr_ptrArray *  a )
     91static TR_INLINE int tr_ptrArraySize( const tr_ptrArray *  a )
    9292{
    9393    return a->n_items;
    9494}
    9595
    96 static inline tr_bool tr_ptrArrayEmpty( const tr_ptrArray * a )
     96static TR_INLINE tr_bool tr_ptrArrayEmpty( const tr_ptrArray * a )
    9797{
    9898    return tr_ptrArraySize(a) == 0;
  • trunk/libtransmission/ratecontrol.h

    r7618 r7663  
    6464***/
    6565
    66 static inline void tr_rcConstruct ( tr_ratecontrol * rc ) { memset( rc, 0, sizeof( tr_ratecontrol ) ); }
     66static TR_INLINE void tr_rcConstruct ( tr_ratecontrol * rc ) { memset( rc, 0, sizeof( tr_ratecontrol ) ); }
    6767
    68 static inline void tr_rcDestruct  ( tr_ratecontrol * rc ) { memset( rc, 0xDEAD, sizeof( tr_ratecontrol ) ); }
     68static TR_INLINE void tr_rcDestruct  ( tr_ratecontrol * rc ) { memset( rc, 0xDEAD, sizeof( tr_ratecontrol ) ); }
    6969
    7070void             tr_rcTransferred ( tr_ratecontrol         * ratecontrol,
  • trunk/libtransmission/torrent.c

    r7648 r7663  
    378378/* the tiers will be sorted from lowest to highest,
    379379 * and trackers are randomized within the tiers */
    380 static inline int
     380static TR_INLINE int
    381381compareRandomTracker( const void * va,
    382382                      const void * vb )
     
    654654}
    655655
    656 static inline void
     656static TR_INLINE void
    657657tr_torrentManualUpdateImpl( void * vtor )
    658658{
  • trunk/libtransmission/torrent.h

    r7632 r7663  
    197197
    198198/* get the index of this piece's first block */
    199 static inline tr_block_index_t
     199static TR_INLINE tr_block_index_t
    200200tr_torPieceFirstBlock( const tr_torrent * tor, const tr_piece_index_t piece )
    201201{
     
    204204
    205205/* what piece index is this block in? */
    206 static inline tr_piece_index_t
     206static TR_INLINE tr_piece_index_t
    207207tr_torBlockPiece( const tr_torrent * tor, const tr_block_index_t block )
    208208{
     
    211211
    212212/* how many blocks are in this piece? */
    213 static inline uint32_t
     213static TR_INLINE uint32_t
    214214tr_torPieceCountBlocks( const tr_torrent * tor, const tr_piece_index_t piece )
    215215{
     
    219219
    220220/* how many bytes are in this piece? */
    221 static inline uint32_t
     221static TR_INLINE uint32_t
    222222tr_torPieceCountBytes( const tr_torrent * tor, const tr_piece_index_t piece )
    223223{
     
    227227
    228228/* how many bytes are in this block? */
    229 static inline uint32_t
     229static TR_INLINE uint32_t
    230230tr_torBlockCountBytes( const tr_torrent * tor, const tr_block_index_t block )
    231231{
     
    234234}
    235235
    236 static inline void tr_torrentLock( const tr_torrent * tor )
     236static TR_INLINE void tr_torrentLock( const tr_torrent * tor )
    237237{
    238238    tr_globalLock( tor->session );
    239239}
    240240
    241 static inline void tr_torrentUnlock( const tr_torrent * tor )
     241static TR_INLINE void tr_torrentUnlock( const tr_torrent * tor )
    242242{
    243243    tr_globalUnlock( tor->session );
    244244}
    245245
    246 static inline tr_bool
     246static TR_INLINE tr_bool
    247247tr_torrentExists( const tr_session * session, const uint8_t *   torrentHash )
    248248{
     
    250250}
    251251
    252 static inline tr_bool
     252static TR_INLINE tr_bool
    253253tr_torrentIsSeed( const tr_torrent * tor )
    254254{
     
    256256}
    257257
    258 static inline tr_bool tr_torrentIsPrivate( const tr_torrent * tor )
     258static TR_INLINE tr_bool tr_torrentIsPrivate( const tr_torrent * tor )
    259259{
    260260    return ( tor != NULL ) && tor->info.isPrivate;
    261261}
    262262
    263 static inline tr_bool tr_torrentAllowsPex( const tr_torrent * tor )
     263static TR_INLINE tr_bool tr_torrentAllowsPex( const tr_torrent * tor )
    264264{
    265265    return ( tor != NULL  ) && tor->session->isPexEnabled && !tr_torrentIsPrivate( tor );
    266266}
    267267
    268 static inline tr_bool tr_torrentIsPieceChecked( const tr_torrent  * tor, tr_piece_index_t i )
     268static TR_INLINE tr_bool tr_torrentIsPieceChecked( const tr_torrent  * tor, tr_piece_index_t i )
    269269{
    270270    return tr_bitfieldHas( &tor->checkedPieces, i );
  • trunk/libtransmission/transmission.h

    r7652 r7663  
    5151#include <time.h> /* time_t */
    5252
    53 #if defined(_MSC_VER) && !defined( __cplusplus )
    54  #define inline __inline
     53#if defined( WIN32 ) && defined(_MSC_VER)
     54 #define TR_INLINE __inline
     55#else
     56 #define TR_INLINE inline
    5557#endif
    5658
     
    14231425
    14241426/** @brief Sanity checker to test that the direction is TR_UP or TR_DOWN */
    1425 static inline tr_bool tr_isDirection( tr_direction d ) { return d==TR_UP || d==TR_DOWN; }
     1427static TR_INLINE tr_bool tr_isDirection( tr_direction d ) { return d==TR_UP || d==TR_DOWN; }
    14261428
    14271429/** @brief Sanity checker to test that a bool is TRUE or FALSE */
    1428 static inline tr_bool tr_isBool( tr_bool b ) { return b==1 || b==0; }
     1430static TR_INLINE tr_bool tr_isBool( tr_bool b ) { return b==1 || b==0; }
    14291431
    14301432/** @} */
  • trunk/libtransmission/utils.h

    r7656 r7663  
    275275***/
    276276
    277 static inline void* tr_malloc( size_t size )
     277static TR_INLINE void* tr_malloc( size_t size )
    278278{
    279279    return size ? malloc( size ) : NULL;
    280280}
    281 static inline void* tr_malloc0( size_t size )
     281static TR_INLINE void* tr_malloc0( size_t size )
    282282{
    283283    return size ? calloc( 1, size ) : NULL;
    284284}
    285 static inline void tr_free( void * p )
     285static TR_INLINE void tr_free( void * p )
    286286{
    287287    if( p != NULL )
    288288        free( p );
    289289}
    290 static inline void* tr_memdup( const void * src, int byteCount )
     290static TR_INLINE void* tr_memdup( const void * src, int byteCount )
    291291{
    292292    return memcpy( tr_malloc( byteCount ), src, byteCount );
     
    302302    ( (struct_type *) realloc ( ( mem ), ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( n_structs ) ) ) )
    303303
    304 char*       tr_strndup( const void * str, int len ) TR_GNUC_MALLOC;
    305 
    306 static inline char* tr_strdup( const void * in )
    307 {
    308     return tr_strndup( in, in ? strlen( in ) : 0 );
     304/** @param in is a void* so that callers can pass in both signed & unsigned without a cast */
     305char* tr_strndup( const void * in, int len ) TR_GNUC_MALLOC;
     306
     307/** @param in is a void* so that callers can pass in both signed & unsigned without a cast */
     308static TR_INLINE char* tr_strdup( const void * in )
     309{
     310    return tr_strndup( in, in ? strlen( (const char *) in ) : 0 );
    309311}
    310312
     
    388390tr_bitfield* tr_bitfieldDestruct( tr_bitfield* );
    389391
    390 static inline tr_bitfield* tr_bitfieldNew( size_t bitcount )
     392static TR_INLINE tr_bitfield* tr_bitfieldNew( size_t bitcount )
    391393{
    392394    return tr_bitfieldConstruct( tr_new0( tr_bitfield, 1 ), bitcount );
    393395}
    394396
    395 static inline void tr_bitfieldFree( tr_bitfield * b )
     397static TR_INLINE void tr_bitfieldFree( tr_bitfield * b )
    396398{
    397399    tr_free( tr_bitfieldDestruct( b ) );
     
    423425    need to call tr_bitfieldTestFast() first before you
    424426    start looping. */
    425 static inline tr_bool tr_bitfieldHasFast( const tr_bitfield * b, const size_t nth )
     427static TR_INLINE tr_bool tr_bitfieldHasFast( const tr_bitfield * b, const size_t nth )
    426428{
    427429    return ( b->bits[nth>>3u] << ( nth & 7u ) & 0x80 ) != 0;
     
    429431
    430432/** @param high the highest nth bit you're going to access */
    431 static inline tr_bool tr_bitfieldTestFast( const tr_bitfield * b, const size_t high )
     433static TR_INLINE tr_bool tr_bitfieldTestFast( const tr_bitfield * b, const size_t high )
    432434{
    433435    return ( b != NULL )
     
    436438}
    437439
    438 static inline tr_bool tr_bitfieldHas( const tr_bitfield * b, size_t nth )
     440static TR_INLINE tr_bool tr_bitfieldHas( const tr_bitfield * b, size_t nth )
    439441{
    440442    return tr_bitfieldTestFast( b, nth ) && tr_bitfieldHasFast( b, nth );
Note: See TracChangeset for help on using the changeset viewer.