]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/pwritev.c
* sysdeps/unix/sysv/linux/preadv.c: Avoid prototype for static
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / pwritev.c
CommitLineData
e109c612
UD
1/* Copyright (C) 2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19#include <errno.h>
20#include <stddef.h>
21#include <sys/param.h>
22#if __WORDSIZE == 64 && !defined PWRITEV
23/* Hide the pwritev64 declaration. */
24# define pwritev64 __redirect_pwritev64
25#endif
26#include <sys/uio.h>
27
28#include <sysdep-cancel.h>
29#include <sys/syscall.h>
30#include <kernel-features.h>
31
32#ifndef PWRITEV
33# define PWRITEV pwritev
34# define PWRITEV_REPLACEMENT __atomic_pwritev_replacement
35# define PWRITE __pwrite
36# define OFF_T off_t
37#endif
38
f9fe75e9 39#ifndef __ASSUME_PWRITEV
e109c612
UD
40static ssize_t PWRITEV_REPLACEMENT (int, __const struct iovec *,
41 int, OFF_T) internal_function;
f9fe75e9 42#endif
e109c612
UD
43
44
45ssize_t
46PWRITEV (fd, vector, count, offset)
47 int fd;
48 const struct iovec *vector;
49 int count;
50 OFF_T offset;
51{
52#ifdef __NR_pwritev
53 ssize_t result;
54
55 if (SINGLE_THREAD_P)
56 result = INLINE_SYSCALL (pwritev, 5, fd, vector, count, offset >> 32,
57 offset & 0xffffffff);
58 else
59 {
60 int oldtype = LIBC_CANCEL_ASYNC ();
61
62 result = INLINE_SYSCALL (pwritev, 5, fd, vector, count, offset >> 32,
63 offset & 0xffffffff);
64
65 LIBC_CANCEL_RESET (oldtype);
66 }
67# ifdef __ASSUME_PWRITEV
68 return result;
69# endif
70#endif
71
72#ifndef __ASSUME_PWRITEV
73# ifdef __NR_pwritev
74 if (result >= 0 || errno != ENOSYS)
75 return result;
76# endif
77
78 return PWRITEV_REPLACEMENT (fd, vector, count, offset);
79#endif
80}
81#if __WORDSIZE == 64 && defined pwritev64
82# undef pwritev64
83strong_alias (pwritev, pwritev64)
84#endif
85
86#ifndef __ASSUME_PWRITEV
87# undef PWRITEV
88# define PWRITEV static internal_function PWRITEV_REPLACEMENT
89# include <sysdeps/posix/pwritev.c>
90#endif