xref: /llvm-project/libcxxabi/test/cxa_thread_atexit_test.pass.cpp (revision a7f9895cc18995549c7facb96e72718da282a864)
1eb8650a7SLouis Dionne //===----------------------------------------------------------------------===//
2e434b34fSJonathan Roelofs //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e434b34fSJonathan Roelofs //
7e434b34fSJonathan Roelofs //===----------------------------------------------------------------------===//
8e434b34fSJonathan Roelofs 
9*a7f9895cSLouis Dionne // UNSUPPORTED: no-threads
10879d18bfSEric Fiselier // REQUIRES: linux
11e434b34fSJonathan Roelofs 
12e434b34fSJonathan Roelofs #include <assert.h>
13e434b34fSJonathan Roelofs #include <cxxabi.h>
14e434b34fSJonathan Roelofs 
15e434b34fSJonathan Roelofs static bool AtexitImplCalled = false;
16e434b34fSJonathan Roelofs 
__cxa_thread_atexit_impl(void (* dtor)(void *),void * obj,void * dso_symbol)17e434b34fSJonathan Roelofs extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj,
18e434b34fSJonathan Roelofs                                         void *dso_symbol) {
19e434b34fSJonathan Roelofs   assert(dtor == reinterpret_cast<void (*)(void *)>(1));
20e434b34fSJonathan Roelofs   assert(obj == reinterpret_cast<void *>(2));
21e434b34fSJonathan Roelofs   assert(dso_symbol == reinterpret_cast<void *>(3));
22e434b34fSJonathan Roelofs   AtexitImplCalled = true;
23e434b34fSJonathan Roelofs   return 4;
24e434b34fSJonathan Roelofs }
25e434b34fSJonathan Roelofs 
main(int,char **)26504bc07dSLouis Dionne int main(int, char**) {
27e434b34fSJonathan Roelofs   int RV = __cxxabiv1::__cxa_thread_atexit(
28e434b34fSJonathan Roelofs       reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2),
29e434b34fSJonathan Roelofs       reinterpret_cast<void *>(3));
30b4e15b8cSEric Fiselier   assert(RV == 4);
31e434b34fSJonathan Roelofs   assert(AtexitImplCalled);
32e434b34fSJonathan Roelofs   return 0;
33e434b34fSJonathan Roelofs }
34