OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [darwin-crt-tm.c] - Blame information for rev 749

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

Line No. Rev Author Line
1 734 jeremybenn
/* Provide the runtime infrastructure for the transactional memory lib.
2
   Copyright (C) 2011 Free Software Foundation, Inc.
3
   Contributed by Iain Sandoe <iains@gcc.gnu.org>
4
 
5
   This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
 
12
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
for more details.
16
 
17
Under Section 7 of GPL version 3, you are granted additional
18
permissions described in the GCC Runtime Library Exception, version
19
3.1, as published by the Free Software Foundation.
20
 
21
You should have received a copy of the GNU General Public License and
22
a copy of the GCC Runtime Library Exception along with this program;
23
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
<http://www.gnu.org/licenses/>.  */
25
 
26
#include "tsystem.h"
27
#include <stddef.h>
28
#include <dlfcn.h>
29
#include <mach-o/dyld.h>
30
#include <mach-o/getsect.h>
31
 
32
#ifdef __LP64__
33
#define GET_DATA_TMCT(mh,size) \
34
  getsectdatafromheader_64 ((struct mach_header_64*) mh, \
35
                            "__DATA", "__tm_clone_table", (uint64_t *)size)
36
#else
37
#define GET_DATA_TMCT(mh,size) \
38
  getsectdatafromheader (mh, "__DATA", "__tm_clone_table", (uint32_t *)size)
39
#endif
40
 
41
#define WEAK __attribute__((weak))
42
#define UNUSED __attribute__((unused))
43
 
44
extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
45
extern void _ITM_deregisterTMCloneTable (void *) WEAK;
46
 
47
#if defined(START) || defined(END)
48
static inline void *getTMCloneTable (const void *f, size_t *tmct_siz)
49
{
50
  char *tmct_fixed, *tmct = NULL;
51
  unsigned int i, img_count;
52
  struct mach_header *mh;
53
  Dl_info info;
54
 
55
  if (! dladdr (f, &info) || info.dli_fbase == NULL)
56
    abort ();
57
 
58
  mh = (struct mach_header *) info.dli_fbase;
59
  tmct_fixed = GET_DATA_TMCT (mh, tmct_siz);
60
  *tmct_siz /= (sizeof (size_t) * 2);
61
  /* No tm_clone_table or no clones. */
62
  if (tmct_fixed == NULL || *tmct_siz == 0)
63
    return NULL;
64
 
65
  img_count = _dyld_image_count();
66
  for (i = 0; i < img_count && tmct == NULL; i++)
67
    {
68
      if (mh == _dyld_get_image_header(i))
69
        tmct = tmct_fixed + (unsigned long)_dyld_get_image_vmaddr_slide(i);
70
    }
71
 
72
  return tmct;
73
}
74
#endif
75
 
76
#ifdef START
77
 
78
void __doTMRegistrations (void) __attribute__ ((constructor));
79
 
80
void __doTMRegistrations (void)
81
{
82
  size_t tmct_siz;
83
  void *tmct;
84
 
85
  tmct = getTMCloneTable ((const void *)&__doTMRegistrations, &tmct_siz);
86
  if (_ITM_registerTMCloneTable != NULL && tmct != NULL)
87
    _ITM_registerTMCloneTable (tmct, (size_t)tmct_siz);
88
}
89
 
90
#endif
91
 
92
#ifdef END
93
 
94
void __doTMdeRegistrations (void) __attribute__ ((destructor));
95
 
96
void __doTMdeRegistrations (void)
97
{
98
  size_t tmct_siz;
99
  void *tmct;
100
 
101
  tmct = getTMCloneTable ((const void *)&__doTMdeRegistrations, &tmct_siz);
102
  if (_ITM_deregisterTMCloneTable != NULL && tmct != NULL)
103
    _ITM_deregisterTMCloneTable (tmct);
104
}
105
 
106
/* Provide dummy functions to satisfy linkage for versions of the Darwin
107
   tool-chain that that can't handle undefined weak refs at the link stage.
108
   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
109
 
110
extern void *__cxa_allocate_exception (size_t) WEAK;
111
extern void __cxa_throw (void *, void *, void *) WEAK;
112
extern void *__cxa_begin_catch (void *) WEAK;
113
extern void *__cxa_end_catch (void) WEAK;
114
extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
115
 
116
extern void *_ZnwX (size_t) WEAK;
117
extern void _ZdlPv (void *) WEAK;
118
extern void *_ZnaX (size_t) WEAK;
119
extern void _ZdaPv (void *) WEAK;
120
 
121
typedef const struct nothrow_t { } *c_nothrow_p;
122
 
123
extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
124
extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
125
extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
126
extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
127
 
128
void *__cxa_allocate_exception (size_t s UNUSED) { return NULL; }
129
void __cxa_throw (void * a UNUSED, void * b UNUSED, void * c UNUSED)
130
  { return; }
131
void *__cxa_begin_catch (void * a UNUSED) { return NULL; }
132
void *__cxa_end_catch (void) { return NULL; }
133
void __cxa_tm_cleanup (void * a UNUSED, void * b UNUSED, unsigned int c UNUSED)
134
  { return; }
135
 
136
void *_ZnwX (size_t s UNUSED) { return NULL; }
137
void _ZdlPv (void * a UNUSED) { return; }
138
void *_ZnaX (size_t s UNUSED) { return NULL; }
139
void _ZdaPv (void * a UNUSED) { return; }
140
 
141
void *_ZnwXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
142
  { return NULL; }
143
void _ZdlPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED)  { return; }
144
void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
145
  { return NULL; }
146
void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { return; }
147
 
148
#endif

powered by: WebSVN 2.1.0

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