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 24... | Line 24... | ||
24 | INDEX |
24 | INDEX |
25 | _fread_r |
25 | _fread_r |
Line 26... | Line 26... | ||
26 | 26 | ||
27 | ANSI_SYNOPSIS |
27 | ANSI_SYNOPSIS |
28 | #include |
28 | #include |
29 | size_t fread(void *<[buf]>, size_t <[size]>, size_t <[count]>, |
29 | size_t fread(void *restrict <[buf]>, size_t <[size]>, size_t <[count]>, |
Line 30... | Line 30... | ||
30 | FILE *<[fp]>); |
30 | FILE *restrict <[fp]>); |
31 | 31 | ||
32 | #include |
32 | #include |
Line 33... | Line 33... | ||
33 | size_t _fread_r(struct _reent *<[ptr]>, void *<[buf]>, |
33 | size_t _fread_r(struct _reent *<[ptr]>, void *restrict <[buf]>, |
34 | size_t <[size]>, size_t <[count]>, FILE *<[fp]>); |
34 | size_t <[size]>, size_t <[count]>, FILE *restrict <[fp]>); |
35 | 35 | ||
36 | TRAD_SYNOPSIS |
36 | TRAD_SYNOPSIS |
Line 129... | Line 129... | ||
129 | #endif |
129 | #endif |
Line 130... | Line 130... | ||
130 | 130 | ||
131 | size_t |
131 | size_t |
132 | _DEFUN(_fread_r, (ptr, buf, size, count, fp), |
132 | _DEFUN(_fread_r, (ptr, buf, size, count, fp), |
133 | struct _reent * ptr _AND |
133 | struct _reent * ptr _AND |
134 | _PTR buf _AND |
134 | _PTR __restrict buf _AND |
135 | size_t size _AND |
135 | size_t size _AND |
136 | size_t count _AND |
136 | size_t count _AND |
137 | FILE * fp) |
137 | FILE * __restrict fp) |
138 | { |
138 | { |
139 | register size_t resid; |
139 | register size_t resid; |
140 | register char *p; |
140 | register char *p; |
141 | register int r; |
141 | register int r; |
Line 144... | Line 144... | ||
144 | if ((resid = count * size) == 0) |
144 | if ((resid = count * size) == 0) |
145 | return 0; |
145 | return 0; |
Line 146... | Line 146... | ||
146 | 146 | ||
Line 147... | Line 147... | ||
147 | CHECK_INIT(ptr, fp); |
147 | CHECK_INIT(ptr, fp); |
148 | 148 | ||
149 | _flockfile (fp); |
149 | _newlib_flockfile_start (fp); |
150 | ORIENT (fp, -1); |
150 | ORIENT (fp, -1); |
151 | if (fp->_r < 0) |
151 | if (fp->_r < 0) |
152 | fp->_r = 0; |
152 | fp->_r = 0; |
Line 193... | Line 193... | ||
193 | if (rc) |
193 | if (rc) |
194 | { |
194 | { |
195 | #ifdef __SCLE |
195 | #ifdef __SCLE |
196 | if (fp->_flags & __SCLE) |
196 | if (fp->_flags & __SCLE) |
197 | { |
197 | { |
198 | _funlockfile (fp); |
198 | _newlib_flockfile_exit (fp); |
199 | return crlf_r (ptr, fp, buf, total-resid, 1) / size; |
199 | return crlf_r (ptr, fp, buf, total-resid, 1) / size; |
200 | } |
200 | } |
201 | #endif |
201 | #endif |
202 | _funlockfile (fp); |
202 | _newlib_flockfile_exit (fp); |
203 | return (total - resid) / size; |
203 | return (total - resid) / size; |
204 | } |
204 | } |
205 | } |
205 | } |
206 | } |
206 | } |
207 | else |
207 | else |
Line 218... | Line 218... | ||
218 | { |
218 | { |
219 | /* no more input: return partial result */ |
219 | /* no more input: return partial result */ |
220 | #ifdef __SCLE |
220 | #ifdef __SCLE |
221 | if (fp->_flags & __SCLE) |
221 | if (fp->_flags & __SCLE) |
222 | { |
222 | { |
223 | _funlockfile (fp); |
223 | _newlib_flockfile_exit (fp); |
224 | return crlf_r (ptr, fp, buf, total-resid, 1) / size; |
224 | return crlf_r (ptr, fp, buf, total-resid, 1) / size; |
225 | } |
225 | } |
226 | #endif |
226 | #endif |
227 | _funlockfile (fp); |
227 | _newlib_flockfile_exit (fp); |
228 | return (total - resid) / size; |
228 | return (total - resid) / size; |
229 | } |
229 | } |
230 | } |
230 | } |
231 | _CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); |
231 | _CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); |
232 | fp->_r -= resid; |
232 | fp->_r -= resid; |
Line 235... | Line 235... | ||
235 | 235 | ||
236 | /* Perform any CR/LF clean-up if necessary. */ |
236 | /* Perform any CR/LF clean-up if necessary. */ |
237 | #ifdef __SCLE |
237 | #ifdef __SCLE |
238 | if (fp->_flags & __SCLE) |
238 | if (fp->_flags & __SCLE) |
239 | { |
239 | { |
240 | _funlockfile (fp); |
240 | _newlib_flockfile_exit (fp); |
241 | return crlf_r(ptr, fp, buf, total, 0) / size; |
241 | return crlf_r(ptr, fp, buf, total, 0) / size; |
242 | } |
242 | } |
243 | #endif |
243 | #endif |
244 | _funlockfile (fp); |
244 | _newlib_flockfile_end (fp); |
245 | return count; |
245 | return count; |
Line 246... | Line 246... | ||
246 | } |
246 | } |
247 | 247 | ||
248 | #ifndef _REENT_ONLY |
248 | #ifndef _REENT_ONLY |
249 | size_t |
249 | size_t |
250 | _DEFUN(fread, (buf, size, count, fp), |
250 | _DEFUN(fread, (buf, size, count, fp), |
251 | _PTR buf _AND |
251 | _PTR __restrict buf _AND |
252 | size_t size _AND |
252 | size_t size _AND |
253 | size_t count _AND |
253 | size_t count _AND |
254 | FILE * fp) |
254 | FILE *__restrict fp) |
255 | { |
255 | { |
256 | return _fread_r (_REENT, buf, size, count, fp); |
256 | return _fread_r (_REENT, buf, size, count, fp); |