From: Pavel Pisa Date: Mon, 29 Mar 2010 13:52:12 +0000 (+0200) Subject: The system stub updated from rtime/sysless version. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/76a2d859317df1d5293a7121466599f66a74fcad The system stub updated from rtime/sysless version. These changes are required to build with GCC-4.4.3 + NewLib-18 arm-elf toolchain. Changes provided by Tran Duy Khanh. Signed-off-by: Pavel Pisa --- diff --git a/embedded/arch/arm/generic/libs/misc/system_stub.c b/embedded/arch/arm/generic/libs/misc/system_stub.c index 31a8f66..3ec804c 100644 --- a/embedded/arch/arm/generic/libs/misc/system_stub.c +++ b/embedded/arch/arm/generic/libs/misc/system_stub.c @@ -12,12 +12,14 @@ #include #include #include +#include "system_stub.h" /* Register name faking - works in collusion with the linker. */ register char * stack_ptr asm ("sp"); system_stub_ops_t system_stub_ops; +int _read(int file, char *ptr, int len); int _read (int file, char * ptr, @@ -28,6 +30,7 @@ _read (int file, return system_stub_ops.read(file,ptr,len); } +int _write(int file, const char *ptr, int len); int _write (int file, const char * ptr, @@ -49,6 +52,7 @@ _lseek (int file, return system_stub_ops.lseek(file,pos,dir); } +int _open(const char *path, int flags, ...); int _open (const char * path, int flags, @@ -59,6 +63,7 @@ _open (const char * path, return system_stub_ops.open(path,flags,0); } +int _close(int file); int _close (int file) { @@ -69,6 +74,7 @@ _close (int file) typedef int (local_call_t)(void); +void _exit(int n); void _exit (int n) { @@ -76,18 +82,21 @@ _exit (int n) while(1); } +void abort(void); void abort(void) { ((local_call_t*)0)(); while(1); } +int _kill(int n, int m); int _kill (int n, int m) { return -1; } +int _getpid(void); int _getpid (void) { @@ -95,6 +104,7 @@ _getpid (void) } +void *_sbrk(ptrdiff_t incr); void * _sbrk (ptrdiff_t incr) { @@ -106,9 +116,9 @@ _sbrk (ptrdiff_t incr) if (heap_end == NULL) heap_end = & end; - + prev_heap_end = heap_end; - + if (heap_end + incr > stack_ptr) { /* Some of the libstdc++-v3 tests rely upon detecting @@ -117,50 +127,58 @@ _sbrk (ptrdiff_t incr) extern void abort (void); _write (1, "_sbrk: Heap and stack collision\n", 32); - + abort (); #else errno = ENOMEM; return (caddr_t) -1; #endif } - + heap_end += incr; return /*(caddr_t)*/ prev_heap_end; } +int _fstat(int file, struct stat *st); int _fstat (int file, struct stat * st) { return -1; } +int _stat (const char *fname, struct stat *st); int _stat (const char *fname, struct stat *st) { return -1; } +int _link(const char *path1, const char *path2); int -_link (const char *path1, const char *path2 ) +_link (const char *path1, + const char *path2) { return -1; } +int _unlink(const char *path); int _unlink (const char *path) { return -1; } +void _raise(void); void _raise (void) { return; } +int _gettimeofday(struct timeval *tp, struct timezone *tzp); int -_gettimeofday (struct timeval * tp, struct timezone * tzp) +_gettimeofday (struct timeval *tp, + struct timezone *tzp) { if(tp) @@ -179,11 +197,12 @@ _gettimeofday (struct timeval * tp, struct timezone * tzp) } /* Return a clock that ticks at 100Hz. */ +clock_t _times(struct tms *tp); clock_t _times (struct tms * tp) { clock_t timeval = 0; - + if (tp) { tp->tms_utime = timeval; /* user time */ @@ -191,23 +210,26 @@ _times (struct tms * tp) tp->tms_cutime = 0; /* user time, children */ tp->tms_cstime = 0; /* system time, children */ } - + return timeval; }; +int isatty(int fd); int isatty (int fd) { return 1; } +int _system(const char *s); int _system (const char *s) { return -1; } +int _rename(const char *oldpath, const char *newpath); int _rename (const char * oldpath, const char * newpath) { @@ -219,41 +241,108 @@ _rename (const char * oldpath, const char * newpath) struct _reent; -int _close_r(struct _reent * reent, int file) - { return _close(file);} +int _close_r(struct _reent *reent, int file) +{ return _close(file);} /* -int _fcntl_r(struct _reent *, int, int, int) + int _fcntl_r(struct _reent *, int, int, int) { return _fcntl( int, int, int);} */ -int _fstat_r(struct _reent * reent, int file, struct stat * st) - { return _fstat(file, st);} +int _fstat_r(struct _reent *reent, int file, struct stat *st); +int _fstat_r(struct _reent *reent, int file, struct stat *st) +{ return _fstat(file, st);} + +int _getpid_r(struct _reent *reent); +int _getpid_r(struct _reent *reent) +{ return _getpid();} + +int _kill_r(struct _reent *reent, int n, int m); +int _kill_r(struct _reent *reent, int n, int m) +{ return _kill(n, m);} + +int _link_r(struct _reent *reent, const char *path1, const char *path2); +int _link_r(struct _reent *reent, const char *path1, const char *path2) +{ return _link(path1, path2);} + +_off_t _lseek_r(struct _reent *reent, int file, _off_t pos, int dir); +_off_t _lseek_r(struct _reent *reent, int file, _off_t pos, int dir) +{ return _lseek(file, pos, dir);} + +int _open_r(struct _reent *reent, const char *path, int flags, int opts); +int _open_r(struct _reent *reent, const char *path, int flags, int opts) +{ return _open(path, flags, opts);} -int _getpid_r(struct _reent * reent) - { return _getpid();} +_ssize_t _read_r(struct _reent *reent, int file, void *ptr, size_t len); +_ssize_t _read_r(struct _reent *reent, int file, void *ptr, size_t len) +{ return _read(file, ptr, len);} -int _kill_r(struct _reent * reent, int n, int m) - { return _kill(n, m);} +void *_sbrk_r(struct _reent *reent, ptrdiff_t incr); +void *_sbrk_r(struct _reent *reent, ptrdiff_t incr) +{ return _sbrk(incr);} -int _link_r(struct _reent * reent, const char *path1, const char *path2) - { return _link(path1, path2);} +int _stat_r(struct _reent *reent, const char *path, struct stat *st); +int _stat_r(struct _reent *reent, const char *path, struct stat *st) +{ return _stat(path, st);} + +int _unlink_r(struct _reent *reent, const char *path); +int _unlink_r(struct _reent *reent, const char *path) +{ return _unlink(path);} + +_ssize_t _write_r(struct _reent *reent, int file, const void *ptr, size_t len); +_ssize_t _write_r(struct _reent *reent, int file, const void *ptr, size_t len) +{ return _write(file, ptr, len);} + +/* FIXME: TDK added dummy functions. Need to implement. */ +int _isatty(int fd); +int _isatty(int fd) +{ + return -1; +} + +int _swistat(int fd, struct stat *st); +int _swistat(int fd, struct stat *st) +{ + return -1; +} -_off_t _lseek_r(struct _reent * reent, int file, _off_t pos, int dir) - { return _lseek(file, pos, dir);} +/* Return a clock that ticks at 100Hz. */ +clock_t _clock(void); +clock_t _clock(void) +{ + clock_t timeval; + return timeval; +} -int _open_r(struct _reent * reent, const char * path, int flags, int opts) - { return _open(path, flags, opts);} +int _swiclose(int fh); +int _swiclose(int fh) +{ + return -1; +} -_ssize_t _read_r(struct _reent * reent, int file, void * ptr, size_t len) - { return _read(file, ptr, len);} +int _swiopen(const char *path, int flags); +int _swiopen(const char *path, int flags) +{ + return -1; +} -void *_sbrk_r(struct _reent * reent, ptrdiff_t incr) - { return _sbrk(incr);} +int _swiwrite(int fh, char *ptr, int len); +int _swiwrite(int fh, char *ptr, int len) +{ + return -1; +} -int _stat_r(struct _reent * reent, const char * path, struct stat * st) - { return _stat(path, st);} +int _swilseek(int fd, int ptr, int dir); +int _swilseek(int fd, int ptr, int dir) +{ + return -1; +} -int _unlink_r(struct _reent * reent, const char * path) - { return _unlink(path);} +int _swiread(int fh, char *ptr, int len); +int _swiread(int fh, char *ptr, int len) +{ + return -1; +} -_ssize_t _write_r(struct _reent * reent, int file, const void * ptr, size_t len) - { return _write(file, ptr, len);} +void initialise_monitor_handles(void); +void initialise_monitor_handles(void) +{ +}