3 * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
4 * Based in part on the files
5 * ./sysdeps/unix/sysv/linux/pwrite.c,
6 * ./sysdeps/unix/sysv/linux/pread.c,
7 * sysdeps/posix/pread.c
8 * sysdeps/posix/pwrite.c
9 * from GNU libc 2.2.5, but reworked considerably...
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU Library General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
21 * You should have received a copy of the GNU Library General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #define _LARGEFILE64_SOURCE
30 /* We absolutely do _NOT_ want interfaces silently
31 * * * renamed under us or very bad things will happen... */
32 #ifdef __USE_FILE_OFFSET64
33 # undef __USE_FILE_OFFSET64
38 #include <sys/types.h>
39 #include <sys/syscall.h>
43 #ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
45 # error "__NR_pread and __NR_pread64 both defined???"
47 # define __NR_pread __NR_pread64
53 _syscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset);
55 #define __NR___syscall_pread __NR_pread
56 static inline _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
57 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
59 ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
61 return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
63 strong_alias(__libc_pread,pread)
65 #if defined __UCLIBC_HAS_LFS__
66 ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
68 uint32_t low = offset & 0xffffffff;
69 uint32_t high = offset >> 32;
70 return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
72 strong_alias(__libc_pread64,pread64)
73 #endif /* __UCLIBC_HAS_LFS__ */
74 #endif /* !__mips64 */
76 #endif /* __NR_pread */
78 /**********************************************************************/
80 #ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
82 # error "__NR_pwrite and __NR_pwrite64 both defined???"
84 # define __NR_pwrite __NR_pwrite64
90 _syscall4(ssize_t, pwrite, int, fd, const void *, buf, size_t, count, off_t, offset);
92 #define __NR___syscall_pwrite __NR_pwrite
93 static inline _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
94 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
96 ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
98 return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
100 strong_alias(__libc_pwrite,pwrite)
102 #if defined __UCLIBC_HAS_LFS__
103 ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
105 uint32_t low = offset & 0xffffffff;
106 uint32_t high = offset >> 32;
107 return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
109 strong_alias(__libc_pwrite64,pwrite64)
110 #endif /* __UCLIBC_HAS_LFS__ */
111 #endif /* !__mips64 */
112 #endif /* __NR_pwrite */