OSDN Git Service

make DODEBUG=y happy, update sysdeps/common/* copyright
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / mips / pread_write.c
1 /* vi: set sw=4 ts=4:
2  *
3  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7 /* Based in part on the files
8  *              ./sysdeps/unix/sysv/linux/pwrite.c,
9  *              ./sysdeps/unix/sysv/linux/pread.c, 
10  *              sysdeps/posix/pread.c
11  *              sysdeps/posix/pwrite.c
12  * from GNU libc 2.2.5, but reworked considerably...
13  */
14
15 #define _GNU_SOURCE
16 #define _LARGEFILE64_SOURCE
17 #include <features.h>
18 #undef __OPTIMIZE__
19 /* We absolutely do _NOT_ want interfaces silently
20  *  *  * renamed under us or very bad things will happen... */
21 #ifdef __USE_FILE_OFFSET64
22 # undef __USE_FILE_OFFSET64
23 #endif
24
25
26 #include <errno.h>
27 #include <sys/types.h>
28 #include <sys/syscall.h>
29 #include <unistd.h>
30 #include <stdint.h>
31
32 #ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
33 # ifdef __NR_pread
34 #  error "__NR_pread and __NR_pread64 both defined???"
35 # endif
36 # define __NR_pread __NR_pread64
37 #endif
38
39 #ifdef __NR_pread
40
41 #ifdef __mips64
42 _syscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset);
43 #else /* !__mips64 */
44 #define __NR___syscall_pread __NR_pread 
45 static inline _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf, 
46                 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
47
48 ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
49
50         return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
51 }
52 strong_alias(__libc_pread,pread)
53
54 #if defined __UCLIBC_HAS_LFS__ 
55 ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
56
57     uint32_t low = offset & 0xffffffff;
58     uint32_t high = offset >> 32;
59         return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
60 }
61 strong_alias(__libc_pread64,pread64)
62 #endif /* __UCLIBC_HAS_LFS__  */
63 #endif /* !__mips64 */
64
65 #endif /* __NR_pread */
66
67 /**********************************************************************/
68
69 #ifdef __NR_pwrite64            /* Newer kernels renamed but it's the same.  */
70 # ifdef __NR_pwrite
71 #  error "__NR_pwrite and __NR_pwrite64 both defined???"
72 # endif
73 # define __NR_pwrite __NR_pwrite64
74 #endif
75
76 #ifdef __NR_pwrite
77
78 #ifdef __mips64
79 _syscall4(ssize_t, pwrite, int, fd, const void *, buf, size_t, count, off_t, offset);
80 #else /* !__mips64 */
81 #define __NR___syscall_pwrite __NR_pwrite 
82 static inline _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf, 
83                 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
84
85 ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
86
87         return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
88 }
89 strong_alias(__libc_pwrite,pwrite)
90
91 #if defined __UCLIBC_HAS_LFS__ 
92 ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
93
94     uint32_t low = offset & 0xffffffff;
95     uint32_t high = offset >> 32;
96         return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
97 }
98 strong_alias(__libc_pwrite64,pwrite64)
99 #endif /* __UCLIBC_HAS_LFS__  */
100 #endif /* !__mips64 */
101 #endif /* __NR_pwrite */