blob: 0f9324bfc7bb3c951688ea5c0dd536f859803677 [file] [log] [blame]
Louis Dionne6edba262021-11-17 16:25:01 -05001//===----------------------------------------------------------------------===//
Dan Albert29cbadc2014-12-18 00:03:57 +00002//
Chandler Carruth87bc9b42019-01-19 10:56:40 +00003// 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 Albert29cbadc2014-12-18 00:03:57 +00006//
7//===----------------------------------------------------------------------===//
8
Eric Fiseliere527e7c2016-10-31 14:14:04 +00009// UNSUPPORTED: libcxxabi-no-threads
Eric Fiselierd487fb22015-02-03 23:50:47 +000010// REQUIRES: linux
Dan Albert29cbadc2014-12-18 00:03:57 +000011
12#include <assert.h>
13#include <cxxabi.h>
14
15static bool AtexitImplCalled = false;
16
17extern "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 Dionnea33d6aa2020-10-08 13:36:33 -040026int main(int, char**) {
Dan Albert29cbadc2014-12-18 00:03:57 +000027 int RV = __cxxabiv1::__cxa_thread_atexit(
28 reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2),
29 reinterpret_cast<void *>(3));
Eric Fiselier13c33822016-09-16 08:16:07 +000030 assert(RV == 4);
Dan Albert29cbadc2014-12-18 00:03:57 +000031 assert(AtexitImplCalled);
32 return 0;
33}