fix issues with gdb 8.0
[uclibc-ng.git] / libc / stdio / fwide.c
blob422d789f3d0858308ffea697f35d5a0206f83414
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.
6 */
8 #include "_stdio.h"
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);
31 return mode;