2 * llseek.c -- stub calling the llseek system call
4 * Copyright (C) 1994 Remy Card. This file may be redistributed
5 * under the terms of the GNU Public License.
12 #if defined(__GNUC__) || defined(HAS_LONG_LONG)
13 typedef long long ext2_loff_t;
15 typedef long ext2_loff_t;
18 extern ext2_loff_t ext2_llseek (unsigned int, ext2_loff_t, unsigned int);
25 #define my_llseek _llseek
27 #else /* HAVE_LLSEEK */
29 #if defined(__alpha__) || defined(__ia64__)
31 #define my_llseek lseek
34 #include <linux/unistd.h> /* for __NR__llseek */
38 static int _llseek (unsigned int fd, unsigned long oh,
39 unsigned long ol, ext2_loff_t *result,
42 return syscall (__NR__llseek, fd, oh, ol, result, origin);
47 /* no __NR__llseek on compilation machine - might give it explicitly */
48 static int _llseek (unsigned int fd, unsigned long oh,
49 unsigned long ol, long long *result,
50 unsigned int origin) {
57 static ext2_loff_t my_llseek (unsigned int fd, ext2_loff_t offset,
63 retval = _llseek (fd, ((unsigned long long) offset) >> 32,
64 ((unsigned long long) offset) & 0xffffffff,
66 return (retval == -1 ? (ext2_loff_t) retval : result);
69 #endif /* __alpha__ */
71 #endif /* HAVE_LLSEEK */
73 ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset,
77 static int do_compat = 0;
80 result = my_llseek (fd, offset, origin);
81 if (!(result == -1 && errno == ENOSYS))
85 * Just in case this code runs on top of an old kernel
86 * which does not support the llseek system call
90 * Now try ordinary lseek.
94 if ((sizeof(off_t) >= sizeof(ext2_loff_t)) ||
95 (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1))))
96 return lseek(fd, (off_t) offset, origin);
104 ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset,
107 if ((sizeof(off_t) < sizeof(ext2_loff_t)) &&
108 (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) {
112 return lseek (fd, (off_t) offset, origin);