1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
10 /* TODO: According to SUSv3 should return EBADF if invalid stream. */
12 int fwide(register FILE *stream
, int mode
)
14 __STDIO_AUTO_THREADLOCK_VAR
;
16 __STDIO_AUTO_THREADLOCK(stream
);
18 __STDIO_STREAM_VALIDATE(stream
);
20 if (mode
&& !(stream
->__modeflags
& (__FLAG_WIDE
|__FLAG_NARROW
))) {
21 stream
->__modeflags
|= ((mode
> 0) ? __FLAG_WIDE
: __FLAG_NARROW
);
24 mode
= (stream
->__modeflags
& __FLAG_WIDE
)
25 - (stream
->__modeflags
& __FLAG_NARROW
);
27 assert((stream
->__modeflags
& (__FLAG_WIDE
|__FLAG_NARROW
))
28 != (__FLAG_WIDE
|__FLAG_NARROW
));
29 __STDIO_AUTO_THREADUNLOCK(stream
);