OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [18_support/] [bad_exception/] [23591_thread-1.c] - Blame information for rev 565

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-require-sharedlib "" }
2
// { dg-options "-g -O2 -pthread -ldl -x c" { target *-*-linux* } }
3
 
4
// Copyright (C) 2005, 2009 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.
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
18
// with this library; see the file COPYING3.  If not see
19
// <http://www.gnu.org/licenses/>.
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.