2012-04-29 20:52:25 +02:00
|
|
|
//
|
|
|
|
// SharedLibrary_HPUX.cpp
|
|
|
|
//
|
|
|
|
// $Id: //poco/1.4/Foundation/src/SharedLibrary_HPUX.cpp#2 $
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: SharedLibrary
|
|
|
|
// Module: SharedLibrary
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
2014-05-04 21:02:42 +02:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2012-04-29 20:52:25 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/SharedLibrary_HPUX.h"
|
|
|
|
#include <dl.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
|
|
|
|
|
|
FastMutex SharedLibraryImpl::_mutex;
|
|
|
|
|
|
|
|
|
|
|
|
SharedLibraryImpl::SharedLibraryImpl()
|
|
|
|
{
|
|
|
|
_handle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SharedLibraryImpl::~SharedLibraryImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
|
|
|
|
{
|
|
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
|
|
|
|
|
|
if (_handle) throw LibraryAlreadyLoadedException(path);
|
|
|
|
_handle = shl_load(path.c_str(), BIND_DEFERRED, 0);
|
|
|
|
if (!_handle) throw LibraryLoadException(path);
|
|
|
|
_path = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SharedLibraryImpl::unloadImpl()
|
|
|
|
{
|
|
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
|
|
|
|
|
|
if (_handle)
|
|
|
|
{
|
|
|
|
shl_unload(_handle);
|
|
|
|
_handle = 0;
|
|
|
|
_path.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SharedLibraryImpl::isLoadedImpl() const
|
|
|
|
{
|
|
|
|
return _handle != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
|
|
|
|
{
|
|
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
|
|
|
|
|
|
void* result = 0;
|
|
|
|
if (_handle && shl_findsym(&_handle, name.c_str(), TYPE_UNDEFINED, &result) != -1)
|
|
|
|
return result;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& SharedLibraryImpl::getPathImpl() const
|
|
|
|
{
|
|
|
|
return _path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string SharedLibraryImpl::suffixImpl()
|
|
|
|
{
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
return "d.sl";
|
|
|
|
#else
|
|
|
|
return ".sl";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|