source: trunk/libs/newlib/src/newlib/libc/sys/w65/syscalls.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.1 KB
Line 
1#include <_ansi.h>
2#include <sys/types.h>
3#include <sys/stat.h>
4#include "sys/syscall.h"
5int errno;
6
7
8
9int
10_read (int file,
11       char *ptr,
12       int len)
13{
14  return __trap3 (SYS_read, file, ptr, len);
15}
16
17
18int
19_lseek (int file,
20        int ptr,
21        int dir)
22{
23  return __trap3 (SYS_lseek, file, ptr, dir);
24}
25
26static
27writechar (char c)
28{
29  asm ("lda %0" : : "r" (c));
30  asm ("wdm");
31}
32
33
34
35int
36_write (
37         int file,
38         char *ptr,
39         int len)
40{
41  return __trap3 (SYS_write, file, ptr, len);
42}
43
44
45
46int
47_close (int file)
48{
49  return __trap3 (SYS_close, file, 0, 0);
50}
51
52
53
54caddr_t
55_sbrk (int incr)
56{
57  extern char end;              /* Defined by the linker */
58  static char *heap_end;
59  char *prev_heap_end;
60
61  if (heap_end == 0)
62    {
63      heap_end = &end;
64    }
65  prev_heap_end = heap_end;
66  if (heap_end + incr > stack_ptr)
67    {
68      _write (1, "Heap and stack collision\n", 25);
69      abort ();
70    }
71
72  heap_end += incr;
73  return (caddr_t) prev_heap_end;
74}
75
76
77
78
79int
80_fstat (int file,
81        struct stat *st)
82{
83  st->st_mode = S_IFCHR;
84  return 0;
85}
86
87
88int
89_open (
90        char *path,
91        int flags)
92{
93  return __trap3 (SYS_open, path, flags, 0);
94}
95
96int
97_unlink ()
98{
99  return -1;
100}
101
102isatty (fd)
103     int fd;
104{
105  return 1;
106}
107
108
109
110_exit (n)
111{
112  return __trap3 (SYS_exit, n, 0, 0);
113}
114
115
116_kill (n, m)
117{
118  return __trap3 (SYS_exit, 0xdead, 0, 0);
119}
120
121
122_getpid (n)
123{
124  return 1;
125}
126
127
128
129
130_raise ()
131{
132
133}
134
135int
136_stat (const char *path, struct stat *st)
137
138{
139  return _trap3 (SYS_stat, path, st, 0);
140}
141
142int
143_chmod (const char *path, short mode)
144{
145  return _trap3 (SYS_chmod, path, mode);
146}
147
148int
149_chown (const char *path, short owner, short group)
150{
151  return _trap3 (SYS_chown, path, owner, group);
152}
153
154int
155_utime (path, times)
156     const char *path;
157     char *times;
158{
159  return _trap3 (SYS_utime, path, times);
160}
161
162int
163_fork ()
164{
165  return _trap3 (SYS_fork);
166}
167
168int
169_wait (statusp)
170     int *statusp;
171{
172  return _trap3 (SYS_wait);
173}
174
175int
176_execve (const char *path, char *const argv[], char *const envp[])
177{
178  return _trap3 (SYS_execve, path, argv, envp);
179}
180
181int
182_execv (const char *path, char *const argv[])
183{
184  return _trap3 (SYS_execv, path, argv);
185}
186
187int
188_pipe (int *fd)
189{
190  return _trap3 (SYS_pipe, fd);
191}
Note: See TracBrowser for help on using the repository browser.