summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-12 14:23:17 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-12 14:23:17 +0000
commit6602ba129f062e26a875d8f3b947504500dcc261 (patch)
tree2e359d08a98c8f7f16d2fde9f5a46ed10b2673b5 /libc/sysdeps/linux
parent0f0f20abd295592740a1e764abb976e0db337d86 (diff)
smaller brk() for i386. Inspected assembly to see it's still valid.
text data bss dec hex filename - 44 0 4 48 30 libc/sysdeps/linux/i386/brk.o + 42 0 4 46 2e libc/sysdeps/linux/i386/brk.o
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r--libc/sysdeps/linux/i386/brk.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/libc/sysdeps/linux/i386/brk.c b/libc/sysdeps/linux/i386/brk.c
index 2be9c1802..744d1d037 100644
--- a/libc/sysdeps/linux/i386/brk.c
+++ b/libc/sysdeps/linux/i386/brk.c
@@ -27,23 +27,21 @@ void *__curbrk attribute_hidden = 0;
/* libc_hidden_proto(brk) */
int brk (void *addr)
{
- void *__unbounded newbrk, *__unbounded scratch;
+ void *newbrk, *ebx;
- __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)));
+ __asm__ (
+ "int $0x80\n"
+ : "=a" (newbrk), "=b" (ebx)
+ : "0" (__NR_brk), "1" (addr)
+ );
- __curbrk = newbrk;
+ __curbrk = newbrk;
- if (newbrk < addr)
- {
- __set_errno (ENOMEM);
- return -1;
- }
+ if (newbrk < addr) {
+ __set_errno(ENOMEM);
+ return -1;
+ }
- return 0;
+ return 0;
}
libc_hidden_def(brk)