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>
16 /* Register name faking - works in collusion with the linker. */
17 register char * stack_ptr asm ("sp");
19 system_stub_ops_t system_stub_ops;
26 if(!system_stub_ops.read)
28 return system_stub_ops.read(file,ptr,len);
36 if(!system_stub_ops.write)
38 return system_stub_ops.write(file,ptr,len);
47 if(!system_stub_ops.lseek)
49 return system_stub_ops.lseek(file,pos,dir);
53 _open (const char * path,
57 if(!system_stub_ops.open)
59 return system_stub_ops.open(path,flags,0);
65 if(!system_stub_ops.close)
67 return system_stub_ops.close(file);
70 typedef int (local_call_t)(void);
99 _sbrk (ptrdiff_t incr)
101 extern char end asm ("end"); /* Defined by the linker. */
102 static char *heap_end;
103 char * prev_heap_end;
107 if (heap_end == NULL)
110 prev_heap_end = heap_end;
112 if (heap_end + incr > stack_ptr)
114 /* Some of the libstdc++-v3 tests rely upon detecting
115 out of memory errors, so do not abort here. */
117 extern void abort (void);
119 _write (1, "_sbrk: Heap and stack collision\n", 32);
130 return /*(caddr_t)*/ prev_heap_end;
134 _fstat (int file, struct stat * st)
139 int _stat (const char *fname, struct stat *st)
145 _link (const char *path1, const char *path2 )
151 _unlink (const char *path)
163 _gettimeofday (struct timeval * tp, struct timezone * tzp)
171 /* Return fixed data for the timezone. */
174 tzp->tz_minuteswest = 0;
181 /* Return a clock that ticks at 100Hz. */
183 _times (struct tms * tp)
189 tp->tms_utime = timeval; /* user time */
190 tp->tms_stime = 0; /* system time */
191 tp->tms_cutime = 0; /* user time, children */
192 tp->tms_cstime = 0; /* system time, children */
206 _system (const char *s)
212 _rename (const char * oldpath, const char * newpath)
217 /* extern (.*) ([^ ]*) _PARAMS \(\(struct _reent \*(,*)(.*)\)\); */
218 /* \1 \2 (struct _reent *\3\4) { return \2(\4);} */
222 int _close_r(struct _reent * reent, int file)
223 { return _close(file);}
225 int _fcntl_r(struct _reent *, int, int, int)
226 { return _fcntl( int, int, int);}
228 int _fstat_r(struct _reent * reent, int file, struct stat * st)
229 { return _fstat(file, st);}
231 int _getpid_r(struct _reent * reent)
234 int _kill_r(struct _reent * reent, int n, int m)
235 { return _kill(n, m);}
237 int _link_r(struct _reent * reent, const char *path1, const char *path2)
238 { return _link(path1, path2);}
240 _off_t _lseek_r(struct _reent * reent, int file, _off_t pos, int dir)
241 { return _lseek(file, pos, dir);}
243 int _open_r(struct _reent * reent, const char * path, int flags, int opts)
244 { return _open(path, flags, opts);}
246 _ssize_t _read_r(struct _reent * reent, int file, void * ptr, size_t len)
247 { return _read(file, ptr, len);}
249 void *_sbrk_r(struct _reent * reent, ptrdiff_t incr)
250 { return _sbrk(incr);}
252 int _stat_r(struct _reent * reent, const char * path, struct stat * st)
253 { return _stat(path, st);}
255 int _unlink_r(struct _reent * reent, const char * path)
256 { return _unlink(path);}
258 _ssize_t _write_r(struct _reent * reent, int file, const void * ptr, size_t len)
259 { return _write(file, ptr, len);}