移除对pthread的依赖

v0.27.3
Matthew 9 months ago
parent 1d3009d723
commit b7e091ce77

@ -46,6 +46,7 @@ if (MSVC)
target_compile_definitions(exiv2-xmp PRIVATE XML_STATIC) target_compile_definitions(exiv2-xmp PRIVATE XML_STATIC)
endif() endif()
include(CheckIncludeFile)
check_include_file( "stdint.h" EXV_HAVE_STDINT_H ) check_include_file( "stdint.h" EXV_HAVE_STDINT_H )
if (EXV_HAVE_STDINT_H) if (EXV_HAVE_STDINT_H)
target_compile_definitions(exiv2-xmp PRIVATE EXV_HAVE_STDINT_H) target_compile_definitions(exiv2-xmp PRIVATE EXV_HAVE_STDINT_H)

@ -112,22 +112,25 @@ WXMP_Result void_wResult;
// ! Would be OK but overkill to specify PTHREAD_MUTEX_RECURSIVE. // ! Would be OK but overkill to specify PTHREAD_MUTEX_RECURSIVE.
bool XMP_InitMutex ( XMP_Mutex * mutex ) { bool XMP_InitMutex ( XMP_Mutex * mutex ) {
int err = pthread_mutex_init ( mutex, 0 ); // int err = pthread_mutex_init ( mutex, 0 );
return (err == 0 ); // return (err == 0 );
return true;
} }
void XMP_TermMutex ( XMP_Mutex & mutex ) { void XMP_TermMutex ( XMP_Mutex & mutex ) {
(void) pthread_mutex_destroy ( &mutex ); // (void) pthread_mutex_destroy ( &mutex );
} }
void XMP_EnterCriticalRegion ( XMP_Mutex & mutex ) { void XMP_EnterCriticalRegion ( XMP_Mutex & mutex ) {
int err = pthread_mutex_lock ( &mutex ); // int err = pthread_mutex_lock ( &mutex );
if ( err != 0 ) XMP_Throw ( "XMP_EnterCriticalRegion - pthread_mutex_lock failure", kXMPErr_ExternalFailure ); // if ( err != 0 ) XMP_Throw ( "XMP_EnterCriticalRegion - pthread_mutex_lock failure", kXMPErr_ExternalFailure );
mutex.lock();
} }
void XMP_ExitCriticalRegion ( XMP_Mutex & mutex ) { void XMP_ExitCriticalRegion ( XMP_Mutex & mutex ) {
int err = pthread_mutex_unlock ( &mutex ); // int err = pthread_mutex_unlock ( &mutex );
if ( err != 0 ) XMP_Throw ( "XMP_ExitCriticalRegion - pthread_mutex_unlock failure", kXMPErr_ExternalFailure ); // if ( err != 0 ) XMP_Throw ( "XMP_ExitCriticalRegion - pthread_mutex_unlock failure", kXMPErr_ExternalFailure );
mutex.unlock();
} }
#endif #endif

@ -25,8 +25,8 @@
#if XMP_WinBuild #if XMP_WinBuild
#include <windows.h> #include <windows.h>
#else #else
// Use pthread for both Mac and generic UNIX. // Use mutex for both Mac and generic UNIX.
#include <pthread.h> #include <mutex>
#endif #endif
#if XMP_WinBuild #if XMP_WinBuild
@ -196,7 +196,8 @@ extern WXMP_Result void_wResult;
#endif #endif
#define XMP_Throw(msg,id) { AnnounceThrow ( msg ); throw XMP_Error ( id, msg ); } // #define XMP_Throw(msg,id) { AnnounceThrow ( msg ); throw XMP_Error ( id, msg ); }
#define XMP_Throw(msg,id) { }
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
@ -204,7 +205,7 @@ extern WXMP_Result void_wResult;
typedef CRITICAL_SECTION XMP_Mutex; typedef CRITICAL_SECTION XMP_Mutex;
#else #else
// Use pthread for both Mac and generic UNIX. // Use pthread for both Mac and generic UNIX.
typedef pthread_mutex_t XMP_Mutex; typedef std::mutex XMP_Mutex;
#endif #endif
extern XMP_Mutex sXMPCoreLock; extern XMP_Mutex sXMPCoreLock;

Loading…
Cancel
Save