From 6050095beeb624b4ba2516dac7ef1683f8806b4b Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 27 Feb 2010 18:17:21 +0000 Subject: [PATCH] Revert any potential overriding macro before declaring a new function. --- src/libzzuf/lib-fd.c | 25 ++++++++++++++++++++++ src/libzzuf/lib-mem.c | 11 ++++++++++ src/libzzuf/lib-signal.c | 2 ++ src/libzzuf/lib-stream.c | 46 ++++++++++++++++++++++++++++++++++------ 4 files changed, 78 insertions(+), 6 deletions(-) diff --git a/src/libzzuf/lib-fd.c b/src/libzzuf/lib-fd.c index 66d6a3c..1878210 100644 --- a/src/libzzuf/lib-fd.c +++ b/src/libzzuf/lib-fd.c @@ -195,12 +195,14 @@ static int (*ORIG(close)) (int fd); } \ } while(0) +#undef open int NEW(open)(const char *file, int oflag, ...) { int ret; ZZ_OPEN(open); return ret; } #if defined HAVE_OPEN64 +#undef open64 int NEW(open64)(const char *file, int oflag, ...) { int ret; ZZ_OPEN(open64); return ret; @@ -208,6 +210,7 @@ int NEW(open64)(const char *file, int oflag, ...) #endif #if defined HAVE___OPEN64 +#undef __open64 int NEW(__open64)(const char *file, int oflag, ...) { int ret; ZZ_OPEN(__open64); return ret; @@ -215,6 +218,7 @@ int NEW(__open64)(const char *file, int oflag, ...) #endif #if defined HAVE_DUP +#undef dup int NEW(dup)(int oldfd) { int ret; @@ -236,6 +240,7 @@ int NEW(dup)(int oldfd) #endif #if defined HAVE_DUP2 +#undef dup2 int NEW(dup2)(int oldfd, int newfd) { int ret; @@ -262,6 +267,7 @@ int NEW(dup2)(int oldfd, int newfd) #endif #if defined HAVE_ACCEPT +#undef accept int NEW(accept)(int sockfd, SOCKADDR_T *addr, SOCKLEN_T *addrlen) { int ret; @@ -328,6 +334,7 @@ int NEW(accept)(int sockfd, SOCKADDR_T *addr, SOCKLEN_T *addrlen) } while(0); #if defined HAVE_BIND +#undef bind int NEW(bind)(int sockfd, const SOCKADDR_T *my_addr, SOCKLEN_T addrlen) { int ret; ZZ_CONNECT(bind, my_addr); return ret; @@ -335,6 +342,7 @@ int NEW(bind)(int sockfd, const SOCKADDR_T *my_addr, SOCKLEN_T addrlen) #endif #if defined HAVE_CONNECT +#undef connect int NEW(connect)(int sockfd, const SOCKADDR_T *serv_addr, SOCKLEN_T addrlen) { @@ -343,6 +351,7 @@ int NEW(connect)(int sockfd, const SOCKADDR_T *serv_addr, #endif #if defined HAVE_SOCKET +#undef socket int NEW(socket)(int domain, int type, int protocol) { int ret; @@ -389,6 +398,7 @@ int NEW(socket)(int domain, int type, int protocol) } while(0); #if defined HAVE_RECV +#undef recv RECV_T NEW(recv)(int s, void *buf, size_t len, int flags) { int ret; ZZ_RECV(recv); return ret; @@ -396,6 +406,7 @@ RECV_T NEW(recv)(int s, void *buf, size_t len, int flags) #endif #if defined HAVE___RECV_CHK +#undef __recv_chk RECV_T NEW(__recv_chk)(int s, void *buf, size_t len, int flags) { int ret; ZZ_RECV(__recv_chk); return ret; @@ -435,6 +446,7 @@ RECV_T NEW(__recv_chk)(int s, void *buf, size_t len, int flags) } while(0) #if defined HAVE_RECVFROM +#undef recvfrom RECV_T NEW(recvfrom)(int s, void *buf, size_t len, int flags, SOCKADDR_T *from, SOCKLEN_T *fromlen) { @@ -443,6 +455,7 @@ RECV_T NEW(recvfrom)(int s, void *buf, size_t len, int flags, #endif #if defined HAVE___RECVFROM_CHK +#undef __recvfrom_chk RECV_T NEW(__recvfrom_chk)(int s, void *buf, size_t len, int flags, SOCKADDR_T *from, SOCKLEN_T *fromlen) { @@ -451,6 +464,7 @@ RECV_T NEW(__recvfrom_chk)(int s, void *buf, size_t len, int flags, #endif #if defined HAVE_RECVMSG +#undef recvmsg RECV_T NEW(recvmsg)(int s, struct msghdr *hdr, int flags) { ssize_t ret; @@ -495,11 +509,13 @@ RECV_T NEW(recvmsg)(int s, struct msghdr *hdr, int flags) } while(0) #if defined READ_USES_SSIZE_T +#undef read ssize_t NEW(read)(int fd, void *buf, size_t count) { int ret; ZZ_READ(read); return (ssize_t)ret; } #else +#undef read int NEW(read)(int fd, void *buf, unsigned int count) { int ret; ZZ_READ(read); return ret; @@ -507,6 +523,7 @@ int NEW(read)(int fd, void *buf, unsigned int count) #endif #if defined HAVE___READ_CHK +#undef __read_chk ssize_t NEW(__read_chk)(int fd, void *buf, size_t count) { int ret; ZZ_READ(__read_chk); return (ssize_t)ret; @@ -514,6 +531,7 @@ ssize_t NEW(__read_chk)(int fd, void *buf, size_t count) #endif #if defined HAVE_READV +#undef readv ssize_t NEW(readv)(int fd, const struct iovec *iov, int count) { ssize_t ret; @@ -533,6 +551,7 @@ ssize_t NEW(readv)(int fd, const struct iovec *iov, int count) #endif #if defined HAVE_PREAD +#undef pread ssize_t NEW(pread)(int fd, void *buf, size_t count, off_t offset) { int ret; @@ -582,6 +601,7 @@ ssize_t NEW(pread)(int fd, void *buf, size_t count, off_t offset) _zz_setpos(fd, ret); \ } while(0) +#undef lseek off_t NEW(lseek)(int fd, off_t offset, int whence) { off_t ret; @@ -590,6 +610,7 @@ off_t NEW(lseek)(int fd, off_t offset, int whence) } #if defined HAVE_LSEEK64 +#undef lseek64 off64_t NEW(lseek64)(int fd, off64_t offset, int whence) { off64_t ret; ZZ_LSEEK(lseek64, off64_t); return ret; @@ -597,6 +618,7 @@ off64_t NEW(lseek64)(int fd, off64_t offset, int whence) #endif #if defined HAVE___LSEEK64 +#undef __lseek64 off64_t NEW(__lseek64)(int fd, off64_t offset, int whence) { off64_t ret; ZZ_LSEEK(__lseek64, off64_t); return ret; @@ -604,6 +626,7 @@ off64_t NEW(__lseek64)(int fd, off64_t offset, int whence) #endif #if defined HAVE_AIO_READ +#undef aio_read int NEW(aio_read)(struct aiocb *aiocbp) { int ret; @@ -623,6 +646,7 @@ int NEW(aio_read)(struct aiocb *aiocbp) return ret; } +#undef aio_return ssize_t NEW(aio_return)(struct aiocb *aiocbp) { ssize_t ret; @@ -652,6 +676,7 @@ ssize_t NEW(aio_return)(struct aiocb *aiocbp) } #endif +#undef close int NEW(close)(int fd) { int ret; diff --git a/src/libzzuf/lib-mem.c b/src/libzzuf/lib-mem.c index aea3c75..24c6dac 100644 --- a/src/libzzuf/lib-mem.c +++ b/src/libzzuf/lib-mem.c @@ -153,6 +153,7 @@ void _zz_mem_init(void) LOADSYM(realloc); } +#undef calloc void *NEW(calloc)(size_t nmemb, size_t size) { void *ret; @@ -176,6 +177,7 @@ void *NEW(calloc)(size_t nmemb, size_t size) return ret; } +#undef malloc void *NEW(malloc)(size_t size) { void *ret; @@ -197,6 +199,7 @@ void *NEW(malloc)(size_t size) return ret; } +#undef free void NEW(free)(void *ptr) { if((uintptr_t)ptr >= DUMMY_START && (uintptr_t)ptr < DUMMY_STOP) @@ -213,6 +216,7 @@ void NEW(free)(void *ptr) ORIG(free)(ptr); } +#undef realloc void *NEW(realloc)(void *ptr, size_t size) { void *ret; @@ -244,6 +248,7 @@ void *NEW(realloc)(void *ptr, size_t size) } #if defined HAVE_VALLOC +#undef valloc void *NEW(valloc)(size_t size) { void *ret; @@ -257,6 +262,7 @@ void *NEW(valloc)(size_t size) #endif #if defined HAVE_MEMALIGN +#undef memalign void *NEW(memalign)(size_t boundary, size_t size) { void *ret; @@ -270,6 +276,7 @@ void *NEW(memalign)(size_t boundary, size_t size) #endif #if defined HAVE_POSIX_MEMALIGN +#undef posix_memalign int NEW(posix_memalign)(void **memptr, size_t alignment, size_t size) { int ret; @@ -339,6 +346,7 @@ int nbmaps = 0; } while(0) #if defined HAVE_MMAP +#undef mmap void *NEW(mmap)(void *start, size_t length, int prot, int flags, int fd, off_t offset) { @@ -347,6 +355,7 @@ void *NEW(mmap)(void *start, size_t length, int prot, int flags, #endif #if defined HAVE_MMAP64 +#undef mmap64 void *NEW(mmap64)(void *start, size_t length, int prot, int flags, int fd, off64_t offset) { @@ -355,6 +364,7 @@ void *NEW(mmap64)(void *start, size_t length, int prot, int flags, #endif #if defined HAVE_MUNMAP +#undef munmap int NEW(munmap)(void *start, size_t length) { int ret, i; @@ -378,6 +388,7 @@ int NEW(munmap)(void *start, size_t length) #endif #if defined HAVE_MAP_FD +#undef map_fd kern_return_t NEW(map_fd)(int fd, vm_offset_t offset, vm_offset_t *addr, boolean_t find_space, vm_size_t numbytes) { diff --git a/src/libzzuf/lib-signal.c b/src/libzzuf/lib-signal.c index 9d9c8af..f5919d6 100644 --- a/src/libzzuf/lib-signal.c +++ b/src/libzzuf/lib-signal.c @@ -90,6 +90,7 @@ static int isfatal(int signum) } } +#undef signal SIG_T NEW(signal)(int signum, SIG_T handler) { SIG_T ret; @@ -107,6 +108,7 @@ SIG_T NEW(signal)(int signum, SIG_T handler) } #if defined HAVE_SIGACTION +#undef sigaction int NEW(sigaction)(int signum, const struct sigaction *act, struct sigaction *oldact) { diff --git a/src/libzzuf/lib-stream.c b/src/libzzuf/lib-stream.c index f9af751..65e2a72 100644 --- a/src/libzzuf/lib-stream.c +++ b/src/libzzuf/lib-stream.c @@ -53,18 +53,22 @@ #include "fd.h" #if defined HAVE___SREFILL +#undef __srefill int NEW(__srefill)(FILE *fp); #endif #if defined HAVE___FILBUF +#undef __filbuf int NEW(__filbuf)(FILE *fp); #endif #if defined HAVE___SRGET && !defined HAVE___SREFILL +#undef __srget int NEW(__srget)(FILE *fp); #endif #if defined HAVE___UFLOW +#undef __uflow int NEW(__uflow)(FILE *fp); #endif @@ -293,12 +297,14 @@ static inline void debug_stream(char const *prefix, FILE *stream) path, mode, fd0, fd1); \ } while(0) +#undef fopen FILE *NEW(fopen)(const char *path, const char *mode) { FILE *ret; ZZ_FOPEN(fopen); return ret; } #if defined HAVE_FOPEN64 +#undef fopen64 FILE *NEW(fopen64)(const char *path, const char *mode) { FILE *ret; ZZ_FOPEN(fopen64); return ret; @@ -306,18 +312,21 @@ FILE *NEW(fopen64)(const char *path, const char *mode) #endif #if defined HAVE___FOPEN64 +#undef __fopen64 FILE *NEW(__fopen64)(const char *path, const char *mode) { FILE *ret; ZZ_FOPEN(__fopen64); return ret; } #endif +#undef freopen FILE *NEW(freopen)(const char *path, const char *mode, FILE *stream) { FILE *ret; ZZ_FREOPEN(freopen); return ret; } #if defined HAVE_FREOPEN64 +#undef freopen64 FILE *NEW(freopen64)(const char *path, const char *mode, FILE *stream) { FILE *ret; ZZ_FREOPEN(freopen64); return ret; @@ -325,6 +334,7 @@ FILE *NEW(freopen64)(const char *path, const char *mode, FILE *stream) #endif #if defined HAVE___FREOPEN64 +#undef __freopen64 FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream) { FILE *ret; ZZ_FREOPEN(__freopen64); return ret; @@ -438,12 +448,14 @@ FILE *NEW(__freopen64)(const char *path, const char *mode, FILE *stream) debug("%s([%i])", __func__, fd); \ } while(0) +#undef fseek int NEW(fseek)(FILE *stream, long offset, int whence) { int ret; ZZ_FSEEK(fseek); return ret; } #if defined HAVE_FSEEKO +#undef fseeko int NEW(fseeko)(FILE *stream, off_t offset, int whence) { int ret; ZZ_FSEEK(fseeko); return ret; @@ -451,6 +463,7 @@ int NEW(fseeko)(FILE *stream, off_t offset, int whence) #endif #if defined HAVE_FSEEKO64 +#undef fseeko64 int NEW(fseeko64)(FILE *stream, off64_t offset, int whence) { int ret; ZZ_FSEEK(fseeko64); return ret; @@ -458,6 +471,7 @@ int NEW(fseeko64)(FILE *stream, off64_t offset, int whence) #endif #if defined HAVE___FSEEKO64 +#undef __fseeko64 int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence) { int ret; ZZ_FSEEK(__fseeko64); return ret; @@ -465,6 +479,7 @@ int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence) #endif #if defined HAVE_FSETPOS64 +#undef fsetpos64 int NEW(fsetpos64)(FILE *stream, const fpos64_t *pos) { int ret; ZZ_FSETPOS(fsetpos64); return ret; @@ -472,12 +487,14 @@ int NEW(fsetpos64)(FILE *stream, const fpos64_t *pos) #endif #if defined HAVE___FSETPOS64 +#undef __fsetpos64 int NEW(__fsetpos64)(FILE *stream, const fpos64_t *pos) { int ret; ZZ_FSETPOS(__fsetpos64); return ret; } #endif +#undef rewind void NEW(rewind)(FILE *stream) { ZZ_REWIND(rewind); @@ -538,13 +555,14 @@ void NEW(rewind)(FILE *stream) (long int)size, (long int)nmemb, fd, (long int)ret); \ } while(0) +#undef fread size_t NEW(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t ret; ZZ_FREAD(fread); return ret; } #if defined HAVE_FREAD_UNLOCKED -#undef fread_unlocked /* can be a macro; we don’t want that */ +#undef fread_unlocked size_t NEW(fread_unlocked)(void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t ret; ZZ_FREAD(fread_unlocked); return ret; @@ -618,24 +636,26 @@ size_t NEW(__fread_unlocked_chk)(void *ptr, size_t size, size_t nmemb, debug("%s([%i]) = '%c'", __func__, fd, ret); \ } while(0) -#undef getc /* can be a macro; we don’t want that */ +#undef getc int NEW(getc)(FILE *stream) { int ret; ZZ_FGETC(getc, stream, stream); return ret; } -#undef getchar /* can be a macro; we don’t want that */ +#undef getchar int NEW(getchar)(void) { int ret; ZZ_FGETC(getchar, stdin, /* empty */); return ret; } +#undef fgetc int NEW(fgetc)(FILE *stream) { int ret; ZZ_FGETC(fgetc, stream, stream); return ret; } #if defined HAVE__IO_GETC +#undef _IO_fgetc int NEW(_IO_getc)(FILE *stream) { int ret; ZZ_FGETC(_IO_getc, stream, stream); return ret; @@ -643,7 +663,7 @@ int NEW(_IO_getc)(FILE *stream) #endif #if defined HAVE_GETC_UNLOCKED -#undef getc_unlocked /* can be a macro; we don’t want that */ +#undef getc_unlocked int NEW(getc_unlocked)(FILE *stream) { int ret; ZZ_FGETC(getc_unlocked, stream, stream); return ret; @@ -651,7 +671,7 @@ int NEW(getc_unlocked)(FILE *stream) #endif #if defined HAVE_GETCHAR_UNLOCKED -#undef getchar_unlocked /* can be a macro; we don’t want that */ +#undef getchar_unlocked int NEW(getchar_unlocked)(void) { int ret; ZZ_FGETC(getchar_unlocked, stdin, /* empty */); return ret; @@ -659,7 +679,7 @@ int NEW(getchar_unlocked)(void) #endif #if defined HAVE_FGETC_UNLOCKED -#undef fgetc_unlocked /* can be a macro; we don’t want that */ +#undef fgetc_unlocked int NEW(fgetc_unlocked)(FILE *stream) { int ret; ZZ_FGETC(fgetc_unlocked, stream, stream); return ret; @@ -740,12 +760,14 @@ int NEW(fgetc_unlocked)(FILE *stream) debug("%s(%p, %i, [%i]) = %p", __func__, s, size, fd, ret); \ } while(0) +#undef fgets char *NEW(fgets)(char *s, int size, FILE *stream) { char *ret; ZZ_FGETS(fgets, fgetc); return ret; } #if defined HAVE_FGETS_UNLOCKED +#undef fgets_unlocked char *NEW(fgets_unlocked)(char *s, int size, FILE *stream) { char *ret; ZZ_FGETS(fgets_unlocked, fgetc_unlocked); return ret; @@ -753,6 +775,7 @@ char *NEW(fgets_unlocked)(char *s, int size, FILE *stream) #endif #if defined HAVE___FGETS_CHK +#undef __fgets_chk char *NEW(__fgets_chk)(char *s, int size, FILE *stream) { char *ret; ZZ_FGETS(__fgets_chk, fgetc); return ret; @@ -760,6 +783,7 @@ char *NEW(__fgets_chk)(char *s, int size, FILE *stream) #endif #if defined HAVE___FGETS_UNLOCKED_CHK +#undef __fgets_unlocked_chk char *NEW(__fgets_unlocked_chk)(char *s, int size, FILE *stream) { char *ret; ZZ_FGETS(__fgets_unlocked_chk, fgetc_unlocked); return ret; @@ -770,6 +794,7 @@ char *NEW(__fgets_unlocked_chk)(char *s, int size, FILE *stream) * ungetc */ +#undef ungetc int NEW(ungetc)(int c, FILE *stream) { int oldpos, ret, fd; @@ -799,6 +824,7 @@ int NEW(ungetc)(int c, FILE *stream) * fclose */ +#undef fclose int NEW(fclose)(FILE *fp) { int ret, fd; @@ -906,6 +932,7 @@ int NEW(fclose)(FILE *fp) } while(0) #if defined HAVE_GETLINE +#undef getline ssize_t NEW(getline)(char **lineptr, size_t *n, FILE *stream) { ssize_t ret; ZZ_GETDELIM(getline, '\n', 0); return ret; @@ -913,6 +940,7 @@ ssize_t NEW(getline)(char **lineptr, size_t *n, FILE *stream) #endif #if defined HAVE_GETDELIM +#undef getdelim ssize_t NEW(getdelim)(char **lineptr, size_t *n, int delim, FILE *stream) { ssize_t ret; ZZ_GETDELIM(getdelim, delim, 1); return ret; @@ -920,6 +948,7 @@ ssize_t NEW(getdelim)(char **lineptr, size_t *n, int delim, FILE *stream) #endif #if defined HAVE___GETDELIM +#undef __getdelim ssize_t NEW(__getdelim)(char **lineptr, size_t *n, int delim, FILE *stream) { ssize_t ret; ZZ_GETDELIM(__getdelim, delim, 1); return ret; @@ -931,6 +960,7 @@ ssize_t NEW(__getdelim)(char **lineptr, size_t *n, int delim, FILE *stream) */ #if defined HAVE_FGETLN +#undef fgetln char *NEW(fgetln)(FILE *stream, size_t *len) { int64_t oldpos, newpos; @@ -1070,6 +1100,7 @@ char *NEW(fgetln)(FILE *stream, size_t *len) while(0) #if defined HAVE___SREFILL +#undef __srefill int NEW(__srefill)(FILE *fp) { int ret; ZZ_REFILL(__srefill, 0); return ret; @@ -1077,6 +1108,7 @@ int NEW(__srefill)(FILE *fp) #endif #if defined HAVE___SRGET && !defined HAVE___SREFILL +#undef __srget int NEW(__srget)(FILE *fp) { int ret; ZZ_REFILL(__srget, 1); return ret; @@ -1084,6 +1116,7 @@ int NEW(__srget)(FILE *fp) #endif #if defined HAVE___FILBUF +#undef __filbuf int NEW(__filbuf)(FILE *fp) { int ret; ZZ_REFILL(__filbuf, 1); return ret; @@ -1091,6 +1124,7 @@ int NEW(__filbuf)(FILE *fp) #endif #if defined HAVE___UFLOW +#undef __uflow int NEW(__uflow)(FILE *fp) { int ret; ZZ_REFILL(__uflow, 1); return ret;