]>
Commit | Line | Data |
---|---|---|
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 | 18 | |
cd682e15 | 19 | #include <assert.h> |
d71b808a | 20 | #include <errno.h> |
741845cb | 21 | #include <endian.h> |
af6f3906 | 22 | #include <unistd.h> |
0dee6738 | 23 | |
6ee8d334 | 24 | #include <sysdep-cancel.h> |
36ecfe56 UD |
25 | #include <sys/syscall.h> |
26 | ||
4b172769 RM |
27 | #ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */ |
28 | # ifdef __NR_pwrite | |
29 | # error "__NR_pwrite and __NR_pwrite64 both defined???" | |
30 | # endif | |
0f0d786f | 31 | # define __NR_pwrite __NR_pwrite64 |
4b172769 RM |
32 | #endif |
33 | ||
d71b808a | 34 | |
6ee8d334 | 35 | static ssize_t |
ce6e047f UD |
36 | #ifdef NO_CANCELLATION |
37 | inline __attribute ((always_inline)) | |
38 | #endif | |
6ee8d334 | 39 | do_pwrite (int fd, const void *buf, size_t count, off_t offset) |
af6f3906 | 40 | { |
d71b808a UD |
41 | ssize_t result; |
42 | ||
cd682e15 | 43 | assert (sizeof (offset) == 4); |
a2da1673 | 44 | result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, |
cd682e15 | 45 | __LONG_LONG_PAIR (offset >> 31, offset)); |
d71b808a UD |
46 | |
47 | return result; | |
af6f3906 UD |
48 | } |
49 | ||
6ee8d334 UD |
50 | |
51 | ssize_t | |
14bb4e57 | 52 | __libc_pwrite (int fd, const void *buf, size_t count, off_t offset) |
6ee8d334 UD |
53 | { |
54 | if (SINGLE_THREAD_P) | |
55 | return do_pwrite (fd, buf, count, offset); | |
56 | ||
57 | int oldtype = LIBC_CANCEL_ASYNC (); | |
58 | ||
59 | ssize_t result = do_pwrite (fd, buf, count, offset); | |
60 | ||
61 | LIBC_CANCEL_RESET (oldtype); | |
62 | ||
63 | return result; | |
64 | } | |
65 | ||
778c59c8 UD |
66 | strong_alias (__libc_pwrite, __pwrite) |
67 | weak_alias (__libc_pwrite, pwrite) |