libc-tsd.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* libc-internal interface for thread-specific data. LinuxThreads version.
  2. Copyright (C) 1997-2002, 2003 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 License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. 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; see the file COPYING.LIB. If
  14. not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef _BITS_LIBC_TSD_H
  16. #define _BITS_LIBC_TSD_H 1
  17. #include <linuxthreads/descr.h>
  18. #ifdef __UCLIBC_HAS_TLS__
  19. #include <tls.h>
  20. /* When __thread works, the generic definition is what we want. */
  21. # include <sysdeps/generic/bits/libc-tsd.h>
  22. #else
  23. # include <bits/libc-lock.h>
  24. # ifndef SHARED
  25. extern void ** __pthread_internal_tsd_address (int);
  26. extern void *__pthread_internal_tsd_get (int);
  27. extern int __pthread_internal_tsd_set (int, const void *);
  28. weak_extern (__pthread_internal_tsd_address)
  29. weak_extern (__pthread_internal_tsd_get)
  30. weak_extern (__pthread_internal_tsd_set)
  31. # endif
  32. #define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data;
  33. #define __libc_tsd_address(KEY) \
  34. __libc_maybe_call2 (pthread_internal_tsd_address, \
  35. (_LIBC_TSD_KEY_##KEY), &__libc_tsd_##KEY##_data)
  36. #define __libc_tsd_get(KEY) \
  37. __libc_maybe_call2 (pthread_internal_tsd_get, \
  38. (_LIBC_TSD_KEY_##KEY), __libc_tsd_##KEY##_data)
  39. #define __libc_tsd_set(KEY, VALUE) \
  40. __libc_maybe_call2 (pthread_internal_tsd_set, \
  41. (_LIBC_TSD_KEY_##KEY, (VALUE)), \
  42. (__libc_tsd_##KEY##_data = (VALUE), 0))
  43. #endif
  44. #endif /* bits/libc-tsd.h */