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 <errno.h> |
| 8 | #include <unistd.h> |
| 9 | #include <sys/syscall.h> |
| 10 | |
| 11 | libc_hidden_proto(brk) |
| 12 | |
| 13 | #define __NR___syscall_brk __NR_brk |
| 14 | static inline _syscall1(void *, __syscall_brk, void *, end) |
| 15 | |
| 16 | /* This must be initialized data because commons can't have aliases. */ |
| 17 | void * __curbrk attribute_hidden = 0; |
| 18 | |
| 19 | int brk(void *addr) |
| 20 | { |
| 21 | void *newbrk = __syscall_brk(addr); |
| 22 | |
| 23 | __curbrk = newbrk; |
| 24 | |
| 25 | if (newbrk < addr) { |
| 26 | __set_errno (ENOMEM); |
| 27 | return -1; |
| 28 | } |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | libc_hidden_def(brk) |