11 #if defined(_SMALL_PRINTF) || defined(SMALL_SCANF)
16 #include <sys/types.h>
18 #include <sys/fcntl.h>
25 #include <sys/times.h>
36 int _system _PARAMS ((
const char *));
40 int _rename _PARAMS ((
const char *,
const char *));
41 int isatty _PARAMS ((
int));
44 clock_t _times _PARAMS ((
struct tms *));
45 int _gettimeofday _PARAMS ((
struct timeval *,
struct timezone *));
49 void _raise _PARAMS ((
void));
51 int _unlink _PARAMS ((
void));
52 int _link _PARAMS ((
void));
54 int _stat _PARAMS ((
const char *,
struct stat *));
56 int _fstat _PARAMS ((
int,
struct stat *));
59 int _getpid _PARAMS ((
int));
61 int _kill _PARAMS ((
int,
int));
62 void _exit _PARAMS ((
int));
63 int _close _PARAMS ((
int));
65 int _swiclose _PARAMS ((
int));
66 int _open _PARAMS ((
const char *,
int, ...));
67 int _swiopen _PARAMS ((
const char *,
int));
68 int _write _PARAMS ((
int,
char *,
int));
69 int _swiwrite _PARAMS ((
int,
char *,
int));
70 int _lseek _PARAMS ((
int,
int,
int));
71 int _swilseek _PARAMS ((
int,
int,
int));
72 int _read _PARAMS ((
int,
char *,
int));
73 int _swiread _PARAMS ((
int,
char *,
int));
74 void initialise_monitor_handles _PARAMS ((
void));
76 static int wrap _PARAMS ((
int));
77 static int error _PARAMS ((
int));
78 static int get_errno _PARAMS ((
void));
79 static int remap_handle _PARAMS ((
int));
80 static int findslot _PARAMS ((
int));
83 register char * stack_ptr
asm (
"sp");
87 extern void _EXFUN(__sinit,(
struct _reent *));
90 #define CHECK_INIT(fp) \
93 if ((fp)->_data == 0) \
94 (fp)->_data = _REENT; \
95 if (!(fp)->_data->__sdidinit) \
96 __sinit ((fp)->_data); \
101 #define FILE_HANDLE_OFFSET (0x20)
103 static int std_files_checked;
104 static int monitor_stdin;
105 static int monitor_stdout;
106 static int monitor_stderr;
117 #define MAX_OPEN_FILES 20
118 static poslog openfiles [MAX_OPEN_FILES];
188 static int get_errno (
void)
190 asm (
"swi %a0" ::
"i" (SWI_GetErrno));
193 static int error (
int result)
195 errno = get_errno ();
201 static int wrap (
int result)
216 int _lseek (
int file,
223 extern void __io_putchar(
char c );
225 int _write (
int file,
231 for (todo = 0; todo < len; todo++)
233 __io_putchar( *ptr++ );
239 int _open (
const char * path,
246 int _close (
int file)
259 int _kill (
int n,
int m)
265 #if 0 //VC090825: moved to independent lib std_sbrk.lib
266 caddr_t _sbrk (
int incr)
269 static char *heap_end;
275 prev_heap_end = heap_end;
276 if (heap_end + incr > stack_ptr)
278 _write (1,
"Heap and stack collision\n", 25);
283 return (caddr_t) prev_heap_end;
285 #endif //if 0 //VC090825: moved to independent lib std_sbrk.lib
289 #include <sys/stat.h>
292 int _fstat(
int file,
struct stat *st)
294 st->st_mode = S_IFCHR;
301 int _stat (
const char *fname,
struct stat *st)
303 st->st_mode = S_IFCHR;
327 int _gettimeofday (
struct timeval * tp,
struct timezone * tzp)
335 asm (
"swi %a1; mov %0, r0" :
"=r" (value):
"i" (SWI_Time) :
"r0");
344 tzp->tz_minuteswest = 0;
354 clock_t _times (
struct tms * tp)
358 asm (
"swi %a1; mov %0, r0" :
"=r" (timeval):
"i" (SWI_Clock) :
"r0");
362 tp->tms_utime = timeval;
382 int _system (
const char *s)
393 int _rename (
const char * oldpath,
const char * newpath)