Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 1 | //===--------------------- cxa_thread_atexit_test.cpp ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Eric Fiselier | 8b9be66 | 2016-10-31 14:14:04 +0000 | [diff] [blame] | 10 | // UNSUPPORTED: libcxxabi-no-threads |
Eric Fiselier | cc8269f | 2015-02-03 23:50:47 +0000 | [diff] [blame] | 11 | // REQUIRES: linux |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 12 | |
| 13 | #include <assert.h> |
| 14 | #include <cxxabi.h> |
| 15 | |
| 16 | static bool AtexitImplCalled = false; |
| 17 | |
| 18 | extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj, |
| 19 | void *dso_symbol) { |
| 20 | assert(dtor == reinterpret_cast<void (*)(void *)>(1)); |
| 21 | assert(obj == reinterpret_cast<void *>(2)); |
| 22 | assert(dso_symbol == reinterpret_cast<void *>(3)); |
| 23 | AtexitImplCalled = true; |
| 24 | return 4; |
| 25 | } |
| 26 | |
| 27 | int main() { |
| 28 | int RV = __cxxabiv1::__cxa_thread_atexit( |
| 29 | reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2), |
| 30 | reinterpret_cast<void *>(3)); |
Eric Fiselier | 933c4df | 2016-09-16 08:16:07 +0000 | [diff] [blame] | 31 | assert(RV == 4); |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 32 | assert(AtexitImplCalled); |
| 33 | return 0; |
| 34 | } |