Windows-port: some special code and switches for statical libraries added

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@73 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Oxy 2006-07-31 05:32:33 +00:00
parent 736efca5dd
commit 8c21b2c4d9
6 changed files with 61 additions and 13 deletions

6
README
View File

@ -272,6 +272,12 @@ Rename Pre-build.2 to pthreads.
Open the provided workspace build\libupnp.dsw with Visual C++ 6.0 and select Open the provided workspace build\libupnp.dsw with Visual C++ 6.0 and select
Build->Build libupnp.dll (F7) Build->Build libupnp.dll (F7)
For building a static library instead of a DLL and for using the static
pthreads-w32 library following switches need to be defined additionally:
UPNP_STATIC_LIB - for creating a statically linkable UPnP-library
PTW32_STATIC_LIB - for using the static pthreads32 library
5) Install/Uninstall Instructions 5) Install/Uninstall Instructions
------------------------------------------- -------------------------------------------

View File

@ -38,6 +38,7 @@
#include <assert.h> #include <assert.h>
#ifdef WIN32 #ifdef WIN32
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS #ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users // set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport) #define EXPORT_SPEC __declspec(dllexport)
@ -47,6 +48,9 @@
#else #else
#define EXPORT_SPEC #define EXPORT_SPEC
#endif #endif
#else
#define EXPORT_SPEC
#endif
typedef int BOOL; typedef int BOOL;

View File

@ -527,6 +527,7 @@ extern "C" {
#define imillisleep(x) usleep(1000*x) #define imillisleep(x) usleep(1000*x)
#ifdef WIN32 #ifdef WIN32
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS #ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users // set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport) #define EXPORT_SPEC __declspec(dllexport)
@ -536,6 +537,9 @@ extern "C" {
#else #else
#define EXPORT_SPEC #define EXPORT_SPEC
#endif #endif
#else
#define EXPORT_SPEC
#endif
//NK: Added for satisfying the gcc compiler //NK: Added for satisfying the gcc compiler

View File

@ -382,6 +382,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
int retCode = 0; int retCode = 0;
int persistent = -1; int persistent = -1;
ThreadPool *tp = ( ThreadPool * ) arg; ThreadPool *tp = ( ThreadPool * ) arg;
//leuk_he allow static linking
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_thread_attach_np();
#endif
#endif
assert( tp != NULL ); assert( tp != NULL );
@ -449,7 +455,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
tp->totalThreads--; tp->totalThreads--;
ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_cond_broadcast( &tp->start_and_shutdown );
ithread_mutex_unlock( &tp->mutex ); ithread_mutex_unlock( &tp->mutex );
//leuk_he
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_thread_detach_np ();
#endif
#endif
return NULL; return NULL;
} }
@ -478,6 +489,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_cond_broadcast( &tp->start_and_shutdown );
ithread_mutex_unlock( &tp->mutex ); ithread_mutex_unlock( &tp->mutex );
//leuk_he
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_thread_detach_np ();
#endif
#endif
return NULL; return NULL;
} else { } else {
@ -705,6 +722,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
if( tp == NULL ) { if( tp == NULL ) {
return EINVAL; return EINVAL;
} }
//leuk_he
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#endif
retCode += ithread_mutex_init( &tp->mutex, NULL ); retCode += ithread_mutex_init( &tp->mutex, NULL );
assert( retCode == 0 ); assert( retCode == 0 );

View File

@ -47,6 +47,7 @@
#endif #endif
#ifdef WIN32 #ifdef WIN32
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS #ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users // set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport) #define EXPORT_SPEC __declspec(dllexport)
@ -56,6 +57,9 @@
#else #else
#define EXPORT_SPEC #define EXPORT_SPEC
#endif #endif
#else
#define EXPORT_SPEC
#endif
#ifndef WIN32 #ifndef WIN32
#define UpnpCloseSocket close #define UpnpCloseSocket close

View File

@ -415,6 +415,13 @@ UpnpFinish( )
// remove all virtual dirs // remove all virtual dirs
UpnpRemoveAllVirtualDirs( ); UpnpRemoveAllVirtualDirs( );
//leuk_he allow static linking:
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_thread_detach_np ();
#endif
#endif
UpnpSdkInit = 0; UpnpSdkInit = 0;