yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> |
| 3 | * |
| 4 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 5 | */ |
| 6 | |
| 7 | #include <unistd.h> |
| 8 | #include <sys/syscall.h> |
| 9 | #include <errno.h> |
| 10 | #include "sysdep.h" |
| 11 | |
| 12 | extern void * __curbrk attribute_hidden; |
| 13 | extern int __init_brk (void) attribute_hidden; |
| 14 | |
| 15 | int brk(void * end_data_seg) |
| 16 | { |
| 17 | if (__init_brk () == 0) { |
| 18 | /* |
| 19 | * Notice that we don't need to save/restore the GOT |
| 20 | * register since that is not call clobbered by the syscall. |
| 21 | */ |
| 22 | __asm__ ("move.d %1,$r10\n\t" |
| 23 | "movu.w " STR(__NR_brk) ",$r9\n\t" |
| 24 | "break 13\n\t" |
| 25 | "move.d $r10, %0" |
| 26 | : "=r" (__curbrk) |
| 27 | : "g" (end_data_seg) |
| 28 | : "r9", "r10"); |
| 29 | |
| 30 | if (__curbrk == end_data_seg) |
| 31 | return 0; |
| 32 | __set_errno(ENOMEM); |
| 33 | } |
| 34 | return -1; |
| 35 | |
| 36 | } |
| 37 | libc_hidden_def(brk) |