OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [unix/] [pwrite.c] - Diff between revs 207 and 345

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

Rev 207 Rev 345
#ifndef _NO_PWRITE
#ifndef _NO_PWRITE
/*
/*
FUNCTION
FUNCTION
<<pwrite>>---write a file from specified position
<<pwrite>>---write a file from specified position
 
 
INDEX
INDEX
        pwrite
        pwrite
INDEX
INDEX
        _pwrite_r
        _pwrite_r
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <unistd.h>
        #include <unistd.h>
        ssize_t pwrite(int <[fd]>, const void *<[buf]>,
        ssize_t pwrite(int <[fd]>, const void *<[buf]>,
                       size_t <[n]>, off_t <[off]>);
                       size_t <[n]>, off_t <[off]>);
        ssize_t _pwrite_r(struct _reent *<[rptr]>, int <[fd]>,
        ssize_t _pwrite_r(struct _reent *<[rptr]>, int <[fd]>,
                          const void *<[buf]>, size_t <[n]>, off_t <[off]>);
                          const void *<[buf]>, size_t <[n]>, off_t <[off]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <unistd.h>
        #include <unistd.h>
        ssize_t pwrite(<[fd]>, <[buf]>, <[n]>, <[off]>)
        ssize_t pwrite(<[fd]>, <[buf]>, <[n]>, <[off]>)
        int <[fd]>;
        int <[fd]>;
        const void *<[buf]>;
        const void *<[buf]>;
        size_t <[n]>;
        size_t <[n]>;
        off_t <[off]>;
        off_t <[off]>;
 
 
        ssize_t _pwrite_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>)
        ssize_t _pwrite_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>)
        struct _reent *<[rptr]>;
        struct _reent *<[rptr]>;
        int <[fd]>;
        int <[fd]>;
        const void *<[buf]>;
        const void *<[buf]>;
        size_t <[n]>;
        size_t <[n]>;
        off_t <[off]>;
        off_t <[off]>;
 
 
DESCRIPTION
DESCRIPTION
The <<pwrite>> function is similar to <<write>>.  One difference is that
The <<pwrite>> function is similar to <<write>>.  One difference is that
<<pwrite>> has an additional parameter <[off]> which is the offset to
<<pwrite>> has an additional parameter <[off]> which is the offset to
position in the file before writing.  The function also differs in that
position in the file before writing.  The function also differs in that
the file position is unchanged by the function (i.e. the file position
the file position is unchanged by the function (i.e. the file position
is the same before and after a call to <<pwrite>>).
is the same before and after a call to <<pwrite>>).
 
 
The <<_pwrite_r>> function is the same as <<pwrite>>, only a reentrant
The <<_pwrite_r>> function is the same as <<pwrite>>, only a reentrant
struct pointer <[rptr]> is provided to preserve reentrancy.
struct pointer <[rptr]> is provided to preserve reentrancy.
 
 
RETURNS
RETURNS
<<pwrite>> returns the number of bytes written or <<-1>> if failure occurred.
<<pwrite>> returns the number of bytes written or <<-1>> if failure occurred.
 
 
PORTABILITY
PORTABILITY
<<pwrite>> is non-ANSI and is specified by the Single Unix Specification.
<<pwrite>> is non-ANSI and is specified by the Single Unix Specification.
 
 
Supporting OS subroutine required: <<write>>, <<lseek>>.
Supporting OS subroutine required: <<write>>, <<lseek>>.
*/
*/
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <unistd.h>
#include <unistd.h>
#include <reent.h>
#include <reent.h>
 
 
ssize_t
ssize_t
_DEFUN (_pwrite_r, (rptr, fd, buf, n, off),
_DEFUN (_pwrite_r, (rptr, fd, buf, n, off),
     struct _reent *rptr _AND
     struct _reent *rptr _AND
     int fd _AND
     int fd _AND
     _CONST _PTR buf _AND
     _CONST _PTR buf _AND
     size_t n _AND
     size_t n _AND
     off_t off)
     off_t off)
{
{
  off_t cur_pos;
  off_t cur_pos;
  _READ_WRITE_RETURN_TYPE num_written;
  _READ_WRITE_RETURN_TYPE num_written;
 
 
  if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1)
  if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1)
    return -1;
    return -1;
 
 
  if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1)
  if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1)
    return -1;
    return -1;
 
 
  num_written = _write_r (rptr, fd, buf, n);
  num_written = _write_r (rptr, fd, buf, n);
 
 
  if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
  if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
    return -1;
    return -1;
 
 
  return (ssize_t)num_written;
  return (ssize_t)num_written;
}
}
 
 
#ifndef _REENT_ONLY
#ifndef _REENT_ONLY
 
 
ssize_t
ssize_t
_DEFUN (pwrite, (fd, buf, n, off),
_DEFUN (pwrite, (fd, buf, n, off),
     int fd _AND
     int fd _AND
     _CONST _PTR buf _AND
     _CONST _PTR buf _AND
     size_t n _AND
     size_t n _AND
     off_t off)
     off_t off)
{
{
  return _pwrite_r (_REENT, fd, buf, n, off);
  return _pwrite_r (_REENT, fd, buf, n, off);
}
}
 
 
#endif /* !_REENT_ONLY  */
#endif /* !_REENT_ONLY  */
#endif /* !_NO_PWRITE  */
#endif /* !_NO_PWRITE  */
 
 

powered by: WebSVN 2.1.0

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