thread-freeres.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Free resources stored in thread-local variables on thread exit.
  2. Copyright (C) 2003-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <libc-internal.h>
  16. #include <malloc-internal.h>
  17. #include <resolv/resolv-internal.h>
  18. #include <rpc/rpc.h>
  19. #include <string.h>
  20. /* Thread shutdown function. Note that this function must be called
  21. for threads during shutdown for correctness reasons. Unlike
  22. __libc_subfreeres, skipping calls to it is not a valid optimization.
  23. This is called directly from pthread_create as the thread exits. */
  24. void
  25. __libc_thread_freeres (void)
  26. {
  27. call_function_static_weak (__rpc_thread_destroy);
  28. call_function_static_weak (__res_thread_freeres);
  29. call_function_static_weak (__strerror_thread_freeres);
  30. /* This should come last because it shuts down malloc for this
  31. thread and the other shutdown functions might well call free. */
  32. call_function_static_weak (__malloc_arena_thread_freeres);
  33. }