Blame sysdeps/generic/libc-tsd.h

Packit 6c4009
/* libc-internal interface for thread-specific data.  Stub or TLS version.
Packit 6c4009
   Copyright (C) 1998-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _GENERIC_LIBC_TSD_H
Packit 6c4009
#define _GENERIC_LIBC_TSD_H 1
Packit 6c4009
Packit 6c4009
/* This file defines the following macros for accessing a small fixed
Packit 6c4009
   set of thread-specific `void *' data used only internally by libc.
Packit 6c4009
Packit 6c4009
   __libc_tsd_define(CLASS, TYPE, KEY)	-- Define or declare a datum with TYPE
Packit 6c4009
					   for KEY.  CLASS can be `static' for
Packit 6c4009
					   keys used in only one source file,
Packit 6c4009
					   empty for global definitions, or
Packit 6c4009
					   `extern' for global declarations.
Packit 6c4009
   __libc_tsd_address(TYPE, KEY)	-- Return the `TYPE *' pointing to
Packit 6c4009
					   the current thread's datum for KEY.
Packit 6c4009
   __libc_tsd_get(TYPE, KEY)		-- Return the `TYPE' datum for KEY.
Packit 6c4009
   __libc_tsd_set(TYPE, KEY, VALUE)	-- Set the datum for KEY to VALUE.
Packit 6c4009
Packit 6c4009
   The set of available KEY's will usually be provided as an enum,
Packit 6c4009
   and contains (at least):
Packit 6c4009
		_LIBC_TSD_KEY_MALLOC
Packit 6c4009
		_LIBC_TSD_KEY_DL_ERROR
Packit 6c4009
		_LIBC_TSD_KEY_RPC_VARS
Packit 6c4009
   All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros.
Packit 6c4009
   Some implementations may not provide any enum at all and instead
Packit 6c4009
   using string pasting in the macros.  */
Packit 6c4009
Packit 6c4009
#include <tls.h>
Packit 6c4009
Packit 6c4009
/* When full support for __thread variables is available, this interface is
Packit 6c4009
   just a trivial wrapper for it.  Without TLS, this is the generic/stub
Packit 6c4009
   implementation for wholly single-threaded systems.
Packit 6c4009
Packit 6c4009
   We don't define an enum for the possible key values, because the KEYs
Packit 6c4009
   translate directly into variables by macro magic.  */
Packit 6c4009
Packit 6c4009
#define __libc_tsd_define(CLASS, TYPE, KEY)	\
Packit 6c4009
  CLASS __thread TYPE __libc_tsd_##KEY attribute_tls_model_ie;
Packit 6c4009
Packit 6c4009
#define __libc_tsd_address(TYPE, KEY)		(&__libc_tsd_##KEY)
Packit 6c4009
#define __libc_tsd_get(TYPE, KEY)		(__libc_tsd_##KEY)
Packit 6c4009
#define __libc_tsd_set(TYPE, KEY, VALUE)	(__libc_tsd_##KEY = (VALUE))
Packit 6c4009
Packit 6c4009
#endif	/* libc-tsd.h */