Last change
on this file since 680 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.5 KB
|
Line | |
---|
1 | /* |
---|
2 | * Copyright (c) 2003 Red Hat, Inc. All rights reserved. |
---|
3 | * |
---|
4 | * This copyrighted material is made available to anyone wishing to use, modify, |
---|
5 | * copy, or redistribute it subject to the terms and conditions of the BSD |
---|
6 | * License. This program is distributed in the hope that it will be useful, |
---|
7 | * but WITHOUT ANY WARRANTY expressed or implied, including the implied |
---|
8 | * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy |
---|
9 | * of this license is available at http://www.opensource.org/licenses. Any |
---|
10 | * Red Hat trademarks that are incorporated in the source code or documentation |
---|
11 | * are not subject to the BSD License and may only be used or replicated with |
---|
12 | * the express permission of Red Hat, Inc. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <errno.h> |
---|
16 | |
---|
17 | extern int __heap __far; /* beginning of heap */ |
---|
18 | extern int __heap_end __far; /* if at address 0, use stack pointer as limit */ |
---|
19 | |
---|
20 | static char *the_break = (char *)(& __heap); |
---|
21 | |
---|
22 | int |
---|
23 | is_addr_0 (int address) |
---|
24 | { |
---|
25 | return address ? 0 : 1; |
---|
26 | } |
---|
27 | |
---|
28 | void * |
---|
29 | sbrk(int inc) |
---|
30 | { |
---|
31 | char *current_heap_limit = (char *) (& __heap_end); |
---|
32 | |
---|
33 | /* is_addr_0 avoids optimizing out this block. */ |
---|
34 | if (is_addr_0 ((int) current_heap_limit)) |
---|
35 | { |
---|
36 | int something; |
---|
37 | int margin = 4096; |
---|
38 | current_heap_limit = (char *) (& something) - margin; |
---|
39 | } |
---|
40 | |
---|
41 | if ((the_break + inc) < current_heap_limit) |
---|
42 | { |
---|
43 | void *rv = (void *) the_break; |
---|
44 | the_break += inc; |
---|
45 | return rv; |
---|
46 | } |
---|
47 | else |
---|
48 | { |
---|
49 | errno = ENOMEM; |
---|
50 | return (void *) -1; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | int |
---|
55 | brk (void *ptr) |
---|
56 | { |
---|
57 | the_break = ptr; |
---|
58 | return 0; |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.