kolibrios-gitea/contrib/sdk/sources/newlib/crt/tls.S
Sergey Semyonov (Serge) 754f9336f0 upload sdk
git-svn-id: svn://kolibrios.org@4349 a494cfbc-eb01-0410-851d-a64ba20cac60
2013-12-15 08:09:20 +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