]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/stdio/fwide.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / stdio / fwide.c
1 /* Copyright (C) 2004       Manuel Novoa III    <mjn3@codepoet.org>
2  *
3  * GNU Library General Public License (LGPL) version 2 or later.
4  *
5  * Dedicated to Toni.  See uClibc/DEDICATION.mjn3 for details.
6  */
7
8 #include "_stdio.h"
9
10 /* TODO: According to SUSv3 should return EBADF if invalid stream. */
11
12 int fwide(register FILE *stream, int mode)
13 {
14         __STDIO_AUTO_THREADLOCK_VAR;
15
16         __STDIO_AUTO_THREADLOCK(stream);
17
18         __STDIO_STREAM_VALIDATE(stream);
19
20         if (mode && !(stream->__modeflags & (__FLAG_WIDE|__FLAG_NARROW))) {
21                 stream->__modeflags |= ((mode > 0) ? __FLAG_WIDE : __FLAG_NARROW);
22         }
23
24         mode = (stream->__modeflags & __FLAG_WIDE)
25                 - (stream->__modeflags & __FLAG_NARROW);
26
27         assert((stream->__modeflags & (__FLAG_WIDE|__FLAG_NARROW))
28                    != (__FLAG_WIDE|__FLAG_NARROW));
29         __STDIO_AUTO_THREADUNLOCK(stream);
30
31         return mode;
32 }