Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1.  
  2.  
  3. .section .text
  4.  
  5. .global _tls_alloc
  6. .global __tls_map
  7.  
  8. .align 4
  9. _tls_alloc:
  10.  
  11.            pushl $tls_mutex
  12.            call ___mutex_lock
  13.            popl %eax
  14.  
  15.            movl tls_map_start, %edx
  16. .align 4
  17. .test:
  18.            bsfl (%edx), %eax
  19.            jnz .done
  20.  
  21.            add $4, %edx
  22.            cmpl $128+__tls_map, %edx
  23.            jb .test
  24.  
  25.            xorl %eax, %eax
  26.            mov %eax, tls_mutex
  27.            ret
  28.  
  29. .done:
  30.            btrl %eax, (%edx)
  31.            movl %edx, tls_map_start
  32.            movl $0, tls_mutex
  33.  
  34.            subl $__tls_map, %edx
  35.            leal (%eax, %edx, 8), %eax
  36.            shll $2, %eax
  37.            ret
  38.  
  39. .section .data
  40.  
  41. tls_mutex:         .long(0)
  42. tls_map_start:     .long(__tls_map)
  43.  
  44. .section .bss
  45.  
  46. .align 16
  47.  
  48. __tls_map:         .space 128
  49.