diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-09-18 10:14:37 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-09-18 10:14:37 -0400 |
commit | 3f72cdac73030761120cf32aeef44e7d03e2f1fa (patch) | |
tree | d52dde9adbb8386100d98371d4e954fb88af2c41 /src/thread/i386 | |
parent | 455fc98389fac09d8cf7ec4cde310a5b7ca47485 (diff) | |
download | musl-3f72cdac73030761120cf32aeef44e7d03e2f1fa.tar.gz musl-3f72cdac73030761120cf32aeef44e7d03e2f1fa.tar.xz musl-3f72cdac73030761120cf32aeef44e7d03e2f1fa.zip |
overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone function signature and replaced it with the "standard" linux __clone/clone signature. this was necessary to expose clone to applications anyway, and it makes it easier to port __clone to new archs, since it's now testable independently of pthread_create. secondly, i have removed all references to the ugly ldt descriptor structure (i386 only) from the c code and pthread structure. in places where it is needed, it is now created on the stack just when it's needed, in assembly code. thus, the i386 __clone function takes the desired thread pointer as its argument, rather than an ldt descriptor pointer, just like on all other sane archs. this should not affect applications since there is really no way an application can use clone with threads/tls in a way that doesn't horribly conflict with and clobber the underlying implementation's use. applications are expected to use clone only for creating actual processes, possibly with new namespace features and whatnot.
Diffstat (limited to 'src/thread/i386')
-rw-r--r-- | src/thread/i386/__set_thread_area.s | 21 | ||||
-rw-r--r-- | src/thread/i386/clone.s | 73 |
2 files changed, 60 insertions, 34 deletions
diff --git a/src/thread/i386/__set_thread_area.s b/src/thread/i386/__set_thread_area.s index a43525ec..cccf1cd3 100644 --- a/src/thread/i386/__set_thread_area.s +++ b/src/thread/i386/__set_thread_area.s @@ -2,20 +2,21 @@ .global __set_thread_area .type __set_thread_area,@function __set_thread_area: - pushl %ebx - movl 8(%esp),%ecx - movl $-1,4(%ecx) - movl %ecx,8(%ecx) - movl $0xfffff,12(%ecx) - movl $0x51,16(%ecx) - leal 4(%ecx),%ebx - movl $243,%eax + push %ebx + push $0x51 + push $0xfffff + push 16(%esp) + push $-1 + mov %esp,%ebx + xor %eax,%eax + mov $243,%al int $128 - popl %ebx testl %eax,%eax jnz 1f - movl 4(%ecx),%ecx + movl (%esp),%ecx leal 3(,%ecx,8),%ecx movw %cx,%gs 1: + addl $16,%esp + popl %ebx ret diff --git a/src/thread/i386/clone.s b/src/thread/i386/clone.s index 7af5f5db..bebf01a3 100644 --- a/src/thread/i386/clone.s +++ b/src/thread/i386/clone.s @@ -1,26 +1,51 @@ .text -.global __uniclone -.type __uniclone,@function -__uniclone: - movl 4(%esp),%ecx - subl $24,%ecx - movl 8(%esp),%eax - movl %eax,16(%ecx) - movl 12(%esp),%eax - movl %eax,24(%ecx) - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl %eax,8(%eax) - leal 20(%eax),%edx - leal 4(%eax),%esi - movl %edx,%edi - movl $0x7d0f00,%ebx - movl $120,%eax - int $128 - popl %ebp - popl %edi - popl %esi - popl %ebx +.global __clone +.weak clone +.type __clone,@function +.type clone,@function +__clone: +clone: + push %ebp + mov %esp,%ebp + push %ebx + push %esi + push %edi + + xor %eax,%eax + push $0x51 + mov %gs,%ax + push $0xfffff + shr $3,%eax + push 28(%ebp) + push %eax + mov $120,%al + + mov 12(%ebp),%ecx + mov 16(%ebp),%ebx + and $-16,%ecx + sub $16,%ecx + mov 20(%ebp),%edi + mov %edi,(%ecx) + mov 24(%ebp),%edx + mov %esp,%esi + mov 32(%ebp),%edi + mov 8(%ebp),%ebp + int $128 + test %eax,%eax + jnz 1f + + mov %ebp,%eax + xor %ebp,%ebp + call *%eax + mov %eax,%ebx + xor %eax,%eax + inc %eax + int $128 + hlt + +1: add $16,%esp + pop %edi + pop %esi + pop %ebx + pop %ebp ret |