riscv64: fix linking with binutils 2.40
[uclibc-ng.git] / libc / sysdeps / linux / metag / brk.c
blob355e88fc76234d108c4be726775b71e242874369
1 /*
2 * Copyright (C) 2013 Imagination Technologies Ltd.
4 * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
5 */
7 #include <errno.h>
8 #include <unistd.h>
9 #include <sys/syscall.h>
11 libc_hidden_proto(brk)
13 /* This must be initialized data because commons can't have aliases. */
14 void * __curbrk attribute_hidden = 0;
16 int brk (void *addr)
18 void *newbrk;
20 __asm__ __volatile__ ("MOV D1Re0,%2\n\t"
21 "MOV D1Ar1,%1\n\t"
22 "SWITCH #0x440001\n\t"
23 "MOV %0,D0Re0"
24 : "=r" (newbrk)
25 : "r" (addr), "K" (__NR_brk)
26 : "D0Re0", "D1Re0", "D1Ar1");
28 __curbrk = newbrk;
30 if (newbrk < addr)
32 __set_errno (ENOMEM);
33 return -1;
36 return 0;
38 libc_hidden_def(brk)