mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
(trunk libT) #3617 "1000+ warnings of 'inlining failed' in libtransmission when compiled with gcc 4.4.4" -- fixed.
This commit is contained in:
parent
de4ab85030
commit
8d15c48a3f
10 changed files with 139 additions and 86 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "bitfield.h"
|
||||
#include "bitset.h"
|
||||
|
||||
tr_bitfield*
|
||||
tr_bitfieldConstruct( tr_bitfield * b, size_t bitCount )
|
||||
|
@ -209,3 +210,24 @@ tr_bitfieldCountTrueBits( const tr_bitfield* b )
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
void
|
||||
tr_bitsetReserve( tr_bitset * b, size_t size )
|
||||
{
|
||||
if( b->bitfield.bitCount < size )
|
||||
{
|
||||
tr_bitfield * tmp = tr_bitfieldDup( &b->bitfield );
|
||||
|
||||
tr_bitfieldDestruct( &b->bitfield );
|
||||
tr_bitfieldConstruct( &b->bitfield, size );
|
||||
|
||||
if( ( tmp->bits != NULL ) && ( tmp->byteCount > 0 ) )
|
||||
memcpy( b->bitfield.bits, tmp->bits, tmp->byteCount );
|
||||
|
||||
tr_bitfieldFree( tmp );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,22 +41,7 @@ tr_bitsetDestructor( tr_bitset * b )
|
|||
tr_bitfieldDestruct( &b->bitfield );
|
||||
}
|
||||
|
||||
static inline void
|
||||
tr_bitsetReserve( tr_bitset * b, size_t size )
|
||||
{
|
||||
if( b->bitfield.bitCount < size )
|
||||
{
|
||||
tr_bitfield * tmp = tr_bitfieldDup( &b->bitfield );
|
||||
|
||||
tr_bitfieldDestruct( &b->bitfield );
|
||||
tr_bitfieldConstruct( &b->bitfield, size );
|
||||
|
||||
if( ( tmp->bits != NULL ) && ( tmp->byteCount > 0 ) )
|
||||
memcpy( b->bitfield.bits, tmp->bits, tmp->byteCount );
|
||||
|
||||
tr_bitfieldFree( tmp );
|
||||
}
|
||||
}
|
||||
void tr_bitsetReserve( tr_bitset * b, size_t size );
|
||||
|
||||
static inline tr_bool
|
||||
tr_bitsetHasFast( const tr_bitset * b, const size_t nth )
|
||||
|
|
|
@ -612,6 +612,11 @@ tr_peerIoAddrStr( const tr_address * addr, tr_port port )
|
|||
return buf;
|
||||
}
|
||||
|
||||
const char* tr_peerIoGetAddrStr( const tr_peerIo * io )
|
||||
{
|
||||
return tr_isPeerIo( io ) ? tr_peerIoAddrStr( &io->addr, io->port ) : "error";
|
||||
}
|
||||
|
||||
void
|
||||
tr_peerIoSetIOFuncs( tr_peerIo * io,
|
||||
tr_can_read_cb readcb,
|
||||
|
@ -820,6 +825,24 @@ tr_peerIoWriteBuf( tr_peerIo * io,
|
|||
evbuffer_drain( buf, n );
|
||||
}
|
||||
|
||||
void
|
||||
tr_peerIoWriteUint16( tr_peerIo * io,
|
||||
struct evbuffer * outbuf,
|
||||
uint16_t writeme )
|
||||
{
|
||||
const uint16_t tmp = htons( writeme );
|
||||
tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint16_t ) );
|
||||
}
|
||||
|
||||
void
|
||||
tr_peerIoWriteUint32( tr_peerIo * io,
|
||||
struct evbuffer * outbuf,
|
||||
uint32_t writeme )
|
||||
{
|
||||
const uint32_t tmp = htonl( writeme );
|
||||
tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint32_t ) );
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
@ -851,6 +874,25 @@ tr_peerIoReadBytes( tr_peerIo * io,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tr_peerIoReadUint16( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint16_t * setme )
|
||||
{
|
||||
uint16_t tmp;
|
||||
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );
|
||||
*setme = ntohs( tmp );
|
||||
}
|
||||
|
||||
void tr_peerIoReadUint32( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint32_t * setme )
|
||||
{
|
||||
uint32_t tmp;
|
||||
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );
|
||||
*setme = ntohl( tmp );
|
||||
}
|
||||
|
||||
void
|
||||
tr_peerIoDrain( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
|
|
|
@ -192,10 +192,7 @@ static inline tr_session* tr_peerIoGetSession ( tr_peerIo * io )
|
|||
const char* tr_peerIoAddrStr( const struct tr_address * addr,
|
||||
tr_port port );
|
||||
|
||||
static inline const char* tr_peerIoGetAddrStr( const tr_peerIo * io )
|
||||
{
|
||||
return tr_isPeerIo( io ) ? tr_peerIoAddrStr( &io->addr, io->port ) : "error";
|
||||
}
|
||||
const char* tr_peerIoGetAddrStr( const tr_peerIo * io );
|
||||
|
||||
const struct tr_address * tr_peerIoGetAddress( const tr_peerIo * io,
|
||||
tr_port * port );
|
||||
|
@ -300,21 +297,13 @@ static inline void tr_peerIoWriteUint8( tr_peerIo * io,
|
|||
tr_peerIoWriteBytes( io, outbuf, &writeme, sizeof( uint8_t ) );
|
||||
}
|
||||
|
||||
static inline void tr_peerIoWriteUint16( tr_peerIo * io,
|
||||
struct evbuffer * outbuf,
|
||||
uint16_t writeme )
|
||||
{
|
||||
const uint16_t tmp = htons( writeme );
|
||||
tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint16_t ) );
|
||||
}
|
||||
void tr_peerIoWriteUint16( tr_peerIo * io,
|
||||
struct evbuffer * outbuf,
|
||||
uint16_t writeme );
|
||||
|
||||
static inline void tr_peerIoWriteUint32( tr_peerIo * io,
|
||||
struct evbuffer * outbuf,
|
||||
uint32_t writeme )
|
||||
{
|
||||
const uint32_t tmp = htonl( writeme );
|
||||
tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint32_t ) );
|
||||
}
|
||||
void tr_peerIoWriteUint32( tr_peerIo * io,
|
||||
struct evbuffer * outbuf,
|
||||
uint32_t writeme );
|
||||
|
||||
void tr_peerIoReadBytes( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
|
@ -328,23 +317,13 @@ static inline void tr_peerIoReadUint8( tr_peerIo * io,
|
|||
tr_peerIoReadBytes( io, inbuf, setme, sizeof( uint8_t ) );
|
||||
}
|
||||
|
||||
static inline void tr_peerIoReadUint16( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint16_t * setme )
|
||||
{
|
||||
uint16_t tmp;
|
||||
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );
|
||||
*setme = ntohs( tmp );
|
||||
}
|
||||
void tr_peerIoReadUint16( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint16_t * setme );
|
||||
|
||||
static inline void tr_peerIoReadUint32( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint32_t * setme )
|
||||
{
|
||||
uint32_t tmp;
|
||||
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );
|
||||
*setme = ntohl( tmp );
|
||||
}
|
||||
void tr_peerIoReadUint32( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
uint32_t * setme );
|
||||
|
||||
void tr_peerIoDrain( tr_peerIo * io,
|
||||
struct evbuffer * inbuf,
|
||||
|
|
|
@ -306,7 +306,7 @@ pokeBatchPeriod( tr_peermsgs * msgs,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
dbgOutMessageLen( tr_peermsgs * msgs )
|
||||
{
|
||||
dbgmsg( msgs, "outMessage size is now %zu", EVBUFFER_LENGTH( msgs->outMessages ) );
|
||||
|
|
|
@ -1161,7 +1161,7 @@ tr_sessionGetActiveSpeedLimit_KBps( const tr_session * session,
|
|||
tr_direction dir,
|
||||
double * setme_KBps )
|
||||
{
|
||||
int Bps;
|
||||
int Bps = 0;
|
||||
const tr_bool is_active = tr_sessionGetActiveSpeedLimit_Bps( session, dir, &Bps );
|
||||
*setme_KBps = toSpeedKBps( Bps );
|
||||
return is_active;
|
||||
|
|
|
@ -401,7 +401,6 @@ static tr_bool
|
|||
tr_torrentIsSeedIdleLimitDone( tr_torrent * tor )
|
||||
{
|
||||
uint16_t idleMinutes;
|
||||
#warning can this use the idleSecs from tr_stat?
|
||||
return tr_torrentGetSeedIdle( tor, &idleMinutes )
|
||||
&& difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= idleMinutes * 60u;
|
||||
}
|
||||
|
|
|
@ -254,7 +254,8 @@ static int lpd_extractParam( const char* const str, const char* const name, int
|
|||
|
||||
/**
|
||||
* @brief Configures additional capabilities for a socket */
|
||||
static inline int lpd_configureSocket( int sock, int add )
|
||||
static int
|
||||
lpd_configureSocket( int sock, int add )
|
||||
{
|
||||
#ifdef WIN32
|
||||
unsigned long flags = 1;
|
||||
|
|
|
@ -333,6 +333,35 @@ tr_msg( const char * file, int line,
|
|||
****
|
||||
***/
|
||||
|
||||
void*
|
||||
tr_malloc( size_t size )
|
||||
{
|
||||
return size ? malloc( size ) : NULL;
|
||||
}
|
||||
|
||||
void*
|
||||
tr_malloc0( size_t size )
|
||||
{
|
||||
return size ? calloc( 1, size ) : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
tr_free( void * p )
|
||||
{
|
||||
if( p != NULL )
|
||||
free( p );
|
||||
}
|
||||
|
||||
void*
|
||||
tr_memdup( const void * src, size_t byteCount )
|
||||
{
|
||||
return memcpy( tr_malloc( byteCount ), src, byteCount );
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
void
|
||||
tr_set_compare( const void * va,
|
||||
size_t aCount,
|
||||
|
@ -660,6 +689,12 @@ tr_buildPath( const char *first_element, ... )
|
|||
*****
|
||||
****/
|
||||
|
||||
char*
|
||||
tr_strdup( const void * in )
|
||||
{
|
||||
return tr_strndup( in, in ? (int)strlen((const char *)in) : 0 );
|
||||
}
|
||||
|
||||
char*
|
||||
tr_strndup( const void * in, int len )
|
||||
{
|
||||
|
@ -1128,6 +1163,19 @@ tr_base64_decode( const void * input,
|
|||
****
|
||||
***/
|
||||
|
||||
void
|
||||
tr_removeElementFromArray( void * array,
|
||||
unsigned int index_to_remove,
|
||||
size_t sizeof_element,
|
||||
size_t nmemb )
|
||||
{
|
||||
char * a = (char*) array;
|
||||
|
||||
memmove( a + sizeof_element * index_to_remove,
|
||||
a + sizeof_element * ( index_to_remove + 1 ),
|
||||
sizeof_element * ( --nmemb - index_to_remove ) );
|
||||
}
|
||||
|
||||
int
|
||||
tr_lowerBound( const void * key,
|
||||
const void * base,
|
||||
|
|
|
@ -295,23 +295,13 @@ char* tr_utf8clean( const char * str, int len ) TR_GNUC_MALLOC;
|
|||
***/
|
||||
|
||||
/** @brief Portability wrapper around malloc() in which `0' is a safe argument */
|
||||
static inline void* tr_malloc( size_t size )
|
||||
{
|
||||
return size ? malloc( size ) : NULL;
|
||||
}
|
||||
void* tr_malloc( size_t size );
|
||||
|
||||
/** @brief Portability wrapper around calloc() in which `0' is a safe argument */
|
||||
static inline void* tr_malloc0( size_t size )
|
||||
{
|
||||
return size ? calloc( 1, size ) : NULL;
|
||||
}
|
||||
void* tr_malloc0( size_t size );
|
||||
|
||||
/** @brief Portability wrapper around free() in which `NULL' is a safe argument */
|
||||
static inline void tr_free( void * p )
|
||||
{
|
||||
if( p != NULL )
|
||||
free( p );
|
||||
}
|
||||
void tr_free( void * p );
|
||||
|
||||
/**
|
||||
* @brief make a newly-allocated copy of a chunk of memory
|
||||
|
@ -319,10 +309,7 @@ static inline void tr_free( void * p )
|
|||
* @param byteCount the number of bytes to copy
|
||||
* @return a newly-allocated copy of `src' that can be freed with tr_free()
|
||||
*/
|
||||
static inline void* tr_memdup( const void * src, size_t byteCount )
|
||||
{
|
||||
return memcpy( tr_malloc( byteCount ), src, byteCount );
|
||||
}
|
||||
void* tr_memdup( const void * src, size_t byteCount );
|
||||
|
||||
#define tr_new( struct_type, n_structs ) \
|
||||
( (struct_type *) tr_malloc ( ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( n_structs ) ) ) )
|
||||
|
@ -348,10 +335,7 @@ char* tr_strndup( const void * in, int len ) TR_GNUC_MALLOC;
|
|||
* @param in is a void* so that callers can pass in both signed & unsigned without a cast
|
||||
* @return a newly-allocated copy of `in' that can be freed with tr_free()
|
||||
*/
|
||||
static inline char* tr_strdup( const void * in )
|
||||
{
|
||||
return tr_strndup( in, in ? (int)strlen((const char *)in) : 0 );
|
||||
}
|
||||
char* tr_strdup( const void * in );
|
||||
|
||||
/** @brief similar to bsearch() but returns the index of the lower bound */
|
||||
int tr_lowerBound( const void * key,
|
||||
|
@ -520,17 +504,10 @@ int tr_moveFile( const char * oldpath, const char * newpath,
|
|||
tr_bool * renamed ) TR_GNUC_NONNULL(1,2);
|
||||
|
||||
/** @brief convenience function to remove an item from an array */
|
||||
static inline void tr_removeElementFromArray( void * array,
|
||||
unsigned int index_to_remove,
|
||||
size_t sizeof_element,
|
||||
size_t nmemb )
|
||||
{
|
||||
char * a = (char*) array;
|
||||
|
||||
memmove( a + sizeof_element * index_to_remove,
|
||||
a + sizeof_element * ( index_to_remove + 1 ),
|
||||
sizeof_element * ( --nmemb - index_to_remove ) );
|
||||
}
|
||||
void tr_removeElementFromArray( void * array,
|
||||
unsigned int index_to_remove,
|
||||
size_t sizeof_element,
|
||||
size_t nmemb );
|
||||
|
||||
/***
|
||||
****
|
||||
|
|
Loading…
Add table
Reference in a new issue