|
|
#include <errno.h> | #include <errno.h> |
#include <unistd.h> | #include <unistd.h> |
| |
#if defined(__GNUC__) || defined(HAS_LONG_LONG) |
#if defined(__GNUC__) |
typedef long long llse_loff_t; | typedef long long llse_loff_t; |
#else | #else |
typedef long llse_loff_t; | typedef long llse_loff_t; |
|
|
| |
#ifdef __linux__ | #ifdef __linux__ |
| |
#ifdef HAVE_LLSEEK |
|
#include <syscall.h> |
|
|
|
#else /* HAVE_LLSEEK */ |
|
|
|
#if defined(__alpha__) || defined(__ia64__) || defined(__s390x__) | #if defined(__alpha__) || defined(__ia64__) || defined(__s390x__) |
| |
#define my_llseek lseek | #define my_llseek lseek |
| |
#else | #else |
#include <linux/unistd.h> /* for __NR__llseek */ |
|
|
|
static int _llseek (unsigned int, unsigned long, |
|
unsigned long, llse_loff_t *, unsigned int); |
|
|
|
#ifdef __NR__llseek |
|
|
|
static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high, |
|
unsigned long, offset_low,llse_loff_t *,result, |
|
unsigned int, origin) |
|
|
|
#else |
|
|
|
/* no __NR__llseek on compilation machine - might give it explicitly */ |
|
static int _llseek (unsigned int fd, unsigned long oh, |
|
unsigned long ol, llse_loff_t *result, |
|
unsigned int origin) { |
|
errno = ENOSYS; |
|
return -1; |
|
} |
|
|
|
#endif |
|
| |
static llse_loff_t my_llseek (unsigned int fd, llse_loff_t offset, |
#define my_llseek lseek64 |
unsigned int origin) |
|
{ |
|
llse_loff_t result; |
|
int retval; |
|
|
|
retval = _llseek (fd, ((unsigned long long) offset) >> 32, |
|
((unsigned long long) offset) & 0xffffffff, |
|
&result, origin); |
|
return (retval == -1 ? (llse_loff_t) retval : result); |
|
} |
|
| |
#endif /* __alpha__ */ |
#endif /* alpha, ia64, s390x */ |
| |
#endif /* HAVE_LLSEEK */ |
|
| |
llse_loff_t llse_llseek (unsigned int fd, llse_loff_t offset, | llse_loff_t llse_llseek (unsigned int fd, llse_loff_t offset, |
unsigned int origin) | unsigned int origin) |