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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [pwrite64.c] - Blame information for rev 438

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
<<pwrite64>>---write a large file from specified position
4
 
5
INDEX
6
        pwrite64
7
 
8
ANSI_SYNOPSIS
9
        #include <unistd.h>
10
        ssize_t pwrite64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <unistd.h>
14
        ssize_t pwrite64(<[fd]>, <[buf]>, <[n]>, <[off]>)
15
        int <[fd]>;
16
        void *<[buf]>;
17
        size_t <[n]>;
18
        loff_t <[off]>;
19
 
20
DESCRIPTION
21
The <<pwrite64>> function is similar to <<pwrite>>.  The only difference is
22
that it operates on large files and so takes a 64-bit offset.  Like <<pwrite>>>,
23
the file position is unchanged by the function (i.e. the file position
24
is the same before and after a call to <<pwrite>>).
25
 
26
RETURNS
27
<<pwrite64>> returns the number of bytes written or <<-1>> if failure occurred.
28
 
29
PORTABILITY
30
<<pwrite64>> is an EL/IX extension.
31
 
32
Supporting OS subroutine required: <<write>>, <<lseek64>>.
33
*/
34
 
35
#include <_ansi.h>
36
#include <unistd.h>
37
#include <reent.h>
38
#include <machine/weakalias.h>
39
 
40
ssize_t
41
_DEFUN (__libc_pwrite64, (fd, buf, n, off),
42
     int fd _AND
43
     _PTR buf _AND
44
     size_t n _AND
45
     loff_t off)
46
{
47
  loff_t cur_pos;
48
  _READ_WRITE_RETURN_TYPE num_written;
49
 
50
  if ((cur_pos = lseek64 (fd, 0, SEEK_CUR)) == (loff_t)-1)
51
    return -1;
52
 
53
  if (lseek64 (fd, off, SEEK_SET) == (loff_t)-1)
54
    return -1;
55
 
56
  num_written = write (fd, buf, n);
57
 
58
  if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1)
59
    return -1;
60
 
61
  return (ssize_t)num_written;
62
}
63
weak_alias(__libc_pwrite64,pwrite64)
64
 

powered by: WebSVN 2.1.0

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