1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(trunk libT) win32 portability fixes, reported by Alexey

This commit is contained in:
Charles Kerr 2009-01-10 02:22:13 +00:00
parent 7683452514
commit c6a454d2e2
6 changed files with 18 additions and 9 deletions

View file

@ -161,12 +161,12 @@ makeroom( tr_benc * val,
const int len = val->val.l.alloc + count +
( count % LIST_SIZE ? LIST_SIZE -
( count % LIST_SIZE ) : 0 );
void * new = realloc( val->val.l.vals, len * sizeof( tr_benc ) );
if( NULL == new )
void * tmp = realloc( val->val.l.vals, len * sizeof( tr_benc ) );
if( !tmp )
return 1;
val->val.l.alloc = len;
val->val.l.vals = new;
val->val.l.vals = tmp;
}
return 0;

View file

@ -63,10 +63,13 @@ struct __tr_list
struct __tr_list * next, * prev;
};
#define __tr_list_entry(ptr, type, member) ({ \
const struct __tr_list *__mptr = (ptr); \
(void *)( (char *)__mptr - offsetof(type,member) ); \
})
/**
* Given a __tr_list node that's embedded in a struct, returns a pointer to the struct.
* @param ptr pointer to the embedded __tr_list
* @param type struct type that has contains the __tr_list
* @param field the name of the struct's _tr_list field
*/
#define __tr_list_entry(ptr,type,field) ((type*) (((char*)ptr) - offsetof(type,field)))
typedef int ( *__tr_list_cmp_t ) ( const void * a, const void * b );
typedef void ( *__tr_list_free_t )( void * );

View file

@ -32,6 +32,7 @@
#ifdef WIN32
#include <winsock2.h> /* inet_addr */
#include <WS2tcpip.h>
#else
#include <arpa/inet.h> /* inet_addr */
#include <netdb.h>

View file

@ -32,6 +32,7 @@
#ifdef WIN32
#include <inttypes.h>
#include <winsock2.h>
#include <WS2tcpip.h>
typedef int socklen_t;
#else
#include <sys/types.h>

View file

@ -11,6 +11,7 @@
*/
#include <assert.h>
#include <errno.h>
#include <limits.h> /* INT_MAX */
#include <string.h>
#include <stdio.h>
@ -87,8 +88,7 @@ didWriteWrapper( tr_peerIo * io, size_t bytes_transferred )
{
while( bytes_transferred )
{
struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next,
struct tr_datatype, head );
struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next, struct tr_datatype, head );
const size_t payload = MIN( next->length, bytes_transferred );
const size_t overhead = getPacketOverhead( payload );

View file

@ -50,6 +50,10 @@ extern "C" {
#endif
#include <time.h> /* time_t */
#if defined(_MSC_VER) && !defined( __cplusplus )
#define inline __inline
#endif
#define SHA_DIGEST_LENGTH 20
#define TR_INET6_ADDRSTRLEN 46