syscalls.c

00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <sys/stat.h>
00005 #include <pm.h>
00006 
00007 #define STDIN_FILENO 0 /* standard input file descriptor */
00008 #define STDOUT_FILENO 1 /* standard output file descriptor */
00009 #define STDERR_FILENO 2 /* standard error file descriptor */
00010 
00011 void 
00012 _exit(int n)
00013 {
00014         while(1)
00015         {
00016                 n = n;
00017         }
00018 }
00019 
00020 int
00021 _stat(char *file, struct stat *st) {
00022         return 0;
00023 }
00024 
00025 int
00026 _fstat(int fd, struct stat * st)
00027 {
00028         if(fd == STDOUT_FILENO)
00029         {
00030                 memset(st, 0, sizeof (* st));
00031                 st->st_mode = S_IFCHR;
00032                 st->st_blksize = 1024;
00033                 return 0;
00034         }
00035         else
00036         {
00037                 return(-1);
00038         }
00039 }
00040 
00041 register char *stack_ptr asm ("sp");
00042 
00043 caddr_t
00044 _sbrk_r(void *reent, size_t incr)
00045 {
00046         extern char end asm ("end"); // Defined by the linker
00047         static char *heap_end;
00048         char *prev_heap_end;
00049 
00050         if( heap_end == NULL )
00051                 heap_end = &end;
00052         prev_heap_end = heap_end;
00053 
00054         if(( heap_end + incr ) > stack_ptr )
00055         {
00056                 /* Some of the libstdc++-v3 tests rely upon detecting */
00057                 /* out of memory errors, so do not abort here. */
00058                 exit(1);
00059                 return (caddr_t) -1;
00060         }
00061 
00062         heap_end += incr;
00063         return (caddr_t) prev_heap_end;
00064 }
00065 
00066 int
00067 _isatty(int fd)
00068 {
00069         return 1;
00070 }
00071 
00072 int
00073 _lseek(int fd, int ptr,int dir)
00074 {
00075         return -1;
00076 }
00077 
00078 int
00079 _open(const char *name, int mode)
00080 {
00081         return -1;
00082 }
00083 
00084 int
00085 _close(int fd)
00086 {
00087     return -1;
00088 }
00089 
00090 int
00091 _write(int fd, const void *data, unsigned int count)
00092 {
00093     count = -1;
00094     return(count);
00095 }
00096 
00097 int _write_r(void *reent, int fd, char *ptr, size_t len)
00098 {
00099         size_t i;
00100 
00101         for (i=0; i<len; i++)
00102         {
00103         plat_putByte(ptr[i]);
00104         }
00105         return len;
00106 }
00107 
00108 
00109 int
00110 _read(int fd, void *buffer, unsigned int count)
00111 {
00112     return -1;
00113 }

Generated on Mon Oct 18 07:40:46 2010 for Python-on-a-chip by  doxygen 1.5.9