Commit | Line | Data |
---|---|---|
b0f4b84b DJ |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3 | Copyright 2007 Free Software Foundation, Inc. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 2 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
18 | 02111-1307, USA. */ | |
19 | ||
20 | #include <stdio.h> | |
21 | #include <stdlib.h> | |
22 | ||
23 | #ifdef __WIN32__ | |
24 | #include <windows.h> | |
25 | #define dlopen(name, mode) LoadLibrary (name) | |
26 | #define dlsym(handle, func) GetProcAddress (handle, func) | |
27 | #define dlclose(handle) FreeLibrary (handle) | |
28 | #define dlerror() "an error occurred" | |
29 | #else | |
30 | #include <dlfcn.h> | |
31 | #endif | |
32 | ||
33 | int main() | |
34 | { | |
35 | void *handle; | |
36 | void (*func) (void); | |
37 | ||
38 | handle = dlopen (SHLIB_NAME, RTLD_LAZY); | |
39 | if (!handle) | |
40 | { | |
41 | fprintf (stderr, dlerror ()); | |
42 | exit (1); | |
43 | } | |
44 | ||
45 | func = (void (*)(void)) dlsym (handle, "shrfunc"); | |
46 | if (!func) | |
47 | { | |
48 | fprintf (stderr, dlerror ()); | |
49 | exit (1); | |
50 | } | |
51 | ||
52 | func (); | |
53 | ||
54 | dlclose (handle); | |
55 | ||
56 | return 0; | |
57 | } |