(libT) move the TR_GNUC macros from utils.h to a standalone header file so other libT headers can use them without getting an extra dependency tree.

This commit is contained in:
Charles Kerr 2008-10-22 18:42:37 +00:00
parent ee5797caa3
commit f0eddb5c20
10 changed files with 86 additions and 92 deletions

View File

@ -21,8 +21,6 @@
#include "lock.h"
#include "logo.h"
#define UNUSED G_GNUC_UNUSED
static TrCore * myCore = NULL;
static GtkActionGroup * myGroup = NULL;

View File

@ -88,6 +88,7 @@ noinst_HEADERS = \
torrent.h \
tracker.h \
tr-getopt.h \
tr-gnuc.h \
transmission.h \
trevent.h \
upnp.h \

View File

@ -13,32 +13,31 @@
#ifndef TR_BLOCKLIST_H
#define TR_BLOCKLIST_H
#include "tr-gnuc.h"
struct in_addr;
typedef struct tr_blocklist tr_blocklist;
tr_blocklist* _tr_blocklistNew( const char * filename,
int isEnabled );
int isEnabled ) TR_GNUC_MALLOC;
int _tr_blocklistExists( const tr_blocklist * );
int _tr_blocklistExists ( const tr_blocklist * blocklist );
const char* _tr_blocklistGetFilename( const tr_blocklist * );
const char* _tr_blocklistGetFilename ( const tr_blocklist * blocklist );
int _tr_blocklistGetRuleCount( const tr_blocklist * );
int _tr_blocklistGetRuleCount( const tr_blocklist * blocklist );
void _tr_blocklistFree( tr_blocklist * );
void _tr_blocklistFree ( tr_blocklist * blocklist );
int _tr_blocklistIsEnabled( tr_blocklist * );
int _tr_blocklistIsEnabled ( tr_blocklist * blocklist );
void _tr_blocklistSetEnabled( tr_blocklist *,
int isEnabled );
void _tr_blocklistSetEnabled ( tr_blocklist * blocklist,
int isEnabled );
int _tr_blocklistHasAddress(
tr_blocklist *,
const struct
in_addr * addr );
int _tr_blocklistHasAddress ( tr_blocklist * blocklist,
const struct in_addr * addr );
int _tr_blocklistSetContent(
tr_blocklist *,
const char * filename );
int _tr_blocklistSetContent ( tr_blocklist * blocklist,
const char * filename );
#endif

View File

@ -29,12 +29,12 @@ typedef int ( *handshakeDoneCB )( struct tr_handshake * handshake,
tr_handshake * tr_handshakeNew( struct tr_peerIo * io,
tr_encryption_mode encryptionMode,
handshakeDoneCB doneCB,
void * doneUserData );
void * doneUserData )
TR_GNUC_MALLOC;
const struct in_addr * tr_handshakeGetAddr(
const struct tr_handshake * handshake,
uint16_t
* setme_port );
const struct tr_handshake * handshake,
uint16_t * setme_port );
void tr_handshakeAbort( tr_handshake * handshake );

View File

