URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
[/] [or1k_old/] [trunk/] [newlib/] [libgloss/] [m32r/] [crtsysc.c] - Rev 39
Go to most recent revision | Compare with Previous | Blame | View Log
#include <_ansi.h> #include <sys/types.h> #include <sys/stat.h> #include <reent.h> #include "sys/syscall.h" int __trap0 (int function, int p1, int p2, int p3, struct _reent *r); #define TRAP0(f, p1, p2, p3) \ __trap0 (f, (int) (p1), (int) (p2), (int) (p3), _REENT) asm (" .text .global __trap0 __trap0: trap #0 ; trap 0 returns result in r0, error code in r2 cmpui r2,#1 ; is error code zero? bc .Lret ; yes, skip setting errno .fillinsn ld r4,@(sp) ; no, set errno st r2,@r4 .Lret: jmp lr ; return to caller .fillinsn "); int _open (const char *path, int flags) { return TRAP0 (SYS_open, path, flags, 0); } int _close (int file) { return TRAP0 (SYS_close, file, 0, 0); } int _read (int file, char *ptr, int len) { return TRAP0 (SYS_read, file, ptr, len); } int _lseek (int file, int ptr, int dir) { return TRAP0 (SYS_lseek, file, ptr, dir); } int _write (int file, char *ptr, int len) { return TRAP0 (SYS_write, file, ptr, len); } caddr_t _sbrk (int incr) { /* `_end' is defined in the linker script. We must handle it carefully as we don't want the compiler to think it lives in the small data area. Use medium model to ensure 32 bit addressability. */ extern char _end __attribute__ ((__model__(__medium__))); static char *heap_end; char *prev_heap_end; char *sp = (char *)&sp; if (heap_end == 0) { heap_end = &_end; } prev_heap_end = heap_end; if (heap_end > sp) { _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 _unlink () { return -1; } /* FIXME: can we not nuke the 10,000 copies of this function and fudge things (which is all this function does) in _fstat? */ int isatty (int fd) { return 1; } void _exit (n) { TRAP0 (SYS_exit, n, 0, 0); } _kill (n, m) { return TRAP0 (SYS_exit, 0xdead, 0, 0); } _getpid (n) { return 1; } _raise () { } int _stat (const char *path, struct stat *st) { return TRAP0 (SYS_stat, path, st, 0); } int _chmod (const char *path, short mode) { return TRAP0 (SYS_chmod, path, mode, 0); } int _utime (path, times) const char *path; char *times; { return TRAP0 (SYS_utime, path, times, 0); }
Go to most recent revision | Compare with Previous | Blame | View Log