blob: 7eb4863081c48c7dd85c73930fbd4a69723f443d [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
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; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#include <unistd.h>
23#include <sys/syscall.h>
24#include <errno.h>
25
26libc_hidden_proto(brk)
27
28/* This must be initialized data because commons can't have aliases. */
29void * __curbrk attribute_hidden = 0;
30
31int brk (void *addr)
32{
33 void *newbrk;
34
35 __asm__ __volatile__ ( \
36 "mv .d1 %2, A4\n\t" \
37 "mvk .s2 %1, B0\n\t" \
38 "swe\n\t" \
39 "nop\n\t" \
40 "mv .d2 B0, %0" \
41 : "=b" (newbrk) \
42 : "i" (__NR_brk), \
43 "a" (addr) \
44 : "memory", "cc", "B0", "A4"); \
45
46 __curbrk = newbrk;
47
48 if (newbrk < addr) {
49 __set_errno (ENOMEM);
50 return -1;
51 }
52 return 0;
53}
54libc_hidden_def(brk)