]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/18_support/bad_exception/23591_thread-1.c
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 18_support / bad_exception / 23591_thread-1.c
CommitLineData
cddfb1c7 1// { dg-require-sharedlib "" }
2077db1b 2// { dg-options "-g -O2 -pthread -ldl -x c -fvtable-verify=none" { target *-*-linux* *-*-gnu* } }
cddfb1c7 3
5624e564 4// Copyright (C) 2005-2015 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.
28static 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);
8fc81078 35 if (!lib)
cddfb1c7
BK
36 {
37 printf("dlopen failed: %s\n", strerror(errno));
8fc81078 38 return 0;
cddfb1c7
BK
39 }
40 cb = (function_type) dlsym(lib, "try_throw_exception");
8fc81078 41 if (!cb)
cddfb1c7
BK
42 {
43 printf("dlsym failed: %s\n", strerror(errno));
8fc81078 44 return 0;
cddfb1c7
BK
45 }
46 cb();
47 dlclose(lib);
8fc81078 48 return 0;
cddfb1c7
BK
49}
50
51// libstdc++/23591
52int main(void)
53{
54 pthread_t pt;
55
8fc81078 56 if (pthread_create(&pt, 0, &run, 0) != 0)
cddfb1c7 57 return 1;
8fc81078 58 if (pthread_join(pt, 0) != 0)
cddfb1c7
BK
59 return 1;
60
61 return 0;
62}