blob: b3ede687189ae51c61f0c20404afe32f7581341a [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* 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
11
12/* Note: The standard says fputs returns a nonnegative number on
13 * success. In this implementation, we return the length of the
14 * string written on success.
15 */
16
17#ifdef __DO_UNLOCKED
18
19int fputs_unlocked(register const char * __restrict s,
20 FILE * __restrict stream)
21{
22 size_t n = strlen(s);
23
24 return ((fwrite_unlocked(s, 1, n, stream) == n) ? n : EOF);
25}
26libc_hidden_def(fputs_unlocked)
27
28#ifndef __UCLIBC_HAS_THREADS__
29strong_alias(fputs_unlocked,fputs)
30libc_hidden_def(fputs)
31#endif
32
33#elif defined __UCLIBC_HAS_THREADS__
34
35int fputs(const char * __restrict s, register FILE * __restrict stream)
36{
37 int retval;
38 __STDIO_AUTO_THREADLOCK_VAR;
39
40 __STDIO_AUTO_THREADLOCK(stream);
41
42 retval = fputs_unlocked(s, stream);
43
44 __STDIO_AUTO_THREADUNLOCK(stream);
45
46 return retval;
47}
48libc_hidden_def(fputs)
49
50#endif