thread_local_impl.cpp 769 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-04-27 flybreak the first version.
  9. */
  10. #include <pthread.h>
  11. #include <cstdlib>
  12. typedef void (*destructor) (void *);
  13. extern "C"
  14. int __cxa_thread_atexit_impl(destructor dtor, void* obj, void* dso_symbol)
  15. {
  16. pthread_key_t key_tmp;
  17. if (pthread_key_create(&key_tmp, dtor) != 0)
  18. abort();
  19. pthread_setspecific(key_tmp, obj);
  20. return 0;
  21. }
  22. #if defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/
  23. #include <cxxabi.h>
  24. extern"C"
  25. int __cxxabiv1::__cxa_thread_atexit(destructor dtor, void *obj, void *dso_handle)
  26. {
  27. return __cxa_thread_atexit_impl(dtor, obj, dso_handle);
  28. }
  29. #endif