fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / stdio / puts.c
blobe270199d21fa94759ec61a50d8df94a0bd363758
1 /*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 FUNCTION
20 <<puts>>---write a character string
22 INDEX
23 puts
24 INDEX
25 _puts_r
27 ANSI_SYNOPSIS
28 #include <stdio.h>
29 int puts(const char *<[s]>);
31 int _puts_r(void *<[reent]>, const char *<[s]>);
33 TRAD_SYNOPSIS
34 #include <stdio.h>
35 int puts(<[s]>)
36 char *<[s]>;
38 int _puts_r(<[reent]>, <[s]>)
39 char *<[reent]>;
40 char *<[s]>;
42 DESCRIPTION
43 <<puts>> writes the string at <[s]> (followed by a newline, instead of
44 the trailing null) to the standard output stream.
46 The alternate function <<_puts_r>> is a reentrant version. The extra
47 argument <[reent]> is a pointer to a reentrancy structure.
49 RETURNS
50 If successful, the result is a nonnegative integer; otherwise, the
51 result is <<EOF>>.
53 PORTABILITY
54 ANSI C requires <<puts>>, but does not specify that the result on
55 success must be <<0>>; any non-negative value is permitted.
57 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
58 <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */
60 #if defined(LIBC_SCCS) && !defined(lint)
61 static char sccsid[] = "%W% (Berkeley) %G%";
62 #endif /* LIBC_SCCS and not lint */
64 #include <stdio.h>
65 #include <string.h>
67 #include "fvwrite.h"
68 #include "local.h"
71 * Write the given string to stdout, appending a newline.
74 int
75 _DEFUN (_puts_r, (ptr, s),
76 struct _reent *ptr _AND
77 _CONST char * s)
79 size_t c = strlen (s);
80 struct __suio uio;
81 struct __siov iov[2];
83 iov[0].iov_base = s;
84 iov[0].iov_len = c;
85 iov[1].iov_base = "\n";
86 iov[1].iov_len = 1;
87 uio.uio_resid = c + 1;
88 uio.uio_iov = &iov[0];
89 uio.uio_iovcnt = 2;
91 _REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
92 return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n');
95 #ifndef _REENT_ONLY
97 int
98 _DEFUN (puts, (s),
99 char _CONST * s)
101 return _puts_r (_REENT, s);
104 #endif