Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 /* diet stdio */ 00002 #ifndef _DIETSTDIO_H 00003 #define _DIETSTDIO_H 00004 #include <sys/cdefs.h> 00005 #include <sys/types.h> 00006 #include "dietfeatures.h" 00007 #ifdef WANT_THREAD_SAFE 00008 #include <pthread.h> 00009 #endif 00010 #include <stdarg.h> 00011 00012 #ifdef WANT_SMALL_STDIO_BUFS 00013 #define BUFSIZE 128 00014 #else 00015 #define BUFSIZE 2048 00016 #endif 00017 #ifndef EOF 00018 #define EOF (-1) 00019 #endif 00020 typedef struct FILE{ 00021 int fd; 00022 int flags; 00023 uint bs; /* read: bytes in buffer */ 00024 uint bm; /* position in buffer */ 00025 uint buflen; /* length of buf */ 00026 char *buf; 00027 struct FILE *next; /* for fflush */ 00028 pid_t popen_kludge; 00029 unsigned char ungetbuf; 00030 char ungotten; 00031 #ifdef WANT_THREAD_SAFE 00032 pthread_mutex_t m; 00033 #endif 00034 }FILE; 00035 00036 #define ERRORINDICATOR 1 00037 #define EOFINDICATOR 2 00038 #define BUFINPUT 4 00039 #define BUFLINEWISE 8 00040 #define NOBUF 16 00041 #define STATICBUF 32 00042 #define FDPIPE 64 00043 #define CANREAD 128 00044 #define CANWRITE 256 00045 #define CHECKLINEWISE 512 00046 00047 #define _IONBF 0 00048 #define _IOLBF 1 00049 #define _IOFBF 2 00050 00051 //#include <stdio.h> 00052 00053 /* internal function to flush buffer. 00054 * However, if next is BUFINPUT and the buffer is an input buffer, it 00055 * will not be flushed. Vice versa for output */ 00056 extern int __fflush4(FILE *stream,int next); 00057 extern size_t fwrite(const void *ptr, size_t size, size_t nmemb,FILE *stream); 00058 extern int __buffered_outs(const char *s,size_t len); 00059 int fflush_unlocked(FILE *stream); 00060 00061 /* ..scanf */ 00062 struct arg_scanf { 00063 void *data; 00064 int (*getch)(void*); 00065 int (*putch)(int,void*); 00066 }; 00067 00068 int __v_scanf(struct arg_scanf* fn, const char *format, va_list arg_ptr); 00069 00070 struct arg_printf { 00071 void *data; 00072 int (*put)(void*,size_t,void*); 00073 }; 00074 00075 int __v_printf(struct arg_printf* fn, const char *format, va_list arg_ptr); 00076 int vprintf(const char *format, va_list ap); 00077 00078 extern FILE *__stdio_root; 00079 extern FILE *stdout; 00080 extern FILE *stdin; 00081 00082 int __fflush_stdin(void); 00083 int __fflush_stdout(void); 00084 int __fflush_stderr(void); 00085 int fflush(FILE *stream); 00086 00087 FILE* __stdio_init_file(int fd,int closeonerror,int mode); 00088 int __stdio_parse_mode(const char *mode) __attribute__((__pure__)); 00089 void __stdio_flushall(void); 00090 00091 #ifndef __THREAD_INTERNAL_H__ 00092 int __libc_close(int fd); 00093 int __libc_open(const char*fn,int flags,...); 00094 ssize_t __libc_read(int fd,void*buf,size_t len); 00095 ssize_t __libc_write(int fd,const void*buf,size_t len); 00096 #endif 00097 00098 FILE *fopen_unlocked(const char *path, const char *mode) __THROW; 00099 FILE *fdopen_unlocked(int fildes, const char *mode) __THROW; 00100 FILE *freopen_unlocked(const char *path, const char *mode, FILE *stream) __THROW; 00101 int fputc_unlocked(int c, FILE *stream); 00102 00103 int __stdout_is_tty(void); 00104 int __stdin_is_tty(void); 00105 #endif