[BACK]Return to tls.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / tls

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/tls/tls.c between version 1.9 and 1.9.2.1

version 1.9, 2018/07/13 19:50:21 version 1.9.2.1, 2019/11/26 08:12:26
Line 46  __RCSID("$NetBSD$");
Line 46  __RCSID("$NetBSD$");
 #include <link_elf.h>  #include <link_elf.h>
 #include <lwp.h>  #include <lwp.h>
 #include <stdbool.h>  #include <stdbool.h>
   #include <stdalign.h>
 #include <stddef.h>  #include <stddef.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
Line 84  _rtld_tls_allocate(void)
Line 85  _rtld_tls_allocate(void)
         uint8_t *p;          uint8_t *p;
   
         if (initial_thread_tcb == NULL) {          if (initial_thread_tcb == NULL) {
 #ifdef __HAVE_TLS_VARIANT_II  #ifdef __HAVE_TLS_VARIANT_I
                 tls_size = roundup2(tls_size, sizeof(void *));                  tls_allocation = tls_size;
   #else
                   tls_allocation = roundup2(tls_size, alignof(max_align_t));
 #endif  #endif
                 tls_allocation = tls_size + sizeof(*tcb);  
   
                 initial_thread_tcb = p = mmap(NULL, tls_allocation,                  initial_thread_tcb = p = mmap(NULL,
                     PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);                      tls_allocation + sizeof(*tcb), PROT_READ | PROT_WRITE,
                       MAP_ANON, -1, 0);
         } else {          } else {
                 p = calloc(1, tls_allocation);                  p = calloc(1, tls_allocation + sizeof(*tcb));
         }          }
         if (p == NULL) {          if (p == NULL) {
                 static const char msg[] =  "TLS allocation failed, terminating\n";                  static const char msg[] =  "TLS allocation failed, terminating\n";
Line 105  _rtld_tls_allocate(void)
Line 108  _rtld_tls_allocate(void)
         p += sizeof(struct tls_tcb);          p += sizeof(struct tls_tcb);
 #else  #else
         /* LINTED tls_size is rounded above */          /* LINTED tls_size is rounded above */
         tcb = (struct tls_tcb *)(p + tls_size);          tcb = (struct tls_tcb *)(p + tls_allocation);
           p = (uint8_t *)tcb - tls_size;
         tcb->tcb_self = tcb;          tcb->tcb_self = tcb;
 #endif  #endif
         memcpy(p, tls_initaddr, tls_initsize);          memcpy(p, tls_initaddr, tls_initsize);
Line 125  _rtld_tls_free(struct tls_tcb *tcb)
Line 129  _rtld_tls_free(struct tls_tcb *tcb)
         p = (uint8_t *)tcb;          p = (uint8_t *)tcb;
 #else  #else
         /* LINTED */          /* LINTED */
         p = (uint8_t *)tcb - tls_size;          p = (uint8_t *)tcb - tls_allocation;
 #endif  #endif
         if (p == initial_thread_tcb)          if (p == initial_thread_tcb)
                 munmap(p, tls_allocation);                  munmap(p, tls_allocation + sizeof(*tcb));
         else          else
                 free(p);                  free(p);
 }  }
Line 148  __libc_static_tls_setup_cb(struct dl_phd
Line 152  __libc_static_tls_setup_cb(struct dl_phd
                         continue;                          continue;
                 tls_initaddr = (void *)(phdr->p_vaddr + data->dlpi_addr);                  tls_initaddr = (void *)(phdr->p_vaddr + data->dlpi_addr);
                 tls_initsize = phdr->p_filesz;                  tls_initsize = phdr->p_filesz;
   #ifdef __HAVE_TLS_VARIANT_I
                 tls_size = phdr->p_memsz;                  tls_size = phdr->p_memsz;
   #else
                   tls_size = roundup2(phdr->p_memsz, phdr->p_align);
   #endif
         }          }
         return 0;          return 0;
 }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.9.2.1

CVSweb <webmaster@jp.NetBSD.org>