Subversion Repositories Kolibri OS

Rev

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
	_freopen_r
25
	_freopen_r
Line 26... Line 26...
26
 
26
 
27
ANSI_SYNOPSIS
27
ANSI_SYNOPSIS
28
	#include 
28
	#include 
29
	FILE *freopen(const char *<[file]>, const char *<[mode]>,
29
	FILE *freopen(const char *restrict <[file]>, const char *restrict <[mode]>,
30
		      FILE *<[fp]>);
30
		      FILE *restrict <[fp]>);
31
	FILE *_freopen_r(struct _reent *<[ptr]>, const char *<[file]>,
31
	FILE *_freopen_r(struct _reent *<[ptr]>, const char *restrict <[file]>,
Line 32... Line 32...
32
		      const char *<[mode]>, FILE *<[fp]>);
32
		      const char *restrict <[mode]>, FILE *restrict <[fp]>);
33
 
33
 
34
TRAD_SYNOPSIS
34
TRAD_SYNOPSIS
35
	#include 
35
	#include 
Line 88... Line 88...
88
 */
88
 */
Line 89... Line 89...
89
 
89
 
90
FILE *
90
FILE *
91
_DEFUN(_freopen_r, (ptr, file, mode, fp),
91
_DEFUN(_freopen_r, (ptr, file, mode, fp),
92
       struct _reent *ptr _AND
92
       struct _reent *ptr _AND
93
       const char *file _AND
93
       const char *__restrict file _AND
94
       const char *mode _AND
94
       const char *__restrict mode _AND
95
       register FILE *fp)
95
       register FILE *__restrict fp)
96
{
96
{
97
  register int f;
97
  register int f;
98
  int flags, oflags;
98
  int flags, oflags;
Line 99... Line 99...
99
  int e = 0;
99
  int e = 0;
Line -... Line 100...
-
 
100
 
-
 
101
  CHECK_INIT (ptr, fp);
-
 
102
 
-
 
103
  /* We can't use the _newlib_flockfile_XXX macros here due to the
-
 
104
     interlocked locking with the sfp_lock. */
-
 
105
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
100
 
106
  int __oldcancel;
Line 101... Line 107...
101
  CHECK_INIT (ptr, fp);
107
  pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
102
 
108
#endif
103
  _flockfile (fp);
109
  _flockfile (fp);
-
 
110
 
-
 
111
  if ((flags = __sflags (ptr, mode, &oflags)) == 0)
-
 
112
    {
104
 
113
      _funlockfile (fp);
105
  if ((flags = __sflags (ptr, mode, &oflags)) == 0)
114
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
106
    {
115
      pthread_setcancelstate (__oldcancel, &__oldcancel);
Line 107... Line 116...
107
      _funlockfile (fp);
116
#endif
Line 197... Line 206...
197
    FREEUB (ptr, fp);
206
    FREEUB (ptr, fp);
198
  fp->_ub._size = 0;
207
  fp->_ub._size = 0;
199
  if (HASLB (fp))
208
  if (HASLB (fp))
200
    FREELB (ptr, fp);
209
    FREELB (ptr, fp);
201
  fp->_lb._size = 0;
210
  fp->_lb._size = 0;
202
  fp->_flags & ~__SORD;
211
  fp->_flags &= ~__SORD;
203
  fp->_flags2 = 0;
212
  fp->_flags2 = 0;
204
  memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
213
  memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
Line 205... Line 214...
205
 
214
 
206
  if (f < 0)
215
  if (f < 0)
Line 211... Line 220...
211
      _funlockfile (fp);
220
      _funlockfile (fp);
212
#ifndef __SINGLE_THREAD__
221
#ifndef __SINGLE_THREAD__
213
      __lock_close_recursive (fp->_lock);
222
      __lock_close_recursive (fp->_lock);
214
#endif
223
#endif
215
      __sfp_lock_release ();
224
      __sfp_lock_release ();
-
 
225
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
-
 
226
      pthread_setcancelstate (__oldcancel, &__oldcancel);
-
 
227
#endif
216
      return NULL;
228
      return NULL;
217
    }
229
    }
Line 218... Line 230...
218
 
230
 
219
  fp->_flags = flags;
231
  fp->_flags = flags;
Line 228... Line 240...
228
  if (__stextmode (fp->_file))
240
  if (__stextmode (fp->_file))
229
    fp->_flags |= __SCLE;
241
    fp->_flags |= __SCLE;
230
#endif
242
#endif
Line 231... Line 243...
231
 
243
 
-
 
244
  _funlockfile (fp);
-
 
245
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
-
 
246
  pthread_setcancelstate (__oldcancel, &__oldcancel);
232
  _funlockfile (fp);
247
#endif
233
  return fp;
248
  return fp;
Line 234... Line 249...
234
}
249
}
Line 235... Line 250...
235
 
250
 
236
#ifndef _REENT_ONLY
251
#ifndef _REENT_ONLY
237
 
252
 
238
FILE *
253
FILE *
239
_DEFUN(freopen, (file, mode, fp),
254
_DEFUN(freopen, (file, mode, fp),
240
       _CONST char *file _AND
255
       _CONST char *__restrict file _AND
241
       _CONST char *mode _AND
256
       _CONST char *__restrict mode _AND
242
       register FILE *fp)
257
       register FILE *__restrict fp)
Line 243... Line 258...
243
{
258
{