Subversion Repositories Kolibri OS

Rev

Rev 4921 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4921 Rev 6099
Line 93... Line 93...
93
       const char *__restrict file _AND
93
       const char *__restrict file _AND
94
       const char *__restrict mode _AND
94
       const char *__restrict mode _AND
95
       register FILE *__restrict fp)
95
       register FILE *__restrict fp)
96
{
96
{
97
  register int f;
97
  register int f;
98
  int flags, oflags;
98
  int flags, oflags, oflags2;
99
  int e = 0;
99
  int e = 0;
Line 100... Line 100...
100
 
100
 
Line 101... Line 101...
101
  CHECK_INIT (ptr, fp);
101
  CHECK_INIT (ptr, fp);
102
 
102
 
103
  /* We can't use the _newlib_flockfile_XXX macros here due to the
103
  /* We can't use the _newlib_flockfile_XXX macros here due to the
104
     interlocked locking with the sfp_lock. */
104
     interlocked locking with the sfp_lock. */
105
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
105
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
106
  int __oldcancel;
106
  int __oldcancel;
-
 
107
  pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
-
 
108
#endif
107
  pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
109
  oflags2 = fp->_flags2;
Line 108... Line 110...
108
#endif
110
  if (!(oflags2 & __SNLK))
109
  _flockfile (fp);
111
    _flockfile (fp);
-
 
112
 
110
 
113
  if ((flags = __sflags (ptr, mode, &oflags)) == 0)
111
  if ((flags = __sflags (ptr, mode, &oflags)) == 0)
114
    {
112
    {
115
      if (!(oflags2 & __SNLK))
113
      _funlockfile (fp);
116
	_funlockfile (fp);
114
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
117
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
Line 207... Line 210...
207
  fp->_ub._size = 0;
210
  fp->_ub._size = 0;
208
  if (HASLB (fp))
211
  if (HASLB (fp))
209
    FREELB (ptr, fp);
212
    FREELB (ptr, fp);
210
  fp->_lb._size = 0;
213
  fp->_lb._size = 0;
211
  fp->_flags &= ~__SORD;
214
  fp->_flags &= ~__SORD;
212
  fp->_flags2 = 0;
215
  fp->_flags2 &= ~__SWID;
213
  memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
216
  memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
Line 214... Line 217...
214
 
217
 
215
  if (f < 0)
218
  if (f < 0)
216
    {				/* did not get it after all */
219
    {				/* did not get it after all */
217
      __sfp_lock_acquire ();
220
      __sfp_lock_acquire ();
218
      fp->_flags = 0;		/* set it free */
221
      fp->_flags = 0;		/* set it free */
-
 
222
      ptr->_errno = e;		/* restore in case _close clobbered */
219
      ptr->_errno = e;		/* restore in case _close clobbered */
223
      if (!(oflags2 & __SNLK))
220
      _funlockfile (fp);
224
	_funlockfile (fp);
221
#ifndef __SINGLE_THREAD__
225
#ifndef __SINGLE_THREAD__
222
      __lock_close_recursive (fp->_lock);
226
      __lock_close_recursive (fp->_lock);
223
#endif
227
#endif
Line 239... Line 243...
239
#ifdef __SCLE
243
#ifdef __SCLE
240
  if (__stextmode (fp->_file))
244
  if (__stextmode (fp->_file))
241
    fp->_flags |= __SCLE;
245
    fp->_flags |= __SCLE;
242
#endif
246
#endif
Line -... Line 247...
-
 
247
 
243
 
248
  if (!(oflags2 & __SNLK))
244
  _funlockfile (fp);
249
    _funlockfile (fp);
245
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
250
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
246
  pthread_setcancelstate (__oldcancel, &__oldcancel);
251
  pthread_setcancelstate (__oldcancel, &__oldcancel);
247
#endif
252
#endif