Fix test cases/common/125 on Cygwin

pull/1567/head
Jon Turney 8 years ago
parent b4b55c3022
commit 16ad550872
  1. 3
      test cases/common/125 shared module/meson.build
  2. 17
      test cases/common/125 shared module/module.c

@ -5,7 +5,8 @@ l = shared_library('runtime', 'runtime.c')
# Do NOT link the module with the runtime library. This # Do NOT link the module with the runtime library. This
# is a common approach for plugins that are only used # is a common approach for plugins that are only used
# with dlopen. Any symbols are resolved dynamically # 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') m = shared_module('mymodule', 'module.c')
e = executable('prog', 'prog.c', link_with : l, dependencies : dl) e = executable('prog', 'prog.c', link_with : l, dependencies : dl)
test('import test', e, args : m) test('import test', e, args : m)

@ -9,14 +9,24 @@
#endif #endif
#endif #endif
#ifdef _WIN32 #if defined(_WIN32) || defined(__CYGWIN__)
#include <stdio.h> #include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
typedef int (*fptr) (void); 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 /* 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 * 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 * 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); CloseHandle (snapshot);
return f; return f;
} }
#endif
int DLL_PUBLIC func() { int DLL_PUBLIC func() {
fptr f; fptr f;

Loading…
Cancel
Save