OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc2/] [newlib/] [libc/] [stdio/] [puts.c] - Diff between revs 207 and 520

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 520
/*
/*
 * Copyright (c) 1990 The Regents of the University of California.
 * Copyright (c) 1990 The Regents of the University of California.
 * All rights reserved.
 * All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms are permitted
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * distribution and use acknowledge that the software was developed
 * by the University of California, Berkeley.  The name of the
 * by the University of California, Berkeley.  The name of the
 * University may not be used to endorse or promote products derived
 * University may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 * from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */
 */
 
 
/*
/*
FUNCTION
FUNCTION
<<puts>>---write a character string
<<puts>>---write a character string
 
 
INDEX
INDEX
        puts
        puts
INDEX
INDEX
        _puts_r
        _puts_r
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdio.h>
        #include <stdio.h>
        int puts(const char *<[s]>);
        int puts(const char *<[s]>);
 
 
        int _puts_r(struct _reent *<[reent]>, const char *<[s]>);
        int _puts_r(struct _reent *<[reent]>, const char *<[s]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdio.h>
        #include <stdio.h>
        int puts(<[s]>)
        int puts(<[s]>)
        char *<[s]>;
        char *<[s]>;
 
 
        int _puts_r(<[reent]>, <[s]>)
        int _puts_r(<[reent]>, <[s]>)
        struct _reent *<[reent]>;
        struct _reent *<[reent]>;
        char *<[s]>;
        char *<[s]>;
 
 
DESCRIPTION
DESCRIPTION
<<puts>> writes the string at <[s]> (followed by a newline, instead of
<<puts>> writes the string at <[s]> (followed by a newline, instead of
the trailing null) to the standard output stream.
the trailing null) to the standard output stream.
 
 
The alternate function <<_puts_r>> is a reentrant version.  The extra
The alternate function <<_puts_r>> is a reentrant version.  The extra
argument <[reent]> is a pointer to a reentrancy structure.
argument <[reent]> is a pointer to a reentrancy structure.
 
 
RETURNS
RETURNS
If successful, the result is a nonnegative integer; otherwise, the
If successful, the result is a nonnegative integer; otherwise, the
result is <<EOF>>.
result is <<EOF>>.
 
 
PORTABILITY
PORTABILITY
ANSI C requires <<puts>>, but does not specify that the result on
ANSI C requires <<puts>>, but does not specify that the result on
success must be <<0>>; any non-negative value is permitted.
success must be <<0>>; any non-negative value is permitted.
 
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
*/
 
 
#if defined(LIBC_SCCS) && !defined(lint)
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#endif /* LIBC_SCCS and not lint */
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <reent.h>
#include <reent.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include "fvwrite.h"
#include "fvwrite.h"
#include "local.h"
#include "local.h"
 
 
/*
/*
 * Write the given string to stdout, appending a newline.
 * Write the given string to stdout, appending a newline.
 */
 */
 
 
int
int
_DEFUN(_puts_r, (ptr, s),
_DEFUN(_puts_r, (ptr, s),
       struct _reent *ptr _AND
       struct _reent *ptr _AND
       _CONST char * s)
       _CONST char * s)
{
{
  size_t c = strlen (s);
  size_t c = strlen (s);
  struct __suio uio;
  struct __suio uio;
  struct __siov iov[2];
  struct __siov iov[2];
 
 
  iov[0].iov_base = s;
  iov[0].iov_base = s;
  iov[0].iov_len = c;
  iov[0].iov_len = c;
  iov[1].iov_base = "\n";
  iov[1].iov_base = "\n";
  iov[1].iov_len = 1;
  iov[1].iov_len = 1;
  uio.uio_resid = c + 1;
  uio.uio_resid = c + 1;
  uio.uio_iov = &iov[0];
  uio.uio_iov = &iov[0];
  uio.uio_iovcnt = 2;
  uio.uio_iovcnt = 2;
  _REENT_SMALL_CHECK_INIT (ptr);
  _REENT_SMALL_CHECK_INIT (ptr);
  ORIENT (stdout, -1);
  ORIENT (stdout, -1);
  return (__sfvwrite_r (ptr, _stdout_r (ptr), &uio) ? EOF : '\n');
  return (__sfvwrite_r (ptr, _stdout_r (ptr), &uio) ? EOF : '\n');
}
}
 
 
#ifndef _REENT_ONLY
#ifndef _REENT_ONLY
 
 
int
int
_DEFUN(puts, (s),
_DEFUN(puts, (s),
       char _CONST * s)
       char _CONST * s)
{
{
  return _puts_r (_REENT, s);
  return _puts_r (_REENT, s);
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.