1 | /*
|
---|
2 | * TOPPERS/ASP/FMP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Advanced Standard Profile/Flexible MultiProcessor Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2003-2005 by
|
---|
7 | * GJ Business Division RICOH COMPANY,LTD. JAPAN
|
---|
8 | * Copyright (C) 2015-2017 by TOPPERS PROJECT Educational Working Group.
|
---|
9 | *
|
---|
10 | * 上記著作権者は,Free Software Foundation によって公表されている
|
---|
11 | * GNU General Public License の Version 2 に記述されている条件か,以
|
---|
12 | * 下の(1)~(4)の条件を満たす場合に限り,本ソフトウェア(本ソフトウェ
|
---|
13 | * アを改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
|
---|
14 | * 利用と呼ぶ)することを無償で許諾する.
|
---|
15 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
16 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
17 | * スコード中に含まれていること.
|
---|
18 | * (2) 本ソフトウェアを再利用可能なバイナリコード(リロケータブルオブ
|
---|
19 | * ジェクトファイルやライブラリなど)の形で利用する場合には,利用
|
---|
20 | * に伴うドキュメント(利用者マニュアルなど)に,上記の著作権表示,
|
---|
21 | * この利用条件および下記の無保証規定を掲載すること.
|
---|
22 | * (3) 本ソフトウェアを再利用不可能なバイナリコードの形または機器に組
|
---|
23 | * み込んだ形で利用する場合には,次のいずれかの条件を満たすこと.
|
---|
24 | * (a) 利用に伴うドキュメント(利用者マニュアルなど)に,上記の著作
|
---|
25 | * 権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
26 | * (b) 利用の形態を,別に定める方法によって,上記著作権者に報告する
|
---|
27 | * こと.
|
---|
28 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
29 | * 害からも,上記著作権者を免責すること.
|
---|
30 | *
|
---|
31 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者は,
|
---|
32 | * 本ソフトウェアに関して,その適用可能性も含めて,いかなる保証も行わ
|
---|
33 | * ない.また,本ソフトウェアの利用により直接的または間接的に生じたい
|
---|
34 | * かなる損害に関しても,その責任を負わない.
|
---|
35 | *
|
---|
36 | * @(#) $Id$
|
---|
37 | */
|
---|
38 | /*
|
---|
39 | * Copyright (c) 1990 The Regents of the University of California.
|
---|
40 | * All rights reserved.
|
---|
41 | *
|
---|
42 | * Redistribution and use in source and binary forms are permitted
|
---|
43 | * provided that the above copyright notice and this paragraph are
|
---|
44 | * duplicated in all such forms and that any documentation,
|
---|
45 | * advertising materials, and other materials related to such
|
---|
46 | * distribution and use acknowledge that the software was developed
|
---|
47 | * by the University of California, Berkeley. The name of the
|
---|
48 | * University may not be used to endorse or promote products derived
|
---|
49 | * from this software without specific prior written permission.
|
---|
50 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
---|
51 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
---|
52 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
53 | *
|
---|
54 | * @(#)stdio.h 5.3 (Berkeley) 3/15/86
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * NB: to fit things in six character monocase externals, the
|
---|
59 | * stdio code uses the prefix `__ms' for embedded stdio objects, typically
|
---|
60 | * followed by a three-character attempt at a mnemonic.
|
---|
61 | */
|
---|
62 | #ifndef _STDIO_H_
|
---|
63 | #define _STDIO_H_
|
---|
64 |
|
---|
65 | #ifdef __cplusplus
|
---|
66 | extern "C" {
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | //#define __need___va_list
|
---|
70 | #include <stdarg.h>
|
---|
71 |
|
---|
72 | #define _SMALL_STDIO_
|
---|
73 |
|
---|
74 | #include <target_stddef.h>
|
---|
75 |
|
---|
76 | typedef struct __msFILE {
|
---|
77 | int _flags; /* flags, below; this FILE is free if 0 */
|
---|
78 | int _file; /* fileno, if Unix descriptor, else -1 */
|
---|
79 | int (* _func_in)(void*); /* pointer to a character input function */
|
---|
80 | /* pointer to a character input string function */
|
---|
81 | int (* _func_ins)(void*, unsigned int, char *);
|
---|
82 | void (* _func_out)(void*, int); /* pointer to a character output function */
|
---|
83 | /* pointer to a character output string function */
|
---|
84 | int (* _func_outs)(void*, unsigned int, char *);
|
---|
85 | /* pointer to a character output flush function */
|
---|
86 | int (* _func_flush)(struct __msFILE *);
|
---|
87 | void * _dev; /* pointer to local device structure */
|
---|
88 | } FILE;
|
---|
89 |
|
---|
90 | #define __SLBF 0x0001 /* line buffered */
|
---|
91 | #define __SNBF 0x0002 /* unbuffered */
|
---|
92 | #define __SRD 0x0004 /* OK to read */
|
---|
93 | #define __SWR 0x0008 /* OK to write */
|
---|
94 | /* RD and WR are never simultaneously asserted */
|
---|
95 | #define __SRW 0x0010 /* open for reading & writing */
|
---|
96 | #define __SEOF 0x0020 /* found EOF */
|
---|
97 | #define __SERR 0x0040 /* found error */
|
---|
98 | #define __SMBF 0x0080 /* _buf is from malloc */
|
---|
99 | #define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */
|
---|
100 | #define __SSTR 0x0200 /* this is an sprintf/snprintf string */
|
---|
101 | #define __SOPT 0x0400 /* do fseek() optimisation */
|
---|
102 | #define __SNPT 0x0800 /* do not do fseek() optimisation */
|
---|
103 | #define __SOFF 0x1000 /* set iff _offset is in fact correct */
|
---|
104 | #define __SMOD 0x2000 /* true => fgetline modified _p text */
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * The following three definitions are for ANSI C, which took them
|
---|
108 | * from System V, which stupidly took internal interface macros and
|
---|
109 | * made them official arguments to setvbuf(), without renaming them.
|
---|
110 | * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
|
---|
111 | *
|
---|
112 | * Although these happen to match their counterparts above, the
|
---|
113 | * implementation does not rely on that (so these could be renumbered).
|
---|
114 | */
|
---|
115 | #define _IOFBF 0 /* setvbuf should set fully buffered */
|
---|
116 | #define _IOLBF 1 /* setvbuf should set line buffered */
|
---|
117 | #define _IONBF 2 /* setvbuf should set unbuffered */
|
---|
118 |
|
---|
119 | #ifndef NULL
|
---|
120 | #define NULL 0
|
---|
121 | #endif
|
---|
122 |
|
---|
123 | #define BUFSIZ 1024
|
---|
124 | #define EOF (-1)
|
---|
125 |
|
---|
126 | extern FILE _iob[];
|
---|
127 | #define stdin (&_iob[0]) /* FILE input */
|
---|
128 | #define stdout (&_iob[1]) /* FILE output */
|
---|
129 | #define stderr (&_iob[2]) /* FILE error input output */
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * Functions defined in ANSI C standard.
|
---|
133 | */
|
---|
134 |
|
---|
135 | #ifdef __GNUC__
|
---|
136 | #define __VALIST __gnuc_va_list
|
---|
137 | #else
|
---|
138 | #define __VALIST char*
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | int fgetc(FILE *);
|
---|
142 | int fgets(char *, int, FILE *);
|
---|
143 | int fputc(int, FILE *);
|
---|
144 | int fputs(const char *, FILE *);
|
---|
145 | int putchar(int);
|
---|
146 | int puts(const char *);
|
---|
147 | int printf(const char *, ...);
|
---|
148 | int vprintf(const char *, va_list args);
|
---|
149 | int sprintf(char *, const char *, ...);
|
---|
150 | int vsprintf(char *, const char *, va_list args);
|
---|
151 | int snprintf(char *, size_t, const char *, ...);
|
---|
152 | int scanf(const char *, ...);
|
---|
153 | int sscanf(char *, const char *, ...);
|
---|
154 | int fflush(FILE *);
|
---|
155 | FILE *fopen(const char *, const char *);
|
---|
156 | int fclose(FILE *);
|
---|
157 | size_t fread(void *, size_t, size_t, FILE *);
|
---|
158 | size_t fwrite(const void *, size_t, size_t, FILE *);
|
---|
159 | int fseek(FILE *, long, int);
|
---|
160 | long ftell(FILE *);
|
---|
161 | int fprintf(FILE *, const char *, ...);
|
---|
162 | int vfprintf(FILE *, const char *, va_list args);
|
---|
163 |
|
---|
164 | #define feof(p) (((p)->_flags & __SEOF) != 0)
|
---|
165 | #define ferror(p) (((p)->_flags & __SERR) != 0)
|
---|
166 | #define clearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
|
---|
167 | #define putc(c,fp) fputc(c,fp)
|
---|
168 | #define getchar() fgetc(stdin)
|
---|
169 | #define getc(fp) fgetc(fp)
|
---|
170 |
|
---|
171 | /*
|
---|
172 | * NOT SUPPORT stdio functions
|
---|
173 | */
|
---|
174 | #define gets(s) puts("NOT SUPPORT gets !\n")
|
---|
175 | #define ungetc(c, st) puts("NOT SUPPORT ungetc !\n")
|
---|
176 | #if !defined(__cplusplus) && defined(__GNUC__)
|
---|
177 | #define fscanf(st, format, ...) puts("NOT SUPPORT fscanf !\n")
|
---|
178 | #endif
|
---|
179 |
|
---|
180 | extern void _setup_stdio(signed int *pport);
|
---|
181 | extern FILE *_get_stdio(int no);
|
---|
182 |
|
---|
183 | #ifdef __cplusplus
|
---|
184 | }
|
---|
185 | #endif
|
---|
186 | #endif /* _STDIO_H_ */
|
---|