]>
Commit | Line | Data |
---|---|---|
cddfb1c7 BK |
1 | // { dg-require-sharedlib "" } |
2 | // { dg-options "-g -O2 -pthread -ldl -x c" { target *-*-linux* } } | |
3 | ||
748086b7 | 4 | // Copyright (C) 2005, 2009 Free Software Foundation, Inc. |
cddfb1c7 BK |
5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
748086b7 | 9 | // Free Software Foundation; either version 3, or (at your option) |
cddfb1c7 BK |
10 | // any later version. |
11 | // | |
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | // | |
17 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
18 | // with this library; see the file COPYING3. If not see |
19 | // <http://www.gnu.org/licenses/>. | |
cddfb1c7 BK |
20 | |
21 | #include <pthread.h> | |
22 | #include <dlfcn.h> | |
23 | #include <errno.h> | |
24 | #include <stdio.h> | |
25 | #include <string.h> | |
26 | ||
27 | // NB: This must be compiled and linked as a "C" executable. | |
28 | static void* run(void* arg) | |
29 | { | |
30 | typedef void (*function_type) (void); | |
31 | void* lib; | |
32 | void (*cb)(); | |
33 | ||
34 | lib = dlopen("./testsuite_shared.so", RTLD_NOW); | |
35 | if (lib == NULL) | |
36 | { | |
37 | printf("dlopen failed: %s\n", strerror(errno)); | |
38 | return NULL; | |
39 | } | |
40 | cb = (function_type) dlsym(lib, "try_throw_exception"); | |
41 | if (cb == NULL) | |
42 | { | |
43 | printf("dlsym failed: %s\n", strerror(errno)); | |
44 | return NULL; | |
45 | } | |
46 | cb(); | |
47 | dlclose(lib); | |
48 | return NULL; | |
49 | } | |
50 | ||
51 | // libstdc++/23591 | |
52 | int main(void) | |
53 | { | |
54 | pthread_t pt; | |
55 | ||
56 | if (pthread_create(&pt, NULL, &run, NULL) != 0) | |
57 | return 1; | |
58 | if (pthread_join(pt, NULL) != 0) | |
59 | return 1; | |
60 | ||
61 | return 0; | |
62 | } |