netinet/in.h: add IPPROTO_MH
[uclibc-ng.git] / libc / stdio / puts.c
blob67775ff7ccef118dceb18185a35c6cca64a4cfad
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"
11 int puts(register const char * __restrict s)
13 register FILE *stream = stdout; /* This helps bcc optimize. */
14 int n;
15 __STDIO_AUTO_THREADLOCK_VAR;
17 __STDIO_AUTO_THREADLOCK(stream);
19 /* Note: Don't try to optimize by switching to FBF until the newline.
20 * If the string itself contained a newline a write error occurred,
21 * then we could have a newline in the buffer of an LBF stream. */
23 /* Note: Nonportable as fputs need only return nonnegative on success. */
24 if ((n = fputs_unlocked(s, stream)) != EOF) {
25 ++n;
26 if (__fputc_unlocked('\n', stream) == EOF) {
27 n = EOF;
31 __STDIO_AUTO_THREADUNLOCK(stream);
33 return n;