| OLD | NEW |
| 1 #ifndef _STDIO_IMPL_H | 1 #ifndef _STDIO_IMPL_H |
| 2 #define _STDIO_IMPL_H | 2 #define _STDIO_IMPL_H |
| 3 | 3 |
| 4 #include <stdio.h> | 4 #include <stdio.h> |
| 5 #include "syscall.h" | 5 #include "syscall.h" |
| 6 #include "libc.h" | 6 #include "libc.h" |
| 7 | 7 |
| 8 #define UNGET 8 | 8 #define UNGET 8 |
| 9 | 9 |
| 10 #define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0) | 10 #define FFINALLOCK(f) ((f)->lock >= 0 ? __lockfile((f)) : 0) |
| 11 #define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0) | 11 #define FLOCK(f) int __need_unlock = ((f)->lock >= 0 ? __lockfile((f)) : 0) |
| 12 #define FUNLOCK(f) if (__need_unlock) __unlockfile((f)); else | 12 #define FUNLOCK(f) \ |
| 13 if (__need_unlock) \ |
| 14 __unlockfile((f)); \ |
| 15 else |
| 13 | 16 |
| 14 #define F_PERM 1 | 17 #define F_PERM 1 |
| 15 #define F_NORD 4 | 18 #define F_NORD 4 |
| 16 #define F_NOWR 8 | 19 #define F_NOWR 8 |
| 17 #define F_EOF 16 | 20 #define F_EOF 16 |
| 18 #define F_ERR 32 | 21 #define F_ERR 32 |
| 19 #define F_SVB 64 | 22 #define F_SVB 64 |
| 20 #define F_APP 128 | 23 #define F_APP 128 |
| 21 | 24 |
| 22 struct _IO_FILE { | 25 struct _IO_FILE { |
| 23 » unsigned flags; | 26 unsigned flags; |
| 24 » unsigned char *rpos, *rend; | 27 unsigned char *rpos, *rend; |
| 25 » int (*close)(FILE *); | 28 int (*close)(FILE*); |
| 26 » unsigned char *wend, *wpos; | 29 unsigned char *wend, *wpos; |
| 27 » unsigned char *mustbezero_1; | 30 unsigned char* mustbezero_1; |
| 28 » unsigned char *wbase; | 31 unsigned char* wbase; |
| 29 » size_t (*read)(FILE *, unsigned char *, size_t); | 32 size_t (*read)(FILE*, unsigned char*, size_t); |
| 30 » size_t (*write)(FILE *, const unsigned char *, size_t); | 33 size_t (*write)(FILE*, const unsigned char*, size_t); |
| 31 » off_t (*seek)(FILE *, off_t, int); | 34 off_t (*seek)(FILE*, off_t, int); |
| 32 » unsigned char *buf; | 35 unsigned char* buf; |
| 33 » size_t buf_size; | 36 size_t buf_size; |
| 34 » FILE *prev, *next; | 37 FILE *prev, *next; |
| 35 » int fd; | 38 int fd; |
| 36 » int pipe_pid; | 39 int pipe_pid; |
| 37 » long lockcount; | 40 long lockcount; |
| 38 » short dummy3; | 41 short dummy3; |
| 39 » signed char mode; | 42 signed char mode; |
| 40 » signed char lbf; | 43 signed char lbf; |
| 41 » volatile int lock; | 44 volatile int lock; |
| 42 » volatile int waiters; | 45 volatile int waiters; |
| 43 » void *cookie; | 46 void* cookie; |
| 44 » off_t off; | 47 off_t off; |
| 45 » char *getln_buf; | 48 char* getln_buf; |
| 46 » void *mustbezero_2; | 49 void* mustbezero_2; |
| 47 » unsigned char *shend; | 50 unsigned char* shend; |
| 48 » off_t shlim, shcnt; | 51 off_t shlim, shcnt; |
| 49 » FILE *prev_locked, *next_locked; | 52 FILE *prev_locked, *next_locked; |
| 50 » struct __locale_struct *locale; | 53 struct __locale_struct* locale; |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 size_t __stdio_read(FILE *, unsigned char *, size_t); | 56 size_t __stdio_read(FILE*, unsigned char*, size_t); |
| 54 size_t __stdio_write(FILE *, const unsigned char *, size_t); | 57 size_t __stdio_write(FILE*, const unsigned char*, size_t); |
| 55 size_t __stdout_write(FILE *, const unsigned char *, size_t); | 58 size_t __stdout_write(FILE*, const unsigned char*, size_t); |
| 56 off_t __stdio_seek(FILE *, off_t, int); | 59 off_t __stdio_seek(FILE*, off_t, int); |
| 57 int __stdio_close(FILE *); | 60 int __stdio_close(FILE*); |
| 58 | 61 |
| 59 size_t __string_read(FILE *, unsigned char *, size_t); | 62 size_t __string_read(FILE*, unsigned char*, size_t); |
| 60 | 63 |
| 61 int __toread(FILE *); | 64 int __toread(FILE*); |
| 62 int __towrite(FILE *); | 65 int __towrite(FILE*); |
| 63 | 66 |
| 64 #if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303) | 67 #if defined(__PIC__) && (100 * __GNUC__ + __GNUC_MINOR__ >= 303) |
| 65 __attribute__((visibility("protected"))) | 68 __attribute__((visibility("protected"))) |
| 66 #endif | 69 #endif |
| 67 int __overflow(FILE *, int), __uflow(FILE *); | 70 int __overflow(FILE *, int), __uflow(FILE *); |
| 68 | 71 |
| 69 int __fseeko(FILE *, off_t, int); | 72 int __fseeko(FILE*, off_t, int); |
| 70 int __fseeko_unlocked(FILE *, off_t, int); | 73 int __fseeko_unlocked(FILE*, off_t, int); |
| 71 off_t __ftello(FILE *); | 74 off_t __ftello(FILE*); |
| 72 off_t __ftello_unlocked(FILE *); | 75 off_t __ftello_unlocked(FILE*); |
| 73 size_t __fwritex(const unsigned char *, size_t, FILE *); | 76 size_t __fwritex(const unsigned char*, size_t, FILE*); |
| 74 int __putc_unlocked(int, FILE *); | 77 int __putc_unlocked(int, FILE*); |
| 75 | 78 |
| 76 FILE *__fdopen(int, const char *); | 79 FILE* __fdopen(int, const char*); |
| 77 int __fmodeflags(const char *); | 80 int __fmodeflags(const char*); |
| 78 | 81 |
| 79 FILE *__ofl_add(FILE *f); | 82 FILE* __ofl_add(FILE* f); |
| 80 FILE **__ofl_lock(void); | 83 FILE** __ofl_lock(void); |
| 81 void __ofl_unlock(void); | 84 void __ofl_unlock(void); |
| 82 | 85 |
| 83 #define feof(f) ((f)->flags & F_EOF) | 86 #define feof(f) ((f)->flags & F_EOF) |
| 84 #define ferror(f) ((f)->flags & F_ERR) | 87 #define ferror(f) ((f)->flags & F_ERR) |
| 85 | 88 |
| 86 #define getc_unlocked(f) \ | 89 #define getc_unlocked(f) (((f)->rpos < (f)->rend) ? *(f)->rpos++ : __uflow((f))) |
| 87 » ( ((f)->rpos < (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) | |
| 88 | 90 |
| 89 #define putc_unlocked(c, f) \ | 91 #define putc_unlocked(c, f) \ |
| 90 » ( ((unsigned char)(c)!=(f)->lbf && (f)->wpos<(f)->wend) \ | 92 (((unsigned char)(c) != (f)->lbf && (f)->wpos < (f)->wend) \ |
| 91 » ? *(f)->wpos++ = (c) : __overflow((f),(c)) ) | 93 ? *(f)->wpos++ = (c) \ |
| 94 : __overflow((f), (c))) |
| 92 | 95 |
| 93 /* Caller-allocated FILE * operations */ | 96 /* Caller-allocated FILE * operations */ |
| 94 FILE *__fopen_rb_ca(const char *, FILE *, unsigned char *, size_t); | 97 FILE* __fopen_rb_ca(const char*, FILE*, unsigned char*, size_t); |
| 95 int __fclose_ca(FILE *); | 98 int __fclose_ca(FILE*); |
| 96 | 99 |
| 97 #endif | 100 #endif |
| OLD | NEW |