Browse Source

Use lib_t type for lib_* functions

tags/1.9.6
falkTX 10 years ago
parent
commit
90805901b5
5 changed files with 18 additions and 15 deletions
  1. +2
    -2
      source/backend/plugin/CarlaPluginInternal.hpp
  2. +1
    -1
      source/bridges-ui/CarlaBridgeClient.hpp
  3. +1
    -1
      source/discovery/carla-discovery.cpp
  4. +4
    -4
      source/utils/CarlaLibCounter.hpp
  5. +10
    -7
      source/utils/CarlaLibUtils.hpp

+ 2
- 2
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -217,8 +217,8 @@ struct CarlaPlugin::ProtectedData {
bool enabled;
bool needsReset;

void* lib;
void* uiLib;
lib_t lib;
lib_t uiLib;

// misc
int8_t ctrlChannel;


+ 1
- 1
source/bridges-ui/CarlaBridgeClient.hpp View File

@@ -117,7 +117,7 @@ private:
struct UI {
CarlaBridgeToolkit* const toolkit;
CarlaString filename;
void* lib;
lib_t lib;
bool quit;

UI(CarlaBridgeToolkit* const toolkit_)


+ 1
- 1
source/discovery/carla-discovery.cpp View File

@@ -1638,7 +1638,7 @@ int main(int argc, char* argv[])
}

bool openLib = false;
void* handle = nullptr;
lib_t handle = nullptr;

switch (type)
{


+ 4
- 4
source/utils/CarlaLibCounter.hpp View File

@@ -58,7 +58,7 @@ public:
fLibs.clear();
}

void* open(const char* const filename, const bool canDelete = true) noexcept
lib_t open(const char* const filename, const bool canDelete = true) noexcept
{
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr);

@@ -87,7 +87,7 @@ public:
}
}

void* const libPtr(lib_open(filename));
const lib_t libPtr(lib_open(filename));

if (libPtr == nullptr)
{
@@ -108,7 +108,7 @@ public:
return nullptr;
}

bool close(void* const libPtr) noexcept
bool close(const lib_t libPtr) noexcept
{
CARLA_SAFE_ASSERT_RETURN(libPtr != nullptr, false);

@@ -151,7 +151,7 @@ public:

private:
struct Lib {
void* lib;
lib_t lib;
const char* filename;
int count;
bool canDelete;


+ 10
- 7
source/utils/CarlaLibUtils.hpp View File

@@ -20,8 +20,11 @@

#include "CarlaUtils.hpp"

#ifndef CARLA_OS_WIN
#ifdef CARLA_OS_WIN
typedef HMODULE lib_t;
#else
# include <dlfcn.h>
typedef void* lib_t;
#endif

// -----------------------------------------------------------------------
@@ -32,13 +35,13 @@
* May return null, in which case "lib_error" has the error.
*/
static inline
void* lib_open(const char* const filename) noexcept
lib_t lib_open(const char* const filename) noexcept
{
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr);

try {
#ifdef CARLA_OS_WIN
return (void*)::LoadLibraryA(filename);
return ::LoadLibraryA(filename);
#else
return ::dlopen(filename, RTLD_NOW|RTLD_LOCAL);
#endif
@@ -50,13 +53,13 @@ void* lib_open(const char* const filename) noexcept
* If false is returned, "lib_error" has the error.
*/
static inline
bool lib_close(void* const lib) noexcept
bool lib_close(const lib_t lib) noexcept
{
CARLA_SAFE_ASSERT_RETURN(lib != nullptr, false);

try {
#ifdef CARLA_OS_WIN
return ::FreeLibrary((HMODULE)lib);
return ::FreeLibrary(lib);
#else
return (::dlclose(lib) == 0);
#endif
@@ -69,14 +72,14 @@ bool lib_close(void* const lib) noexcept
*/
template<typename Func>
static inline
Func lib_symbol(void* const lib, const char* const symbol) noexcept
Func lib_symbol(const lib_t lib, const char* const symbol) noexcept
{
CARLA_SAFE_ASSERT_RETURN(lib != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(symbol != nullptr && symbol[0] != '\0', nullptr);

try {
#ifdef CARLA_OS_WIN
return (Func)::GetProcAddress((HMODULE)lib, symbol);
return (Func)::GetProcAddress(lib, symbol);
#else
return (Func)(uintptr_t)::dlsym(lib, symbol);
#endif


Loading…
Cancel
Save