This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

thread safety level of fwide


Hi, everyone

fwide() is annotated as 
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock 
in the glibc manual.

After reading it's source code, I think it should be marked with race:stream.
The reasoning is fwide() uses fp several times inside without holding the lock over all of them.

How do you think about that?

The fwide()'s code is as follows:
int
fwide (fp, mode)
     _IO_FILE *fp;
     int mode;
{
  int result;

  /* Normalize the value.  */
  mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1); 

  if (mode == 0 || fp->_mode != 0)
    /* The caller simply wants to know about the current orientation
       or the orientation already has been determined.  */
    return fp->_mode;

  _IO_acquire_lock (fp);
  result = _IO_fwide (fp, mode);
  _IO_release_lock (fp);

  return result;
}

Best regards
-- 
Ma Shimiao
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]