Rev 4874 | Rev 6099 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 1990, 2007 The Regents of the University of California. |
2 | * Copyright (c) 1990, 2007 The Regents of the University of California. |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms are permitted |
5 | * Redistribution and use in source and binary forms are permitted |
6 | * provided that the above copyright notice and this paragraph are |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, |
7 | * duplicated in all such forms and that any documentation, |
8 | * advertising materials, and other materials related to such |
8 | * advertising materials, and other materials related to such |
9 | * distribution and use acknowledge that the software was developed |
9 | * distribution and use acknowledge that the software was developed |
10 | * by the University of California, Berkeley. The name of the |
10 | * by the University of California, Berkeley. The name of the |
11 | * University may not be used to endorse or promote products derived |
11 | * University may not be used to endorse or promote products derived |
12 | * from this software without specific prior written permission. |
12 | * from this software without specific prior written permission. |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
16 | * |
16 | * |
17 | * %W% (UofMD/Berkeley) %G% |
17 | * %W% (UofMD/Berkeley) %G% |
18 | */ |
18 | */ |
19 | 19 | ||
20 | /* |
20 | /* |
21 | * Information local to this implementation of stdio, |
21 | * Information local to this implementation of stdio, |
22 | * in particular, macros and private variables. |
22 | * in particular, macros and private variables. |
23 | */ |
23 | */ |
24 | 24 | ||
25 | #include <_ansi.h> |
25 | #include <_ansi.h> |
26 | #include |
26 | #include |
27 | #include |
27 | #include |
28 | #include |
28 | #include |
29 | #include |
29 | #include |
30 | #include |
30 | #include |
31 | #ifdef __SCLE |
31 | #ifdef __SCLE |
32 | # include |
32 | # include |
33 | #endif |
33 | #endif |
- | 34 | ||
- | 35 | /* The following define determines if the per-reent stdin, stdout and stderr |
|
- | 36 | streams are closed during _reclaim_reent(). The stdin, stdout and stderr |
|
- | 37 | streams are initialized to use file descriptors 0, 1 and 2 respectively. In |
|
- | 38 | case _STDIO_CLOSE_PER_REENT_STD_STREAMS is defined these file descriptors |
|
- | 39 | will be closed via close() provided the owner of the reent structure |
|
- | 40 | triggerd the on demand reent initilization, see CHECK_INIT(). */ |
|
- | 41 | #ifndef __rtems__ |
|
- | 42 | #define _STDIO_CLOSE_PER_REENT_STD_STREAMS |
|
- | 43 | #endif |
|
- | 44 | ||
- | 45 | /* The following macros are supposed to replace calls to _flockfile/_funlockfile |
|
- | 46 | and __sfp_lock_acquire/__sfp_lock_release. In case of multi-threaded |
|
- | 47 | environments using pthreads, it's not sufficient to lock the stdio functions |
|
- | 48 | against concurrent threads accessing the same data, the locking must also be |
|
- | 49 | secured against thread cancellation. |
|
- | 50 | ||
- | 51 | The below macros have to be used in pairs. The _newlib_XXX_start macro |
|
- | 52 | starts with a opening curly brace, the _newlib_XXX_end macro ends with a |
|
- | 53 | closing curly brace, so the start macro and the end macro mark the code |
|
- | 54 | start and end of a critical section. In case the code leaves the critical |
|
- | 55 | section before reaching the end of the critical section's code end, use |
|
- | 56 | the appropriate _newlib_XXX_exit macro. */ |
|
- | 57 | ||
- | 58 | #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) \ |
|
- | 59 | && !defined (__rtems__) |
|
- | 60 | #define _STDIO_WITH_THREAD_CANCELLATION_SUPPORT |
|
- | 61 | #endif |
|
- | 62 | ||
- | 63 | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT |
|
- | 64 | #include |
|
- | 65 | ||
- | 66 | /* Start a stream oriented critical section: */ |
|
- | 67 | # define _newlib_flockfile_start(_fp) \ |
|
- | 68 | { \ |
|
- | 69 | int __oldfpcancel; \ |
|
- | 70 | pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldfpcancel); \ |
|
- | 71 | _flockfile (_fp) |
|
- | 72 | ||
- | 73 | /* Exit from a stream oriented critical section prematurely: */ |
|
- | 74 | # define _newlib_flockfile_exit(_fp) \ |
|
- | 75 | _funlockfile (_fp); \ |
|
- | 76 | pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); |
|
- | 77 | ||
- | 78 | /* End a stream oriented critical section: */ |
|
- | 79 | # define _newlib_flockfile_end(_fp) \ |
|
- | 80 | _funlockfile (_fp); \ |
|
- | 81 | pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); \ |
|
- | 82 | } |
|
- | 83 | ||
- | 84 | /* Start a stream list oriented critical section: */ |
|
- | 85 | # define _newlib_sfp_lock_start() \ |
|
- | 86 | { \ |
|
- | 87 | int __oldsfpcancel; \ |
|
- | 88 | pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldsfpcancel); \ |
|
- | 89 | __sfp_lock_acquire () |
|
- | 90 | ||
- | 91 | /* Exit from a stream list oriented critical section prematurely: */ |
|
- | 92 | # define _newlib_sfp_lock_exit() \ |
|
- | 93 | __sfp_lock_release (); \ |
|
- | 94 | pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); |
|
- | 95 | ||
- | 96 | /* End a stream list oriented critical section: */ |
|
- | 97 | # define _newlib_sfp_lock_end() \ |
|
- | 98 | __sfp_lock_release (); \ |
|
- | 99 | pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \ |
|
- | 100 | } |
|
- | 101 | ||
- | 102 | #else /* !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ |
|
- | 103 | ||
- | 104 | # define _newlib_flockfile_start(_fp) \ |
|
- | 105 | { \ |
|
- | 106 | _flockfile(_fp) |
|
- | 107 | ||
- | 108 | # define _newlib_flockfile_exit(_fp) \ |
|
- | 109 | _funlockfile(_fp); \ |
|
- | 110 | ||
- | 111 | # define _newlib_flockfile_end(_fp) \ |
|
- | 112 | _funlockfile(_fp); \ |
|
- | 113 | } |
|
- | 114 | ||
- | 115 | # define _newlib_sfp_lock_start() \ |
|
- | 116 | { \ |
|
- | 117 | __sfp_lock_acquire () |
|
- | 118 | ||
- | 119 | # define _newlib_sfp_lock_exit() \ |
|
- | 120 | __sfp_lock_release (); |
|
- | 121 | ||
- | 122 | # define _newlib_sfp_lock_end() \ |
|
- | 123 | __sfp_lock_release (); \ |
|
- | 124 | } |
|
- | 125 | ||
34 | 126 | #endif /* _STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ |
|
35 | 127 | ||
36 | extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); |
128 | extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); |
37 | extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
129 | extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
38 | extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
130 | extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
39 | extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
131 | extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
40 | extern int _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
132 | extern int _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
41 | extern int _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
133 | extern int _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
42 | extern int _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
134 | extern int _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
43 | extern int _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
135 | extern int _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
44 | extern int _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
136 | extern int _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
45 | int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *, |
137 | int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *, |
46 | va_list) |
138 | va_list) |
47 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
139 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
48 | int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *, |
140 | int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *, |
49 | va_list) |
141 | va_list) |
50 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
142 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
51 | int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
143 | int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
52 | va_list)); |
144 | va_list)); |
53 | int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
145 | int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
54 | va_list)); |
146 | va_list)); |
55 | extern FILE *_EXFUN(__sfp,(struct _reent *)); |
147 | extern FILE *_EXFUN(__sfp,(struct _reent *)); |
56 | extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); |
148 | extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); |
57 | extern int _EXFUN(__sflush_r,(struct _reent *,FILE *)); |
149 | extern int _EXFUN(__sflush_r,(struct _reent *,FILE *)); |
58 | extern int _EXFUN(__srefill_r,(struct _reent *,FILE *)); |
150 | extern int _EXFUN(__srefill_r,(struct _reent *,FILE *)); |
59 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *, |
151 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *, |
60 | int)); |
152 | _READ_WRITE_BUFSIZE_TYPE)); |
61 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *, |
153 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *, |
62 | char *, int)); |
154 | char *, |
- | 155 | _READ_WRITE_BUFSIZE_TYPE)); |
|
63 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *, |
156 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *, |
64 | const char *, int)); |
157 | const char *, |
- | 158 | _READ_WRITE_BUFSIZE_TYPE)); |
|
65 | extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int)); |
159 | extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int)); |
66 | extern int _EXFUN(__sclose,(struct _reent *, void *)); |
160 | extern int _EXFUN(__sclose,(struct _reent *, void *)); |
67 | extern int _EXFUN(__stextmode,(int)); |
161 | extern int _EXFUN(__stextmode,(int)); |
68 | extern _VOID _EXFUN(__sinit,(struct _reent *)); |
162 | extern _VOID _EXFUN(__sinit,(struct _reent *)); |
69 | extern _VOID _EXFUN(_cleanup_r,(struct _reent *)); |
163 | extern _VOID _EXFUN(_cleanup_r,(struct _reent *)); |
70 | extern _VOID _EXFUN(__smakebuf_r,(struct _reent *, FILE *)); |
164 | extern _VOID _EXFUN(__smakebuf_r,(struct _reent *, FILE *)); |
71 | extern int _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *))); |
165 | extern int _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *))); |
72 | extern int _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *))); |
166 | extern int _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *))); |
73 | struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n)); |
167 | struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n)); |
74 | extern int _EXFUN(__submore, (struct _reent *, FILE *)); |
168 | extern int _EXFUN(__submore, (struct _reent *, FILE *)); |
75 | 169 | ||
76 | #ifdef __LARGE64_FILES |
170 | #ifdef __LARGE64_FILES |
77 | extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int)); |
171 | extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int)); |
78 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *, |
172 | extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *, |
79 | const char *, int)); |
173 | const char *, |
- | 174 | _READ_WRITE_BUFSIZE_TYPE)); |
|
80 | #endif |
175 | #endif |
81 | 176 | ||
82 | /* Called by the main entry point fns to ensure stdio has been initialized. */ |
177 | /* Called by the main entry point fns to ensure stdio has been initialized. */ |
83 | 178 | ||
84 | #ifdef _REENT_SMALL |
179 | #ifdef _REENT_SMALL |
85 | #define CHECK_INIT(ptr, fp) \ |
180 | #define CHECK_INIT(ptr, fp) \ |
86 | do \ |
181 | do \ |
87 | { \ |
182 | { \ |
- | 183 | struct _reent *_check_init_ptr = (ptr); \ |
|
88 | if ((ptr) && !(ptr)->__sdidinit) \ |
184 | if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \ |
89 | __sinit (ptr); \ |
185 | __sinit (_check_init_ptr); \ |
90 | if ((fp) == (FILE *)&__sf_fake_stdin) \ |
186 | if ((fp) == (FILE *)&__sf_fake_stdin) \ |
91 | (fp) = _stdin_r(ptr); \ |
187 | (fp) = _stdin_r(_check_init_ptr); \ |
92 | else if ((fp) == (FILE *)&__sf_fake_stdout) \ |
188 | else if ((fp) == (FILE *)&__sf_fake_stdout) \ |
93 | (fp) = _stdout_r(ptr); \ |
189 | (fp) = _stdout_r(_check_init_ptr); \ |
94 | else if ((fp) == (FILE *)&__sf_fake_stderr) \ |
190 | else if ((fp) == (FILE *)&__sf_fake_stderr) \ |
95 | (fp) = _stderr_r(ptr); \ |
191 | (fp) = _stderr_r(_check_init_ptr); \ |
96 | } \ |
192 | } \ |
97 | while (0) |
193 | while (0) |
98 | #else /* !_REENT_SMALL */ |
194 | #else /* !_REENT_SMALL */ |
99 | #define CHECK_INIT(ptr, fp) \ |
195 | #define CHECK_INIT(ptr, fp) \ |
100 | do \ |
196 | do \ |
101 | { \ |
197 | { \ |
- | 198 | struct _reent *_check_init_ptr = (ptr); \ |
|
102 | if ((ptr) && !(ptr)->__sdidinit) \ |
199 | if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \ |
103 | __sinit (ptr); \ |
200 | __sinit (_check_init_ptr); \ |
104 | } \ |
201 | } \ |
105 | while (0) |
202 | while (0) |
106 | #endif /* !_REENT_SMALL */ |
203 | #endif /* !_REENT_SMALL */ |
107 | 204 | ||
108 | #define CHECK_STD_INIT(ptr) \ |
205 | #define CHECK_STD_INIT(ptr) \ |
109 | do \ |
206 | do \ |
110 | { \ |
207 | { \ |
- | 208 | struct _reent *_check_init_ptr = (ptr); \ |
|
111 | if ((ptr) && !(ptr)->__sdidinit) \ |
209 | if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \ |
112 | __sinit (ptr); \ |
210 | __sinit (_check_init_ptr); \ |
113 | } \ |
211 | } \ |
114 | while (0) |
212 | while (0) |
115 | 213 | ||
116 | /* Return true and set errno and stream error flag iff the given FILE |
214 | /* Return true and set errno and stream error flag iff the given FILE |
117 | cannot be written now. */ |
215 | cannot be written now. */ |
118 | 216 | ||
119 | #define cantwrite(ptr, fp) \ |
217 | #define cantwrite(ptr, fp) \ |
120 | ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ |
218 | ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ |
121 | __swsetup_r(ptr, fp)) |
219 | __swsetup_r(ptr, fp)) |
122 | 220 | ||
123 | /* Test whether the given stdio file has an active ungetc buffer; |
221 | /* Test whether the given stdio file has an active ungetc buffer; |
124 | release such a buffer, without restoring ordinary unread data. */ |
222 | release such a buffer, without restoring ordinary unread data. */ |
125 | 223 | ||
126 | #define HASUB(fp) ((fp)->_ub._base != NULL) |
224 | #define HASUB(fp) ((fp)->_ub._base != NULL) |
127 | #define FREEUB(ptr, fp) { \ |
225 | #define FREEUB(ptr, fp) { \ |
128 | if ((fp)->_ub._base != (fp)->_ubuf) \ |
226 | if ((fp)->_ub._base != (fp)->_ubuf) \ |
129 | _free_r(ptr, (char *)(fp)->_ub._base); \ |
227 | _free_r(ptr, (char *)(fp)->_ub._base); \ |
130 | (fp)->_ub._base = NULL; \ |
228 | (fp)->_ub._base = NULL; \ |
131 | } |
229 | } |
132 | 230 | ||
133 | /* Test for an fgetline() buffer. */ |
231 | /* Test for an fgetline() buffer. */ |
134 | 232 | ||
135 | #define HASLB(fp) ((fp)->_lb._base != NULL) |
233 | #define HASLB(fp) ((fp)->_lb._base != NULL) |
136 | #define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \ |
234 | #define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \ |
137 | (fp)->_lb._base = NULL; } |
235 | (fp)->_lb._base = NULL; } |
- | 236 | ||
138 | 237 | #ifdef _WIDE_ORIENT |
|
139 | /* |
238 | /* |
140 | * Set the orientation for a stream. If o > 0, the stream has wide- |
239 | * Set the orientation for a stream. If o > 0, the stream has wide- |
141 | * orientation. If o < 0, the stream has byte-orientation. |
240 | * orientation. If o < 0, the stream has byte-orientation. |
142 | */ |
241 | */ |
143 | #define ORIENT(fp,ori) \ |
242 | #define ORIENT(fp,ori) \ |
144 | do \ |
243 | do \ |
145 | { \ |
244 | { \ |
146 | if (!((fp)->_flags & __SORD)) \ |
245 | if (!((fp)->_flags & __SORD)) \ |
147 | { \ |
246 | { \ |
148 | (fp)->_flags |= __SORD; \ |
247 | (fp)->_flags |= __SORD; \ |
149 | if (ori > 0) \ |
248 | if (ori > 0) \ |
150 | (fp)->_flags2 |= __SWID; \ |
249 | (fp)->_flags2 |= __SWID; \ |
151 | else \ |
250 | else \ |
152 | (fp)->_flags2 &= ~__SWID; \ |
251 | (fp)->_flags2 &= ~__SWID; \ |
153 | } \ |
252 | } \ |
154 | } \ |
253 | } \ |
155 | while (0) |
254 | while (0) |
- | 255 | #else |
|
- | 256 | #define ORIENT(fp,ori) |
|
- | 257 | #endif |
|
156 | 258 | ||
157 | /* WARNING: _dcvt is defined in the stdlib directory, not here! */ |
259 | /* WARNING: _dcvt is defined in the stdlib directory, not here! */ |
158 | 260 | ||
159 | char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int)); |
261 | char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int)); |
160 | char *_EXFUN(_sicvt,(char *, short, char)); |
262 | char *_EXFUN(_sicvt,(char *, short, char)); |
161 | char *_EXFUN(_icvt,(char *, int, char)); |
263 | char *_EXFUN(_icvt,(char *, int, char)); |
162 | char *_EXFUN(_licvt,(char *, long, char)); |
264 | char *_EXFUN(_licvt,(char *, long, char)); |
163 | #ifdef __GNUC__ |
265 | #ifdef __GNUC__ |
164 | char *_EXFUN(_llicvt,(char *, long long, char)); |
266 | char *_EXFUN(_llicvt,(char *, long long, char)); |
165 | #endif |
267 | #endif |
166 | 268 | ||
167 | #define CVT_BUF_SIZE 128 |
269 | #define CVT_BUF_SIZE 128 |
168 | 270 | ||
169 | #define NDYNAMIC 4 /* add four more whenever necessary */ |
271 | #define NDYNAMIC 4 /* add four more whenever necessary */ |
170 | 272 | ||
171 | #ifdef __SINGLE_THREAD__ |
273 | #ifdef __SINGLE_THREAD__ |
172 | #define __sfp_lock_acquire() |
274 | #define __sfp_lock_acquire() |
173 | #define __sfp_lock_release() |
275 | #define __sfp_lock_release() |
174 | #define __sinit_lock_acquire() |
276 | #define __sinit_lock_acquire() |
175 | #define __sinit_lock_release() |
277 | #define __sinit_lock_release() |
176 | #else |
278 | #else |
177 | _VOID _EXFUN(__sfp_lock_acquire,(_VOID)); |
279 | _VOID _EXFUN(__sfp_lock_acquire,(_VOID)); |
178 | _VOID _EXFUN(__sfp_lock_release,(_VOID)); |
280 | _VOID _EXFUN(__sfp_lock_release,(_VOID)); |
179 | _VOID _EXFUN(__sinit_lock_acquire,(_VOID)); |
281 | _VOID _EXFUN(__sinit_lock_acquire,(_VOID)); |
180 | _VOID _EXFUN(__sinit_lock_release,(_VOID)); |
282 | _VOID _EXFUN(__sinit_lock_release,(_VOID)); |
181 | #endif |
283 | #endif |
182 | 284 | ||
183 | /* Types used in positional argument support in vfprinf/vfwprintf. |
285 | /* Types used in positional argument support in vfprinf/vfwprintf. |
184 | The implementation is char/wchar_t dependent but the class and state |
286 | The implementation is char/wchar_t dependent but the class and state |
185 | tables are only defined once in vfprintf.c. */ |
287 | tables are only defined once in vfprintf.c. */ |
186 | typedef enum { |
288 | typedef enum { |
187 | ZERO, /* '0' */ |
289 | ZERO, /* '0' */ |
188 | DIGIT, /* '1-9' */ |
290 | DIGIT, /* '1-9' */ |
189 | DOLLAR, /* '$' */ |
291 | DOLLAR, /* '$' */ |
190 | MODFR, /* spec modifier */ |
292 | MODFR, /* spec modifier */ |
191 | SPEC, /* format specifier */ |
293 | SPEC, /* format specifier */ |
192 | DOT, /* '.' */ |
294 | DOT, /* '.' */ |
193 | STAR, /* '*' */ |
295 | STAR, /* '*' */ |
194 | FLAG, /* format flag */ |
296 | FLAG, /* format flag */ |
195 | OTHER, /* all other chars */ |
297 | OTHER, /* all other chars */ |
196 | MAX_CH_CLASS /* place-holder */ |
298 | MAX_CH_CLASS /* place-holder */ |
197 | } __CH_CLASS; |
299 | } __CH_CLASS; |
198 | 300 | ||
199 | typedef enum { |
301 | typedef enum { |
200 | START, /* start */ |
302 | START, /* start */ |
201 | SFLAG, /* seen a flag */ |
303 | SFLAG, /* seen a flag */ |
202 | WDIG, /* seen digits in width area */ |
304 | WDIG, /* seen digits in width area */ |
203 | WIDTH, /* processed width */ |
305 | WIDTH, /* processed width */ |
204 | SMOD, /* seen spec modifier */ |
306 | SMOD, /* seen spec modifier */ |
205 | SDOT, /* seen dot */ |
307 | SDOT, /* seen dot */ |
206 | VARW, /* have variable width specifier */ |
308 | VARW, /* have variable width specifier */ |
207 | VARP, /* have variable precision specifier */ |
309 | VARP, /* have variable precision specifier */ |
208 | PREC, /* processed precision */ |
310 | PREC, /* processed precision */ |
209 | VWDIG, /* have digits in variable width specification */ |
311 | VWDIG, /* have digits in variable width specification */ |
210 | VPDIG, /* have digits in variable precision specification */ |
312 | VPDIG, /* have digits in variable precision specification */ |
211 | DONE, /* done */ |
313 | DONE, /* done */ |
212 | MAX_STATE, /* place-holder */ |
314 | MAX_STATE, /* place-holder */ |
213 | } __STATE; |
315 | } __STATE; |
214 | 316 | ||
215 | typedef enum { |
317 | typedef enum { |
216 | NOOP, /* do nothing */ |
318 | NOOP, /* do nothing */ |
217 | NUMBER, /* build a number from digits */ |
319 | NUMBER, /* build a number from digits */ |
218 | SKIPNUM, /* skip over digits */ |
320 | SKIPNUM, /* skip over digits */ |
219 | GETMOD, /* get and process format modifier */ |
321 | GETMOD, /* get and process format modifier */ |
220 | GETARG, /* get and process argument */ |
322 | GETARG, /* get and process argument */ |
221 | GETPW, /* get variable precision or width */ |
323 | GETPW, /* get variable precision or width */ |
222 | GETPWB, /* get variable precision or width and pushback fmt char */ |
324 | GETPWB, /* get variable precision or width and pushback fmt char */ |
223 | GETPOS, /* get positional parameter value */ |
325 | GETPOS, /* get positional parameter value */ |
224 | PWPOS, /* get positional parameter value for variable width or precision */ |
326 | PWPOS, /* get positional parameter value for variable width or precision */ |
225 | } __ACTION; |
327 | } __ACTION; |
226 | 328 | ||
227 | extern _CONST __CH_CLASS __chclass[256]; |
329 | extern _CONST __CH_CLASS __chclass[256]; |
228 | extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS]; |
330 | extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS]; |
229 | extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS];> |
331 | extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS];> |