OSDN Git Service

r288@cf-ppc-macosx: monabuilder | 2008-12-07 13:17:34 +0900
[pf3gnuchains/pf3gnuchains3x.git] / newlib / libc / sys / linux / io64.c
1 /* libc/sys/linux/io64.c - large file input/output system calls */
2
3 /* Copyright 2002, Red Hat Inc. */
4
5
6 #define __KERNEL_PROTOTYPES
7
8 #include <stdarg.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <sys/types.h>
12 #include <sys/uio.h>
13 #include <sys/stat.h>
14 #include <sys/ioctl.h>
15 #include <machine/syscall.h>
16
17 #define __NR___truncate64 __NR_truncate64
18 #define __NR___ftruncate64 __NR_ftruncate64
19
20 _syscall2(int,fstat64,int,fd,struct stat64 *,st)
21 _syscall2(int,lstat64,const char *,name,struct stat64 *,st)
22 _syscall2(int,stat64,const char *,name,struct stat64 *,st)
23
24 static _syscall3(int,__truncate64,const char *,name,int,high,int,low)
25
26 int __libc_truncate64(const char *name, off64_t length)
27 {
28   return __truncate64(name,(length >> 32), (length & 0xffffffff));
29 }
30 weak_alias(__libc_truncate64,truncate64)
31
32 static _syscall3(int,__ftruncate64,int,fd,int,high,int,low);
33
34 int __libc_ftruncate64(int fd, off64_t length)
35 {
36   return __ftruncate64(fd,(length >> 32),(length & 0xffffffff));
37 }
38 weak_alias(__libc_ftruncate64,ftruncate64)
39
40 static _syscall5(void,_llseek,int,fd,off_t,hi,off_t,lo,loff_t *,pos,int,whence)
41
42 loff_t __libc_lseek64(int fd, loff_t offset, int whence)
43 {
44   loff_t pos;
45   __libc__llseek(fd, offset >> 32, offset & 0xffffffff, &pos, whence);
46   return pos;
47 }
48 weak_alias(__libc_lseek64,lseek64);
49 weak_alias(__libc_lseek64,_lseek64);
50
51 int __libc_open64(const char *path, int oflag, ...)
52 {
53    mode_t mode = 0;
54    if (oflag & O_CREAT)
55      {
56        va_list list;
57        va_start(list, oflag);
58        mode = va_arg(list, int);
59        va_end(list);
60      }
61    return __libc_open(path, oflag | O_LARGEFILE, mode);
62 }
63 weak_alias(__libc_open64,open64);
64 weak_alias(__libc_open64,_open64);
65 weak_alias(__libc_open64,__open64);
66 weak_alias(__libc_fstat64,_fstat64);
67 weak_alias(__libc_stat64,_stat64);
68
69