Move crt sources out of API specific directories.

We use one set of sources for all API levels, and the code to find
these made checkbuild.py messier than it needed to be. Move them into
a non-API level specific location.

Test: ndk/checkbuild.py && ndk/run_tests.py
Bug: None
Change-Id: I8e571037b761ebc64b0bf234abd90511778f3224
diff --git a/ndk/platforms/android-9/arch-arm/src/__dso_handle.h b/ndk/crt/arm/__dso_handle.h
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/__dso_handle.h
rename to ndk/crt/arm/__dso_handle.h
diff --git a/ndk/platforms/android-9/arch-arm/src/__dso_handle_so.h b/ndk/crt/arm/__dso_handle_so.h
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/__dso_handle_so.h
rename to ndk/crt/arm/__dso_handle_so.h
diff --git a/ndk/platforms/android-21/arch-arm64/src/atexit.h b/ndk/crt/arm/atexit.h
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/atexit.h
rename to ndk/crt/arm/atexit.h
diff --git a/ndk/platforms/android-9/arch-arm/src/crtbegin.c b/ndk/crt/arm/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/crtbegin.c
rename to ndk/crt/arm/crtbegin.c
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c b/ndk/crt/arm/crtbegin_so.c
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c
rename to ndk/crt/arm/crtbegin_so.c
diff --git a/ndk/platforms/android-9/arch-arm/src/crtend_android.S b/ndk/crt/arm/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/crtend_android.S
rename to ndk/crt/arm/crtend_android.S
diff --git a/ndk/platforms/android-9/arch-arm/src/crtend_so.S b/ndk/crt/arm/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/crtend_so.S
rename to ndk/crt/arm/crtend_so.S
diff --git a/ndk/platforms/android-21/arch-arm64/src/atexit.h b/ndk/crt/arm64/atexit.h
similarity index 100%
copy from ndk/platforms/android-21/arch-arm64/src/atexit.h
copy to ndk/crt/arm64/atexit.h
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtbegin.c b/ndk/crt/arm64/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtbegin.c
rename to ndk/crt/arm64/crtbegin.c
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c b/ndk/crt/arm64/crtbegin_so.c
similarity index 100%
copy from ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c
copy to ndk/crt/arm64/crtbegin_so.c
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtend_android.S b/ndk/crt/arm64/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtend_android.S
rename to ndk/crt/arm64/crtend_android.S
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtend_so.S b/ndk/crt/arm64/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtend_so.S
rename to ndk/crt/arm64/crtend_so.S
diff --git a/ndk/platforms/android-9/arch-mips/src/atexit.h b/ndk/crt/mips/atexit.h
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/atexit.h
rename to ndk/crt/mips/atexit.h
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin.c b/ndk/crt/mips/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtbegin.c
rename to ndk/crt/mips/crtbegin.c
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_so.c b/ndk/crt/mips/crtbegin_so.c
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtbegin_so.c
rename to ndk/crt/mips/crtbegin_so.c
diff --git a/ndk/platforms/android-9/arch-mips/src/crtend_android.S b/ndk/crt/mips/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtend_android.S
rename to ndk/crt/mips/crtend_android.S
diff --git a/ndk/platforms/android-9/arch-mips/src/crtend_so.S b/ndk/crt/mips/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtend_so.S
rename to ndk/crt/mips/crtend_so.S
diff --git a/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h b/ndk/crt/mips64/asm_multiarch.h
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/asm_multiarch.h
rename to ndk/crt/mips64/asm_multiarch.h
diff --git a/ndk/platforms/android-9/arch-mips/src/atexit.h b/ndk/crt/mips64/atexit.h
similarity index 100%
copy from ndk/platforms/android-9/arch-mips/src/atexit.h
copy to ndk/crt/mips64/atexit.h
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtbegin.c b/ndk/crt/mips64/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-21/arch-mips64/src/crtbegin.c
rename to ndk/crt/mips64/crtbegin.c
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_so.c b/ndk/crt/mips64/crtbegin_so.c
similarity index 100%
copy from ndk/platforms/android-9/arch-mips/src/crtbegin_so.c
copy to ndk/crt/mips64/crtbegin_so.c
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtend_android.S b/ndk/crt/mips64/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-21/arch-mips64/src/crtend_android.S
rename to ndk/crt/mips64/crtend_android.S
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtend_so.S b/ndk/crt/mips64/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-21/arch-mips64/src/crtend_so.S
rename to ndk/crt/mips64/crtend_so.S
diff --git a/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.h b/ndk/crt/x86/__stack_chk_fail_local.h
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.h
rename to ndk/crt/x86/__stack_chk_fail_local.h
diff --git a/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h b/ndk/crt/x86/asm_multiarch.h
similarity index 100%
copy from ndk/platforms/android-9/arch-x86/src/asm_multiarch.h
copy to ndk/crt/x86/asm_multiarch.h
diff --git a/ndk/platforms/android-21/arch-arm64/src/atexit.h b/ndk/crt/x86/atexit.h
similarity index 100%
copy from ndk/platforms/android-21/arch-arm64/src/atexit.h
copy to ndk/crt/x86/atexit.h
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin.c b/ndk/crt/x86/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtbegin.c
rename to ndk/crt/x86/crtbegin.c
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_so.c b/ndk/crt/x86/crtbegin_so.c
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtbegin_so.c
rename to ndk/crt/x86/crtbegin_so.c
diff --git a/ndk/platforms/android-9/arch-x86/src/crtend_android.S b/ndk/crt/x86/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtend_android.S
rename to ndk/crt/x86/crtend_android.S
diff --git a/ndk/platforms/android-9/arch-x86/src/crtend_so.S b/ndk/crt/x86/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtend_so.S
rename to ndk/crt/x86/crtend_so.S
diff --git a/ndk/crt/x86_64 b/ndk/crt/x86_64
new file mode 120000
index 0000000..f4bad79
--- /dev/null
+++ b/ndk/crt/x86_64
@@ -0,0 +1 @@
+x86
\ No newline at end of file
diff --git a/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h b/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h
deleted file mode 100644
index 91cb8af..0000000
--- a/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifdef __LP64__
-# define ASM_PTR_SIZE(x) .quad x
-# define ASM_ALIGN_TO_PTR_SIZE .balign 8
-#else
-# define ASM_PTR_SIZE(x) .long x
-# define ASM_ALIGN_TO_PTR_SIZE .balign 4
-#endif
-
diff --git a/ndk/platforms/android-21/arch-mips64/src/atexit.h b/ndk/platforms/android-21/arch-mips64/src/atexit.h
deleted file mode 100644
index 3ded9bf..0000000
--- a/ndk/platforms/android-21/arch-mips64/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtbegin_so.c b/ndk/platforms/android-21/arch-mips64/src/crtbegin_so.c
deleted file mode 100644
index 925dc8c..0000000
--- a/ndk/platforms/android-21/arch-mips64/src/crtbegin_so.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-extern void __cxa_finalize(void *);
-extern void *__dso_handle;
-
-__attribute__((visibility("hidden"),destructor))
-void __on_dlclose() {
-  __cxa_finalize(&__dso_handle);
-}
-
-#include "__dso_handle_so.h"
-#include "atexit.h"
diff --git a/ndk/platforms/android-21/arch-x86_64/src b/ndk/platforms/android-21/arch-x86_64/src
deleted file mode 120000
index 18d4e35..0000000
--- a/ndk/platforms/android-21/arch-x86_64/src
+++ /dev/null
@@ -1 +0,0 @@
-../../android-9/arch-x86/src
\ No newline at end of file
diff --git a/ndk/platforms/android-9/arch-arm/src/atexit.h b/ndk/platforms/android-9/arch-arm/src/atexit.h
deleted file mode 100644
index 90aa030..0000000
--- a/ndk/platforms/android-9/arch-arm/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}
diff --git a/ndk/platforms/android-9/arch-arm/src/crtbegin_so.c b/ndk/platforms/android-9/arch-arm/src/crtbegin_so.c
deleted file mode 100644
index cd0257a..0000000
--- a/ndk/platforms/android-9/arch-arm/src/crtbegin_so.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-extern void __cxa_finalize(void *);
-extern void *__dso_handle;
-
-__attribute__((visibility("hidden"),destructor))
-void __on_dlclose() {
-  __cxa_finalize(&__dso_handle);
-}
-
-/* CRT_LEGACY_WORKAROUND should only be defined when building
- * this file as part of the platform's C library.
- *
- * The C library already defines a function named 'atexit()'
- * for backwards compatibility with older NDK-generated binaries.
- *
- * For newer ones, 'atexit' is actually embedded in the C
- * runtime objects that are linked into the final ELF
- * binary (shared library or executable), and will call
- * __cxa_atexit() in order to un-register any atexit()
- * handler when a library is unloaded.
- *
- * This function must be global *and* hidden. Only the
- * code inside the same ELF binary should be able to access it.
- */
-
-#ifdef CRT_LEGACY_WORKAROUND
-#include "__dso_handle.h"
-#else
-#include "__dso_handle_so.h"
-#include "atexit.h"
-#endif
diff --git a/ndk/platforms/android-9/arch-x86/src/atexit.h b/ndk/platforms/android-9/arch-x86/src/atexit.h
deleted file mode 100644
index 90aa030..0000000
--- a/ndk/platforms/android-9/arch-x86/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}