OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / sh / pread_write.c
1 /* vi: set sw=4 ts=4:
2  *
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...
10  *
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.
15  *
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
19  * for more details.
20  *
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
24  */
25
26 #define _GNU_SOURCE
27 #define _LARGEFILE64_SOURCE
28 #include <features.h>
29 #undef __OPTIMIZE__
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
34 #endif
35
36
37 #include <errno.h>
38 #include <sys/types.h>
39 #include <sys/syscall.h>
40 #include <unistd.h>
41 #include <stdint.h>
42
43 #ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
44 # ifdef __NR_pread
45 #  error "__NR_pread and __NR_pread64 both defined???"
46 # endif
47 # define __NR_pread __NR_pread64
48 #endif
49
50 #ifdef __NR_pread
51
52
53 #define __NR___syscall_pread __NR_pread 
54 static inline _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf, 
55                 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
56
57 ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
58
59         return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR((off_t)0,offset)));
60 }
61 strong_alias(__libc_pread,pread)
62
63 #if defined __UCLIBC_HAS_LFS__ 
64 ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
65
66     uint32_t low = offset & 0xffffffff;
67     uint32_t high = offset >> 32;
68         return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
69 }
70 strong_alias(__libc_pread64,pread64)
71 #endif /* __UCLIBC_HAS_LFS__  */
72
73 #endif /* __NR_pread */
74
75 /**********************************************************************/
76
77 #ifdef __NR_pwrite64            /* Newer kernels renamed but it's the same.  */
78 # ifdef __NR_pwrite
79 #  error "__NR_pwrite and __NR_pwrite64 both defined???"
80 # endif
81 # define __NR_pwrite __NR_pwrite64
82 #endif
83
84 #ifdef __NR_pwrite
85
86 #define __NR___syscall_pwrite __NR_pwrite 
87 static inline _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf, 
88                 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
89
90 ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
91
92         return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR((off_t)0,offset)));
93 }
94 strong_alias(__libc_pwrite,pwrite)
95
96 #if defined __UCLIBC_HAS_LFS__ 
97 ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
98
99     uint32_t low = offset & 0xffffffff;
100     uint32_t high = offset >> 32;
101         return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
102 }
103 strong_alias(__libc_pwrite64,pwrite64)
104 #endif /* __UCLIBC_HAS_LFS__  */
105
106 #endif /* __NR_pwrite */