SF Tracker [ 1663004 ] Compile on Cygwin
Submitted By: Jon Foster - jongfoster This patch gives basic support for building under Cygwin - it compiles, links, and a simple UPnP device application can initialise. I'm not sure if it actually works yet, but this is definitely a step in the right direction. Patch is against the 1.4.1 release. Changes are: * threadutil/inc/ithread.h: Fix the ithread mutex support to use documented, portable APIs (if present) rather than the Non-Portable (_NP) ones it uses now. This is required because Cygwin implements only the portable API. * threadutil/src/ThreadPool.c: Fake SetPolicyType() to do nothing on Cygwin because otherwise it fails. Should probably investigate why it fails and add a proper implementation later. * upnp/src/api/upnpapi.c: On Cygwin, zero out the GlobalHndMutex structure before initialising it. Without this, the initialisation fails. This appears to be a bug in Cygwin. * upnp/src/genlib/net/uri/uri.c: Use gethostbyname() on Cygwin. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@151 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
2c2a5f7c18
commit
41cb45146c
31
ChangeLog
31
ChangeLog
@ -3,14 +3,39 @@
|
||||
Version 1.4.3
|
||||
*************************************************************************
|
||||
|
||||
2007-03-13 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* SF Tracker [ 1663004 ] Compile on Cygwin
|
||||
Submitted By: Jon Foster - jongfoster
|
||||
This patch gives basic support for building under Cygwin - it compiles,
|
||||
links, and a simple UPnP device application can initialise. I'm not sure
|
||||
if it actually works yet, but this is definitely a step in the right
|
||||
direction.
|
||||
|
||||
Patch is against the 1.4.1 release. Changes are:
|
||||
|
||||
* threadutil/inc/ithread.h: Fix the ithread mutex support to use
|
||||
documented, portable APIs (if present) rather than the Non-Portable (_NP)
|
||||
ones it uses now. This is required because Cygwin implements only the
|
||||
portable API.
|
||||
|
||||
* threadutil/src/ThreadPool.c: Fake SetPolicyType() to do nothing on Cygwin
|
||||
because otherwise it fails. Should probably investigate why it fails and
|
||||
add a proper implementation later.
|
||||
|
||||
* upnp/src/api/upnpapi.c: On Cygwin, zero out the GlobalHndMutex structure
|
||||
before initialising it. Without this, the initialisation fails. This
|
||||
appears to be a bug in Cygwin.
|
||||
|
||||
* upnp/src/genlib/net/uri/uri.c: Use gethostbyname() on Cygwin.
|
||||
|
||||
2007-03-05 Oxy <oxygenic(at)users.sourceforge.net>
|
||||
* Code adapted and typedefs added to compile cleanly under Windows
|
||||
with Borland C++ Builder and MS Visual C++
|
||||
|
||||
|
||||
2007-03-03 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
|
||||
* Fixed nasty segmentation fault bug on membuffer.c.
|
||||
|
||||
|
||||
*************************************************************************
|
||||
Version 1.4.2
|
||||
*************************************************************************
|
||||
|
@ -47,11 +47,21 @@ extern "C" {
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
/* This system has SuS2-compliant mutex attributes.
|
||||
* E.g. on Cygwin, where we don't have the old nonportable (NP) symbols
|
||||
*/
|
||||
#define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_NORMAL
|
||||
#define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK
|
||||
#else
|
||||
#define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_FAST_NP
|
||||
#define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE_NP
|
||||
#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK_NP
|
||||
#endif
|
||||
|
||||
#define ITHREAD_CANCELED PTHREAD_CANCELED
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Name: ithread_t
|
||||
@ -181,8 +191,11 @@ extern "C" {
|
||||
* Returns EINVAL if the kind is not supported.
|
||||
* See man page for pthread_mutexattr_setkind_np
|
||||
*****************************************************************************/
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
|
||||
#else
|
||||
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ithread_mutexattr_getkind_np
|
||||
@ -203,7 +216,11 @@ extern "C" {
|
||||
* Always returns 0.
|
||||
* See man page for pthread_mutexattr_getkind_np
|
||||
*****************************************************************************/
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
|
||||
#else
|
||||
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@ -542,8 +559,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PTHREAD_MUTEX_RECURSIVE
|
||||
//NK: Added for satisfying the gcc compiler
|
||||
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -90,6 +90,10 @@ FreeThreadPoolJob( ThreadPool * tp,
|
||||
static int
|
||||
SetPolicyType( PolicyType in )
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
/* TODO not currently working... */
|
||||
return 0;
|
||||
#else
|
||||
#ifdef WIN32
|
||||
return sched_setscheduler( 0, in);
|
||||
#else
|
||||
@ -99,6 +103,7 @@ SetPolicyType( PolicyType in )
|
||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||
return sched_setscheduler( 0, in, ¤t );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -207,6 +207,11 @@ int UpnpInit( IN const char *HostIP,
|
||||
( UPNP_INFO, API, __FILE__, __LINE__, "Inside UpnpInit \n" );
|
||||
)
|
||||
//initialize mutex
|
||||
#ifdef __CYGWIN__
|
||||
/* On Cygwin, pthread_mutex_init() fails without this memset. */
|
||||
/* TODO: Fix Cygwin so we don't need this memset(). */
|
||||
memset(&GlobalHndMutex, 0, sizeof(GlobalHndMutex));
|
||||
#endif
|
||||
if( ithread_mutex_init( &GlobalHndMutex, NULL ) != 0 ) {
|
||||
return UPNP_E_INIT_FAILED;
|
||||
}
|
||||
|
@ -611,7 +611,9 @@ parse_hostport( const char *in,
|
||||
int errCode = 0;
|
||||
|
||||
//call gethostbyname_r (reentrant form of gethostbyname)
|
||||
#if defined(WIN32)
|
||||
// TODO: Use autoconf to discover this rather than the
|
||||
// platform-specific stuff below
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
h=gethostbyname(temp_host_name);
|
||||
#elif defined(SPARC_SOLARIS)
|
||||
errCode = gethostbyname_r( temp_host_name,
|
||||
|
Loading…
Reference in New Issue
Block a user