1 /* Support files for GNU libc. Files in the system namespace go here.
2 Files in the C namespace (ie those that do not start with an
3 underscore) go in .c. */
11 #include <sys/times.h>
14 #include <system_def.h>
15 #include "system_stub.h"
17 /* Register name faking - works in collusion with the linker. */
18 register char * stack_ptr asm ("sp");
20 system_stub_ops_t system_stub_ops;
22 int _read(int file, char *ptr, int len);
28 if(!system_stub_ops.read)
30 return system_stub_ops.read(file,ptr,len);
33 int _write(int file, const char *ptr, int len);
39 if(!system_stub_ops.write)
41 return system_stub_ops.write(file,ptr,len);
50 if(!system_stub_ops.lseek)
52 return system_stub_ops.lseek(file,pos,dir);
55 int _open(const char *path, int flags, ...);
57 _open (const char * path,
61 if(!system_stub_ops.open)
63 return system_stub_ops.open(path,flags,0);
70 if(!system_stub_ops.close)
72 return system_stub_ops.close(file);
75 typedef int (local_call_t)(void);
92 int _kill(int n, int m);
107 void *_sbrk(ptrdiff_t incr);
109 _sbrk (ptrdiff_t incr)
111 extern char end asm ("end"); /* Defined by the linker. */
112 static char *heap_end;
113 char * prev_heap_end;
117 if (heap_end == NULL)
120 prev_heap_end = heap_end;
122 if (heap_end + incr > stack_ptr)
124 /* Some of the libstdc++-v3 tests rely upon detecting
125 out of memory errors, so do not abort here. */
127 extern void abort (void);
129 _write (1, "_sbrk: Heap and stack collision\n", 32);
140 return /*(caddr_t)*/ prev_heap_end;
143 int _fstat(int file, struct stat *st);
145 _fstat (int file, struct stat * st)
150 int _stat (const char *fname, struct stat *st);
151 int _stat (const char *fname, struct stat *st)
156 int _link(const char *path1, const char *path2);
158 _link (const char *path1,
164 int _unlink(const char *path);
166 _unlink (const char *path)
178 int _gettimeofday(struct timeval *tp, struct timezone *tzp);
180 _gettimeofday (struct timeval *tp,
181 struct timezone *tzp)
189 /* Return fixed data for the timezone. */
192 tzp->tz_minuteswest = 0;
199 /* Return a clock that ticks at 100Hz. */
200 clock_t _times(struct tms *tp);
202 _times (struct tms * tp)
208 tp->tms_utime = timeval; /* user time */
209 tp->tms_stime = 0; /* system time */
210 tp->tms_cutime = 0; /* user time, children */
211 tp->tms_cstime = 0; /* system time, children */
225 int _system(const char *s);
227 _system (const char *s)
232 int _rename(const char *oldpath, const char *newpath);
234 _rename (const char * oldpath, const char * newpath)
239 /* extern (.*) ([^ ]*) _PARAMS \(\(struct _reent \*(,*)(.*)\)\); */
240 /* \1 \2 (struct _reent *\3\4) { return \2(\4);} */
244 int _close_r(struct _reent *reent, int file)
245 { return _close(file);}
247 int _fcntl_r(struct _reent *, int, int, int)
248 { return _fcntl( int, int, int);}
250 int _fstat_r(struct _reent *reent, int file, struct stat *st);
251 int _fstat_r(struct _reent *reent, int file, struct stat *st)
252 { return _fstat(file, st);}
254 int _getpid_r(struct _reent *reent);
255 int _getpid_r(struct _reent *reent)
258 int _kill_r(struct _reent *reent, int n, int m);
259 int _kill_r(struct _reent *reent, int n, int m)
260 { return _kill(n, m);}
262 int _link_r(struct _reent *reent, const char *path1, const char *path2);
263 int _link_r(struct _reent *reent, const char *path1, const char *path2)
264 { return _link(path1, path2);}
266 _off_t _lseek_r(struct _reent *reent, int file, _off_t pos, int dir);
267 _off_t _lseek_r(struct _reent *reent, int file, _off_t pos, int dir)
268 { return _lseek(file, pos, dir);}
270 int _open_r(struct _reent *reent, const char *path, int flags, int opts);
271 int _open_r(struct _reent *reent, const char *path, int flags, int opts)
272 { return _open(path, flags, opts);}
274 _ssize_t _read_r(struct _reent *reent, int file, void *ptr, size_t len);
275 _ssize_t _read_r(struct _reent *reent, int file, void *ptr, size_t len)
276 { return _read(file, ptr, len);}
278 void *_sbrk_r(struct _reent *reent, ptrdiff_t incr);
279 void *_sbrk_r(struct _reent *reent, ptrdiff_t incr)
280 { return _sbrk(incr);}
282 int _stat_r(struct _reent *reent, const char *path, struct stat *st);
283 int _stat_r(struct _reent *reent, const char *path, struct stat *st)
284 { return _stat(path, st);}
286 int _unlink_r(struct _reent *reent, const char *path);
287 int _unlink_r(struct _reent *reent, const char *path)
288 { return _unlink(path);}
290 _ssize_t _write_r(struct _reent *reent, int file, const void *ptr, size_t len);
291 _ssize_t _write_r(struct _reent *reent, int file, const void *ptr, size_t len)
292 { return _write(file, ptr, len);}
294 /* FIXME: TDK added dummy functions. Need to implement. */
301 int _swistat(int fd, struct stat *st);
302 int _swistat(int fd, struct stat *st)
307 /* Return a clock that ticks at 100Hz. */
308 clock_t _clock(void);
315 int _swiclose(int fh);
316 int _swiclose(int fh)
321 int _swiopen(const char *path, int flags);
322 int _swiopen(const char *path, int flags)
327 int _swiwrite(int fh, char *ptr, int len);
328 int _swiwrite(int fh, char *ptr, int len)
333 int _swilseek(int fd, int ptr, int dir);
334 int _swilseek(int fd, int ptr, int dir)
339 int _swiread(int fh, char *ptr, int len);
340 int _swiread(int fh, char *ptr, int len)
345 void initialise_monitor_handles(void);
346 void initialise_monitor_handles(void)