12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "thread_dbP.h"
- # define TLS_DTV_UNALLOCATED ((void *) -1l)
- td_err_e
- td_thr_tlsbase (const td_thrhandle_t *th,
- unsigned long int modid,
- psaddr_t *base)
- {
- if (modid < 1)
- return TD_NOTLS;
- #ifdef __UCLIBC_HAS_TLS__
- union dtv pdtv, *dtvp;
- LOG ("td_thr_tlsbase");
- psaddr_t dtvpp = th->th_unique;
- #if defined(TLS_TCB_AT_TP)
- dtvpp += offsetof (struct _pthread_descr_struct, p_header.data.dtvp);
- #elif defined(TLS_DTV_AT_TP)
- dtvpp += TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
- - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0);
- #else
- # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined."
- #endif
-
- if (ps_pdread (th->th_ta_p->ph, dtvpp, &dtvp, sizeof dtvp) != PS_OK)
- return TD_ERR;
-
- if (ps_pdread (th->th_ta_p->ph, dtvp + modid,
- &pdtv, sizeof (union dtv)) != PS_OK)
- return TD_ERR;
-
- if (pdtv.pointer.val == TLS_DTV_UNALLOCATED)
- return TD_TLSDEFER;
- *base = (char *) pdtv.pointer.val;
- return TD_OK;
- #else
- return TD_ERR;
- #endif
- }
|