Louis Dionne | 6edba26 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
Dan Albert | 29cbadc | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 87bc9b4 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Dan Albert | 29cbadc | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Eric Fiselier | e527e7c | 2016-10-31 14:14:04 +0000 | [diff] [blame] | 9 | // UNSUPPORTED: libcxxabi-no-threads |
Eric Fiselier | d487fb2 | 2015-02-03 23:50:47 +0000 | [diff] [blame] | 10 | // REQUIRES: linux |
Dan Albert | 29cbadc | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 11 | |
| 12 | #include <assert.h> |
| 13 | #include <cxxabi.h> |
| 14 | |
| 15 | static bool AtexitImplCalled = false; |
| 16 | |
| 17 | extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj, |
| 18 | void *dso_symbol) { |
| 19 | assert(dtor == reinterpret_cast<void (*)(void *)>(1)); |
| 20 | assert(obj == reinterpret_cast<void *>(2)); |
| 21 | assert(dso_symbol == reinterpret_cast<void *>(3)); |
| 22 | AtexitImplCalled = true; |
| 23 | return 4; |
| 24 | } |
| 25 | |
Louis Dionne | a33d6aa | 2020-10-08 13:36:33 -0400 | [diff] [blame] | 26 | int main(int, char**) { |
Dan Albert | 29cbadc | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 27 | int RV = __cxxabiv1::__cxa_thread_atexit( |
| 28 | reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2), |
| 29 | reinterpret_cast<void *>(3)); |
Eric Fiselier | 13c3382 | 2016-09-16 08:16:07 +0000 | [diff] [blame] | 30 | assert(RV == 4); |
Dan Albert | 29cbadc | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 31 | assert(AtexitImplCalled); |
| 32 | return 0; |
| 33 | } |