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
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
-------------------------------------------

View File

@ -38,11 +38,15 @@
#include <assert.h>
#ifdef WIN32
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#else
#define EXPORT_SPEC __declspec(dllimport)
#endif
#else
#define EXPORT_SPEC __declspec(dllimport)
#define EXPORT_SPEC
#endif
#else
#define EXPORT_SPEC

View File

@ -527,11 +527,15 @@ extern "C" {
#define imillisleep(x) usleep(1000*x)
#ifdef WIN32
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#else
#define EXPORT_SPEC __declspec(dllimport)
#endif
#else
#define EXPORT_SPEC __declspec(dllimport)
#define EXPORT_SPEC
#endif
#else
#define EXPORT_SPEC

View File

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

View File

@ -47,11 +47,15 @@
#endif
#ifdef WIN32
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#else
#define EXPORT_SPEC __declspec(dllimport)
#endif
#else
#define EXPORT_SPEC __declspec(dllimport)
#define EXPORT_SPEC
#endif
#else
#define EXPORT_SPEC

View File

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