From b3825514b20e9264de82e5c8f13e7718dac6a5eb Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 17 Mar 2011 00:42:23 +0100 Subject: [PATCH] player: amiga-support Proper Amiga-suport is supplied by using the AmiTCP stack when USE_AMITCP is enabled. Add explicit OpenLibrary/CloseLibrary calls, for those people who don't link against auto-opening libs ala VBCC's auto.s. Add a typedef for uint32_t (needed for network communication) for Motorola 68k platforms. Also add a SAS/C support for the 'inline' keyword. Thanks to Aske Simon Christensen for help with the SAS/C support. --- sync/base.h | 13 ++++++++++++- sync/device.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sync/base.h b/sync/base.h index 8eab00a..f3eac93 100644 --- a/sync/base.h +++ b/sync/base.h @@ -7,7 +7,7 @@ /* configure inline keyword */ #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) - #if defined(_MSC_VER) || defined(__GNUC__) + #if defined(_MSC_VER) || defined(__GNUC__) || defined(__SASC) #define inline __inline #else /* compiler does not support inline, make function static instead */ @@ -23,6 +23,8 @@ typedef unsigned int uint32_t; #elif defined(__GNUC__) #include +#elif defined(M68000) + typedef unsigned int uint32_t; #endif /* configure socket-stack */ @@ -31,6 +33,15 @@ #define NOMINMAX #include #include +#elif defined(USE_AMITCP) + #include + #include + #include + #include + #define SOCKET int + #define INVALID_SOCKET -1 + #define select(n,r,w,e,t) WaitSelect(n,r,w,e,t,0) + #define closesocket(x) CloseSocket(x) #else #include #include diff --git a/sync/device.c b/sync/device.c index 93deb5a..4f9c30d 100644 --- a/sync/device.c +++ b/sync/device.c @@ -21,6 +21,10 @@ static const char *sync_track_path(const char *base, const char *name) #ifndef SYNC_PLAYER +#ifdef USE_AMITCP +static struct Library *socket_base = NULL; +#endif + static SOCKET server_connect(const char *host, unsigned short nport) { struct hostent *he; @@ -36,6 +40,12 @@ static SOCKET server_connect(const char *host, unsigned short nport) return INVALID_SOCKET; need_init = 0; } +#elif defined(USE_AMITCP) + if (!socket_base) { + socket_base = OpenLibrary("bsdsocket.library", 4); + if (!socket_base) + return INVALID_SOCKET; + } #endif he = gethostbyname(host); @@ -101,6 +111,13 @@ void sync_destroy_device(struct sync_device *d) free(d->base); sync_data_deinit(&d->data); free(d); + +#if defined(USE_AMITCP) && !defined(SYNC_PLAYER) + if (socket_base) { + CloseLibrary(socket_base); + socket_base = NULL; + } +#endif } #ifdef SYNC_PLAYER