Revert "mips64: time64 for n32 ABI breaks a lot of tests, disable it for now"
[uclibc-ng.git] / libc / sysdeps / linux / nds32 / brk.c
bloba3c38d9b8536f5250850e38261d697ebd911b04c
1 /*
2 * Copyright (C) 2016 Andes Technology, Inc.
3 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
4 */
6 /* brk system call for Linux/NDS32.
7 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with the GNU C Library; if not, write to the Free
21 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 02111-1307 USA. */
24 #include <errno.h>
25 #include <unistd.h>
26 #include <sys/syscall.h>
28 /* This must be initialized data because commons can't have aliases. */
29 void *__curbrk attribute_hidden = 0;
31 libc_hidden_proto(brk)
32 int
33 brk (void *addr)
35 void *newbrk;
37 #ifdef NDS32_ABI_V0
38 __asm__ __volatile__ ("move $r0, %1 \n\t" // save the argment in r0
39 "pushm $r7, $r8 \n\t"
40 "sethi $r7, hi20(%2)\n\t" // put the syscall number in r7
41 "ori $r7, $r7, lo12(%2)\n\t"
42 "syscall 0x7fff \n\t" // do the system call
43 "popm $r7, $r8 \n\t"
44 "move %0, $r5 \n\t" // keep the return value
45 : "=r"(newbrk)
46 : "r"(addr), "i"(SYS_ify(brk))
47 : "$r0", "$r5");
48 #else
49 __asm__ __volatile__ ("move $r0, %1 \n\t" // save the argment in r0
50 "syscall %2 \n\t" // do the system call
51 "move %0, $r0 \n\t" // keep the return value
52 : "=r"(newbrk)
53 : "r"(addr), "i"(SYS_ify(brk))
54 : "$r0");
55 #endif
57 __curbrk = newbrk;
59 if (newbrk < addr)
61 __set_errno (ENOMEM);
62 return -1;
65 return 0;
67 libc_hidden_def(brk)