blob: 6c877bb9a12d9df12957c5003394b72e6ddd217a [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
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
12extern void * __curbrk attribute_hidden;
13extern int __init_brk (void) attribute_hidden;
14
15int 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}
37libc_hidden_def(brk)