_LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_symbol) throw() {
#ifdef HAVE___CXA_THREAD_ATEXIT_IMPL
    return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
#else
    if (__cxa_thread_atexit_impl) {
      return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
    } else {
      // Initialize the dtors std::__libcpp_tls_key (uses __cxa_guard_*() for
      // one-time initialization and __cxa_atexit() for destruction)
      static DtorsManager manager;

      if (!dtors_alive) {
        if (std::__libcpp_tls_set(dtors_key, &dtors_key) != 0) {
          return -1;
        }
        dtors_alive = true;
      }

      auto head = static_cast<DtorList*>(std::malloc(sizeof(DtorList)));
      if (!head) {
        return -1;
      }

      head->dtor = dtor;
      head->obj = obj;
      head->next = dtors;
      dtors = head;

      return 0;
    }
#endif // HAVE___CXA_THREAD_ATEXIT_IMPL
  }
static void* thread_main(void* arg) {
  __cxa_thread_atexit_impl(thread_atexit_fn5, arg, nullptr);
  __cxa_thread_atexit_impl(thread_atexit_fn4, arg, nullptr);
  __cxa_thread_atexit_impl(thread_atexit_fn3, arg, nullptr);
  __cxa_thread_atexit_impl(thread_atexit_fn2, arg, nullptr);
  __cxa_thread_atexit_impl(thread_atexit_fn1, arg, nullptr);
  return nullptr;
}
 int __cxa_thread_atexit(void (*dtor)(void *), void *obj,
                         void *dso_symbol) throw() {
     extern int __cxa_thread_atexit_impl(void (*)(void *), void *, void *);
     return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
 }
Example #4
0
void do_foo (void)
{
  static __thread A b;
  __cxa_thread_atexit_impl (A_dtor, &b, __dso_handle);
}
static void thread_atexit_fn3(void* arg) {
  __cxa_thread_atexit_impl(thread_atexit_from_atexit, arg, nullptr);
  std::string* call_sequence = static_cast<std::string*>(arg);
  *call_sequence += "three, ";
}