Logo
Explore Help
Sign In
fluencelabs/musl
1
0
Fork 0
You've already forked musl
mirror of https://github.com/fluencelabs/musl synced 2025-05-31 08:31:39 +00:00
Code Issues Projects Releases Wiki Activity
musl/src/stdio/fwide.c

13 lines
222 B
C
Raw Normal View History

initial check-in, version 0.5.0
2011-02-12 00:22:29 -05:00
#include "stdio_impl.h"
#define SH (8*sizeof(int)-1)
#define NORMALIZE(x) ((x)>>SH | -((-(x))>>SH))
int fwide(FILE *f, int mode)
{
correct locking in stdio functions that tried to be lock-free these functions must behave as if they obtain the lock via flockfile to satisfy POSIX requirements. since another thread can provably hold the lock when they are called, they must wait to obtain the lock before they can return, even if the correct return value could be obtained without locking. in the case of fclose and freopen, failure to do so could cause correct (albeit obscure) programs to crash or otherwise misbehave; in the case of feof, ferror, and fwide, failure to obtain the lock could sometimes return incorrect results. in any case, having these functions proceed and return while another thread held the lock was wrong.
2012-10-24 23:16:41 -04:00
FLOCK(f);
if (!f->mode) mode = f->mode = NORMALIZE(mode);
FUNLOCK(f);
return mode;
initial check-in, version 0.5.0
2011-02-12 00:22:29 -05:00
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 66ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API