comparison test/dynload_plain/dynload_plain.c @ 233:8216c86b4cbc

- make dynload_plain test build on windows
author Tassilo Philipp
date Sun, 16 Apr 2017 17:50:55 +0200
parents 7076f551faf5
children 808045066f12
comparison
equal deleted inserted replaced
232:76ed51a690a6 233:8216c86b4cbc
25 25
26 #include "../../dynload/dynload.h" 26 #include "../../dynload/dynload.h"
27 #include "../common/platformInit.h" 27 #include "../common/platformInit.h"
28 28
29 #include <string.h> 29 #include <string.h>
30 #include <unistd.h> 30 #if defined(DC_WINDOWS)
31 # include <io.h>
32 # define F_OK 0
33 #else
34 # include <unistd.h>
35 #endif
31 36
32 37
33 int main(int argc, char* argv[]) 38 int main(int argc, char* argv[])
34 { 39 {
35 int r = 0, i; 40 int r = 0, i;
36 void* p; 41 void* p;
37 DLLib* pLib; 42 DLLib* pLib;
43 DLSyms* pSyms;
38 const char* path = NULL; 44 const char* path = NULL;
39 const char* clibs[] = { // hacky/lazy list of some clib paths per platform 45 const char* clibs[] = { // hacky/lazy list of some clib paths per platform
40 "/lib/libc.so", 46 "/lib/libc.so",
41 "/lib/libc.so.6", 47 "/lib/libc.so.6",
42 "/lib/libc.so.7", 48 "/lib/libc.so.7",
46 "/lib32/libc.so", 52 "/lib32/libc.so",
47 "/lib32/libc.so.6", 53 "/lib32/libc.so.6",
48 "/lib32/libc.so.7", 54 "/lib32/libc.so.7",
49 "/usr/lib/system/libsystem_c.dylib", 55 "/usr/lib/system/libsystem_c.dylib",
50 "/usr/lib/libc.dylib", 56 "/usr/lib/libc.dylib",
51 "C:\\Windows\\system32\\msvcrt.dll" 57 "\\Windows\\system32\\msvcrt.dll",
58 "C:\\Windows\\system32\\msvcrt.dll",
59 "D:\\Windows\\system32\\msvcrt.dll",
60 "E:\\Windows\\system32\\msvcrt.dll"
52 }; 61 };
53 62
54 63
55 for(i=0; i<(sizeof(clibs)/sizeof(const char*)); ++i) { 64 for(i=0; i<(sizeof(clibs)/sizeof(const char*)); ++i) {
56 if(access(clibs[i], F_OK) != -1) { 65 if(access(clibs[i], F_OK) != -1) {
80 printf("unable to open library %s\n", path); 89 printf("unable to open library %s\n", path);
81 90
82 91
83 // dlSyms* tests (intentionally after freeing lib above, as they work standalone) 92 // dlSyms* tests (intentionally after freeing lib above, as they work standalone)
84 // -------- 93 // --------
85 DLSyms* pSyms = dlSymsInit(path); // check if we can iterate over symbols - init 94 pSyms = dlSymsInit(path); // check if we can iterate over symbols - init
86 if(pSyms) { 95 if(pSyms) {
87 int n; 96 int n;
88 const char* name; 97 const char* name;
89 98
90 printf("pSyms handle: %p\n", pSyms); 99 printf("pSyms handle: %p\n", pSyms);