Merged trunk at revision 161680 into branch.
[official-gcc.git] / libstdc++-v3 / testsuite / 18_support / bad_exception / 23591_thread-1.c
blobf6c623043cd4fad4145d79b65b5f860e92a7d4b8
1 // { dg-require-sharedlib "" }
2 // { dg-options "-g -O2 -pthread -ldl -x c" { target *-*-linux* } }
4 // Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc.
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
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
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.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <pthread.h>
22 #include <dlfcn.h>
23 #include <errno.h>
24 #include <stdio.h>
25 #include <string.h>
27 // NB: This must be compiled and linked as a "C" executable.
28 static void* run(void* arg)
30 typedef void (*function_type) (void);
31 void* lib;
32 void (*cb)();
34 lib = dlopen("./testsuite_shared.so", RTLD_NOW);
35 if (!lib)
37 printf("dlopen failed: %s\n", strerror(errno));
38 return 0;
40 cb = (function_type) dlsym(lib, "try_throw_exception");
41 if (!cb)
43 printf("dlsym failed: %s\n", strerror(errno));
44 return 0;
46 cb();
47 dlclose(lib);
48 return 0;
51 // libstdc++/23591
52 int main(void)
54 pthread_t pt;
56 if (pthread_create(&pt, 0, &run, 0) != 0)
57 return 1;
58 if (pthread_join(pt, 0) != 0)
59 return 1;
61 return 0;