kolibrios-gitea/contrib/sdk/sources/newlib/libc/crt/tls.S
Sergey Semyonov (Serge) 846fce0120 set default newlib dir's structure
git-svn-id: svn://kolibrios.org@4874 a494cfbc-eb01-0410-851d-a64ba20cac60
2014-04-22 09:02:02 +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