Rev 4874 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
Line 101... | Line 101... | ||
101 | char *buf _AND |
101 | char *buf _AND |
102 | register int mode _AND |
102 | register int mode _AND |
103 | register size_t size) |
103 | register size_t size) |
104 | { |
104 | { |
105 | int ret = 0; |
105 | int ret = 0; |
- | 106 | struct _reent *reent = _REENT; |
|
Line 106... | Line 107... | ||
106 | 107 | ||
Line 107... | Line 108... | ||
107 | CHECK_INIT (_REENT, fp); |
108 | CHECK_INIT (reent, fp); |
Line 108... | Line 109... | ||
108 | 109 | ||
109 | _flockfile (fp); |
110 | _newlib_flockfile_start (fp); |
110 | 111 | ||
111 | /* |
112 | /* |
Line 112... | Line 113... | ||
112 | * Verify arguments. The `int' limit on `size' is due to this |
113 | * Verify arguments. The `int' limit on `size' is due to this |
113 | * particular implementation. |
114 | * particular implementation. |
114 | */ |
115 | */ |
115 | 116 | ||
116 | if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0) |
117 | if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0) |
Line 117... | Line 118... | ||
117 | { |
118 | { |
118 | _funlockfile (fp); |
119 | _newlib_flockfile_exit (fp); |
119 | return (EOF); |
120 | return (EOF); |
120 | } |
121 | } |
121 | 122 | ||
122 | /* |
123 | /* |
Line 123... | Line 124... | ||
123 | * Write current buffer, if any; drop read count, if any. |
124 | * Write current buffer, if any; drop read count, if any. |
124 | * Make sure putc() will not think fp is line buffered. |
125 | * Make sure putc() will not think fp is line buffered. |
125 | * Free old buffer if it was from malloc(). Clear line and |
126 | * Free old buffer if it was from malloc(). Clear line and |
126 | * non buffer flags, and clear malloc flag. |
127 | * non buffer flags, and clear malloc flag. |
127 | */ |
128 | */ |
128 | 129 | ||
Line 129... | Line 130... | ||
129 | _fflush_r (_REENT, fp); |
130 | _fflush_r (reent, fp); |
130 | fp->_r = 0; |
131 | fp->_r = 0; |
Line 156... | Line 157... | ||
156 | nbf: |
157 | nbf: |
157 | fp->_flags |= __SNBF; |
158 | fp->_flags |= __SNBF; |
158 | fp->_w = 0; |
159 | fp->_w = 0; |
159 | fp->_bf._base = fp->_p = fp->_nbuf; |
160 | fp->_bf._base = fp->_p = fp->_nbuf; |
160 | fp->_bf._size = 1; |
161 | fp->_bf._size = 1; |
161 | _funlockfile (fp); |
162 | _newlib_flockfile_exit (fp); |
162 | return (ret); |
163 | return (ret); |
163 | } |
164 | } |
164 | fp->_flags |= __SMBF; |
165 | fp->_flags |= __SMBF; |
165 | } |
166 | } |
166 | /* |
167 | /* |
Line 178... | Line 179... | ||
178 | fp->_lbfsize = buf ? -size : 0; |
179 | fp->_lbfsize = buf ? -size : 0; |
179 | /* FALLTHROUGH */ |
180 | /* FALLTHROUGH */ |
Line 180... | Line 181... | ||
180 | 181 | ||
181 | case _IOFBF: |
182 | case _IOFBF: |
182 | /* no flag */ |
183 | /* no flag */ |
183 | _REENT->__cleanup = _cleanup_r; |
184 | reent->__cleanup = _cleanup_r; |
184 | fp->_bf._base = fp->_p = (unsigned char *) buf; |
185 | fp->_bf._base = fp->_p = (unsigned char *) buf; |
185 | fp->_bf._size = size; |
186 | fp->_bf._size = size; |
186 | break; |
187 | break; |
Line 191... | Line 192... | ||
191 | */ |
192 | */ |
Line 192... | Line 193... | ||
192 | 193 | ||
193 | if (fp->_flags & __SWR) |
194 | if (fp->_flags & __SWR) |
Line 194... | Line 195... | ||
194 | fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : size; |
195 | fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : size; |
195 | 196 | ||
196 | _funlockfile (fp); |
197 | _newlib_flockfile_end (fp); |