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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [pread64.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
FUNCTION
3
<<pread64>>---read a large file from specified position
4
 
5
INDEX
6
        pread64
7
 
8
ANSI_SYNOPSIS
9
        #include <unistd.h>
10
        ssize_t pread64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <unistd.h>
14
        ssize_t pread64(<[fd]>, <[buf]>, <[n]>, <[off]>)
15
        int <[fd]>;
16
        void *<[buf]>;
17
        size_t <[n]>;
18
        loff_t <[off]>;
19
 
20
DESCRIPTION
21
The <<pread64>> function is similar to <<pread>>.  The only difference is
22
that it operates on large files and so takes a 64-bit offset.  Like <<pread>>>,
23
the file position is unchanged by the function (i.e. the file position
24
is the same before and after a call to <<pread>>).
25
 
26
RETURNS
27
<<pread64>> returns the number of bytes read or <<-1>> if failure occurred.
28
 
29
PORTABILITY
30
<<pread64>> is an EL/IX extension.
31
 
32
Supporting OS subroutine required: <<read>>, <<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_pread64, (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_read;
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_read = read (fd, buf, n);
57
 
58
  if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1)
59
    return -1;
60
 
61
  return (ssize_t)num_read;
62
}
63
weak_alias(__libc_pread64,pread64);
64
weak_alias(__libc_pread64,__pread64);
65
 

powered by: WebSVN 2.1.0

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