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.
15 int vdprintf(int filedes
, const char * __restrict format
, va_list arg
)
19 #ifdef __STDIO_BUFFERS
20 char buf
[64]; /* TODO: provide _optional_ buffering? */
22 f
.__bufend
= (unsigned char *) buf
+ sizeof(buf
);
23 f
.__bufstart
= (unsigned char *) buf
;
24 __STDIO_STREAM_DISABLE_GETC(&f
);
25 __STDIO_STREAM_DISABLE_PUTC(&f
);
26 __STDIO_STREAM_INIT_BUFREAD_BUFPOS(&f
);
29 f
.__filedes
= filedes
;
30 f
.__modeflags
= (__FLAG_NARROW
|__FLAG_WRITEONLY
|__FLAG_WRITING
);
32 #ifdef __UCLIBC_HAS_WCHAR__
33 f
.__ungot_width
[0] = 0;
35 #ifdef __STDIO_MBSTATE
36 __INIT_MBSTATE(&(f
.__state
));
39 /* _vfprintf_internal doesn't do any locking, locking init is here
40 * only because of fflush_unlocked. TODO? */
41 #if (defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__)) && defined(__UCLIBC_HAS_THREADS__)
42 f
.__user_locking
= 1; /* Set user locking. */
43 STDIO_INIT_MUTEX(f
.__lock
);
47 #ifdef __USE_OLD_VFPRINTF__
48 rv
= vfprintf(&f
, format
, arg
);
50 rv
= _vfprintf_internal(&f
, format
, arg
);
53 #ifdef __STDIO_BUFFERS
54 /* If not buffering, then fflush is unnecessary. */
55 if ((rv
> 0) && fflush_unlocked(&f
)) {
64 libc_hidden_def(vdprintf
)