Cygwin: Add new APIs tc[gs]etwinsize()
[newlib-cygwin.git] / newlib / libc / sys / w65 / syscalls.c
blob4f5b108b1ad3e6a5ef786cf127f2b41a8261d5a8
1 #include <_ansi.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include "sys/syscall.h"
5 int errno;
9 int
10 _read (int file,
11 char *ptr,
12 int len)
14 return __trap3 (SYS_read, file, ptr, len);
18 int
19 _lseek (int file,
20 int ptr,
21 int dir)
23 return __trap3 (SYS_lseek, file, ptr, dir);
26 static
27 writechar (char c)
29 asm ("lda %0" : : "r" (c));
30 asm ("wdm");
35 int
36 _write (
37 int file,
38 char *ptr,
39 int len)
41 return __trap3 (SYS_write, file, ptr, len);
46 int
47 _close (int file)
49 return __trap3 (SYS_close, file, 0, 0);
54 caddr_t
55 _sbrk (int incr)
57 extern char end; /* Defined by the linker */
58 static char *heap_end;
59 char *prev_heap_end;
61 if (heap_end == 0)
63 heap_end = &end;
65 prev_heap_end = heap_end;
66 if (heap_end + incr > stack_ptr)
68 _write (1, "Heap and stack collision\n", 25);
69 abort ();
72 heap_end += incr;
73 return (caddr_t) prev_heap_end;
79 int
80 _fstat (int file,
81 struct stat *st)
83 st->st_mode = S_IFCHR;
84 return 0;
88 int
89 _open (
90 char *path,
91 int flags)
93 return __trap3 (SYS_open, path, flags, 0);
96 int
97 _unlink ()
99 return -1;
102 isatty (fd)
103 int fd;
105 return 1;
110 _exit (n)
112 return __trap3 (SYS_exit, n, 0, 0);
116 _kill (n, m)
118 return __trap3 (SYS_exit, 0xdead, 0, 0);
122 _getpid (n)
124 return 1;
130 _raise ()
136 _stat (const char *path, struct stat *st)
139 return _trap3 (SYS_stat, path, st, 0);
143 _chmod (const char *path, short mode)
145 return _trap3 (SYS_chmod, path, mode);
149 _chown (const char *path, short owner, short group)
151 return _trap3 (SYS_chown, path, owner, group);
155 _utime (path, times)
156 const char *path;
157 char *times;
159 return _trap3 (SYS_utime, path, times);
163 _fork ()
165 return _trap3 (SYS_fork);
169 _wait (statusp)
170 int *statusp;
172 return _trap3 (SYS_wait);
176 _execve (const char *path, char *const argv[], char *const envp[])
178 return _trap3 (SYS_execve, path, argv, envp);
182 _execv (const char *path, char *const argv[])
184 return _trap3 (SYS_execv, path, argv);
188 _pipe (int *fd)
190 return _trap3 (SYS_pipe, fd);