libc-tsd.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /* Fast thread-specific data internal to libc. */
  18. enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
  19. _LIBC_TSD_KEY_DL_ERROR,
  20. _LIBC_TSD_KEY_RPC_VARS,
  21. _LIBC_TSD_KEY_LOCALE,
  22. _LIBC_TSD_KEY_CTYPE_B,
  23. _LIBC_TSD_KEY_CTYPE_TOLOWER,
  24. _LIBC_TSD_KEY_CTYPE_TOUPPER,
  25. _LIBC_TSD_KEY_N };
  26. #include <features.h>
  27. #include <linuxthreads.old/internals.h>
  28. #ifdef __UCLIBC_HAS_TLS__
  29. #include <tls.h>
  30. /* When __thread works, the generic definition is what we want. */
  31. # include <sysdeps/generic/bits/libc-tsd.h>
  32. #else
  33. # include <bits/libc-lock.h>
  34. # ifndef SHARED
  35. extern void ** __pthread_internal_tsd_address (int);
  36. extern void *__pthread_internal_tsd_get (int);
  37. extern int __pthread_internal_tsd_set (int, const void *);
  38. weak_extern (__pthread_internal_tsd_address)
  39. weak_extern (__pthread_internal_tsd_get)
  40. weak_extern (__pthread_internal_tsd_set)
  41. # endif
  42. #define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data;
  43. #define __libc_tsd_address(KEY) \
  44. __libc_maybe_call2 (pthread_internal_tsd_address, \
  45. (_LIBC_TSD_KEY_##KEY), &__libc_tsd_##KEY##_data)
  46. #define __libc_tsd_get(KEY) \
  47. __libc_maybe_call2 (pthread_internal_tsd_get, \
  48. (_LIBC_TSD_KEY_##KEY), __libc_tsd_##KEY##_data)
  49. #define __libc_tsd_set(KEY, VALUE) \
  50. __libc_maybe_call2 (pthread_internal_tsd_set, \
  51. (_LIBC_TSD_KEY_##KEY, (VALUE)), \
  52. (__libc_tsd_##KEY##_data = (VALUE), 0))
  53. #endif
  54. #endif /* bits/libc-tsd.h */