Blame sysdeps/mach/hurd/tls.h

Packit 6c4009
/* Definitions for thread-local data handling.  Hurd version.
Packit 6c4009
   Copyright (C) 2003-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 _TLS_H
Packit 6c4009
#define _TLS_H
Packit 6c4009
Packit 6c4009
#ifndef __ASSEMBLER__
Packit 6c4009
Packit 6c4009
# include <stddef.h>
Packit 6c4009
# include <stdint.h>
Packit 6c4009
# include <stdbool.h>
Packit 6c4009
# include <sysdep.h>
Packit 6c4009
# include <mach/mig_errors.h>
Packit 6c4009
# include <mach.h>
Packit 6c4009
# include <atomic.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* This is the size of the initial TCB.  */
Packit 6c4009
# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
Packit 6c4009
Packit 6c4009
/* Alignment requirements for the initial TCB.  */
Packit 6c4009
# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
Packit 6c4009
Packit 6c4009
/* This is the size of the TCB.  */
Packit 6c4009
# define TLS_TCB_SIZE TLS_INIT_TCB_SIZE	/* XXX */
Packit 6c4009
Packit 6c4009
/* Alignment requirements for the TCB.  */
Packit 6c4009
# define TLS_TCB_ALIGN TLS_INIT_TCB_ALIGN /* XXX */
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Install the dtv pointer.  The pointer passed is to the element with
Packit 6c4009
   index -1 which contain the length.  */
Packit 6c4009
# define INSTALL_DTV(descr, dtvp) \
Packit 6c4009
  ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
Packit 6c4009
Packit 6c4009
/* Return dtv of given thread descriptor.  */
Packit 6c4009
# define GET_DTV(descr) \
Packit 6c4009
  (((tcbhead_t *) (descr))->dtv)
Packit 6c4009
Packit 6c4009
/* Global scope switch support.  */
Packit 6c4009
#define THREAD_GSCOPE_IN_TCB      0
Packit 6c4009
#define THREAD_GSCOPE_GLOBAL
Packit 6c4009
#define THREAD_GSCOPE_SET_FLAG() \
Packit 6c4009
  atomic_exchange_and_add_acq (&GL(dl_thread_gscope_count), 1)
Packit 6c4009
#define THREAD_GSCOPE_RESET_FLAG() \
Packit 6c4009
  do 									      \
Packit 6c4009
    if (atomic_exchange_and_add_rel (&GL(dl_thread_gscope_count), -1) == 1)   \
Packit 6c4009
      lll_wake (&GL(dl_thread_gscope_count), 0);			      \
Packit 6c4009
  while (0)
Packit 6c4009
#define THREAD_GSCOPE_WAIT() \
Packit 6c4009
  do 									      \
Packit 6c4009
    {									      \
Packit 6c4009
      int count;							      \
Packit 6c4009
      atomic_write_barrier ();						      \
Packit 6c4009
      while ((count = GL(dl_thread_gscope_count)))			      \
Packit 6c4009
        lll_wait (&GL(dl_thread_gscope_count), count, 0);		      \
Packit 6c4009
    }									      \
Packit 6c4009
  while (0)
Packit 6c4009
Packit 6c4009
#endif /* !ASSEMBLER */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#endif /* tls.h */