1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-04 02:28:03 +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:
Charles Kerr 2010-10-11 15:41:27 +00:00
parent de4ab85030
commit 8d15c48a3f
10 changed files with 139 additions and 86 deletions

View file

@ -15,6 +15,7 @@
#include "transmission.h" #include "transmission.h"
#include "bitfield.h" #include "bitfield.h"
#include "bitset.h"
tr_bitfield* tr_bitfield*
tr_bitfieldConstruct( tr_bitfield * b, size_t bitCount ) tr_bitfieldConstruct( tr_bitfield * b, size_t bitCount )
@ -209,3 +210,24 @@ tr_bitfieldCountTrueBits( const tr_bitfield* b )
return ret; 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 );
}
}

View file

@ -41,22 +41,7 @@ tr_bitsetDestructor( tr_bitset * b )
tr_bitfieldDestruct( &b->bitfield ); tr_bitfieldDestruct( &b->bitfield );
} }
static inline void void tr_bitsetReserve( tr_bitset * b, size_t size );
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 );
}
}
static inline tr_bool static inline tr_bool
tr_bitsetHasFast( const tr_bitset * b, const size_t nth ) tr_bitsetHasFast( const tr_bitset * b, const size_t nth )

View file

@ -612,6 +612,11 @@ tr_peerIoAddrStr( const tr_address * addr, tr_port port )
return buf; return buf;
} }
const char* tr_peerIoGetAddrStr( const tr_peerIo * io )
{
return tr_isPeerIo( io ) ? tr_peerIoAddrStr( &io->addr, io->port ) : "error";
}
void void
tr_peerIoSetIOFuncs( tr_peerIo * io, tr_peerIoSetIOFuncs( tr_peerIo * io,
tr_can_read_cb readcb, tr_can_read_cb readcb,
@ -820,6 +825,24 @@ tr_peerIoWriteBuf( tr_peerIo * io,
evbuffer_drain( buf, n ); 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 void
tr_peerIoDrain( tr_peerIo * io, tr_peerIoDrain( tr_peerIo * io,
struct evbuffer * inbuf, struct evbuffer * inbuf,

View file

@ -192,10 +192,7 @@ static inline tr_session* tr_peerIoGetSession ( tr_peerIo * io )
const char* tr_peerIoAddrStr( const struct tr_address * addr, const char* tr_peerIoAddrStr( const struct tr_address * addr,
tr_port port ); tr_port port );
static inline const char* tr_peerIoGetAddrStr( const tr_peerIo * io ) const char* tr_peerIoGetAddrStr( const tr_peerIo * io );
{
return tr_isPeerIo( io ) ? tr_peerIoAddrStr( &io->addr, io->port ) : "error";
}
const struct tr_address * tr_peerIoGetAddress( const tr_peerIo * io, const struct tr_address * tr_peerIoGetAddress( const tr_peerIo * io,
tr_port * port ); tr_port * port );
@ -300,21 +297,13 @@ static inline void tr_peerIoWriteUint8( tr_peerIo * io,
tr_peerIoWriteBytes( io, outbuf, &writeme, sizeof( uint8_t ) ); tr_peerIoWriteBytes( io, outbuf, &writeme, sizeof( uint8_t ) );
} }
static inline void tr_peerIoWriteUint16( tr_peerIo * io, void tr_peerIoWriteUint16( tr_peerIo * io,
struct evbuffer * outbuf, struct evbuffer * outbuf,
uint16_t writeme ) uint16_t writeme );
{
const uint16_t tmp = htons( writeme );
tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint16_t ) );
}
static inline void tr_peerIoWriteUint32( tr_peerIo * io, void tr_peerIoWriteUint32( tr_peerIo * io,
struct evbuffer * outbuf, struct evbuffer * outbuf,
uint32_t writeme ) uint32_t writeme );
{
const uint32_t tmp = htonl( writeme );
tr_peerIoWriteBytes( io, outbuf, &tmp, sizeof( uint32_t ) );
}
void tr_peerIoReadBytes( tr_peerIo * io, void tr_peerIoReadBytes( tr_peerIo * io,
struct evbuffer * inbuf, struct evbuffer * inbuf,
@ -328,23 +317,13 @@ static inline void tr_peerIoReadUint8( tr_peerIo * io,
tr_peerIoReadBytes( io, inbuf, setme, sizeof( uint8_t ) ); tr_peerIoReadBytes( io, inbuf, setme, sizeof( uint8_t ) );
} }
static inline void tr_peerIoReadUint16( tr_peerIo * io, void tr_peerIoReadUint16( tr_peerIo * io,
struct evbuffer * inbuf, struct evbuffer * inbuf,
uint16_t * setme ) uint16_t * setme );
{
uint16_t tmp;
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );
*setme = ntohs( tmp );
}
static inline void tr_peerIoReadUint32( tr_peerIo * io, void tr_peerIoReadUint32( tr_peerIo * io,
struct evbuffer * inbuf, struct evbuffer * inbuf,
uint32_t * setme ) uint32_t * setme );
{
uint32_t tmp;
tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );
*setme = ntohl( tmp );
}
void tr_peerIoDrain( tr_peerIo * io, void tr_peerIoDrain( tr_peerIo * io,
struct evbuffer * inbuf, struct evbuffer * inbuf,

View file

@ -306,7 +306,7 @@ pokeBatchPeriod( tr_peermsgs * msgs,
} }
} }
static inline void static void
dbgOutMessageLen( tr_peermsgs * msgs ) dbgOutMessageLen( tr_peermsgs * msgs )
{ {
dbgmsg( msgs, "outMessage size is now %zu", EVBUFFER_LENGTH( msgs->outMessages ) ); dbgmsg( msgs, "outMessage size is now %zu", EVBUFFER_LENGTH( msgs->outMessages ) );

View file

@ -1161,7 +1161,7 @@ tr_sessionGetActiveSpeedLimit_KBps( const tr_session * session,
tr_direction dir, tr_direction dir,
double * setme_KBps ) double * setme_KBps )
{ {
int Bps; int Bps = 0;
const tr_bool is_active = tr_sessionGetActiveSpeedLimit_Bps( session, dir, &Bps ); const tr_bool is_active = tr_sessionGetActiveSpeedLimit_Bps( session, dir, &Bps );
*setme_KBps = toSpeedKBps( Bps ); *setme_KBps = toSpeedKBps( Bps );
return is_active; return is_active;

View file

@ -401,7 +401,6 @@ static tr_bool
tr_torrentIsSeedIdleLimitDone( tr_torrent * tor ) tr_torrentIsSeedIdleLimitDone( tr_torrent * tor )
{ {
uint16_t idleMinutes; uint16_t idleMinutes;
#warning can this use the idleSecs from tr_stat?
return tr_torrentGetSeedIdle( tor, &idleMinutes ) return tr_torrentGetSeedIdle( tor, &idleMinutes )
&& difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= idleMinutes * 60u; && difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= idleMinutes * 60u;
} }

View file

@ -254,7 +254,8 @@ static int lpd_extractParam( const char* const str, const char* const name, int
/** /**
* @brief Configures additional capabilities for a socket */ * @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 #ifdef WIN32
unsigned long flags = 1; unsigned long flags = 1;

View file

@ -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 void
tr_set_compare( const void * va, tr_set_compare( const void * va,
size_t aCount, 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* char*
tr_strndup( const void * in, int len ) 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 int
tr_lowerBound( const void * key, tr_lowerBound( const void * key,
const void * base, const void * base,

View file

@ -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 */ /** @brief Portability wrapper around malloc() in which `0' is a safe argument */
static inline void* tr_malloc( size_t size ) void* tr_malloc( size_t size );
{
return size ? malloc( size ) : NULL;
}
/** @brief Portability wrapper around calloc() in which `0' is a safe argument */ /** @brief Portability wrapper around calloc() in which `0' is a safe argument */
static inline void* tr_malloc0( size_t size ) void* tr_malloc0( size_t size );
{
return size ? calloc( 1, size ) : NULL;
}
/** @brief Portability wrapper around free() in which `NULL' is a safe argument */ /** @brief Portability wrapper around free() in which `NULL' is a safe argument */
static inline void tr_free( void * p ) void tr_free( void * p );
{
if( p != NULL )
free( p );
}
/** /**
* @brief make a newly-allocated copy of a chunk of memory * @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 * @param byteCount the number of bytes to copy
* @return a newly-allocated copy of `src' that can be freed with tr_free() * @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 ) void* tr_memdup( const void * src, size_t byteCount );
{
return memcpy( tr_malloc( byteCount ), src, byteCount );
}
#define tr_new( struct_type, n_structs ) \ #define tr_new( struct_type, n_structs ) \
( (struct_type *) tr_malloc ( ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( 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 * @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() * @return a newly-allocated copy of `in' that can be freed with tr_free()
*/ */
static inline char* tr_strdup( const void * in ) char* tr_strdup( const void * in );
{
return tr_strndup( in, in ? (int)strlen((const char *)in) : 0 );
}
/** @brief similar to bsearch() but returns the index of the lower bound */ /** @brief similar to bsearch() but returns the index of the lower bound */
int tr_lowerBound( const void * key, 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); tr_bool * renamed ) TR_GNUC_NONNULL(1,2);
/** @brief convenience function to remove an item from an array */ /** @brief convenience function to remove an item from an array */
static inline void tr_removeElementFromArray( void * array, void tr_removeElementFromArray( void * array,
unsigned int index_to_remove, unsigned int index_to_remove,
size_t sizeof_element, size_t sizeof_element,
size_t nmemb ) 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 ) );
}
/*** /***
**** ****