kolibrios-gitea/programs/develop/libraries/newlib/crt/tls.S
Sergey Semyonov (Serge) 2336060a0c newlib: update
git-svn-id: svn://kolibrios.org@1906 a494cfbc-eb01-0410-851d-a64ba20cac60
2011-03-11 18:52:24 +00:00

49 lines
817 B
ArmAsm

.section .text
.global _tls_alloc
.global __tls_map
.align 4
_tls_alloc:
pushl $tls_mutex
call ___mutex_lock
popl %eax
movl tls_map_start, %edx
.align 4
.test:
bsfl (%edx), %eax
jnz .done
add $4, %edx
cmpl $128+__tls_map, %edx
jb .test
xorl %eax, %eax
mov %eax, tls_mutex
ret
.done:
btrl %eax, (%edx)
movl %edx, tls_map_start
movl $0, tls_mutex
subl $__tls_map, %edx
leal (%eax, %edx, 8), %eax
shll $2, %eax
ret
.section .data
tls_mutex: .long(0)
tls_map_start: .long(__tls_map)
.section .bss
.align 16
__tls_map: .space 128