* Implement additional functions required on HP-UX: __fopen64, __fseeko64,
__freopen64, __open64, __lseek64.
This commit is contained in:
parent
b448cd4759
commit
8b1f5bba2c
@ -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 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 lseek64 mmap64 fopen64 dup dup2 fseeko _IO_getc getline getdelim __getdelim fgetln __srefill 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 mmap64 fopen64 __fopen64 __freopen64 dup dup2 fseeko __fseeko64 _IO_getc getline getdelim __getdelim fgetln __srefill 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
|
||||
|
||||
@ -93,18 +93,22 @@ Memory management:
|
||||
\fBmmap\fR(), \fBmunmap\fR(), \fBmalloc\fR(), \fBcalloc\fR(), \fBvalloc\fR(),
|
||||
\fBfree\fR(), \fBmemalign\fR(), \fBposix_memalign\fR()
|
||||
.TP
|
||||
Linux-specific:
|
||||
Required on Linux:
|
||||
\fBopen64\fR(), \fBlseek64\fR(), \fBmmap64\fR(), \fB_IO_getc\fR(),
|
||||
\fBgetline\fR(), \fBgetdelim\fR(), \fB__getdelim\fR(), \fBgetc_unlocked\fR(),
|
||||
\fBgetchar_unlocked\fR(), \fBfgetc_unlocked\fR(), \fBfgets_unlocked\fR(),
|
||||
\fBfread_unlocked\fR()
|
||||
.TP
|
||||
BSD-specific:
|
||||
Required on BSD systems:
|
||||
\fBfgetln\fR(), \fB__srefill\fR()
|
||||
.TP
|
||||
Mac OS X-specific:
|
||||
Required on Mac OS X:
|
||||
\fBmap_fd\fR()
|
||||
.TP
|
||||
Required on HP-UX:
|
||||
\fB__fopen64\fR(), \fB__fseeko64\fR(), \fB__freopen64\fR(), \fB__open64\fR(),
|
||||
\fB__lseek64\fR()
|
||||
.TP
|
||||
Signal handling:
|
||||
\fBsignal\fR(), \fBsigaction\fR()
|
||||
.PP
|
||||
|
||||
24
src/lib-fd.c
24
src/lib-fd.c
@ -83,6 +83,9 @@ static int (*ORIG(open)) (const char *file, int oflag, ...);
|
||||
#if defined HAVE_OPEN64
|
||||
static int (*ORIG(open64)) (const char *file, int oflag, ...);
|
||||
#endif
|
||||
#if defined HAVE___OPEN64
|
||||
static int (*ORIG(__open64))(const char *file, int oflag, ...);
|
||||
#endif
|
||||
#if defined HAVE_DUP
|
||||
static int (*ORIG(dup)) (int oldfd);
|
||||
#endif
|
||||
@ -133,6 +136,9 @@ static off_t (*ORIG(lseek)) (int fd, off_t offset, int whence);
|
||||
#if defined HAVE_LSEEK64
|
||||
static off64_t (*ORIG(lseek64)) (int fd, off64_t offset, int whence);
|
||||
#endif
|
||||
#if defined HAVE___LSEEK64
|
||||
static off64_t (*ORIG(__lseek64)) (int fd, off64_t offset, int whence);
|
||||
#endif
|
||||
static int (*ORIG(close)) (int fd);
|
||||
|
||||
#define OPEN(fn) \
|
||||
@ -179,6 +185,13 @@ int NEW(open64)(const char *file, int oflag, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___OPEN64
|
||||
int NEW(__open64)(const char *file, int oflag, ...)
|
||||
{
|
||||
int ret; OPEN(__open64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE_DUP
|
||||
int NEW(dup)(int oldfd)
|
||||
{
|
||||
@ -522,9 +535,14 @@ off_t NEW(lseek)(int fd, off_t offset, int whence)
|
||||
#if defined HAVE_LSEEK64
|
||||
off64_t NEW(lseek64)(int fd, off64_t offset, int whence)
|
||||
{
|
||||
off64_t ret;
|
||||
LSEEK(lseek64, off64_t);
|
||||
return ret;
|
||||
off64_t ret; LSEEK(lseek64, off64_t); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___LSEEK64
|
||||
off64_t NEW(__lseek64)(int fd, off64_t offset, int whence)
|
||||
{
|
||||
off64_t ret; LSEEK(__lseek64, off64_t); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -48,12 +48,22 @@ static FILE * (*ORIG(fopen)) (const char *path, const char *mode);
|
||||
#if defined HAVE_FOPEN64
|
||||
static FILE * (*ORIG(fopen64)) (const char *path, const char *mode);
|
||||
#endif
|
||||
#if defined HAVE___FOPEN64
|
||||
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
|
||||
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
|
||||
static void (*ORIG(rewind)) (FILE *stream);
|
||||
static size_t (*ORIG(fread)) (void *ptr, size_t size, size_t nmemb,
|
||||
FILE *stream);
|
||||
@ -134,36 +144,49 @@ FILE *NEW(fopen64)(const char *path, const char *mode)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE___FOPEN64
|
||||
FILE *NEW(__fopen64)(const char *path, const char *mode)
|
||||
{
|
||||
FILE *ret; FOPEN(__fopen64); return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FREOPEN(fn) \
|
||||
do \
|
||||
{ \
|
||||
int fd0 = -1, fd1 = -1, disp = 0; \
|
||||
LOADSYM(fn); \
|
||||
if(_zz_ready && (fd0 = fileno(stream)) >= 0 && _zz_iswatched(fd0)) \
|
||||
{ \
|
||||
_zz_unregister(fd0); \
|
||||
disp = 1; \
|
||||
} \
|
||||
_zz_lock(-1); \
|
||||
ret = ORIG(fn)(path, mode, stream); \
|
||||
_zz_unlock(-1); \
|
||||
if(ret && _zz_mustwatch(path)) \
|
||||
{ \
|
||||
fd1 = fileno(ret); \
|
||||
_zz_register(fd1); \
|
||||
disp = 1; \
|
||||
} \
|
||||
if(disp) \
|
||||
debug("%s(\"%s\", \"%s\", [%i]) = [%i]", __func__, \
|
||||
path, mode, fd0, fd1); \
|
||||
} while(0)
|
||||
|
||||
FILE *NEW(freopen)(const char *path, const char *mode, FILE *stream)
|
||||
{
|
||||
FILE *ret;
|
||||
int fd0 = -1, fd1 = -1, disp = 0;
|
||||
|
||||
LOADSYM(freopen);
|
||||
if(_zz_ready && (fd0 = fileno(stream)) >= 0 && _zz_iswatched(fd0))
|
||||
{
|
||||
_zz_unregister(fd0);
|
||||
disp = 1;
|
||||
}
|
||||
|
||||
_zz_lock(-1);
|
||||
ret = ORIG(freopen)(path, mode, stream);
|
||||
_zz_unlock(-1);
|
||||
|
||||
if(ret && _zz_mustwatch(path))
|
||||
{
|
||||
fd1 = fileno(ret);
|
||||
_zz_register(fd1);
|
||||
disp = 1;
|
||||
}
|
||||
|
||||
if(disp)
|
||||
debug("%s(\"%s\", \"%s\", [%i]) = [%i]", __func__,
|
||||
path, mode, fd0, fd1);
|
||||
|
||||
return ret;
|
||||
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___SREFILL /* Don't fuzz or seek if we have __srefill() */
|
||||
# define FSEEK_FUZZ(fn2)
|
||||
#else
|
||||
@ -214,6 +237,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
|
||||
|
||||
void NEW(rewind)(FILE *stream)
|
||||
{
|
||||
int fd;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user