aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test cases/common/125 shared module/meson.build3
-rw-r--r--test cases/common/125 shared module/module.c17
2 files changed, 16 insertions, 4 deletions
diff --git a/test cases/common/125 shared module/meson.build b/test cases/common/125 shared module/meson.build
index 7c15bcc..d96d8fc 100644
--- a/test cases/common/125 shared module/meson.build
+++ b/test cases/common/125 shared module/meson.build
@@ -5,7 +5,8 @@ l = shared_library('runtime', 'runtime.c')
# Do NOT link the module with the runtime library. This
# is a common approach for plugins that are only used
# with dlopen. Any symbols are resolved dynamically
-# at runtime
+# at runtime. This requires extra help on Windows, so
+# should be avoided unless really neccessary.
m = shared_module('mymodule', 'module.c')
e = executable('prog', 'prog.c', link_with : l, dependencies : dl)
test('import test', e, args : m)
diff --git a/test cases/common/125 shared module/module.c b/test cases/common/125 shared module/module.c
index 56078c5..181b760 100644
--- a/test cases/common/125 shared module/module.c
+++ b/test cases/common/125 shared module/module.c
@@ -9,14 +9,24 @@
#endif
#endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
#include <stdio.h>
-#include <windows.h>
-#include <tlhelp32.h>
typedef int (*fptr) (void);
+#ifdef __CYGWIN__
+
+#include <dlfcn.h>
+
+fptr find_any_f (const char *name) {
+ return (fptr) dlsym(RTLD_DEFAULT, name);
+}
+#else /* _WIN32 */
+
+#include <windows.h>
+#include <tlhelp32.h>
+
/* Unlike Linux and OS X, when a library is loaded, all the symbols aren't
* loaded into a single namespace. You must fetch the symbol by iterating over
* all loaded modules. Code for finding the function from any of the loaded
@@ -45,6 +55,7 @@ fptr find_any_f (const char *name) {
CloseHandle (snapshot);
return f;
}
+#endif
int DLL_PUBLIC func() {
fptr f;