blob: 3f26f2b458dade389c61a5d2ba5540448addebe2 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28#include <stddef.h>
29#include <string.h>
30
David 'Digit' Turner3e16f842009-05-14 14:25:26 +020031extern int __cxa_atexit(void (*)(void*), void*, void* );
32
David 'Digit' Turner3b43f872010-07-01 23:09:28 -070033/* Temporary hack: this variable should not be part of the C library
34 * itself, but placed in the .bss section of each executable or
35 * shared library instead.
36 *
37 * We keep it here temporarily until the build system has been
38 * modified properly to use crtbegin_so.S and crtend_so.S when
39 * generating shared libraries.
40 *
41 * It must be a 'weak' symbol to avoid conflicts with the definitions
42 * that have been moved to crtbegin_static.S and crtbegin_dynamic.S
43 *
44 * For the record, it is used for static C++ object construction
45 * and destruction. See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
46 */
47void* __attribute__((weak)) __dso_handle;
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080048
David 'Digit' Turner0ba91ed2009-05-20 11:42:52 +020049/* The "C++ ABI for ARM" document states that static C++ constructors,
50 * which are called from the .init_array, should manually call
51 * __aeabi_atexit() to register static destructors explicitely.
52 *
53 * Note that 'dso_handle' is the address of a magic linker-generate
54 * variable from the shared object that contains the constructor/destructor
55 */
56
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080057/* Make this a weak symbol to avoid a multiple definition error when linking
58 * with libstdc++-v3. */
59int __attribute__((weak))
60__aeabi_atexit (void *object, void (*destructor) (void *), void *dso_handle)
61{
David 'Digit' Turner0ba91ed2009-05-20 11:42:52 +020062 return __cxa_atexit(destructor, object, dso_handle);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080063}
64
65
66void __aeabi_memcpy8(void *dest, const void *src, size_t n) {
67 memcpy(dest, src, n);
68}
69
70void __aeabi_memcpy4(void *dest, const void *src, size_t n) {
71 memcpy(dest, src, n);
72}
73
74void __aeabi_memcpy(void *dest, const void *src, size_t n) {
75 memcpy(dest, src, n);
76}
77
78
79void __aeabi_memmove8(void *dest, const void *src, size_t n) {
80 memmove(dest, src, n);
81}
82
83void __aeabi_memmove4(void *dest, const void *src, size_t n) {
84 memmove(dest, src, n);
85}
86
87void __aeabi_memmove(void *dest, const void *src, size_t n) {
88 memmove(dest, src, n);
89}
90
91/*
92 * __aeabi_memset has the order of its second and third arguments reversed.
93 * This allows __aeabi_memclr to tail-call __aeabi_memset
94 */
95
96void __aeabi_memset8(void *dest, size_t n, int c) {
97 memset(dest, c, n);
98}
99
100void __aeabi_memset4(void *dest, size_t n, int c) {
101 memset(dest, c, n);
102}
103
104void __aeabi_memset(void *dest, size_t n, int c) {
105 memset(dest, c, n);
106}
107
108
109void __aeabi_memclr8(void *dest, size_t n) {
110 __aeabi_memset8(dest, n, 0);
111}
112
113void __aeabi_memclr4(void *dest, size_t n) {
114 __aeabi_memset4(dest, n, 0);
115}
116
117void __aeabi_memclr(void *dest, size_t n) {
118 __aeabi_memset(dest, n, 0);
119}