1 /* consider this code LGPL - davidm */
2 /*
3  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7 
8 #include <unistd.h>
9 #include <sys/syscall.h>
10 #include <errno.h>
11 
12 
13 /* This must be initialized data because commons can't have aliases.  */
14 void * __curbrk = 0;
15 
brk(void * addr)16 int brk (void *addr)
17 {
18     void *newbrk;
19 
20 	__asm__ __volatile__ ("movel %2,%/d1\n\t"
21 			  "moveq %1,%/d0\n\t"
22 			  "trap  #0\n\t"
23 			  "movel %/d0,%0"
24 		:"=g" (newbrk)
25 		:"i" (__NR_brk),"g" (addr) : "%d0", "%d1");
26 
27     __curbrk = newbrk;
28 
29     if (newbrk < addr)
30     {
31 	__set_errno (ENOMEM);
32 	return -1;
33     }
34 
35     return 0;
36 }
37 libc_hidden_def(brk)
38