blob: 1ac02de9cbdad33f9c71438396513f79c95c6d25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <stdio.h>
extern char __start_heap;
extern char __end_heap;
void
_init()
{
}
extern void _exit_halt();
void
_exit(int i)
{
_exit_halt();
}
int
_open(const char* path, int flag, int mode)
{
return 0;
}
caddr_t
_sbrk (size_t nbytes)
{
static char* heap_ptr = NULL;
char* prev_heap_ptr;
if (heap_ptr == NULL)
{
heap_ptr = &__start_heap;
}
/* Align the 'heap_ptr' so that memory will always be allocated at word
boundaries. */
heap_ptr = (char *) ((((unsigned long) heap_ptr) + 7) & ~7);
prev_heap_ptr = heap_ptr;
if ((heap_ptr + nbytes) < &__end_heap)
{
heap_ptr += nbytes;
return (caddr_t) prev_heap_ptr;
}
errno = ENOMEM;
return (caddr_t) -1;
}
int
_read(int handle, char *buffer, unsigned int length)
{
return 0;
}
int
_write(int handle, const char *buffer, unsigned int length)
{
return length;
}
int
_lseek(int file, int ptr, int dir)
{
return 0;
}
int
_close(int handle)
{
return -1;
}
int
_fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int
isatty(int file)
{
return 1;
}
void
_kill(int pid, int val)
{
_exit(val);
}
_getpid()
{
return 1;
}
time_t
time(time_t *t)
{
return -1;
}
int
_fork()
{
return -1;
}
unsigned
sleep(unsigned n)
{
return -1;
}
|