Last change
on this file since 678 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
588 bytes
|
Line | |
---|
1 | #include <_ansi.h> |
---|
2 | #include <errno.h> |
---|
3 | #include <sys/types.h> |
---|
4 | #include <sys/stat.h> |
---|
5 | #include "trap.h" |
---|
6 | |
---|
7 | |
---|
8 | caddr_t |
---|
9 | _sbrk (size_t incr) |
---|
10 | { |
---|
11 | extern char __stack; /* Defined by the linker */ |
---|
12 | extern char _end; /* Defined by the linker */ |
---|
13 | static char *heap_end; |
---|
14 | char *prev_heap_end; |
---|
15 | char *sp = (char *)&sp; |
---|
16 | |
---|
17 | if (heap_end == 0) |
---|
18 | { |
---|
19 | heap_end = &_end; |
---|
20 | } |
---|
21 | prev_heap_end = heap_end; |
---|
22 | heap_end += incr; |
---|
23 | if (heap_end > sp) |
---|
24 | { |
---|
25 | _write (1, "Heap and stack collision\n", 25); |
---|
26 | errno = ENOMEM; |
---|
27 | return (caddr_t)-1; |
---|
28 | } |
---|
29 | return (caddr_t) prev_heap_end; |
---|
30 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.