Back to index

glibc  2.9
libc-tsd.h
Go to the documentation of this file.
00001 /* libc-internal interface for thread-specific data.  LinuxThreads version.
00002    Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License as
00007    published by the Free Software Foundation; either version 2.1 of the
00008    License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00017    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.  */
00019 
00020 #ifndef _BITS_LIBC_TSD_H
00021 #define _BITS_LIBC_TSD_H 1
00022 
00023 #include <linuxthreads/descr.h>
00024 #include <tls.h>
00025 
00026 #if USE_TLS && HAVE___THREAD
00027 
00028 /* When __thread works, the generic definition is what we want.  */
00029 # include_next <bits/libc-tsd.h>
00030 
00031 #else
00032 
00033 # include <bits/libc-lock.h>
00034 
00035 # ifndef SHARED
00036 extern void ** __pthread_internal_tsd_address (int);
00037 extern void *__pthread_internal_tsd_get (int);
00038 extern int __pthread_internal_tsd_set (int, const void *);
00039 
00040 weak_extern (__pthread_internal_tsd_address)
00041 weak_extern (__pthread_internal_tsd_get)
00042 weak_extern (__pthread_internal_tsd_set)
00043 # endif
00044 
00045 #define __libc_tsd_define(CLASS, KEY)     CLASS void *__libc_tsd_##KEY##_data;
00046 #define __libc_tsd_address(KEY) \
00047   __libc_maybe_call2 (pthread_internal_tsd_address,                   \
00048                     (_LIBC_TSD_KEY_##KEY), &__libc_tsd_##KEY##_data)
00049 #define __libc_tsd_get(KEY) \
00050   __libc_maybe_call2 (pthread_internal_tsd_get,                       \
00051                     (_LIBC_TSD_KEY_##KEY), __libc_tsd_##KEY##_data)
00052 #define __libc_tsd_set(KEY, VALUE) \
00053   __libc_maybe_call2 (pthread_internal_tsd_set,                       \
00054                     (_LIBC_TSD_KEY_##KEY, (VALUE)),                   \
00055                      (__libc_tsd_##KEY##_data = (VALUE), 0))
00056 
00057 #endif
00058 
00059 #endif /* bits/libc-tsd.h */