Dan Albert | 12c0c8b | 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 | 879d18bf | 2015-02-03 23:50:47 +0000 | [diff] [blame^] | 10 | // REQUIRES: linux |
Dan Albert | 12c0c8b | 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 | |
| 26 | int main() { |
| 27 | int RV = __cxxabiv1::__cxa_thread_atexit( |
| 28 | reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2), |
| 29 | reinterpret_cast<void *>(3)); |
| 30 | assert(RV = 4); |
| 31 | assert(AtexitImplCalled); |
| 32 | return 0; |
| 33 | } |