summaryrefslogtreecommitdiff
path: root/libc/test/integration/src/__support/threads/main_exit_test.cpp
blob: c90e4e569cfba45e795784cd327f2676872f9931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//===-- Test handling of thread local data --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/__support/threads/thread.h"
#include "test/IntegrationTest/test.h"

bool called = false;

extern "C" {
[[gnu::weak]]
void *__dso_handle = nullptr;
int __cxa_thread_atexit_impl(void (*func)(void *), void *arg, void *dso);
}

[[gnu::destructor]]
void destructor() {
  if (!called)
    __builtin_trap();
}

TEST_MAIN() {
  __cxa_thread_atexit_impl([](void *) { called = true; }, nullptr,
                           __dso_handle);
  return 0;
}