annotate libstdc++-v3/libsupc++/vec.cc @ 120:f93fa5091070

fix conv1.c
author mir3636
date Thu, 08 Mar 2018 14:53:42 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // New abi Support -*- C++ -*-
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 // Copyright (C) 2000-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
4 //
kono
parents:
diff changeset
5 // This file is part of GCC.
kono
parents:
diff changeset
6 //
kono
parents:
diff changeset
7 // GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 // it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 // the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 // any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 // GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 // GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 // Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
18 // permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
19 // 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 // You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
22 // a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
24 // <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 #include <cxxabi.h>
kono
parents:
diff changeset
29 #include <new>
kono
parents:
diff changeset
30 #include <exception>
kono
parents:
diff changeset
31 #include <bits/exception_defines.h>
kono
parents:
diff changeset
32 #include "unwind-cxx.h"
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 namespace __cxxabiv1
kono
parents:
diff changeset
35 {
kono
parents:
diff changeset
36 namespace
kono
parents:
diff changeset
37 {
kono
parents:
diff changeset
38 struct uncatch_exception
kono
parents:
diff changeset
39 {
kono
parents:
diff changeset
40 uncatch_exception();
kono
parents:
diff changeset
41 ~uncatch_exception () { __cxa_begin_catch (&p->unwindHeader); }
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 __cxa_exception* p;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 private:
kono
parents:
diff changeset
46 uncatch_exception&
kono
parents:
diff changeset
47 operator=(const uncatch_exception&);
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 uncatch_exception(const uncatch_exception&);
kono
parents:
diff changeset
50 };
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 uncatch_exception::uncatch_exception() : p(0)
kono
parents:
diff changeset
53 {
kono
parents:
diff changeset
54 __cxa_eh_globals *globals = __cxa_get_globals_fast ();
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 p = globals->caughtExceptions;
kono
parents:
diff changeset
57 p->handlerCount -= 1;
kono
parents:
diff changeset
58 globals->caughtExceptions = p->nextException;
kono
parents:
diff changeset
59 globals->uncaughtExceptions += 1;
kono
parents:
diff changeset
60 }
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 // Compute the total size with overflow checking.
kono
parents:
diff changeset
63 std::size_t compute_size(std::size_t element_count,
kono
parents:
diff changeset
64 std::size_t element_size,
kono
parents:
diff changeset
65 std::size_t padding_size)
kono
parents:
diff changeset
66 {
kono
parents:
diff changeset
67 if (element_size && element_count > std::size_t(-1) / element_size)
kono
parents:
diff changeset
68 _GLIBCXX_THROW_OR_ABORT(std::bad_alloc());
kono
parents:
diff changeset
69 std::size_t size = element_count * element_size;
kono
parents:
diff changeset
70 if (size + padding_size < size)
kono
parents:
diff changeset
71 _GLIBCXX_THROW_OR_ABORT(std::bad_alloc());
kono
parents:
diff changeset
72 return size + padding_size;
kono
parents:
diff changeset
73 }
kono
parents:
diff changeset
74 }
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 // Allocate and construct array.
kono
parents:
diff changeset
77 extern "C" void *
kono
parents:
diff changeset
78 __cxa_vec_new(std::size_t element_count,
kono
parents:
diff changeset
79 std::size_t element_size,
kono
parents:
diff changeset
80 std::size_t padding_size,
kono
parents:
diff changeset
81 __cxa_cdtor_type constructor,
kono
parents:
diff changeset
82 __cxa_cdtor_type destructor)
kono
parents:
diff changeset
83 {
kono
parents:
diff changeset
84 return __cxa_vec_new2(element_count, element_size, padding_size,
kono
parents:
diff changeset
85 constructor, destructor,
kono
parents:
diff changeset
86 &operator new[], &operator delete []);
kono
parents:
diff changeset
87 }
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 extern "C" void *
kono
parents:
diff changeset
90 __cxa_vec_new2(std::size_t element_count,
kono
parents:
diff changeset
91 std::size_t element_size,
kono
parents:
diff changeset
92 std::size_t padding_size,
kono
parents:
diff changeset
93 __cxa_cdtor_type constructor,
kono
parents:
diff changeset
94 __cxa_cdtor_type destructor,
kono
parents:
diff changeset
95 void *(*alloc) (std::size_t),
kono
parents:
diff changeset
96 void (*dealloc) (void *))
kono
parents:
diff changeset
97 {
kono
parents:
diff changeset
98 std::size_t size
kono
parents:
diff changeset
99 = compute_size(element_count, element_size, padding_size);
kono
parents:
diff changeset
100 char *base = static_cast <char *> (alloc (size));
kono
parents:
diff changeset
101 if (!base)
kono
parents:
diff changeset
102 return base;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 if (padding_size)
kono
parents:
diff changeset
105 {
kono
parents:
diff changeset
106 base += padding_size;
kono
parents:
diff changeset
107 reinterpret_cast <std::size_t *> (base)[-1] = element_count;
kono
parents:
diff changeset
108 #ifdef _GLIBCXX_ELTSIZE_IN_COOKIE
kono
parents:
diff changeset
109 reinterpret_cast <std::size_t *> (base)[-2] = element_size;
kono
parents:
diff changeset
110 #endif
kono
parents:
diff changeset
111 }
kono
parents:
diff changeset
112 __try
kono
parents:
diff changeset
113 {
kono
parents:
diff changeset
114 __cxa_vec_ctor(base, element_count, element_size,
kono
parents:
diff changeset
115 constructor, destructor);
kono
parents:
diff changeset
116 }
kono
parents:
diff changeset
117 __catch(...)
kono
parents:
diff changeset
118 {
kono
parents:
diff changeset
119 {
kono
parents:
diff changeset
120 uncatch_exception ue;
kono
parents:
diff changeset
121 // Core issue 901 will probably be resolved such that a
kono
parents:
diff changeset
122 // deleted operator delete means not freeing memory here.
kono
parents:
diff changeset
123 if (dealloc)
kono
parents:
diff changeset
124 dealloc(base - padding_size);
kono
parents:
diff changeset
125 }
kono
parents:
diff changeset
126 __throw_exception_again;
kono
parents:
diff changeset
127 }
kono
parents:
diff changeset
128 return base;
kono
parents:
diff changeset
129 }
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 extern "C" void *
kono
parents:
diff changeset
132 __cxa_vec_new3(std::size_t element_count,
kono
parents:
diff changeset
133 std::size_t element_size,
kono
parents:
diff changeset
134 std::size_t padding_size,
kono
parents:
diff changeset
135 __cxa_cdtor_type constructor,
kono
parents:
diff changeset
136 __cxa_cdtor_type destructor,
kono
parents:
diff changeset
137 void *(*alloc) (std::size_t),
kono
parents:
diff changeset
138 void (*dealloc) (void *, std::size_t))
kono
parents:
diff changeset
139 {
kono
parents:
diff changeset
140 std::size_t size
kono
parents:
diff changeset
141 = compute_size(element_count, element_size, padding_size);
kono
parents:
diff changeset
142 char *base = static_cast<char *>(alloc (size));
kono
parents:
diff changeset
143 if (!base)
kono
parents:
diff changeset
144 return base;
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 if (padding_size)
kono
parents:
diff changeset
147 {
kono
parents:
diff changeset
148 base += padding_size;
kono
parents:
diff changeset
149 reinterpret_cast<std::size_t *>(base)[-1] = element_count;
kono
parents:
diff changeset
150 #ifdef _GLIBCXX_ELTSIZE_IN_COOKIE
kono
parents:
diff changeset
151 reinterpret_cast <std::size_t *> (base)[-2] = element_size;
kono
parents:
diff changeset
152 #endif
kono
parents:
diff changeset
153 }
kono
parents:
diff changeset
154 __try
kono
parents:
diff changeset
155 {
kono
parents:
diff changeset
156 __cxa_vec_ctor(base, element_count, element_size,
kono
parents:
diff changeset
157 constructor, destructor);
kono
parents:
diff changeset
158 }
kono
parents:
diff changeset
159 __catch(...)
kono
parents:
diff changeset
160 {
kono
parents:
diff changeset
161 {
kono
parents:
diff changeset
162 uncatch_exception ue;
kono
parents:
diff changeset
163 if (dealloc)
kono
parents:
diff changeset
164 dealloc(base - padding_size, size);
kono
parents:
diff changeset
165 }
kono
parents:
diff changeset
166 __throw_exception_again;
kono
parents:
diff changeset
167 }
kono
parents:
diff changeset
168 return base;
kono
parents:
diff changeset
169 }
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 // Construct array.
kono
parents:
diff changeset
172 extern "C" __cxa_vec_ctor_return_type
kono
parents:
diff changeset
173 __cxa_vec_ctor(void *array_address,
kono
parents:
diff changeset
174 std::size_t element_count,
kono
parents:
diff changeset
175 std::size_t element_size,
kono
parents:
diff changeset
176 __cxa_cdtor_type constructor,
kono
parents:
diff changeset
177 __cxa_cdtor_type destructor)
kono
parents:
diff changeset
178 {
kono
parents:
diff changeset
179 std::size_t ix = 0;
kono
parents:
diff changeset
180 char *ptr = static_cast<char *>(array_address);
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 __try
kono
parents:
diff changeset
183 {
kono
parents:
diff changeset
184 if (constructor)
kono
parents:
diff changeset
185 for (; ix != element_count; ix++, ptr += element_size)
kono
parents:
diff changeset
186 constructor(ptr);
kono
parents:
diff changeset
187 }
kono
parents:
diff changeset
188 __catch(...)
kono
parents:
diff changeset
189 {
kono
parents:
diff changeset
190 {
kono
parents:
diff changeset
191 uncatch_exception ue;
kono
parents:
diff changeset
192 __cxa_vec_cleanup(array_address, ix, element_size, destructor);
kono
parents:
diff changeset
193 }
kono
parents:
diff changeset
194 __throw_exception_again;
kono
parents:
diff changeset
195 }
kono
parents:
diff changeset
196 _GLIBCXX_CXA_VEC_CTOR_RETURN (array_address);
kono
parents:
diff changeset
197 }
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 // Construct an array by copying.
kono
parents:
diff changeset
200 extern "C" __cxa_vec_ctor_return_type
kono
parents:
diff changeset
201 __cxa_vec_cctor(void *dest_array,
kono
parents:
diff changeset
202 void *src_array,
kono
parents:
diff changeset
203 std::size_t element_count,
kono
parents:
diff changeset
204 std::size_t element_size,
kono
parents:
diff changeset
205 __cxa_cdtor_return_type (*constructor) (void *, void *),
kono
parents:
diff changeset
206 __cxa_cdtor_type destructor)
kono
parents:
diff changeset
207 {
kono
parents:
diff changeset
208 std::size_t ix = 0;
kono
parents:
diff changeset
209 char *dest_ptr = static_cast<char *>(dest_array);
kono
parents:
diff changeset
210 char *src_ptr = static_cast<char *>(src_array);
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 __try
kono
parents:
diff changeset
213 {
kono
parents:
diff changeset
214 if (constructor)
kono
parents:
diff changeset
215 for (; ix != element_count;
kono
parents:
diff changeset
216 ix++, src_ptr += element_size, dest_ptr += element_size)
kono
parents:
diff changeset
217 constructor(dest_ptr, src_ptr);
kono
parents:
diff changeset
218 }
kono
parents:
diff changeset
219 __catch(...)
kono
parents:
diff changeset
220 {
kono
parents:
diff changeset
221 {
kono
parents:
diff changeset
222 uncatch_exception ue;
kono
parents:
diff changeset
223 __cxa_vec_cleanup(dest_array, ix, element_size, destructor);
kono
parents:
diff changeset
224 }
kono
parents:
diff changeset
225 __throw_exception_again;
kono
parents:
diff changeset
226 }
kono
parents:
diff changeset
227 _GLIBCXX_CXA_VEC_CTOR_RETURN (dest_array);
kono
parents:
diff changeset
228 }
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 // Destruct array.
kono
parents:
diff changeset
231 extern "C" void
kono
parents:
diff changeset
232 __cxa_vec_dtor(void *array_address,
kono
parents:
diff changeset
233 std::size_t element_count,
kono
parents:
diff changeset
234 std::size_t element_size,
kono
parents:
diff changeset
235 __cxa_cdtor_type destructor)
kono
parents:
diff changeset
236 {
kono
parents:
diff changeset
237 if (destructor)
kono
parents:
diff changeset
238 {
kono
parents:
diff changeset
239 char *ptr = static_cast<char *>(array_address);
kono
parents:
diff changeset
240 std::size_t ix = element_count;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 ptr += element_count * element_size;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 __try
kono
parents:
diff changeset
245 {
kono
parents:
diff changeset
246 while (ix--)
kono
parents:
diff changeset
247 {
kono
parents:
diff changeset
248 ptr -= element_size;
kono
parents:
diff changeset
249 destructor(ptr);
kono
parents:
diff changeset
250 }
kono
parents:
diff changeset
251 }
kono
parents:
diff changeset
252 __catch(...)
kono
parents:
diff changeset
253 {
kono
parents:
diff changeset
254 {
kono
parents:
diff changeset
255 uncatch_exception ue;
kono
parents:
diff changeset
256 __cxa_vec_cleanup(array_address, ix, element_size, destructor);
kono
parents:
diff changeset
257 }
kono
parents:
diff changeset
258 __throw_exception_again;
kono
parents:
diff changeset
259 }
kono
parents:
diff changeset
260 }
kono
parents:
diff changeset
261 }
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 // Destruct array as a result of throwing an exception.
kono
parents:
diff changeset
264 // [except.ctor]/3 If a destructor called during stack unwinding
kono
parents:
diff changeset
265 // exits with an exception, terminate is called.
kono
parents:
diff changeset
266 extern "C" void
kono
parents:
diff changeset
267 __cxa_vec_cleanup(void *array_address,
kono
parents:
diff changeset
268 std::size_t element_count,
kono
parents:
diff changeset
269 std::size_t element_size,
kono
parents:
diff changeset
270 __cxa_cdtor_type destructor) throw()
kono
parents:
diff changeset
271 {
kono
parents:
diff changeset
272 if (destructor)
kono
parents:
diff changeset
273 {
kono
parents:
diff changeset
274 char *ptr = static_cast <char *> (array_address);
kono
parents:
diff changeset
275 std::size_t ix = element_count;
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 ptr += element_count * element_size;
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 __try
kono
parents:
diff changeset
280 {
kono
parents:
diff changeset
281 while (ix--)
kono
parents:
diff changeset
282 {
kono
parents:
diff changeset
283 ptr -= element_size;
kono
parents:
diff changeset
284 destructor(ptr);
kono
parents:
diff changeset
285 }
kono
parents:
diff changeset
286 }
kono
parents:
diff changeset
287 __catch(...)
kono
parents:
diff changeset
288 {
kono
parents:
diff changeset
289 std::terminate();
kono
parents:
diff changeset
290 }
kono
parents:
diff changeset
291 }
kono
parents:
diff changeset
292 }
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 // Destruct and release array.
kono
parents:
diff changeset
295 extern "C" void
kono
parents:
diff changeset
296 __cxa_vec_delete(void *array_address,
kono
parents:
diff changeset
297 std::size_t element_size,
kono
parents:
diff changeset
298 std::size_t padding_size,
kono
parents:
diff changeset
299 __cxa_cdtor_type destructor)
kono
parents:
diff changeset
300 {
kono
parents:
diff changeset
301 __cxa_vec_delete2(array_address, element_size, padding_size,
kono
parents:
diff changeset
302 destructor,
kono
parents:
diff changeset
303 &operator delete []);
kono
parents:
diff changeset
304 }
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 extern "C" void
kono
parents:
diff changeset
307 __cxa_vec_delete2(void *array_address,
kono
parents:
diff changeset
308 std::size_t element_size,
kono
parents:
diff changeset
309 std::size_t padding_size,
kono
parents:
diff changeset
310 __cxa_cdtor_type destructor,
kono
parents:
diff changeset
311 void (*dealloc) (void *))
kono
parents:
diff changeset
312 {
kono
parents:
diff changeset
313 if (!array_address)
kono
parents:
diff changeset
314 return;
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316 char* base = static_cast<char *>(array_address);
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 if (padding_size)
kono
parents:
diff changeset
319 {
kono
parents:
diff changeset
320 std::size_t element_count = reinterpret_cast<std::size_t *>(base)[-1];
kono
parents:
diff changeset
321 base -= padding_size;
kono
parents:
diff changeset
322 __try
kono
parents:
diff changeset
323 {
kono
parents:
diff changeset
324 __cxa_vec_dtor(array_address, element_count, element_size,
kono
parents:
diff changeset
325 destructor);
kono
parents:
diff changeset
326 }
kono
parents:
diff changeset
327 __catch(...)
kono
parents:
diff changeset
328 {
kono
parents:
diff changeset
329 {
kono
parents:
diff changeset
330 uncatch_exception ue;
kono
parents:
diff changeset
331 dealloc(base);
kono
parents:
diff changeset
332 }
kono
parents:
diff changeset
333 __throw_exception_again;
kono
parents:
diff changeset
334 }
kono
parents:
diff changeset
335 }
kono
parents:
diff changeset
336 dealloc(base);
kono
parents:
diff changeset
337 }
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 extern "C" void
kono
parents:
diff changeset
340 __cxa_vec_delete3(void *array_address,
kono
parents:
diff changeset
341 std::size_t element_size,
kono
parents:
diff changeset
342 std::size_t padding_size,
kono
parents:
diff changeset
343 __cxa_cdtor_type destructor,
kono
parents:
diff changeset
344 void (*dealloc) (void *, std::size_t))
kono
parents:
diff changeset
345 {
kono
parents:
diff changeset
346 if (!array_address)
kono
parents:
diff changeset
347 return;
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 char* base = static_cast <char *> (array_address);
kono
parents:
diff changeset
350 std::size_t size = 0;
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 if (padding_size)
kono
parents:
diff changeset
353 {
kono
parents:
diff changeset
354 std::size_t element_count = reinterpret_cast<std::size_t *> (base)[-1];
kono
parents:
diff changeset
355 base -= padding_size;
kono
parents:
diff changeset
356 size = element_count * element_size + padding_size;
kono
parents:
diff changeset
357 __try
kono
parents:
diff changeset
358 {
kono
parents:
diff changeset
359 __cxa_vec_dtor(array_address, element_count, element_size,
kono
parents:
diff changeset
360 destructor);
kono
parents:
diff changeset
361 }
kono
parents:
diff changeset
362 __catch(...)
kono
parents:
diff changeset
363 {
kono
parents:
diff changeset
364 {
kono
parents:
diff changeset
365 uncatch_exception ue;
kono
parents:
diff changeset
366 dealloc(base, size);
kono
parents:
diff changeset
367 }
kono
parents:
diff changeset
368 __throw_exception_again;
kono
parents:
diff changeset
369 }
kono
parents:
diff changeset
370 }
kono
parents:
diff changeset
371 dealloc(base, size);
kono
parents:
diff changeset
372 }
kono
parents:
diff changeset
373 } // namespace __cxxabiv1
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 #if defined(__arm__) && defined(__ARM_EABI__)
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 // The ARM C++ ABI requires that the library provide these additional
kono
parents:
diff changeset
378 // helper functions. There are placed in this file, despite being
kono
parents:
diff changeset
379 // architecture-specifier, so that the compiler can inline the __cxa
kono
parents:
diff changeset
380 // functions into these functions as appropriate.
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 namespace __aeabiv1
kono
parents:
diff changeset
383 {
kono
parents:
diff changeset
384 extern "C" void *
kono
parents:
diff changeset
385 __aeabi_vec_ctor_nocookie_nodtor (void *array_address,
kono
parents:
diff changeset
386 abi::__cxa_cdtor_type constructor,
kono
parents:
diff changeset
387 std::size_t element_size,
kono
parents:
diff changeset
388 std::size_t element_count)
kono
parents:
diff changeset
389 {
kono
parents:
diff changeset
390 return abi::__cxa_vec_ctor (array_address, element_count, element_size,
kono
parents:
diff changeset
391 constructor, /*destructor=*/NULL);
kono
parents:
diff changeset
392 }
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 extern "C" void *
kono
parents:
diff changeset
395 __aeabi_vec_ctor_cookie_nodtor (void *array_address,
kono
parents:
diff changeset
396 abi::__cxa_cdtor_type constructor,
kono
parents:
diff changeset
397 std::size_t element_size,
kono
parents:
diff changeset
398 std::size_t element_count)
kono
parents:
diff changeset
399 {
kono
parents:
diff changeset
400 if (array_address == NULL)
kono
parents:
diff changeset
401 return NULL;
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 array_address = reinterpret_cast<std::size_t *>(array_address) + 2;
kono
parents:
diff changeset
404 reinterpret_cast<std::size_t *>(array_address)[-2] = element_size;
kono
parents:
diff changeset
405 reinterpret_cast<std::size_t *>(array_address)[-1] = element_count;
kono
parents:
diff changeset
406 return abi::__cxa_vec_ctor (array_address,
kono
parents:
diff changeset
407 element_count, element_size,
kono
parents:
diff changeset
408 constructor, /*destructor=*/NULL);
kono
parents:
diff changeset
409 }
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 extern "C" void *
kono
parents:
diff changeset
412 __aeabi_vec_cctor_nocookie_nodtor (void *dest_array,
kono
parents:
diff changeset
413 void *src_array,
kono
parents:
diff changeset
414 std::size_t element_size,
kono
parents:
diff changeset
415 std::size_t element_count,
kono
parents:
diff changeset
416 void *(*constructor) (void *, void *))
kono
parents:
diff changeset
417 {
kono
parents:
diff changeset
418 return abi::__cxa_vec_cctor (dest_array, src_array,
kono
parents:
diff changeset
419 element_count, element_size,
kono
parents:
diff changeset
420 constructor, NULL);
kono
parents:
diff changeset
421 }
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 extern "C" void *
kono
parents:
diff changeset
424 __aeabi_vec_new_cookie_noctor (std::size_t element_size,
kono
parents:
diff changeset
425 std::size_t element_count)
kono
parents:
diff changeset
426 {
kono
parents:
diff changeset
427 return abi::__cxa_vec_new(element_count, element_size,
kono
parents:
diff changeset
428 2 * sizeof (std::size_t),
kono
parents:
diff changeset
429 /*constructor=*/NULL, /*destructor=*/NULL);
kono
parents:
diff changeset
430 }
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 extern "C" void *
kono
parents:
diff changeset
433 __aeabi_vec_new_nocookie (std::size_t element_size,
kono
parents:
diff changeset
434 std::size_t element_count,
kono
parents:
diff changeset
435 abi::__cxa_cdtor_type constructor)
kono
parents:
diff changeset
436 {
kono
parents:
diff changeset
437 return abi::__cxa_vec_new (element_count, element_size, 0, constructor,
kono
parents:
diff changeset
438 NULL);
kono
parents:
diff changeset
439 }
kono
parents:
diff changeset
440
kono
parents:
diff changeset
441 extern "C" void *
kono
parents:
diff changeset
442 __aeabi_vec_new_cookie_nodtor (std::size_t element_size,
kono
parents:
diff changeset
443 std::size_t element_count,
kono
parents:
diff changeset
444 abi::__cxa_cdtor_type constructor)
kono
parents:
diff changeset
445 {
kono
parents:
diff changeset
446 return abi::__cxa_vec_new(element_count, element_size,
kono
parents:
diff changeset
447 2 * sizeof (std::size_t),
kono
parents:
diff changeset
448 constructor, NULL);
kono
parents:
diff changeset
449 }
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 extern "C" void *
kono
parents:
diff changeset
452 __aeabi_vec_new_cookie(std::size_t element_size,
kono
parents:
diff changeset
453 std::size_t element_count,
kono
parents:
diff changeset
454 abi::__cxa_cdtor_type constructor,
kono
parents:
diff changeset
455 abi::__cxa_cdtor_type destructor)
kono
parents:
diff changeset
456 {
kono
parents:
diff changeset
457 return abi::__cxa_vec_new (element_count, element_size,
kono
parents:
diff changeset
458 2 * sizeof (std::size_t),
kono
parents:
diff changeset
459 constructor, destructor);
kono
parents:
diff changeset
460 }
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463 extern "C" void *
kono
parents:
diff changeset
464 __aeabi_vec_dtor (void *array_address,
kono
parents:
diff changeset
465 abi::__cxa_cdtor_type destructor,
kono
parents:
diff changeset
466 std::size_t element_size,
kono
parents:
diff changeset
467 std::size_t element_count)
kono
parents:
diff changeset
468 {
kono
parents:
diff changeset
469 abi::__cxa_vec_dtor (array_address, element_count, element_size,
kono
parents:
diff changeset
470 destructor);
kono
parents:
diff changeset
471 return reinterpret_cast<std::size_t*> (array_address) - 2;
kono
parents:
diff changeset
472 }
kono
parents:
diff changeset
473
kono
parents:
diff changeset
474 extern "C" void *
kono
parents:
diff changeset
475 __aeabi_vec_dtor_cookie (void *array_address,
kono
parents:
diff changeset
476 abi::__cxa_cdtor_type destructor)
kono
parents:
diff changeset
477 {
kono
parents:
diff changeset
478 if (!array_address)
kono
parents:
diff changeset
479 return NULL;
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 abi::__cxa_vec_dtor (array_address,
kono
parents:
diff changeset
482 reinterpret_cast<std::size_t *>(array_address)[-1],
kono
parents:
diff changeset
483 reinterpret_cast<std::size_t *>(array_address)[-2],
kono
parents:
diff changeset
484 destructor);
kono
parents:
diff changeset
485 return reinterpret_cast<std::size_t*> (array_address) - 2;
kono
parents:
diff changeset
486 }
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488
kono
parents:
diff changeset
489 extern "C" void
kono
parents:
diff changeset
490 __aeabi_vec_delete (void *array_address,
kono
parents:
diff changeset
491 abi::__cxa_cdtor_type destructor)
kono
parents:
diff changeset
492 {
kono
parents:
diff changeset
493 if (!array_address)
kono
parents:
diff changeset
494 return;
kono
parents:
diff changeset
495
kono
parents:
diff changeset
496 abi::__cxa_vec_delete (array_address,
kono
parents:
diff changeset
497 reinterpret_cast<std::size_t *>(array_address)[-2],
kono
parents:
diff changeset
498 2 * sizeof (std::size_t),
kono
parents:
diff changeset
499 destructor);
kono
parents:
diff changeset
500 }
kono
parents:
diff changeset
501
kono
parents:
diff changeset
502 extern "C" void
kono
parents:
diff changeset
503 __aeabi_vec_delete3 (void *array_address,
kono
parents:
diff changeset
504 abi::__cxa_cdtor_type destructor,
kono
parents:
diff changeset
505 void (*dealloc) (void *, std::size_t))
kono
parents:
diff changeset
506 {
kono
parents:
diff changeset
507 if (!array_address)
kono
parents:
diff changeset
508 return;
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 abi::__cxa_vec_delete3 (array_address,
kono
parents:
diff changeset
511 reinterpret_cast<std::size_t *>(array_address)[-2],
kono
parents:
diff changeset
512 2 * sizeof (std::size_t),
kono
parents:
diff changeset
513 destructor, dealloc);
kono
parents:
diff changeset
514 }
kono
parents:
diff changeset
515
kono
parents:
diff changeset
516 extern "C" void
kono
parents:
diff changeset
517 __aeabi_vec_delete3_nodtor (void *array_address,
kono
parents:
diff changeset
518 void (*dealloc) (void *, std::size_t))
kono
parents:
diff changeset
519 {
kono
parents:
diff changeset
520 if (!array_address)
kono
parents:
diff changeset
521 return;
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 abi::__cxa_vec_delete3 (array_address,
kono
parents:
diff changeset
524 reinterpret_cast<std::size_t *>(array_address)[-2],
kono
parents:
diff changeset
525 2 * sizeof (std::size_t),
kono
parents:
diff changeset
526 /*destructor=*/NULL, dealloc);
kono
parents:
diff changeset
527 }
kono
parents:
diff changeset
528 } // namespace __aeabiv1
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 #endif // defined(__arm__) && defined(__ARM_EABI__)