Welcome to mirror list, hosted at ThFree Co, Russian Federation.

syscalls.c « w65 « sys « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4f5b108b1ad3e6a5ef786cf127f2b41a8261d5a8 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <_ansi.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "sys/syscall.h"
int errno;



int
_read (int file,
       char *ptr,
       int len)
{
  return __trap3 (SYS_read, file, ptr, len);
}


int
_lseek (int file,
	int ptr,
	int dir)
{
  return __trap3 (SYS_lseek, file, ptr, dir);
}

static
writechar (char c)
{
  asm ("lda %0" : : "r" (c));
  asm ("wdm");
}



int
_write (
	 int file,
	 char *ptr,
	 int len)
{
  return __trap3 (SYS_write, file, ptr, len);
}



int
_close (int file)
{
  return __trap3 (SYS_close, file, 0, 0);
}



caddr_t
_sbrk (int incr)
{
  extern char end;		/* Defined by the linker */
  static char *heap_end;
  char *prev_heap_end;

  if (heap_end == 0)
    {
      heap_end = &end;
    }
  prev_heap_end = heap_end;
  if (heap_end + incr > stack_ptr)
    {
      _write (1, "Heap and stack collision\n", 25);
      abort ();
    }

  heap_end += incr;
  return (caddr_t) prev_heap_end;
}




int
_fstat (int file,
	struct stat *st)
{
  st->st_mode = S_IFCHR;
  return 0;
}


int
_open (
	char *path,
	int flags)
{
  return __trap3 (SYS_open, path, flags, 0);
}

int
_unlink ()
{
  return -1;
}

isatty (fd)
     int fd;
{
  return 1;
}



_exit (n)
{
  return __trap3 (SYS_exit, n, 0, 0);
}


_kill (n, m)
{
  return __trap3 (SYS_exit, 0xdead, 0, 0);
}


_getpid (n)
{
  return 1;
}




_raise ()
{

}

int
_stat (const char *path, struct stat *st)

{
  return _trap3 (SYS_stat, path, st, 0);
}

int
_chmod (const char *path, short mode)
{
  return _trap3 (SYS_chmod, path, mode);
}

int
_chown (const char *path, short owner, short group)
{
  return _trap3 (SYS_chown, path, owner, group);
}

int
_utime (path, times)
     const char *path;
     char *times;
{
  return _trap3 (SYS_utime, path, times);
}

int
_fork ()
{
  return _trap3 (SYS_fork);
}

int
_wait (statusp)
     int *statusp;
{
  return _trap3 (SYS_wait);
}

int
_execve (const char *path, char *const argv[], char *const envp[])
{
  return _trap3 (SYS_execve, path, argv, envp);
}

int
_execv (const char *path, char *const argv[])
{
  return _trap3 (SYS_execv, path, argv);
}

int
_pipe (int *fd)
{
  return _trap3 (SYS_pipe, fd);
}