1 /*
2 * Port of uClibc for TMS320C6000 DSP architecture
3 * Copyright (C) 2004 Texas Instruments Incorporated
4 * Author of TMS320C6000 port: Aurelien Jacquiot
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Library General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this program; see the file COPYING.LIB. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
21 #include <unistd.h>
22 #include <sys/syscall.h>
23 #include <errno.h>
24
25 libc_hidden_proto(brk)
26
27 /* This must be initialized data because commons can't have aliases. */
28 void * __curbrk attribute_hidden = 0;
29
brk(void * addr)30 int brk (void *addr)
31 {
32 void *newbrk;
33
34 __asm__ __volatile__ ( \
35 "mv .d1 %2, A4\n\t" \
36 "mvk .s2 %1, B0\n\t" \
37 "swe\n\t" \
38 "nop\n\t" \
39 "mv .d2 B0, %0" \
40 : "=b" (newbrk) \
41 : "i" (__NR_brk), \
42 "a" (addr) \
43 : "memory", "cc", "B0", "A4"); \
44
45 __curbrk = newbrk;
46
47 if (newbrk < addr) {
48 __set_errno (ENOMEM);
49 return -1;
50 }
51 return 0;
52 }
53 libc_hidden_def(brk)
54