From 16ad5508721300fc5afab6dff61d650c799a35ac Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Mon, 3 Apr 2017 22:43:54 +0100 Subject: [PATCH] Fix test cases/common/125 on Cygwin --- test cases/common/125 shared module/meson.build | 3 ++- test cases/common/125 shared module/module.c | 17 ++++++++++++++--- 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 7c15bccd2..d96d8fcae 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 56078c565..181b760ff 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 -#include -#include typedef int (*fptr) (void); +#ifdef __CYGWIN__ + +#include + +fptr find_any_f (const char *name) { + return (fptr) dlsym(RTLD_DEFAULT, name); +} +#else /* _WIN32 */ + +#include +#include + /* 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;