mmap64.S for i386
Nikola Vladov <[email protected]> 8 Mar 2011 19:44:24 -0000
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <[email protected]> |
Hi! I wrote two mmap64 functions for i386. Second uses same ideas as current dietlibc. First is simpler and uses the idea from mmap.S on i386. Could some assembrer expert say if they are signal safe -- what happen if a signal arrives during the execution. Regards, /nv ------ first --------- mmap64.S ------------------- #include <syscalls.h> #include <errno.h> .text .global mmap64 .type mmap64,@function mmap64: movl %esp, %eax movl 24(%eax), %ecx testw $0xfff, %cx /* offset in pages */ jnz .Lerror movl 28(%eax), %edx shrdl $12, %edx, %ecx shrl $12, %edx jnz .Lerror pushl %ecx pushl 20(%eax) pushl 16(%eax) pushl 12(%eax) pushl 8(%eax) pushl 4(%eax) movb $__NR_mmap2, %al call __unified_syscall addl $24, %esp ret .Lerror: movl $EINVAL, %eax jmp __error_unified_syscall .Lende2: .size mmap64,.Lende2-mmap64 ------ second --------- mmap64.S ------------------- #include <syscalls.h> #include <errno.h> .text .global mmap64 .type mmap64,@function mmap64: /* man is this ugly! */ push %ebp push %edi push %esi push %ebx movl %esp, %edi movl 0x28(%edi), %ebp movl 0x2c(%edi), %edx movl $-EINVAL, %eax testl $0xfff, %ebp /* offset in pages */ jnz .Lready shrdl $12, %edx, %ebp shrl $12, %edx jnz .Lready movl 0x14(%edi),%ebx movl 0x18(%edi),%ecx movl 0x1c(%edi),%edx movl 0x20(%edi),%esi movl 0x24(%edi),%edi movl $__NR_mmap2,%eax int $0x80 .Lready: pop %ebx pop %esi pop %edi pop %ebp cmp $-132,%eax jbe .Lnoerror neg %eax jmp __error_unified_syscall .Lnoerror: ret .Lende2: .size mmap64,.Lende2-mmap64