@ -17,6 +17,8 @@
***
**/
#include "tr-gnuc.h"
struct in_addr;
struct evbuffer;
struct bufferevent;
@ -28,17 +30,17 @@ typedef struct tr_peerIo tr_peerIo;
***
**/
tr_peerIo* tr_peerIoNewOutgoing(
struct tr_handle * session,
const struct in_addr * addr,
int port,
const uint8_t *
torrentHash );
tr_peerIo* tr_peerIoNewOutgoing( struct tr_handle * session,
const struct in_addr * addr,
int port,
const uint8_t * torrentHash )
TR_GNUC_MALLOC;
tr_peerIo* tr_peerIoNewIncoming( struct tr_handle * session,
const struct in_addr * addr,
uint16_t port,
int socket );
tr_peerIo* tr_peerIoNewIncoming( struct tr_handle * session,
const struct in_addr * addr,
uint16_t port,
int socket )
TR_GNUC_MALLOC;
void tr_peerIoFree( tr_peerIo * io );
@ -68,13 +70,13 @@ const char* tr_peerIoAddrStr( const struct in_addr * addr,
const char* tr_peerIoGetAddrStr( const tr_peerIo * io );
const struct in_addr*tr_peerIoGetAddress( const tr_peerIo * io,
uint16_t * port );
uint16_t * port );
const uint8_t* tr_peerIoGetTorrentHash( tr_peerIo * io );
int tr_peerIoHasTorrentHash( const tr_peerIo * io );
void tr_peerIoSetTorrentHash( tr_peerIo * io,
void tr_peerIoSetTorrentHash( tr_peerIo * io,
const uint8_t * hash );
int tr_peerIoReconnect( tr_peerIo * io );
@ -121,11 +123,6 @@ void tr_peerIoSetIOFuncs( tr_peerIo * io,
int tr_peerIoWantsBandwidth( const tr_peerIo * io,
tr_direction );
#if 0
void tr_peerIoTryRead( tr_peerIo * io );
#endif
void tr_peerIoWrite( tr_peerIo * io,
const void * writeme,
size_t writemeLen );

View File

@ -15,11 +15,8 @@
#include <inttypes.h> /* uint16_t */
#ifdef WIN32
#include <winsock2.h> /* struct in_addr */
#else
#include <netinet/in.h> /* struct in_addr */
#endif
#include "net.h" /* struct in_addr */
#include "tr-gnuc.h"
struct in_addr;
struct tr_handle;
@ -46,7 +43,7 @@ tr_pex;
int tr_pexCompare( const void * a, const void * b );
tr_peerMgr* tr_peerMgrNew( struct tr_handle * );
tr_peerMgr* tr_peerMgrNew( struct tr_handle * ) TR_GNUC_MALLOC;
void tr_peerMgrFree( tr_peerMgr * manager );

View File

@ -27,13 +27,7 @@
#define TR_NAME "Transmission"
#ifndef UNUSED
#ifdef __GNUC__
#define UNUSED __attribute__ ( ( unused ) )
#else
#define UNUSED
#endif
#endif
#include "tr-gnuc.h"
enum
{
@ -47,7 +41,7 @@ enum
typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t;
uint8_t* tr_peerIdNew( void );
uint8_t* tr_peerIdNew( void ) TR_GNUC_MALLOC;
const uint8_t* tr_getPeerId( void );

40
libtransmission/tr-gnuc.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef TR_GNUC_H
#define TR_GNUC_H 1
#ifndef UNUSED
#ifdef __GNUC__
#define UNUSED __attribute__ ( ( unused ) )
#else
#define UNUSED
#endif
#endif
#ifndef TR_GNUC_PRINTF
#ifdef __GNUC__
#define TR_GNUC_PRINTF( fmt,\
args ) __attribute__ ( ( format ( printf, fmt,\
args ) ) )
#else
#define TR_GNUC_PRINTF( fmt, args )
#endif
#endif
#ifndef TR_GNUC_NULL_TERMINATED
#if __GNUC__ >= 4
#define TR_GNUC_NULL_TERMINATED __attribute__ ( ( __sentinel__ ) )
#else
#define TR_GNUC_NULL_TERMINATED
#endif
#endif
#if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 96 )
#define TR_GNUC_CONST __attribute__ ( ( __const ) )
#define TR_GNUC_PURE __attribute__ ( ( __pure__ ) )
#define TR_GNUC_MALLOC __attribute__ ( ( __malloc__ ) )
#else
#define TR_GNUC_CONST
#define TR_GNUC_PURE
#define TR_GNUC_MALLOC
#endif
#endif

View File

@ -36,6 +36,7 @@
extern "C" {
#endif
#include "tr-gnuc.h"
#include "version.h"
#include <inttypes.h> /* uintN_t */
@ -727,7 +728,7 @@ tr_ctorMode;
struct tr_benc;
tr_ctor* tr_ctorNew( const tr_handle * handle );
tr_ctor* tr_ctorNew( const tr_handle * handle ) TR_GNUC_MALLOC;
void tr_ctorFree( tr_ctor * ctor );
@ -809,7 +810,7 @@ int tr_torrentParse( const tr_handle * handle,
TR_EDUPLICATE if there's already a matching torrent object. */
tr_torrent * tr_torrentNew( tr_handle * handle,
const tr_ctor * ctor,
int * setmeError );
int * setmeError ) TR_GNUC_MALLOC;
/** @} */

View File

@ -47,40 +47,7 @@ extern "C" {
#define TRUE 1
#endif
#ifndef UNUSED
#ifdef __GNUC__
#define UNUSED __attribute__ ( ( unused ) )
#else
#define UNUSED
#endif
#endif
#ifndef TR_GNUC_PRINTF
#ifdef __GNUC__
#define TR_GNUC_PRINTF( fmt,\
args ) __attribute__ ( ( format ( printf, fmt,\
args ) ) )
#else
#define TR_GNUC_PRINTF( fmt, args )
#endif
#endif
#ifndef TR_GNUC_NULL_TERMINATED
#if __GNUC__ >= 4
#define TR_GNUC_NULL_TERMINATED __attribute__ ( ( __sentinel__ ) )
#else
#define TR_GNUC_NULL_TERMINATED
#endif
#endif
#if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 96 )
#define TR_GNUC_PURE __attribute__ ( ( __pure__ ) )
#define TR_GNUC_MALLOC __attribute__ ( ( __malloc__ ) )
#else
#define TR_GNUC_PURE
#define TR_GNUC_MALLOC
#endif
#include "tr-gnuc.h"
/***
****
@ -192,10 +159,10 @@ void tr_timevalMsec( uint64_t milliseconds,
/* return the current date in milliseconds */
uint64_t tr_date( void );
uint64_t tr_date( void ) TR_GNUC_CONST;
/* wait the specified number of milliseconds */
void tr_wait( uint64_t delay_milliseconds );
void tr_wait( uint64_t delay_milliseconds ) TR_GNUC_CONST;
/***
****
@ -262,7 +229,7 @@ int tr_snprintf( char * buf,
const char * fmt,
... ) TR_GNUC_PRINTF( 3, 4 );
const char* tr_strerror( int );
const char* tr_strerror( int ) TR_GNUC_CONST;
char* tr_strstrip( char * str );
@ -359,7 +326,7 @@ tr_bitfield* tr_bitfieldOr( tr_bitfield*,
&& tr_bitfieldHasFast( bitfield, nth ) )
double tr_getRatio( double numerator,
double denominator );
double denominator ) TR_GNUC_CONST;
#ifdef __cplusplus
}