* Implement freopen64, fsetpos64 and fseeko64 for OpenSolaris.
This commit is contained in:
parent
66717397fa
commit
36726dcced
@ -38,7 +38,7 @@ AC_SUBST(DLL_LDFLAGS)
|
||||
AC_CHECK_HEADERS(windows.h winsock2.h io.h process.h unistd.h inttypes.h stdint.h getopt.h libc.h malloc.h dlfcn.h regex.h sys/cdefs.h sys/socket.h netinet/in.h arpa/inet.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h sys/time.h endian.h)
|
||||
|
||||
AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
|
||||
AC_CHECK_FUNCS(open64 __open64 lseek64 __lseek64 mmap64 fopen64 __fopen64 __freopen64 dup dup2 fseeko __fseeko64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf map_fd memalign posix_memalign aio_read accept bind connect socket readv pread recv recvfrom recvmsg mmap valloc sigaction getpagesize getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked)
|
||||
AC_CHECK_FUNCS(open64 __open64 lseek64 __lseek64 mmap64 fopen64 __fopen64 freopen64 __freopen64 dup dup2 fseeko fseeko64 __fseeko64 fsetpos64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf map_fd memalign posix_memalign aio_read accept bind connect socket readv pread recv recvfrom recvmsg mmap valloc sigaction getpagesize getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked)
|
||||
|
||||
AC_CHECK_TYPES(sighandler_t, [], [],
|
||||
[#define _GNU_SOURCE
|
||||
|
||||
@ -108,6 +108,9 @@ Required on Mac OS X:
|
||||
Required on HP-UX:
|
||||
\fB__open64\fR(), \fB__lseek64\fR(), \fB__filbuf\fR()
|
||||
.TP
|
||||
Required on OpenSolaris:
|
||||
\fBfreopen64\fR(), \fBfseeko64\fR(), \fBfsetpos64\fR()
|
||||
.TP
|
||||
Signal handling:
|
||||
\fBsignal\fR(), \fBsigaction\fR()
|
||||
.PP
|
||||
|
||||
@ -62,6 +62,10 @@ static FILE * (*ORIG(__fopen64))(const char *path, const char *mode);
|
||||
#endif
|
||||
static FILE * (*ORIG(freopen)) (const char *path, const char *mode,
|
||||
FILE *stream);
|
||||
#if defined HAVE_FREOPEN64
|
||||
static FILE * (*ORIG(freopen64))(const char *path, const char *mode,
|
||||
FILE *stream);
|
||||
#endif
|
||||
#if defined HAVE___FREOPEN64
|
||||
static FILE * (*ORIG(__freopen64)) (const char *path, const char *mode,
|
||||
FILE *stream);
|
||||
@ -70,9 +74,15 @@ static int (*ORIG(fseek)) (FILE *stream, long offset, int whence);
|
||||
#if defined HAVE_FSEEKO
|
||||
static int (*ORIG(fseeko)) (FILE *stream, off_t offset, int whence);
|
||||
#endif
|
||||
#if defined HAVE_FSEEKO64
|
||||
static int (*ORIG(fseeko64)) (FILE *stream, off_t offset, int whence);
|
||||
#endif
|
||||
#if defined HAVE___FSEEKO64
|
||||
static int (*ORIG(__fseeko64)) (FILE *stream, off_t offset, int whence);
|
||||
#endif
|
||||
#if defined HAVE_FSETPOS64
|
||||
static int (*ORIG(fsetpos64))(FILE *stream, const fpos64_t *pos);
|
||||
#endif
|
||||
#if defined HAVE___FSETPOS64
|
||||
static int (*ORIG(__fsetpos64)) (FILE *stream, const fpos64_t *pos);
|
||||
#endif
|
||||
@ -205,6 +215,13 @@ FILE *NEW(freopen)(const char *path, const char *mode, FILE *stream)
|
||||
FILE *ret; FREOPEN(freopen); return ret;
|
||||
}
|
||||
|
||||
#if defined HAVE_FREOPEN64
|
||||
FILE *NEW(freopen64)(const char *path, const char *mode, FILE *stream)
|
||||
{
|
||||
FILE *ret; FREOPEN(freopen64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___FREOPEN64
|
||||
FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream)
|
||||
{
|
||||
@ -262,6 +279,13 @@ int NEW(fseeko)(FILE *stream, off_t offset, int whence)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE_FSEEKO64
|
||||
int NEW(fseeko64)(FILE *stream, off64_t offset, int whence)
|
||||
{
|
||||
int ret; FSEEK(fseeko64, ftello); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___FSEEKO64
|
||||
int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence)
|
||||
{
|
||||
@ -269,24 +293,35 @@ int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FSETPOS(fn) \
|
||||
do \
|
||||
{ \
|
||||
int fd; \
|
||||
LOADSYM(fn); \
|
||||
fd = fileno(stream); \
|
||||
if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \
|
||||
return ORIG(fn)(stream, pos); \
|
||||
_zz_lock(fd); \
|
||||
ret = ORIG(fn)(stream, pos); \
|
||||
_zz_unlock(fd); \
|
||||
debug("%s([%i], %lli) = %i", __func__, \
|
||||
fd, (long long int)*pos, ret); \
|
||||
/* On HP-UX at least, fpos64_t == int64_t */ \
|
||||
_zz_setpos(fd, (int64_t)*pos); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#if defined HAVE_FSETPOS64
|
||||
int NEW(fsetpos64)(FILE *stream, const fpos64_t *pos)
|
||||
{
|
||||
int ret; FSETPOS(fsetpos64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___FSETPOS64
|
||||
int NEW(__fsetpos64)(FILE *stream, const fpos64_t *pos)
|
||||
{
|
||||
int ret, fd;
|
||||
|
||||
LOADSYM(__fsetpos64);
|
||||
fd = fileno(stream);
|
||||
if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd))
|
||||
return ORIG(__fsetpos64)(stream, pos);
|
||||
_zz_lock(fd);
|
||||
ret = ORIG(__fsetpos64)(stream, pos);
|
||||
_zz_unlock(fd);
|
||||
debug("%s([%i], %lli) = %i", __func__,
|
||||
fd, (long long int)*pos, ret);
|
||||
/* On HP-UX at least, fpos64_t == int64_t */
|
||||
_zz_setpos(fd, (int64_t)*pos);
|
||||
|
||||
return ret;
|
||||
int ret; FSETPOS(__fsetpos64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user