]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/metag/brk.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / metag / brk.c
1 /*
2  * Copyright (C) 2013 Imagination Technologies Ltd.
3  *
4  * Licensed under the LGPL v2.1 or later, 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 /* This must be initialized data because commons can't have aliases.  */
14 void * __curbrk attribute_hidden = 0;
15
16 int brk (void *addr)
17 {
18     void *newbrk;
19
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");
27
28     __curbrk = newbrk;
29
30     if (newbrk < addr)
31     {
32         __set_errno (ENOMEM);
33         return -1;
34     }
35
36     return 0;
37 }
38 libc_hidden_def(brk)