]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/pread64.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / pread64.c
CommitLineData
b168057a 1/* Copyright (C) 1997-2015 Free Software Foundation, Inc.
af6f3906
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
af6f3906
UD
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
af6f3906 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
af6f3906
UD
18
19#include <errno.h>
088b9917 20#include <endian.h>
af6f3906 21#include <unistd.h>
0dee6738 22
6ee8d334 23#include <sysdep-cancel.h>
36ecfe56
UD
24#include <sys/syscall.h>
25
4b172769
RM
26#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
27# ifdef __NR_pread
28# error "__NR_pread and __NR_pread64 both defined???"
29# endif
30# define __NR_pread __NR_pread64
31#endif
32
af6f3906 33
6ee8d334
UD
34static ssize_t
35do_pread64 (int fd, void *buf, size_t count, off64_t offset)
af6f3906
UD
36{
37 ssize_t result;
38
a2da1673 39 result = INLINE_SYSCALL (pread, 5, fd, buf, count,
ca1cde9e
GM
40 __LONG_LONG_PAIR ((off_t) (offset >> 32),
41 (off_t) (offset & 0xffffffff)));
af6f3906
UD
42
43 return result;
44}
45
6ee8d334
UD
46
47ssize_t
48__libc_pread64 (fd, buf, count, offset)
49 int fd;
50 void *buf;
51 size_t count;
52 off64_t offset;
53{
54 if (SINGLE_THREAD_P)
55 return do_pread64 (fd, buf, count, offset);
56
57 int oldtype = LIBC_CANCEL_ASYNC ();
58
59 ssize_t result = do_pread64 (fd, buf, count, offset);
60
61 LIBC_CANCEL_RESET (oldtype);
62
63 return result;
64}
65
a96206f4 66weak_alias (__libc_pread64, __pread64)
778c59c8 67weak_alias (__libc_pread64, pread64)