[BACK]Return to tib.h CVS log [TXT][DIR] Up to [local] / src / include

Diff for /src/include/tib.h between version 1.1 and 1.2

version 1.1, 2015/09/14 08:16:14 version 1.2, 2016/03/20 02:30:28
Line 50 
Line 50 
  *              Initializes a TIB for a new thread, using the supplied   *              Initializes a TIB for a new thread, using the supplied
  *              value for the dtv pointer   *              value for the dtv pointer
  *   *
  *      TIB_COPY(tib, oldtib)  
  *              Copies oldtib to tib, (re)initializing the internal members  
  *  
  *      TIB_TO_THREAD(tib)   *      TIB_TO_THREAD(tib)
  *              Given a TIB pointer, return a pointer to the struct pthread   *              Given a TIB pointer, return a pointer to the struct pthread
  *   *
Line 94 
Line 91 
   
   
 /* If <machine/tcb.h> doesn't provide a better way, then use the default */  /* If <machine/tcb.h> doesn't provide a better way, then use the default */
 #ifndef TCB_GET  #ifdef  TCB_GET
 #define TCB_GET()       __get_tcb()  # define TCB_HAVE_MD_GET        1
   #else
   # define TCB_GET()              __get_tcb()
 #endif  #endif
 #ifndef TCB_SET  #ifdef  TCB_SET
 #define TCB_SET(tcb)    __set_tcb(tcb)  # define TCB_HAVE_MD_SET        1
   #else
   # define TCB_SET(tcb)           __set_tcb(tcb)
 #endif  #endif
   
   
Line 111 
Line 112 
  * our thread bits before the TCB, at negative offsets from the   * our thread bits before the TCB, at negative offsets from the
  * TCB pointer.  Ergo, memory is laid out, low to high, as:   * TCB pointer.  Ergo, memory is laid out, low to high, as:
  *   *
  *      pthread structure   *      [pthread structure]
  *      TIB {   *      TIB {
  *              int cancel_flags   *              int cancel_flags
  *              int cancel_requested   *              int cancel_requested
  *              int errno   *              int errno
    *              void *locale
  *              TCB {   *              TCB {
  *                      void *dtv   *                      void *dtv
  *                      void *locale   *                      struct pthread *thread
  *              }   *              }
  *      }   *      }
  *      static TLS data   *      static TLS data
  */   */
   
 struct tib {  struct tib {
         int     __tib_padding           /* padding for 8byte alignment */  #ifdef __LP64__
           int     __tib_padding;          /* padding for 8byte alignment */
   #endif
         int     tib_cancel_flags;          int     tib_cancel_flags;
         int     tib_cancel;          int     tib_cancel;
         int     tib_errno;          int     tib_errno;
         void    *tib_dtv;               /* internal to the runtime linker */  
         void    *tib_locale;          void    *tib_locale;
           void    *tib_dtv;               /* internal to the runtime linker */
           void    *tib_thread;
 };  };
 #define _TIB_PREP(tib)  ((void)((tib)->__tib_padding = 0))  #ifdef __LP64__
   # define _TIB_PREP(tib) ((void)((tib)->__tib_padding = 0))
   #endif
   
 #define _TIBO_PTHREAD           (- _ALIGN(sizeof(struct pthread)))  #define _TIBO_PTHREAD           (- _ALIGN(sizeof(struct pthread)))
   
Line 149 
Line 156 
  *                      self pointer [i386/amd64 only]   *                      self pointer [i386/amd64 only]
  *                      void *dtv   *                      void *dtv
  *              }   *              }
    *              struct pthread *thread
  *              void *locale   *              void *locale
  *              int errno   *              int errno
  *              int cancel_count_flags   *              int cancel_count_flags
  *              int cancel_requested   *              int cancel_requested
  *      }   *      }
  *      pthread structure   *      [pthread structure]
  */   */
   
 struct tib {  struct tib {
 #if defined(__i386) || defined(__amd64)  #if defined(__i386) || defined(__amd64)
         struct  tib *__tib_self;          struct  tib *__tib_self;
 #define __tib_tcb __tib_self  # define __tib_tcb __tib_self
 #endif  #endif
         void    *tib_dtv;               /* internal to the runtime linker */          void    *tib_dtv;               /* internal to the runtime linker */
           void    *tib_thread;
         void    *tib_locale;          void    *tib_locale;
         int     tib_errno;          int     tib_errno;
         int     tib_cancel;             /* set to request cancelation */          int     tib_cancel;             /* set to request cancelation */
         int     tib_cancel_flags;          int     tib_cancel_flags;
 #if !defined(__i386)  #if defined(__LP64__) || defined(__i386)
         int     __tib_padding;          /* padding for 8byte alignment */          int     __tib_padding;          /* padding for 8byte alignment */
 #endif  #endif
 };  };
   
 #define _TIBO_PTHREAD           _ALIGN(sizeof(struct tib))  #define _TIBO_PTHREAD           _ALIGN(sizeof(struct tib))
   
 #if defined(__i386)  #if defined(__i386) || defined(__amd64)
 #define _TIB_PREP(tib)  ((void)((tib)->__tib_self = (tib)))  # define _TIB_PREP(tib) \
 #elif defined(__amd64)  
 #define _TIB_PREP(tib)  \  
         ((void)((tib)->__tib_self = (tib), (tib)->__tib_padding = 0))          ((void)((tib)->__tib_self = (tib), (tib)->__tib_padding = 0))
 #else  #elif defined(__LP64__)
 #define _TIB_PREP(tib)  ((void)((tib)->__tib_padding = 0))  # define _TIB_PREP(tib) ((void)((tib)->__tib_padding = 0))
 #endif  #endif
   
 #define TIB_EXTRA_ALIGN         sizeof(void *)  #define TIB_EXTRA_ALIGN         sizeof(void *)
