123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #ifndef _TLS_H
- #define _TLS_H
- #ifndef __ASSEMBLER__
- # include <pt-machine.h>
- # include <stdbool.h>
- # include <stddef.h>
- typedef union dtv
- {
- size_t counter;
- struct
- {
- void *val;
- bool is_static;
- } pointer;
- } dtv_t;
- #else
- # include <tcb-offsets.h>
- #endif
- #ifdef HAVE_TLS_SUPPORT
- # define USE_TLS 1
- # ifndef __ASSEMBLER__
- typedef struct
- {
- dtv_t *dtv;
- void *private;
- } tcbhead_t;
- # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
- # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
- # define TLS_TCB_SIZE sizeof (tcbhead_t)
- # define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
- # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
- # define TLS_DTV_AT_TP 1
- # define INSTALL_DTV(tcbp, dtvp) \
- ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
- # define INSTALL_NEW_DTV(DTV) \
- (((tcbhead_t *)__thread_self)->dtv = (DTV))
- # define GET_DTV(tcbp) \
- (((tcbhead_t *) (tcbp))->dtv)
- #if defined NEED_DL_SYSINFO
- # define INIT_SYSINFO \
- (((tcbhead_t *) __thread_self)->private = (void *) GLRO(dl_sysinfo))
- #else
- # define INIT_SYSINFO 0
- #endif
- # define TLS_INIT_TP(tcbp, secondcall) \
- (__thread_self = (__typeof (__thread_self)) (tcbp), INIT_SYSINFO, NULL)
- # define THREAD_DTV() \
- (((tcbhead_t *)__thread_self)->dtv)
- # undef THREAD_SELF
- # define THREAD_SELF (__thread_self - 1)
- # undef INIT_THREAD_SELF
- # define INIT_THREAD_SELF(descr, nr) \
- (__thread_self = (struct _pthread_descr_struct *)(descr) + 1)
- # define TLS_MULTIPLE_THREADS_IN_TCB 1
- # endif
- #else
- # ifndef __ASSEMBLER__
- typedef struct
- {
- void *tcb;
- dtv_t *dtv;
- void *self;
- int multiple_threads;
- } tcbhead_t;
- # define NONTLS_INIT_TP \
- do { \
- static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
- __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
- } while (0)
- #endif
- #endif
- #endif
|