diff options
author | Khem Raj <kraj@mvista.com> | 2008-12-23 06:50:20 +0000 |
---|---|---|
committer | Khem Raj <kraj@mvista.com> | 2008-12-23 06:50:20 +0000 |
commit | 6374ca896086574af61eb37ef371e3371b10bb5c (patch) | |
tree | 4c321cab6e21f25534ea9c1e715c5b840ee9b810 /libc/sysdeps/linux/i386/brk.c | |
parent | c229e6446c5fc270b88894269464213dc04f3200 (diff) | |
download | uClibc-alpine-6374ca896086574af61eb37ef371e3371b10bb5c.tar.bz2 uClibc-alpine-6374ca896086574af61eb37ef371e3371b10bb5c.tar.xz |
Get i386 non nptl builds going.
Diffstat (limited to 'libc/sysdeps/linux/i386/brk.c')
-rw-r--r-- | libc/sysdeps/linux/i386/brk.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/libc/sysdeps/linux/i386/brk.c b/libc/sysdeps/linux/i386/brk.c index 2be9c1802..4b47a3b19 100644 --- a/libc/sysdeps/linux/i386/brk.c +++ b/libc/sysdeps/linux/i386/brk.c @@ -25,25 +25,28 @@ void *__curbrk attribute_hidden = 0; /* libc_hidden_proto(brk) */ -int brk (void *addr) +int brk(void *addr) { - void *__unbounded newbrk, *__unbounded scratch; - - __asm__ ("movl %%ebx, %1\n" /* Save %ebx in scratch register. */ - "movl %3, %%ebx\n" /* Put ADDR in %ebx to be syscall arg. */ - "int $0x80 # %2\n" /* Perform the system call. */ - "movl %1, %%ebx\n" /* Restore %ebx from scratch register. */ - : "=a" (newbrk), "=r" (scratch) - : "0" (__NR_brk), "g" (__ptrvalue (addr))); - - __curbrk = newbrk; - - if (newbrk < addr) - { - __set_errno (ENOMEM); - return -1; - } - - return 0; + void *newbrk; + + /* %ebx is used in PIC code, need to save/restore it manually. + * gcc won't do it for us if we will request it in constraints + */ + __asm__("pushl %%ebx\n" + "movl %2, %%ebx\n" + "int $0x80\n" + "popl %%ebx\n" + : "=a" (newbrk) + : "0" (__NR_brk), "g" (addr) + ); + + __curbrk = newbrk; + + if (newbrk < addr) { + __set_errno(ENOMEM); + return -1; + } + + return 0; } libc_hidden_def(brk) |