1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include <unistd.h>
- #include <sys/syscall.h>
- #include <errno.h>
- void *__curbrk attribute_hidden = 0;
- int brk (void *addr)
- {
- void *newbrk;
- register int r2 __asm__("r2") = TRAP_ID_SYSCALL;
- register int r3 __asm__("r3") = __NR_brk;
- register void *r4 __asm__("r4") = addr;
- __asm__ __volatile__ ("trap\n\t" : "=r"(newbrk) : "0"(r2), "r"(r3), "r"(r4));
- __curbrk = newbrk;
- if (newbrk < addr) {
- __set_errno (ENOMEM);
- return -1;
- }
- return 0;
- }
- libc_hidden_def(brk)
|