Mercurial > hg > svcore
diff system/System.cpp @ 1182:a1f410f895d3 3.0-integration
Merge from branch pluginscan
author | Chris Cannam |
---|---|
date | Fri, 15 Apr 2016 16:26:15 +0100 |
parents | 6b1af0f05f06 |
children | e5a1d815f331 |
line wrap: on
line diff
--- a/system/System.cpp Fri Mar 18 14:25:05 2016 +0000 +++ b/system/System.cpp Fri Apr 15 16:26:15 2016 +0100 @@ -325,66 +325,3 @@ double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; } float princargf(float a) { return float(princarg(a)); } -#ifndef _WIN32 - -#include <unistd.h> -#include <sys/wait.h> - -PluginLoadStatus -TestPluginLoadability(QString soname, QString descriptorFn) -{ - //!!! This is POSIX only, no equivalent on Windows, where we'll - //!!! have to do something completely different - - pid_t pid = fork(); - - if (pid < 0) { - return UnknownPluginLoadStatus; // fork failed - } - - if (pid == 0) { // the child process - - void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL); - if (!handle) { - cerr << "isPluginLibraryLoadable: Failed to open plugin library \"" - << soname << "\": " << dlerror() << "\n"; - cerr << "exiting with status 1" << endl; - exit(1); - } - - void *fn = DLSYM(handle, descriptorFn.toLocal8Bit().data()); - if (!fn) { - cerr << "isPluginLibraryLoadable: Failed to find plugin descriptor function \"" << descriptorFn << "\" in library \"" << soname << "\": " << dlerror() << "\n"; - exit(2); - } - -// cerr << "isPluginLibraryLoadable: Successfully loaded library \"" << soname << "\" and retrieved descriptor function" << endl; - - exit(0); - - } else { // the parent process - - int status = 0; - - do { - waitpid(pid, &status, 0); - } while (WIFSTOPPED(status)); - - if (WIFEXITED(status)) { - switch (WEXITSTATUS(status)) { - case 0: return PluginLoadOK; // success - case 1: return PluginLoadFailedToLoadLibrary; - case 2: return PluginLoadFailedToFindDescriptor; - default: return PluginLoadFailedElsewhere; - } - } - - if (WIFSIGNALED(status)) { - return PluginLoadFailedElsewhere; - } - - return UnknownPluginLoadStatus; - } -} - -#endif