ENH: fix for bug 2808, use dlopen on new OSX versions
This commit is contained in:
parent
036fd2134d
commit
4c1ae1b5af
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
// This file is actually several different implementations.
|
// This file is actually several different implementations.
|
||||||
// 1. HP machines which uses shl_load
|
// 1. HP machines which uses shl_load
|
||||||
// 2. Apple OSX which uses NSLinkModule
|
// 2. Mac OS X 10.2.x and earlier which uses NSLinkModule
|
||||||
// 3. Windows which uses LoadLibrary
|
// 3. Windows which uses LoadLibrary
|
||||||
// 4. Most unix systems which use dlopen (default )
|
// 4. Most unix systems (including Mac OS X 10.3 and later) which use dlopen (default)
|
||||||
// Each part of the ifdef contains a complete implementation for
|
// Each part of the ifdef contains a complete implementation for
|
||||||
// the static methods of cmDynamicLoader.
|
// the static methods of cmDynamicLoader.
|
||||||
|
|
||||||
@ -147,10 +147,10 @@ const char* cmDynamicLoader::LastError()
|
|||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// 2. Implementation for Darwin (including OSX) Machines
|
// 2. Implementation for Mac OS X 10.2.x and earlier
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define CMDYNAMICLOADER_DEFINED
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
|
||||||
|
#define CMDYNAMICLOADER_DEFINED 1
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
|
|
||||||
cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname )
|
cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname )
|
||||||
@ -169,7 +169,7 @@ cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname )
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lh = NSLinkModule(image, libname, TRUE);
|
lh = NSLinkModule(image, libname, NSLINKMODULE_OPTION_BINDNOW);
|
||||||
if(lh)
|
if(lh)
|
||||||
{
|
{
|
||||||
cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh);
|
cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh);
|
||||||
@ -179,10 +179,7 @@ cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname )
|
|||||||
|
|
||||||
int cmDynamicLoader::CloseLibrary(cmLibHandle lib)
|
int cmDynamicLoader::CloseLibrary(cmLibHandle lib)
|
||||||
{
|
{
|
||||||
// we have to use lib because the macro may not...
|
NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_NONE);
|
||||||
(void)lib;
|
|
||||||
|
|
||||||
NSUnLinkModule((NSModule)lib, FALSE);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,6 +205,7 @@ const char* cmDynamicLoader::LastError()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -290,7 +288,7 @@ const char* cmDynamicLoader::LastError()
|
|||||||
// 4. Implementation for default UNIX machines.
|
// 4. Implementation for default UNIX machines.
|
||||||
// if nothing has been defined then use this
|
// if nothing has been defined then use this
|
||||||
#ifndef CMDYNAMICLOADER_DEFINED
|
#ifndef CMDYNAMICLOADER_DEFINED
|
||||||
#define CMDYNAMICLOADER_DEFINED
|
#define CMDYNAMICLOADER_DEFINED 1
|
||||||
// Setup for most unix machines
|
// Setup for most unix machines
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
@ -28,14 +28,19 @@
|
|||||||
// Ugly stuff for library handles
|
// Ugly stuff for library handles
|
||||||
// They are different on several different OS's
|
// They are different on several different OS's
|
||||||
#if defined(__hpux)
|
#if defined(__hpux)
|
||||||
# include <dl.h>
|
#include <dl.h>
|
||||||
typedef shl_t cmLibHandle;
|
typedef shl_t cmLibHandle;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
typedef HMODULE cmLibHandle;
|
typedef HMODULE cmLibHandle;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <mach-o/dyld.h>
|
#include <AvailabilityMacros.h>
|
||||||
typedef NSModule cmLibHandle;
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
typedef NSModule cmLibHandle;
|
||||||
|
#else
|
||||||
|
typedef void* cmLibHandle;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
typedef void* cmLibHandle;
|
typedef void* cmLibHandle;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user