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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libitm/] [alloc_cpp.cc] - Blame information for rev 755

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

Line No. Rev Author Line
1 737 jeremybenn
/* Copyright (C) 2009, 2011 Free Software Foundation, Inc.
2
   Contributed by Richard Henderson <rth@redhat.com>.
3
 
4
   This file is part of the GNU Transactional Memory Library (libitm).
5
 
6
   Libitm is free software; you can redistribute it and/or modify it
7
   under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
 
11
   Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14
   more details.
15
 
16
   Under Section 7 of GPL version 3, you are granted additional
17
   permissions described in the GCC Runtime Library Exception, version
18
   3.1, as published by the Free Software Foundation.
19
 
20
   You should have received a copy of the GNU General Public License and
21
   a copy of the GCC Runtime Library Exception along with this program;
22
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
   <http://www.gnu.org/licenses/>.  */
24
 
25
#include "libitm_i.h"
26
 
27
using namespace GTM;
28
 
29
/* Mangling the names by hand requires that we know how size_t is handled.
30
   We've gotten the letter from autoconf, now substitute it into the names.
31
   Everything below uses X as a placeholder for clarity.  */
32
 
33
#define S1(x,y)                 x##y
34
#define S(x,y)                  S1(x,y)
35
 
36
#define _ZnwX                   S(_Znw,MANGLE_SIZE_T)
37
#define _ZnaX                   S(_Zna,MANGLE_SIZE_T)
38
#define _ZnwXRKSt9nothrow_t     S(S(_Znw,MANGLE_SIZE_T),RKSt9nothrow_t)
39
#define _ZnaXRKSt9nothrow_t     S(S(_Zna,MANGLE_SIZE_T),RKSt9nothrow_t)
40
 
41
#define _ZGTtnwX                S(_ZGTtnw,MANGLE_SIZE_T)
42
#define _ZGTtnaX                S(_ZGTtna,MANGLE_SIZE_T)
43
#define _ZGTtnwXRKSt9nothrow_t  S(S(_ZGTtnw,MANGLE_SIZE_T),RKSt9nothrow_t)
44
#define _ZGTtnaXRKSt9nothrow_t  S(S(_ZGTtna,MANGLE_SIZE_T),RKSt9nothrow_t)
45
 
46
/* Everything from libstdc++ is weak, to avoid requiring that library
47
   to be linked into plain C applications using libitm.so.  */
48
 
49
extern "C" {
50
 
51
extern void *_ZnwX (size_t) __attribute__((weak));
52
extern void _ZdlPv (void *) __attribute__((weak));
53
extern void *_ZnaX (size_t) __attribute__((weak));
54
extern void _ZdaPv (void *) __attribute__((weak));
55
 
56
typedef const struct nothrow_t { } *c_nothrow_p;
57
 
58
extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
59
extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
60
extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
61
extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
62
 
63
#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
64
void *_ZnwX (size_t) { return NULL; }
65
void _ZdlPv (void *) { return; }
66
void *_ZnaX (size_t) { return NULL; }
67
void _ZdaPv (void *) { return; }
68
 
69
void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) { return NULL; }
70
void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) { return; }
71
void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) { return NULL; }
72
void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) { return; }
73
#endif /* HAVE_ELF_STYLE_WEAKREF */
74
 
75
/* Wrap the delete nothrow symbols for usage with a single argument.
76
   Perhaps should have a configure type check for this, because the
77
   std::nothrow_t reference argument is unused (empty class), and most
78
   targets don't actually need that second argument.  So we _could_
79
   invoke these functions as if they were a single argument free.  */
80
static void
81
del_opnt (void *ptr)
82
{
83
  _ZdlPvRKSt9nothrow_t (ptr, NULL);
84
}
85
 
86
static void
87
del_opvnt (void *ptr)
88
{
89
  _ZdaPvRKSt9nothrow_t (ptr, NULL);
90
}
91
 
92
/* Wrap: operator new (std::size_t sz)  */
93
void *
94
_ZGTtnwX (size_t sz)
95
{
96
  void *r = _ZnwX (sz);
97
  if (r)
98
    gtm_thr()->record_allocation (r, _ZdlPv);
99
  return r;
100
}
101
 
102
/* Wrap: operator new (std::size_t sz, const std::nothrow_t&)  */
103
void *
104
_ZGTtnwXRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
105
{
106
  void *r = _ZnwXRKSt9nothrow_t (sz, nt);
107
  if (r)
108
    gtm_thr()->record_allocation (r, del_opnt);
109
  return r;
110
}
111
 
112
/* Wrap: operator new[] (std::size_t sz)  */
113
void *
114
_ZGTtnaX (size_t sz)
115
{
116
  void *r = _ZnaX (sz);
117
  if (r)
118
    gtm_thr()->record_allocation (r, _ZdaPv);
119
  return r;
120
}
121
 
122
/* Wrap: operator new[] (std::size_t sz, const std::nothrow_t& nothrow)  */
123
void *
124
_ZGTtnaXRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
125
{
126
  void *r = _ZnaXRKSt9nothrow_t (sz, nt);
127
  if (r)
128
    gtm_thr()->record_allocation (r, del_opvnt);
129
  return r;
130
}
131
 
132
/* Wrap: operator delete(void* ptr)  */
133
void
134
_ZGTtdlPv (void *ptr)
135
{
136
  if (ptr)
137
    gtm_thr()->forget_allocation (ptr, _ZdlPv);
138
}
139
 
140
/* Wrap: operator delete (void *ptr, const std::nothrow_t&)  */
141
void
142
_ZGTtdlPvRKSt9nothrow_t (void *ptr, c_nothrow_p nt UNUSED)
143
{
144
  if (ptr)
145
    gtm_thr()->forget_allocation (ptr, del_opnt);
146
}
147
 
148
/* Wrap: operator delete[] (void *ptr)  */
149
void
150
_ZGTtdaPv (void *ptr)
151
{
152
  if (ptr)
153
    gtm_thr()->forget_allocation (ptr, _ZdaPv);
154
}
155
 
156
/* Wrap: operator delete[] (void *ptr, const std::nothrow_t&)  */
157
void
158
_ZGTtdaPvRKSt9nothrow_t (void *ptr, c_nothrow_p nt UNUSED)
159
{
160
  if (ptr)
161
    gtm_thr()->forget_allocation (ptr, del_opvnt);
162
}
163
 
164
} // extern "C"

powered by: WebSVN 2.1.0

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