Line 191 
Line 198 
   
 /* nothing to do by default */  /* nothing to do by default */
 #ifndef _TIB_PREP  #ifndef _TIB_PREP
 #define _TIB_PREP(tib)  ((void)0)  # define _TIB_PREP(tib) ((void)0)
 #endif  #endif
   
 #define TIB_INIT(tib, dtv)      do {            \  #define TIB_INIT(tib, dtv, thread)      do {            \
                   (tib)->tib_thread       = (thread);     \
                 (tib)->tib_locale       = NULL;         \                  (tib)->tib_locale       = NULL;         \
                 (tib)->tib_cancel_flags = 0;            \                  (tib)->tib_cancel_flags = 0;            \
                 (tib)->tib_cancel       = 0;            \                  (tib)->tib_cancel       = 0;            \
Line 202 
Line 210 
                 (tib)->tib_errno        = 0;            \                  (tib)->tib_errno        = 0;            \
                 _TIB_PREP(tib);                         \                  _TIB_PREP(tib);                         \
         } while (0)          } while (0)
 #define TIB_COPY(tib, oldtib)           do {            \  
                 *(tib) = *(oldtib);                     \  
                 _TIB_PREP(tib);                         \  
         } while (0)  
   
 #ifndef __tib_tcb  #ifndef __tib_tcb
 #define __tib_tcb               tib_dtv  # define __tib_tcb              tib_dtv
 #endif  #endif
 #define _TIBO_TCB               offsetof(struct tib, __tib_tcb)  #define _TIBO_TCB               offsetof(struct tib, __tib_tcb)
   
 #define TCB_TO_TIB(tcb)         ((struct tib *)((char *)(tcb) - _TIBO_TCB))  #define TCB_TO_TIB(tcb)         ((struct tib *)((char *)(tcb) - _TIBO_TCB))
 #define TIB_TO_TCB(tib)         ((char *)(tib) + _TIBO_TCB)  #define TIB_TO_TCB(tib)         ((char *)(tib) + _TIBO_TCB)
 #define TIB_TO_THREAD(tib)      ((struct pthread *)((char *)(tib) + \  #define TIB_TO_THREAD(tib)      ((struct pthread *)(tib)->tib_thread)
                                 _TIBO_PTHREAD))  
 #define THREAD_TO_TIB(thread)   ((struct tib *)((char *)(thread) - \  
                                 _TIBO_PTHREAD))  
 #define TIB_GET()               TCB_TO_TIB(TCB_GET())  #define TIB_GET()               TCB_TO_TIB(TCB_GET())
 #define TIB_THREAD()            TIB_TO_THREAD(TIB_GET())  #define TCB_THREAD()            TIB_TO_THREAD(TIB_GET())
   
   
 __BEGIN_DECLS  __BEGIN_DECLS
 void    *_dl_allocate_tib(size_t _extra, int _flags) __dso_public;  void    *_dl_allocate_tib(size_t _extra) __dso_public;
 #define DAT_UPDATE_CURRENT      1  
 void    _dl_free_tib(void *_tib, size_t _extra) __dso_public;  void    _dl_free_tib(void *_tib, size_t _extra) __dso_public;
   
 /* The actual syscalls */  /* The actual syscalls */
 void    *__get_tcb(void);  void    *__get_tcb(void);
 void    __set_tcb(void *_tcb);  void    __set_tcb(void *_tcb);
   
 /* The function in libc called by crt0 to init the tcb in static processes */  
 void    __init_tcb(char **_envp) __dso_hidden;  
 __END_DECLS  __END_DECLS
   
 #endif /* _TIB_H_ */  #endif /* _TIB_H_ */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2